Need help setting up Servo?
-
Hello!
I am trying to set up a small hobby servo SG90 for a pen plotter replacing the Z axis.
In Marlin it just uses M280 and M282. (one sets the angle for the servo, the other deactivates the servo to save the life of the little motor).
I need a little help in what to put in the configurations (and which file).
When I was using Marlin I think I just used the BLtouch pin and settings.
PS I have now tried Marlin, Klipper and RRF. and RRF is the most intuitive. I love the Upload and print button. Rather than uploading files, finding the file and then setting it to print.
Thanks
Max
-
Perhaps this is what you're looking for?
https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins
-
@westech For the servo for my brush i use:
- in config.g
; Cleaning Brush M950 S1 C"exp.heater3" ; assign GPIO port 1 to heater3 on expansion connector, servo mode M280 P1 S1 ; set (1deg) servo position on GPIO port 1
- for moving the brush
; this macro deploys the brush for cleaning the nozzle(s) ; if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed ; are axles homed ? M291 P"axles not homed! perform homing ?" R"DeployBrush" S3 ; message when not homed G28 ; homing if move.axes[2].machinePosition < 26 ; z < 26mm ? because brush can crash with bed! M291 P"bed to high for brush! move 26mm down?" R"DeployBrush" ; message G0 Z26 ; move z to 26mm M280 P1 S90 ; set servo position to 90° M291 P"brush ready" R"DeployBrush" S1 ; message
For moving the servo use the M280 command
-
@cosmowave said in Need help setting up Servo?:
M950 S1 C"exp.heater3"
Thank you. I had read the wiki, but was confused by the reference to "exp.heater3", so I'm guessing it just is what the pin is called not to do with a heater which I'd imagine uses a mosfet.
I'm super new at this. So for writing a macro how would I do this:
I'd create a file in Marcos folder called
Pen-down.g
M280 P1 S0 "set the servo to 0 degrees" PEN DOWN
Pen-up.g
M280 P1 S90 "set the servo to 90 degrees" PEN UP
Do I need to set M950: ""Create heater, fan, spindle or GPIO/servo pin Just once at the start of a print? or must that be set before each M280 command?
If I will always use that pin for the servo, can it be put in the config.g. It looks like that is how the BLtouch works. Correct.
Thanks.
-
@westech you would need the M950 command in your config file or you can add to the macro. But you would need it somewhere that it will be called at least once each time your duet board is powered up or reset. So the config makes the mouse sense.
-
@baird1fa Thanks, That makes sense. As long as I put it in Config, The Macro does not need to invoke M950 again.
Thanks
Max
-
i was searching for possibility to deactivate servo, to prevent damage (overheat) it in my case, and finally I have found a solution. You have to set "!" in front of pin name and then again any M280. "!" changes polarity of output and next M280 command results in sending unreliable data to servo so it deactivates.
Like in example bellow.Of course then before any M280 command you should put M950.
M950 S1 C"pinname"
M280 P1 S180
M950 S1 C"!pinname"
M280 P1 S180