How can one deal with them?
|Kiwi Bloke||25/02/2021 08:21:31|
|525 forum posts|
This is a question about theory, not implementation. I think it's been addressed in a previous thread, but I haven't found it.
In applications such as 'digital leadscrews' or 'digital dividing' apparatus, calculations involving irrational numbers may be repeated many times. The results of the calculations can only be (to some extent) approximations, so repeated calculations will cause error to accumulate. Typically, the results of such calculations will be used to drive a stepper motor. A suitable gear train is free from such error. I accept that, for practical purposes, calculation and electronics can produce accurate-enough results, but wonder if there's a numerical, computational approach that avoids cumulative error.
Edited By Kiwi Bloke on 25/02/2021 08:22:30
|Frances IoM||25/02/2021 08:49:08|
|1066 forum posts|
|look up the threads by Jim Noci - he + others discus Bresenham's algorithm|
|Andrew Johnston||25/02/2021 09:14:45|
5969 forum posts
One, calculate each point from basics, rather than incrementing a small, approximate, value. Two, chose a calculation/rounding method that gives a uniform spread of errors around the exact value. That way the accumulated error grows much more slowly than the accumulated value, assuming of course that the errors uncorrelated.
|Martin Kyte||25/02/2021 09:39:37|
2309 forum posts
I did just as Andrew suggested when I wrote my dividing head firmware. Calculate the next point as the number of steps from the start point choosing the number that gives the closest to the correct angle (one more or one less). Subtract the cumulative count of steps already commanded and you have your new step count. Basically keep a track of where you should be from the origin and the cumulative motion which will be always an integer number of steps, half steps or whatever. As there are always an integer number of steps per 360 degrees the cumulative count may be reset at each full rotation to avoid numeric overflow.
The important point is that you have spotted the problem
7027 forum posts
Basically if the start, end, and increments are known, it's possible to 'lose' the accumulated error by varying each increment slightly. Say the closest round number to the wanted angle is 211 steps, but this accumulates an error. An algorithm can be applied to distribute the big final error en-route as a series of small errors by stepping a sequence like: 211, 211, 210, 211, 211, 211, 211, 211, 210 ... (No logic in the example, just an illustration.)
Several different algorithms available. Could be as crude as keeping count of the error so far and skipping or adding steps when a threshold is exceeded (this isn't ideal!). Bresenham is famous in computer circles for his efficient integer maths solutions to graphics drawing problems, answering questions like 'Most efficiently, which pixels on a screen need to be switched on to draw the best straight line possible between any two points'.
My Rotary Table does a sum supplied by Duncan Webster to distribute error. Duncan's method is easier to code than Bresenham but, if I remember correctly, consumes more memory and is slower because Duncan uses floating point maths. Doesn't matter because there's plenty of spare memory on the microcontroller and there's no need for the calculation to be done super-fast. Rotary tables are considerably more sluggish than computer screens!
Usually possible to keep the corrections so small they are swamped by the mechanical errors, as when a stepper motor puts 1600 steps per revolution into the input of a 90:1 worm drive. The worm and gear are only as accurate, per tooth, as they were made, less wear and tear.
Mechanical instruments often accumulate error too. A typical DTI is fairly accurate measuring to 0.02mm over a short range, but doesn't maintaining that accuracy over the instruments full travel. It gets large distances wrong because mechanical errors accumulate. Excellent comparators, but don't trust DTI's to measure accurately over any distance.
Edited By SillyOldDuffer on 25/02/2021 10:11:07
|Kiwi Bloke||25/02/2021 10:45:42|
|525 forum posts|
Very many thanks everyone - exactly the info. and insight I was looking for. What a wonderful forum!
Please login to post a reply.
Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!
You can contact us by phone, mail or email about the magazines including becoming a contributor, submitting reader's letters or making queries about articles. You can also get in touch about this website, advertising or other general issues.
Click THIS LINK for full contact details.
For subscription issues please see THIS LINK.