Navigation

    Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    Microsecond resolution when using M280 for servo control

    Tuning and tweaking
    3
    9
    679
    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.
    • hbang
      hbang last edited by hbang

      (Using the Duet Wifi 1.0.4 board with 2.02 firmware)

      I'm currently using the servo command M280 with the "S" argument using the microsecond timing option, giving values between 600 and 2400 microseconds to control a set of servos for a camera gimbal. However, I'm having trouble getting the level of accuracy I was hoping to achieve in pointing the camera.

      It's not clear to me if this is a limitation of the servos, or whether the timing resolution of the pulse being sent by the Duet is small enough to allow the servo to move a very small distance. Right now the minimum change it takes approaches 20 microseconds. Changes less than that won't cause a movement.

      I was hoping to get approximately 1 degree of resolution in movement. The servos are made to rotate nearly 400 degrees over the range of 600us to 2400us, so let's say each approximate degree of movement would require a change in pulse timing of 5us. However it appears I need a value change in the M280 S parameter of about 20us to see any movement, but this results in a movement of about 4 degrees.

      What is the smallest resolution step possible with the M280 command using the microsecond pulse option? I'm currently using the P3, P4, and P5 options to control the servos through the heater outputs on the expansion board.

      Thank you for any insight as to what I don't understand here.

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

        The S value is converted to a PWM signal with a frequency of 50Hz. The resolution depends on whether the output pin you are using is controlled by a PWM channel or a TC channel. On the Duet WiFi/Ethernet, the TC channels have higher resolution than the PWM channels. So if you are using a PWM channel, changing to an output pin that uses a TC channel may help. You can use the chart at https://duet3d.dozuki.com/Wiki/Duet_2_Pinout_table to determine which outputs are PWM (those with PWMLx highlighted) and which are TC (those with TIOAx highlighted).

        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

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

          @dc42
          Thank you! I'll give this a try and let you know how it turns out.

          1 Reply Last reply Reply Quote 0
          • tekkydave
            tekkydave last edited by

            I'm working on a similar project, using 2 SG90 servos to control a raspberry pi camera in x & y axes. I have a Duet WiFi (1.02) and Duex2 (0.8a). I have my servos connected to PMW1 & 2 (Heater3 & 4) and can only get 3 or 4 degree resolution. Would switching them to PMW 4 & 5 (Heater 6 & 7) give better resolution?

            ~ tekkydave ~
            D-Bot: 300x300mm | Duet WiFi + Duex2 | 3 independent z motors | X,Y & Z linear rails | E3D Titan Aero + V6 | Precision Piezo z-probe
            FreeCAD, PrusaSlicer

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

              Heater 4 uses TIOA6 so it should already give you resolution of about 0.0625 microseconds. Whereas heater 3 will give resolution of about 40 microseconds, so it should give about 25 steps between the min and max positions of the servo.

              There is scope to improve the resolution of the PWM channels to around 13us 20us.

              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
              • tekkydave
                tekkydave last edited by

                Thanks. I hadn't noticed that as I was only testing the resolution with PMW1/H3. I'll try moving it to one of the others and see how I get on.

                ~ tekkydave ~
                D-Bot: 300x300mm | Duet WiFi + Duex2 | 3 independent z motors | X,Y & Z linear rails | E3D Titan Aero + V6 | Precision Piezo z-probe
                FreeCAD, PrusaSlicer

                1 Reply Last reply Reply Quote 0
                • tekkydave
                  tekkydave last edited by tekkydave

                  I moved the servo connections to H6 & H7 and they are now responding correctly to 1 degree movements.
                  As I have a v1.02 Duet WiFi I have also connected a capacitor across the GND & 5V pins on H3 to absorb any back-EMF. I only had a 10V rated 220uF electrolytic to hand so used a 470uF 35V part instead.

                  ~ tekkydave ~
                  D-Bot: 300x300mm | Duet WiFi + Duex2 | 3 independent z motors | X,Y & Z linear rails | E3D Titan Aero + V6 | Precision Piezo z-probe
                  FreeCAD, PrusaSlicer

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

                    I'm glad you got it working. I will improve the resolution of the PWM channels to 20us in the next firmware release.

                    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
                    • tekkydave
                      tekkydave last edited by

                      Thanks @dc42

                      ~ tekkydave ~
                      D-Bot: 300x300mm | Duet WiFi + Duex2 | 3 independent z motors | X,Y & Z linear rails | E3D Titan Aero + V6 | Precision Piezo z-probe
                      FreeCAD, PrusaSlicer

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