 Need Help! How to program the formula for decimal degrees when using a rotary table?

Thread: How to program the formula for decimal degrees when using a rotary table?

1. How to program the formula for decimal degrees when using a rotary table?

I've developed a mode driven controller for the Rotary Table on a Lathe and Mill.
In the GOTO-mode for now it only excepts whole degrees inputs.

But how to rotate 0,241or 359,385 degrees in chip code where the WORD value range is only from 1 to 65.535?

Lets say: GearRatio=120, StepSettings=200

So, when calculating the StepPulses during division and multiplying the value exceeds the WORD range and therefore the chip adjusts the value incorrect!?  Reply With Quote

2. Re: How to program the formula for decimal degrees when using a rotary table?

I presume you are using C? Which compiler? Which PIC chip?

ints are 16 bits, as you've discovered.
longs are 32 bits.  Reply With Quote

3. Re: How to program the formula for decimal degrees when using a rotary table?

I'm using MPLAB with PICkit 2 programmer where as the chip I can change to whatever works good.

So should I use the Longs or FloatingPoints in this case?  Reply With Quote

4. Re: How to program the formula for decimal degrees when using a rotary table?

Try very hard to avoid floats - they don't necessarily represent numbers accurately. For example, 10.0 * ( 4.0 / 10.0 ) may not equal 4.0!

I would suggest working with longs with an implied 'decimal' point. For example, the first 16 bits would represent the whole number, the remaining 16 bits represent the fraction part. Start with how many steps per turn your mechanical system has, and work backwards from there. Have a look at Jones on reciprocal multiplication for some ideas on implementing fixed point routines.

And if your chip choice is flexible, look at the PIC24FV series. They work at 5 volts and are available in 20 and 28 pin DIP. I _think_ the PICkit2 can program them.  Reply With Quote

5. Re: How to program the formula for decimal degrees when using a rotary table?

You can do it all in integer.if you could have a set resolution of 0.01 degrees or 36000 counts defined per turn. (360*100)
So each degree is 100 counts. Then its easy for you to decode decimal input knowing the 2 decimal places is 0-9 counts or 0-99 extra.

Then use bregenhams integer algorithm to scale the comanded (0-36000) counts to what the real machine counts per rev is.

Larry  Reply With Quote

6. Re: How to program the formula for decimal degrees when using a rotary table?

Thanks for the replies, some ideas I have not thought of.

vegipete : Try very hard to avoid floats - they don't necessarily represent numbers accurately.
So, floats are no option!

vegipete : I would suggest working with longs with an implied 'decimal' point.
That part was already programmed for entering a decimal at a certain position, but couldn't decide how to proceed.

vegipete :...the remaining 16 bits represent the fraction part.
Larken: Then its easy for you to decode decimal input knowing the 2 decimal places is 0-9 counts or 0-99 extra.
To consider it as a seperate value, I have not came up with that idea! I think that should do the trick.  Reply With Quote

Tags for this Thread

degrees, range, rotary, table, word  Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• 