Cumulative calculation errors

Advert

Cumulative calculation errors

Home Forums General Questions Cumulative calculation errors

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #529972
    Kiwi Bloke
    Participant
      @kiwibloke62605

      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

      Advert
      #28000
      Kiwi Bloke
      Participant
        @kiwibloke62605

        How can one deal with them?

        #529976
        Frances IoM
        Participant
          @francesiom58905

          look up the threads by Jim Noci – he + others discus Bresenham’s algorithm

          #529979
          Anonymous

            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

            #529985
            Martin Kyte
            Participant
              @martinkyte99762

              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

              #529988
              SillyOldDuffer
              Moderator
                @sillyoldduffer

                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

                #529992
                Kiwi Bloke
                Participant
                  @kiwibloke62605

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

                Viewing 7 posts - 1 through 7 (of 7 total)
                • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                Advert

                Latest Replies

                Home Forums General Questions Topics

                Viewing 25 topics - 1 through 25 (of 25 total)
                Viewing 25 topics - 1 through 25 (of 25 total)

                View full reply list.

                Advert

                Newsletter Sign-up