SOLVED - Help needed with Duet Gen 3 external triggers
-
Note. This question relates to Duet generation 3
Short version. I'm trying to change the bed heater fault detection parameters depending on the state of an io pin. I thought I could use M581 but I'm not having much luck. The command I'm using is M581 P"0.io3.in" S0 T2 C0 but I've tried both S0 and S1. I've created a trigger macro called "trigger2" and put it in the .sys folder. That macro just has this single command "M570 H0 P3000 T60 S3000" which should change the heater fault detection parameters to silly numbers - effectively disabling it. For testing I've connected a couple of Dupont leads to io3.in and GND. So shorting these leads should initiate the external trigger which should in turn run the tigger2 macro and alter the heater fault detection settings, but it doesn't. If I enter M570 with no parameters, the heater fault detection remains as configured in config.g. Entering M582 T2 via the console has a similar effect - i.e. no change to the heater fault detection values. So it's likely that I'm doing something stupid but I can't fathom what. Do the trigger macros go in .sys as per the wiki, or should they go in .sys/macros?
Longer version. Essentially, I'm trying to get around a potential problem I'll have with a DC UPS. When power fails, the (24V) UPS will cut in and keep the printer alive. But it won't keep the bed heated because that is mains powered. Therefore after a period of time the bed temperature will drop by more more than the 5 degrees that I have set for (a genuine) heater fault detection. I'm assuming that this might cause the print to stop? If not, then none of this matters. But if so, then I need to get around that. Now the UPS has a set of contacts which will close when the mains power fails. So I'm trying to find a way that I could make use of these contacts to circumvent the heater fault detection when mains power has failed but re-initiate it when mains power is restored. There may be a better way than using M581.
-
does the ups have serial/usb/ethernet interface? if so the Pi could probably help - but having it tied to io on the duet will likely be more reliable.
i used triggers to debug my endstops (i.e. make them audible) when fitting the duet 3 to the cnc and it worked. Triggers live in /sys/ if you run DuetControlServer in a console session instead of a background service does it show you any hints?
-
@bearer The UPS is pretty dumb in that respect. It simply has a few sets of contacts that close on various events. I should have mentioned it but I'm running stand alone - i.e. not using the RPi just yet.
-
ah, can't say i've tried triggers with the standalone firmware.
maybe M118 can help you spit out some debug info to web or usb to determine if the triggers do trigger?
https://duet3d.dozuki.com/Wiki/Gcode#Section_M118_Send_Message_to_Specific_Target -
@bearer I can get the trigger to work if I set the "T" parameter to "0" and so initiate an emergency stop, rather than call a macro. Which is why I think I've done something stupid with the macro. Maybe it needs a "G4" here and there? I'll give that a shot and see if it helps.
-
@deckingman said in Help needed with Duet Gen 3 external triggers:
a trigger macro called "trigger2"
with .g suffix presumably? if T0 works but the macros don't it would explain things if you left out the .g
-
@bearer Yes to the ".g" but I've made a bit of progress thanks to your tip about using M118.
So I have these two commands in config.g
M581 P"0.io3.in" S0 T2 C0; Main board io3. Run macro trigger2 to set bed temperature fault detection to 60 degrees to 0 on falling edge
M581 P"0.io3.in" S1 T3 C0; Main board io3. Run macro trigger3 to restore bed temp fault detection on rising edge
Then I've put M118 S "Trigger 2" at the start of trigger2.g and M118 S "Trigger 3" at the start of trigger3.g.
Now when I short the io3 to GND, nothing happens. But when I then make that open circuit, both trigger 2 and trigger 3 get run. Trigger 3 restores the fault detection parameters back to where they were in config. g which is why it appeared that nothing was happening (because trigger 3 runs straight after trigger 2).
Maybe I can't use triggers in this way? Basically I'm trying run a macro when a switch closes and run a different macro when it opens. So I thought that using S0 and S1 to detect rising edge or falling edge was that way to do that. Am I wrong? What seems to be happening is that both rising edge and falling edge macros run when the switch is open circuit and neither macro runs when it is closed.
-
move the T3 M581 from config.g and move it to trigger2.g
and also reset T2 in trigger3.g and T3 in trigger2.g, should be possible to toggle them with something like that.
-
@bearer Sorry I'm being thick today. I've read that about 6 times but I can't make sense of it. Not sure what this means nor how to reset a "T" parameter. "also reset T2 in trigger3.g and T2 in trigger2.g, "
Wait............I should have checked the documentation for gen 3. https://duet3d.dozuki.com/Wiki/RepRapFirmware_3_overview#Section_M581. It is clearly stated that quote :
"The S parameter is removed. The command waits for a low-to-high input transition. To wait for a high-to-low transition, invert the pin name."
I'll try that.
-
...........and that works a treat!!!.
@bearer - Thanks for your help and sorry for taking up your time - I should have read the documentation.
-
should probably have used "disable" instead of reset. you can program the triggers in trigger files to change it on the fly, but not sure how you'd disable a trigger without the S parameter
-
@bearer said in Help needed with Duet Gen 3 external triggers:
should probably have used "disable" instead of reset. you can program the triggers in trigger files to change it on the fly, but not sure how you'd disable a trigger without the S parameter
No worries - it's all working fine (now that I've done what I should have to start with and read the documentation).