By continuing to use this site, you agree to our use of cookies. Find out more
Forum sponsored by:
Forum sponsored by Forum House Ad Zone

Cumulative calculation errors

How can one deal with them?

All Topics | Latest Posts

Search for:  in Thread Title in  
Kiwi Bloke25/02/2021 08:21:31
912 forum posts
3 photos

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 IoM25/02/2021 08:49:08
1395 forum posts
30 photos
look up the threads by Jim Noci - he + others discus Bresenham's algorithm
Andrew Johnston25/02/2021 09:14:45
avatar
7061 forum posts
719 photos

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.

Andrew

Martin Kyte25/02/2021 09:39:37
avatar
3445 forum posts
62 photos

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

SillyOldDuffer25/02/2021 10:09:22
10668 forum posts
2415 photos

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.

Dave

Edited By SillyOldDuffer on 25/02/2021 10:11:07

Kiwi Bloke25/02/2021 10:45:42
912 forum posts
3 photos

Very many thanks everyone - exactly the info. and insight I was looking for. What a wonderful forum!

All Topics | Latest Posts

Please login to post a reply.

Magazine Locator

Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!

Find Model Engineer & Model Engineers' Workshop

Sign up to our Newsletter

Sign up to our newsletter and get a free digital issue.

You can unsubscribe at anytime. View our privacy policy at www.mortons.co.uk/privacy

Latest Forum Posts
Support Our Partners
cowells
Sarik
MERIDIENNE EXHIBITIONS LTD
Subscription Offer

Latest "For Sale" Ads
Latest "Wanted" Ads
Get In Touch!

Do you want to contact the Model Engineer and Model Engineers' Workshop team?

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.

Digital Back Issues

Social Media online

'Like' us on Facebook
Follow us on Facebook

Follow us on Twitter
 Twitter Logo

Pin us on Pinterest

 

Donate

donate