Emergency stop
-
I’m using a Duet 3 6HC as a controller for a robot with 3 axes. It has been quite easy to setup
I’m now trying to make a stop function activated by an input.
I want the robot to stop moving(pause) when a switch is opening. But I don’t want it to work as a hard emergency stop, where the motors are unpowered, because I don’t want to have to home all axes again and also the robot don’t have force enough to cause any hazards.
For this, I decided to use IO-pin 3 with pull-up and a switch connected to gnd.
After reading this documentation:
https://docs.duet3d.com/User_manual/Connecting_hardware/IO_E_stop
and G-code documentation on reprap.org
From this I’m guessing that this should be the code to add to config.g:M950 J1 C"^io3.in ; Create GPIO with pull-up on connector io3 M581 P1 T1 S0 C0 ; Configure external trigger. P1: Trigger ID, T1: Causes pause, S1: Rising Edge, C0: Trigger at any time.
But it is not working. I tried activating the switch both during homing and during move after homing, but the switch doesn’t do any difference.
I have also tried to change the T parameter to T0, which should make it act as a complete emergency stop(?), which would require a restart after triggering the switch.
But that also doesn’t work.
Is there any g-code command that would let you read the current state of an input pin?
Any ideas on why this is not working? -
@MiguelDK how do you have it wired?
-
-
@MiguelDK I discovered that I missed a " in the end of the M950 definition.
With this corrected, I am able to make the T0 work (Hard emergency stop)
But with T1 (Pause function) it doesn't seem to effect the movement at all.
Any ideas on how to make this work?
Is there any way to read status of the IO pins using G-CODE? -
@MiguelDK it won't pause until the end of that current move has been completed
you could addM669 S1 T1
to add segmentation -
@jay_s_uk I tried to add the M669 command, but I don't see any change in behavior, when toggling the switch during a move.
I have set the C parameter of M581 to 0, to trigger at any time.
Among the configuration files there is "pause.g" which, according to the generated comment, is called when: "a print from the SD card is paused".
Is there a specific file that I should add code to that is called when pausing, while not printing from the SD card? -
@MiguelDK when would you not be printing from the SD card?
-
@jay_s_uk I am using the controller as a robot controller, not as a 3D printer. So I primarily use the G28 and G1 commands using the USB/Serial port.
The robot is inside an enclosure with a door with access for users. The switch connected to input 3, will work as a door switch to detect whenever the door is open.
The robot are normally controlled from a remote location.
Therefore I'd like the robot to pause and perhaps perform a series of G-codes whenever somebody opens the door. -
@MiguelDK the concept of a pause is only valid when a job file is being run. You can call "pause.g" directly using M98 if you want the actions contained in pause.g to run when a job is not being run.
-
@T3P3Tony Ok.
So, is there a way, to stop any movement when an input is triggered. Without the need for re-homing/restarting? -
@MiguelDK
M0 is what you are looking for i think:
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m0-stop-or-unconditional-stop -
-
@T3P3Tony Hmm.. Yeah. I don't think that, it would work.
But meanwhile, I have been playing with the idea that; if I just perform all moves with the H4 parameter like eg.:G1 H4 X150
Then it should, by my understanding stop, when an end-stop is activated and update the current position.
Therefore have updated my config.g with this end-stop definition update:; Endstops M574 X2 S1 P"!^io0.in" ; configure switch-type (e.g. microswitch) endstop for high end on X via pin !^io0.in M574 Y2 S1 P"!^io1.in" ; configure switch-type (e.g. microswitch) endstop for high end on Y via pin !^io1.in M574 Z2 S1 P"!^io2.in" ; configure switch-type (e.g. microswitch) endstop for high end on Z via pin !^io2.in ; Doorswitch M574 X1 Y1 Z1 S1 P"^io3.in" ; configure switch-type endstop for low end on XYZ via pin ^io3.in (We use this as door-switch)
So the doorswitch(endstop) is common for all three axes and then I would expect that if moving with the G1 H4, then all movement would stop and the position would be updated when the door was opened.
But it doesn't work, the movement are not stopped when opening my switch.
Can you tell me what is wrong? -
@MiguelDK You can only have one endstop per motor, or one per axis if there is only one motor. You can only define the endstop for one axis with each M574 command. So the Doorswitch M574 command just isn't going to work. You can only set that input as a trigger, rather than an endstop.
One option might be to wire two endstops in series (if the endstops are Normally Closed) or in parallel (if they are Normally Open). Then if either of them get activated, it functions as an endstop would.
Ian
-
@droftarts Thank you for clarifying this Ian. Contacts in series might be a good solution for this.
Do you know if there is a way to check the status of endstops/inputs using G-code?
Miguel -
@MiguelDK M119 reports the state to the console. If you want to use the state programmatically in meta gcode then the OM keys to look at are:
sensors.endstops[n].triggered