Controlling hobby servos with 6XD mainboard
-
Hello,
I want to connect two Tower Pro MG996R servos to the 6XD mainboard via output 4 & 5. They are powered through a separate 5V PSU which shares the GND with the main PSU.
Following the wiki guide Connecting hobby servos and DC motors and setting things to:
M950 S3 C"out4" ; Servo left, servo mode M280 P3 S0 M950 S4 C"out5" ; Servo right, servo mode M280 P4 S0
This does nothing and the servos don't move at all.
I have also tried connecting one to out6 which provides a 5V PWM but that doesn't help.
Any help will be highly appreciated. -
@semi55 The OUT# pins switch to GND, as MOSFETs (the 'switch') work best when placed after the load (ie 24V > fan/heater > MOSFET 'switch' > GND). This means the pin doesn't supply the +5V PWM signal a servo needs, so you can't use them directly to drive a servo, though there is a workaround (see third point below).
With the 6XD, your options are:
- Use the IO connectors, not OUT connection. However, IO#.out pins only provide a +3.3V PWM signal, and only on IO4 and IO7 (see https://docs.duet3d.com/Duet3D_hardware/Duet_3_family/Duet_3_Mainboard_6XD_Hardware_Overview#specific-capabilities). Most hobby servos recommend +5V signalling, but generally work with +3.3V signalling; I think the Tower Pros should cope with 3.3V signalling. Connect the servo control wires to io4.out and io7.out, configure with:
M950 S3 C"io4.out" ; Servo left, servo mode
M950 S4 C"io7.out" ; Servo right, servo mode
- You can connect one servo to the LASER/VFD output, which is +5V PWM. The LASER/VFD output is shared with OUT6, so don't connect the servo or anything else to OUT6. Connect the servo control wire to the 'vfd' pin on the LASER/VFD/servo connector, configure with:
M950 S3 C"vfd" ; Servo left, servo mode
- You can use IO connectors, but you'll need to 'pullup' the PWM signal to +5V using a simple circuit, with the addition of a 1kohm pullup resistor. See https://forum.duet3d.com/post/118283 (thanks again @DIY-O-Sphere ).
In this configuration, the signal needs to be inverted, as when the pin is 'on', it grounds the 5V signal. Do this by adding a!
to the pin name, eg:
M950 S3 C"!out4" ; Servo left, servo mode
M950 S4 C"!out5" ; Servo right, servo mode
Also note that most servos' working range is more likely to be 10 to 170 degrees. Your
M280 P3 S0
command attempts to make the servo go to 0 degrees, which may cause a motor stall and draw maximum current, which is not good; see https://docs.duet3d.com/User_manual/Connecting_hardware/Motors_servos#stall-currentIan
- Use the IO connectors, not OUT connection. However, IO#.out pins only provide a +3.3V PWM signal, and only on IO4 and IO7 (see https://docs.duet3d.com/Duet3D_hardware/Duet_3_family/Duet_3_Mainboard_6XD_Hardware_Overview#specific-capabilities). Most hobby servos recommend +5V signalling, but generally work with +3.3V signalling; I think the Tower Pros should cope with 3.3V signalling. Connect the servo control wires to io4.out and io7.out, configure with:
-
@droftarts Thank you very much Ian for your elaborate answer. That solved it!
I've chosen the easy route and used I_O4 and I_O7 and they are working perfectly now. -
-