External Pause/Resume Button
-
@owend
This seems to work, although I don't understand why it does and what I had before doesn't:;echo "called at " ^ state.time G4 P1 ; delay 1ms to debounce if sensors.gpIn[9].value=1 ;echo "debounce" M99 ; break out if sensor value is zero again (bouncing) if job.file.fileName !=null ; if there's a job filename then it's reasonably safe to say we are printing if global.PausePress == false ; the button hasn't been pressed so we'll pause ;echo "Pause" M25 else ;echo "resume" M24 set global.PausePress = !global.PausePress ; toggle the value from whatever it was before use "not"
Even with the delay debounce 1ms it now works as expected, So Thank you!
As for the 2 buttons debate, these buttons are way to cool, and lend themselves to the "One button Pause/Resume" idea:
I light and dim the LED in the pause and resume macros so the button is a correct indicator. You can even put a label behind the plastic to mark what its for. The LED is a bit dim on the 3.3v from the output, but I think I can deal with that now that I have this working
-
@burtonenator
The reason it didn't work before is that when the button bounced it called the macro twice in succession.
The long delay was masking this. -
This is a really interesting thread, @burtonenator, thank you. I'm looking for a way to pause and resume the machine (in my case a CNC machine) with a normally open switch, which you seem to have done here. First press to pause, subsequent press to resume. This was referred to as a "feed hold" switch on my Shapeoko, but it wasn't completely workable with an external switch, so I'm hoping this solution is what I'm looking for on Duet3 MB6HC-controlled machine.
Although a flagrant abuse of the code you've shown here (sorry!) is it necessary to have Pause and Resume macros, as I can't see how they are 'called' from this code - or is that what the global.PausePress line refers to?
I'm also assuming the : Pause button lines in the config.g file are necessary, too?
As you can guess, I'm completely new to this, particularly programming the Duet!
I also noted @fcwilt's comment about using two buttons, which the direction I'd probably go in if I can't wrangle your code to fit with my machine.
-
So far this has worked well for me, the only issue is I do have to push the button until the command is recognized, so if the printer is doing a long line, it won't catch unless I have the button down at the end of the line before the next command goes in. This is probably expected and its not that big an issue in practice.
@nightowl999
This is all the magic from the config.g side, its the "T2" that sets it to run the second trigger file (trigger2.g) when the button is pushed.
;Pause Button M950 J9 C"io8.in" M581 P9 T2 S1 ;if !exists global.PausePress ; if it's not created we do so now global PausePress = false
trigger2.g, its the M24 and M25 that actually call the pause and resume files :
;echo "called at " ^ state.time G4 P1 ; delay 10ms to debounce if sensors.gpIn[9].value=1 ;echo "debounce" M99 ; break out if sensor value is zero again (bouncing) if job.file.fileName !=null ; if there's a job filename then it's reasonably safe to say we are printing if global.PausePress == false ; the button hasn't been pressed so we'll pause ;echo "Pause" M25 else ;echo "resume" M24
turning the light on and off was the easy part, just turn the pin for that on or off:
M42 P8 S0 ;LED off set global.PausePress = !global.PausePress ; toggle the value from whatever it was before use "not"
and its magic in config.g:
;output for pause LED M950 P8 C"io8.out" M42 P8 S0 ; off by default
-
That's awesome, thank you @burtonenator!
I see you're using "io8" for this (I'll have to change that to io1 as I'm already using io2, 3, 6 and 8!) but I think that should be fairly straightforward.
I also understand the "; Pause Button" and "; output for pause LED" lines of code are in the config.g file and the code for the M24 and M25 commands are in the trigger.g file, but what I'm not clear on is where the two M42... lines go. Are these in the config.g file too?
I think I've pretty much got the pin outs clear in my head too, but the LEDs in my switch (I think) are 12v, so I may need to get the +ve feed for that elsewhere, probably OUT7, 8 or 9.
Anyway, I'm off to experiment!
Thanks again!
-
@nightowl999
I have the initial M42 in the config.g because it does actually start with that on, so this sets it off, and then after that its in the pause and resume to set it correctly when pressed.
Yea, the out on the io's is 3.3v, I needed a transistor to bring it up to 5v for my LED, which in that one I showed above lists as 12v but looks great at 5v
-
@burtonenator if you used
M950 P8 C"!io8.out"
you could skip the M42 IIRC. -
@burtonenator said in External Pause/Resume Button:
the only issue is I do have to push the button until the command is recognized, so if the printer is doing a long line, it won't catch
Following on from this comment, what in 3D printing terms is "...a long line"? I appreciate this is the code within the gcode file, obviously , but i'm not familiar with how travel speed/time on a 3D printer compares to that of a CNC machine.
Is it a case of CNCers savagely cut their way through stock while 3D printers gently weave their way?
Thanks
-
@nightowl999 said in External Pause/Resume Button:
.a long line
It means that each command would execute and complete before an interruption/pause could take effect before the next command is executed.
You can reduce this effect by increasing the segmentation value. This breaks long running commands up into smaller sections which allows the interruption to happen sooner.
See the details on the M669 command for how to configure segmentation.
-
Sorry, I was being slightly flippant, @phaedrux, although it would be interesting to know how these things compare.
I can cut a a 12" slot in a piece of hardwood with a 1/4" end mill quite qhickly, but I guess it would take a lot longer for a 3D printer to build a 1/4" square bar 12" long quite a bit longer, but I suppose it's trying to compare apples and pears...
-
It's not about the time or speed it takes, it's about the gcode command itself which would be the same in CNC or 3d printer. The point being that in order to interrupt a command in progress it must be segmented to stop it mid execution.
-
@phaedrux I'm being a plum. I was getting confused with another thread! Sorry.
No, this question was really about the delay when activating the pause command for the external switch.
-
@nightowl999 said in External Pause/Resume Button:
it's trying to compare apples and pears...
I like pears but my wife doesn't.
Frederick
-
-
@burtonenator
Just a quick update: I now have full pause/resume control via an external switch. Yaay!Thank you for your wisdom and help.
-
-
I found a little anomaly with the code. It is just a little one, but if you run the file from the Jobs screen, everything works as it should (thanks again), but if you rerun the file from the Start Again button in the Job Control window of the Dashboard, the file will run, but if you use the external button to Pause the process, you get an error:
Error: Cannot print, because no file is selected!
So I'm guessing the "job.file.fileName" line might need a bit of a tweak.
I'll see how I get on...
EDIT: Erm, it doesn't seem to do it now. I'll check again over the next few days and report back...
-
-
-
-
-
-
-
-