584,862 active members*
5,722 visitors online*
Register for free
Login
IndustryArena Forum > CNC Electronics > PIC Programing / Design > How to program the formula for decimal degrees when using a rotary table?
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2015
    Posts
    32

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

  2. #2
    Join Date
    Mar 2006
    Posts
    202

    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
    Join Date
    May 2015
    Posts
    32

    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
    Join Date
    Mar 2006
    Posts
    202

    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
    Join Date
    Feb 2007
    Posts
    962

    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
    Join Date
    May 2015
    Posts
    32

    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.

Similar Threads

  1. Replies: 0
    Last Post: 12-25-2014, 02:11 AM
  2. How to program points on a circle by degrees
    By CaptainVee in forum LinuxCNC (formerly EMC2)
    Replies: 14
    Last Post: 04-02-2013, 04:55 AM
  3. Adding a rotary encoder to a large Rotary Table
    By small.planes in forum Mechanical Calculations/Engineering Design
    Replies: 14
    Last Post: 04-27-2012, 07:27 PM
  4. Replies: 2
    Last Post: 03-12-2012, 12:21 AM
  5. DIY - CNC H/V Rotary Table
    By QSPSB in forum Benchtop Machines
    Replies: 1
    Last Post: 11-19-2010, 02:37 PM

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
  •