Help with if then loop
-
I'm converting my Z probe to a Klicky style microswitch. I'm waiting on parts to finish the dock/undock of the switch. I would like to be able to remove the magnetically held switch by hand until the parts come in. I would like to write a macro to check if the Z probe is 0 then loop back and check again. If the Z probe is greater than 0 then proceed. This sounds simple and I'm sure it is but I'm having trouble with it, running f/w 3.2. Could someone show me how to write this code, thanks.
-
@luckyflyer there's no conditional gcode or object model until 3.3. I suggest you upgrade your firmware to 3.4 now it's stable and then come back
-
@jay_s_uk I'll do that today.
-
After you get your fw updated, check this doc page for details of programming capabilities in 3.4. The if statement is right in there.
And if you are waiting for a user action, you might consider using an M291 that can pause code execution (blocking) until the user responds.
-
@mikeabuilder seems like you forgot adding the link. Here it is: https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands
-
@luckyflyer, this is how I check that the Klicky was indeed picked up. The probe value changes between 0 and 1000. Not sure why I use > 250 and not > 750 but it may not matter.
M400 G4 P250 ; Wait 250ms if {sensors.probes[0].value[0]} > 250 echo "Error: Clickey not picked. Value: " ^ {sensors.probes[0].value[0]} M112 ; Emergency stop. echo "Clicky pick done"
-
Thanks all, I have 3.4 up and running. I'm now struggling with getting mjpeg-streamer working again. Final parts needed for docking the switch will be here Monday. I'm looking forward to having my printer back online.