Define RC Servo as Axis?
-
Is it possible (if not then this is one for the wishlist) to define a servo as an axis?
I have a twin hotend head with a servo mechanism that drops one nozzle while lifting the other to change over active hotends. This changes the distance between the nozzle and the extruder drive. So at the moment I would need to retract the filament that is o the active nozzle, servo lift one and drop the other nozzle, and finally prime the new active nozzle. It woould be great if the extrusion moves could happen at the same time as the servo swap. Less chance of sucking air back into the hotend.
-
@DocTrucker No, as far as I know servos cannot be defined as an axis. Could you control the servo in a second motion system, and coordinate it with the extrusion move that way? See https://docs.duet3d.com/en/User_manual/RepRapFirmware/Multiple_motion_systems
Ian
-
The problem I see with a hobby servo as axis is: you can't control the speed very well. It would be a jerky start/stop motion at best.
Alternatively, there are tiny "N20" geared motors with AB-encoder. You can use simpleFOC to control them via their step/dir interface.
I did similar things with a RP2040 or ESP32 and a BLDC motor -
Not that it really needs showing but here is the mechanism viewed upside down. those clamps secure to the cool side of the heat break after the heat sinks:
https://youtu.be/mDKmF9O7StE?si=4yzGWXIKaESQB9Nr
@o_lampe at slow speeds fair enough, but at higher speeds the motion is smooth enough to be able to move in sync with a stepper. PWM is after all an analogue signal, it just happens that most control systems impose a microsecond resolution to the control. That said few servos even reach that level of resolution. Hooking up Duet systems to the DroneCAN servos would be great, but: [far to little use case/not apropriate for this use case/to expensive].
Well guess that answers my next question which was how to control speed! Not enough use case to add the control loop. I will look into conditional gcode and a loop to increment stepper and servo.
-
...the blocking nature of the G1 Ex Fx commands could be used to time seperate the servo update commands. Just a little work to find usec per mm and max speed of the lift mechanism. Think the conditional gcode loop has legs for this.
-
I had a crack at the conditional gcode this morning and it worked reasonably well, but the movement is sloooow! I will be reading the PWM setting using the object model and developing the code so that it moves from any position. Parking the nozzles to a known position before shut down will also simplify things.
; test ; T0 Nozzle movement = 1.15mm ; T1 Nozzle movement = 1.40mm ; PWM Settings T0 = M280 P0 S1750 ; PWM Settings T1 = M280 P0 S1250 ; PWM range = 500us var e_range = 1.15 var e_step = 0.10 var num_steps = var.e_range / var.e_step; = 28 var e2_step = -1.40 / var.num_steps var pwm_start = 1750 ; T0 high var pwm_end = 1250 ; T0 low. var pwm_current = var.pwm_start var pwm_step = (var.pwm_end - var.pwm_start) / var.num_steps var loop_count = 0 while var.loop_count < var.num_steps set var.loop_count = iterations set var.pwm_current = var.pwm_start + (var.pwm_step * iterations) M280 P0 S{var.pwm_current} G1 E{var.e_step}:{var.e2_step} set var.pwm_current = var.pwm_end M280 P0 S{var.pwm_current}
-
@DocTrucker said in Define RC Servo as Axis?:
the movement is sloooow!
There is no F-param in the
G1 E.....
line, maybe it runs at turtle speed? -
@o_lampe Good spot. Can't see the wood for the trees after a while.
I'll be using whatever the previous F setting was. The other issue that will be choking speed a bit is it will be looking to come to a full stop before executing each change of PWM.
-
@DocTrucker That's what I meant with jerky motion. You can use bigger steps than 5 microseconds for more speed, but too much and they get jerky.