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

Results 1 to 6 of 6

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

  1. #1
    Registered
    Join Date
    May 2015
    Location
    Holland
    Posts
    16
    Downloads
    0
    Uploads
    0

    Lightbulb 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!?

    Similar Threads:
    Last edited by Driller2; 05-20-2015 at 07:27 AM.


  2. #2
    Registered vegipete's Avatar
    Join Date
    Mar 2006
    Location
    Sol 3 (YVR)
    Posts
    202
    Downloads
    0
    Uploads
    0

    Default 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.



  3. #3
    Registered
    Join Date
    May 2015
    Location
    Holland
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default 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?



  4. #4
    Registered vegipete's Avatar
    Join Date
    Mar 2006
    Location
    Sol 3 (YVR)
    Posts
    202
    Downloads
    0
    Uploads
    0

    Default 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.



  5. #5
    Member
    Join Date
    Feb 2007
    Location
    canada
    Posts
    942
    Downloads
    0
    Uploads
    0

    Default 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

    Manufacturer of CNC routers and Viper Servo Drives
    www.LarkenCNC.com and www.Viperservo.com


  6. #6
    Registered
    Join Date
    May 2015
    Location
    Holland
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default 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.



Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

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

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

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