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

Bi-directional DC motor control?

Scheduled Pinned Locked Moved
General Discussion
2
6
962
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.
  • undefined
    rs4race
    last edited by 7 Mar 2018, 23:29

    I'm looking for some advice on using the duet to control a DC motor (6V 90mA). It's part of an actuator to raise and lower a second hotend, so it needs to reverse. My plan was to turn the motor on for a period and turn it off. Reverse motor direction to raise it. Both directions have hardstops.
    Originally I planned to use a fan channel, which seemed simple to implement the gcode, but realized that they aren't bi-directional. Some research suggests to use a H-bridge. It looks like that would require two pins to control both directions.

    I'm curious if there are any pins available other than the 3 fan channels. I'm also curious if an h bridge is the best option? If there are pins available are there any resources I can check out to see how to configure them?

    Thanks!

    1 Reply Last reply Reply Quote 0
    • undefined
      dc42 administrators
      last edited by 7 Mar 2018, 23:56

      An H-bridge is the usual option for controlling a reversing DC motor. You can drive an H-bridge from two pins using M42 commands. See https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins. A suitable H-bridge might be https://www.pololu.com/product/2990 or another in the Pololu range.

      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
      • undefined
        rs4race
        last edited by 8 Mar 2018, 16:01

        Thanks for the advice!

        I picked up a H bridge, checked out the M42 command and the controlling IO pins link you provided.

        What would be the prefered pins to use? I see heaters labeled pins 3-7 which look like 8, 13, 18, 23, and 28 on the expansion header. I don't see any labeled fan on the header though. I assume using a couple of the heater channels would be the way to go?

        To implement this using heater 6 for direction and 7 for speed it would look something like this:
        First disable the channels in config (I assume)
        M307 H6 A-1 C-1 D-1
        M307 H7 A-1 C-1 D-1

        Then to extend the tool
        M42 P6 S0
        M42 P7 S255
        G4 S1
        M42 P7 S0

        and to retract
        M42 P6 S255
        M42 P7 S255
        G4 S1
        M42 P7 S0

        Am I on the right track?

        1 Reply Last reply Reply Quote 0
        • undefined
          dc42 administrators
          last edited by 8 Mar 2018, 16:18

          Yes, that's the sort of thing I had in mind.

          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
          • undefined
            rs4race
            last edited by 9 Mar 2018, 04:47

            I got this to work using heater channels 6 and 7 and the pins 1 and 2 on the header for GND and 5V. I setup the pins with
            M307 H6 A-1 C-1 D-1
            M307 H7 A-1 C-1 D-1

            When I command M42 P6 S0 I read 3.3v to GND (pin 2) and when I command M42 P6 S255 they read 0V. Is this the expected behavior? Are pins 1 and 2 ok for 5V power?

            I powered this with USB.

            1 Reply Last reply Reply Quote 0
            • undefined
              dc42 administrators
              last edited by 9 Mar 2018, 08:25

              The heater outputs are inverted by default, because when they are used to drive heaters there is an inverting level shifter driving the MOSFET.

              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
              6 out of 6
              • First post
                6/6
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA