Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    StepTimer.cpp Internals

    Scheduled Pinned Locked Moved
    Firmware developers
    4
    7
    345
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ezalysundefined
      ezalys
      last edited by

      I'm trying to learn a bit about how the step pulse generation works and am starting by digging around in StepTimer.cpp. I'm trying to understand how exactly the timer interrupt works. The first thing I notice is the following comment

      // The clock rate we use is a compromise. Too fast and the 64-bit square roots take a long time to execute. Too slow and we lose resolution.
      

      Why should the clock rate affect the time of a square root?

      Secondly, I'm not sure how the timers themselves work. Do you try and schedule an interrupt such and such time in the future and put it on a queue, and the ISR looks for the next timer event that should fire and arrange to have the timer interrupt hit you then, or does the ISR itself fire at 1 MHz?

      1 Reply Last reply Reply Quote 0
      • ezalysundefined
        ezalys
        last edited by

        After a bit of further investigation, it looks like isqrt64 is never actually called. What then sets the counter frequency?

        JoergS5undefined dc42undefined 3 Replies Last reply Reply Quote 0
        • JoergS5undefined
          JoergS5 @ezalys
          last edited by JoergS5

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • JoergS5undefined
            JoergS5 @ezalys
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • dc42undefined
              dc42 administrators @ezalys
              last edited by

              @ezalys the isqrt64 function was used in RRF 3.3 and earlier when the step time computations were done using integer maths. Since RRF 3.4 the maths is done using floating point maths instead. isqrt64 is still used in the Duet3Expansion project, for build configurations that use the SAMC21 processor.

              The step clock rate affected the speed because the square root is much faster to compute when operand fits in 32 bits.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              gnydickundefined 1 Reply Last reply Reply Quote 0
              • gnydickundefined
                gnydick @dc42
                last edited by

                @dc42 not really related, but made me think of this, Fast Inverse Square Root. Does those lore make it around your circles?

                dc42undefined 1 Reply Last reply Reply Quote 0
                • dc42undefined
                  dc42 administrators @gnydick
                  last edited by

                  @gnydick yes I've read about that interesting algorithm before. I know of one place where the reciprocal of a square root is used, so it could perhaps be used there. However, most of the processors we use now support a fast floating point square root instruction.

                  Duet WiFi hardware designer and firmware engineer
                  Please do not ask me for Duet support via PM or email, use the forum
                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA