Automating Rotary Table

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
motorSteps = fabs (gear_ratio_top_array[gearratioindex]*Microsteps*StepsPerRevolution)/gear_ratio_bottom_array[gearratioindex];

......

stepsperdiv = (motorSteps / num_divisions);
stepsperdivv = round (stepsperdiv * (cur_pos-1) ) ;
stepsperdiv = round (stepsperdiv * cur_pos ) ;
stepsperdiv_d = stepsperdiv - stepsperdivv + 1 ;



I'm using "fabs()" function..
I solved the floating point error by remembering the previous moved step when calculating, calculating the step to move this time, and re-inserting the amount of the difference.


pyromancer,

I did not have any problem with the Arduino UNO other than it being limited to single precision. In the calculations some index increments return a whole number while others return a fractional value. Obviously it is not possible to send a fraction of a pulse so I rounded the fractional value. That is where the accumulated error went wild. While the Arduino UNO will accept the double type the precision remains to be single. I have since switched to the Arduino DUE and it has true double precision. I mention that to ward off lectures about the use of double in my code. With true double precision the positioning (code) accuracy is as good as high end rotary indexing tables.

I believe that we are using the same logic to manage the accumulated error.

Servo motor encoder ppr: 2048
External gear ratio: 4:1
Internal gear ratio: 90:1
Servo motor encoder ppr per revolution of rotary table axis: 737280 ((4 * 90) * 2048)
Arc(seconds) per servo motor encoder ppr: 1.7578125 (1296000 / 737280) < the resolution
Arc(seconds) per degree: 3600

user = 2048 (3600/ 1.7578125)

Arduino C++
Code:
double getSteps(double dgrs)
{
  double stps = 0.0;
  stps = ((dgrs * user) + crumbs);
  crumbs = (stps - round(stps));
  return round(stps);
}
 

Latest posts

Back
Top