Get Output Pin States for Conditional GCode
-
I have relays connected to "out8" and "out9" on my Duet 3, for the purpose of powering a mister and vacuum.
;Set up vacuum and misting outputs M950 P2 C"out8" ; define P2 as vacuum M950 P3 C"out9" ; define P3 as mister
Everything works correctly, and I added M7/9/10/11.gfiles to enable those functions):
# M7.g M42 P3 S1 ; enable mister G4 P2000 ; wait for 2 seconds # M9.g M42 P3 S0 ; disable mister G4 P2000 ; wait for 2 seconds
Now, I'm trying to create macros to toggle the mister and vacuum on and off, but I can't figure out how to read the outputs to determine if they're on or not so I can do the appropriate action of the toggle (turn it on of it's off, or off if it's on).
Presumably I can do something like the following, I just can't seem to master the right solution to make it work:
# ToggleMister.g if P3 EQ 0 M7 else M9
-
The current value of the pin will be in the object model under sensors probably. Explore the object model using the console in DWC using
M409 F"v" K"sensors"
I think you'll find your pin values under
M409 F"v" K"sensors.inputs"
e.g.
M409 F"v" K"sensors.inputs[1].value"
Once you've nailed it. You can then use echo to test the value and trigger the tool to test changes
echo sensors.inputs[1].value
Now you're in position to use the conditional GCODE. Following what you have above, this might look like this
if sensors.inputs[1].value M7 else M9
-
Hmmm... let me poke around. I only see inputs, not outputs... but maybe it's staring me in the face and it's just not "clicking".
-
And by "I only see inputs", I mean endstops...
{ "key": "sensors", "flags": "v", "result": { "analog": [], "endstops": [ { "triggered": false, "type": "inputPin" }, { "triggered": false, "type": "inputPin" }, { "triggered": false, "type": "inputPin" }, { "triggered": false, "type": "inputPin" } ], "filamentMonitors": [], "inputs": [], "probes": [ { "calibrationTemperature": 25.0, "deployedByUser": false, "disablesHeaters": false, "diveHeight": 5.0, "maxProbeCount": 1, "offsets": [ 0, 0 ], "recoveryTime": 0, "speed": 2.0, "temperatureCoefficient": 0, "threshold": 500, "tolerance": 0.030, "travelSpeed": 100.0, "triggerHeight": 0.700, "type": 0, "value": [ 1000 ] } ] } }
-
Just in case the full dump helps diagnose anything:
I am running RC7 if that makes a difference.
-
Just confirmed with @dc42 that output pin States are not yet in the Object Model however there are plans to add them.
-
I've just added output pin states to the OM, so it will be in the next release.
-
Ahh awesome, thanks guys!