Multithreading
-
Hi! I'm using Duet 3 Mini 5+ and I'm interested in having two functions run concurrently: (1) extruding and moving an axis, (2) moving a hobby servo.
One solution is multithreading. I saw that RRF supports FreeRTOS and have been looking through the documentation. I can't locate the Demo Projects -- can anyone send an example of what relevant files to load into the system libraries and an example script of how to do multithreading in a .g code.
Another question: would it be possible to define the servo as a tool (using M508), and if so, can we define this tool in the same line as the extrusion/axis such that we can move both the servo, extrusion, and linear axis using the same G1 command?
-
@ozgunkilicafsar @dc42 @jay_s_uk @droftarts would you be able to help?
-
@ozgunkilicafsar I think you mean this: https://docs.duet3d.com/User_manual/RepRapFirmware/Multiple_motion_systems
Have a read through, come back with any questions.
Ian
-
@ozgunkilicafsar said in Multithreading:
Another question: would it be possible to define the servo as a tool (using M508), and if so, can we define this tool in the same line as the extrusion/axis such that we can move both the servo, extrusion, and linear axis using the same G1 command?
You can't set a servo as a extruder drive in a tool; the firmware expects the drive to be a stepper motor. Is it a continuously turning servo, or do you just need to turn it to specific positions? You might be able to create a dummy tool with M563 (not M508 - that doesn't seem to be a valid Gcode), defined with an unused stepper driver. Then use M571 https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m571-set-output-on-extrude to control a PWM pin to control the servo. However, I don't think this gives the control over the servo that you are looking for; it's designed to turn on motors while extrusion is running, rather than position servos. So the PWM value is set by M571, and on extrude it would just move the servo to the same position each time. Or if it is a continuously turning servo, I guess it may act more like a motor and turn at a continuous speed.
Ian
-
Multithreading is a bit overkill for driving only a servo. Have you thought of using macros instead?
You can postprocess your printfile by replacing the retract/unretract lines (G10 and G11) with G10.1 and G11.1 respectively. Now you write two macros called G10.1 and G11.1 in which you set the required servo positions (and also trigger the real retract/unretract macros)