# Automating Rotary Table

### Help Support Home Model Engine Machinist Forum:

#### OldRon

##### Well-Known Member
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);
}``````

Replies
0
Views
1K
Replies
0
Views
2K
Replies
22
Views
9K
Replies
10
Views
19K
Replies
3
Views
2K