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

    Driving a RC servo from Fan0 output

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    2
    6
    734
    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.
    • fmaundefined
      fma
      last edited by

      Hi!

      I'm trying to drive a RC servo using the Fan0 output. I disabled it using:

      M106 P0 I-1
      

      Then drive it using:

      M280 P20 S1500
      

      But I don't get anything. Looking at the schematic, I think I need a pullup resistor on the signal pin, as the FET only switches to ground. Am I right? What value do you suggest? 10kOhm?

      Thanks.

      Frédéric

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

        I suggest 1K to +5V. You will also need to invert the polarity using I1 in the M280 command.

        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 1
        • fmaundefined
          fma
          last edited by

          Ok, thank you!

          Frédéric

          1 Reply Last reply Reply Quote 0
          • fmaundefined
            fma
            last edited by fma

            I have a question and a request for the M280 command, as using values below 200 set the angle, and values above 200 set the pulse duration:

            1. is there a way to set the relation between the setpoint angle (value below 200) and the real pulse width sent to the servo? Or is it really hard coded to 0°/544.0µs - 180°/2400.0µs?

            2. I plan to use a servo able to rotate up to 270°. With the current code, it is not possible to set its position using angle, as values above 200 are µs. Could it be possible to use distincts params to set either the angle (any value, using a relation between angle and pulse freely configurable) or the pulse width?

            Thanks.

            Frédéric

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

              1. It's hard coded, because that's how RC servos generally behave, and to change it would mess up the values used by BLTouch.

              2. I guess we could add additional parameters, but I would want the basic behaviour to remain as-is for compatibility with other 3D printer firmwares. I think I chose 200 as the cutoff angle because that's what Marlin did.

              Is there any reason why you can't use microsecond values?

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

                @dc42 said in Driving a RC servo from Fan0 output:

                1. It's hard coded, because that's how RC servos generally behave

                I don't think all servos really use the same angle/pulse width ratios; servos I used so far all differ a little bit, so angles are always wrong. More or less, depending on the brand, and quality.

                1. I guess we could add additional parameters, but I would want the basic behaviour to remain as-is for compatibility with other 3D printer firmwares. I think I chose 200 as the cutoff angle because that's what Marlin did.

                I understand. I propose this:

                • by default, RRF uses the current ratio (0°/544µs - 180°/2400µs)
                • add a param 'R' to change this ratio (for example, R800:2200 to use 0°/800µs - 180°/2200µs);
                • add another param 'F' to force usage of angle or µs ('F0' to force angle, and 'F1' to force µs), so values below 200 could be µs, and values above 200 could be angles (don't limit angles in the firmware; just make the computation, even for negative angles);

                Is there any reason why you can't use microsecond values?

                Yes, I can, but it would be nice to be able to think in degrees, rather than µs. And it would allow me to tune things (offset...) from the config file, instead to have to change values in different places.

                Frédéric

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