- Posts: 224
- Thank you received: 0
Delay or debounce
2 years 2 months ago #308266
by slowpoke
Delay or debounce was created by slowpoke
I'm trying to use one external push button to both pause and resume program execution depending on if the program is running or paused.
I used two and2 gates to perform this task, and it works sort of. The problem is that often when I press the button to pause, the program briefly pauses when the first "pause" and gate fires, however in the 100ms or so it takes for my finger to release the button the 2nd "resume" and gate fires because the program is now paused.
I don't know if there is a slower thread I could place the two and gates in or if there is a way to delay the input to the "resume" and gate?
Excerpt from postgui is below. Thank in advance
# Program Run Button
net pgmRun <= arduino.keypad.PgmRun
net pgmRun => halui.program.run
# Program Stop Button
net pgmStop <= arduino.keypad.PgmStop
net pgmStop => halui.program.stop
# Program Pause Button
net buttonPause <= arduino.keypad.PgmHold
# AND gates to drive PAUSE & RESUME
loadrt and2 count=2
addf and2.0 servo-thread
addf and2.1 servo-thread
# assign nets to AND gate
net pgmRunning halui.program.is-running => and2.0.in0
net buttonPause => and2.0.in1
net pauseThePgm halui.program.pause <= and2.0.out
net pgmPaused halui.program.is-paused => and2.1.in0
net buttonPause => and2.1.in1
net resumeThePgm halui.program.resume <= and2.1.out
#.......................................................
I used two and2 gates to perform this task, and it works sort of. The problem is that often when I press the button to pause, the program briefly pauses when the first "pause" and gate fires, however in the 100ms or so it takes for my finger to release the button the 2nd "resume" and gate fires because the program is now paused.
I don't know if there is a slower thread I could place the two and gates in or if there is a way to delay the input to the "resume" and gate?
Excerpt from postgui is below. Thank in advance
# Program Run Button
net pgmRun <= arduino.keypad.PgmRun
net pgmRun => halui.program.run
# Program Stop Button
net pgmStop <= arduino.keypad.PgmStop
net pgmStop => halui.program.stop
# Program Pause Button
net buttonPause <= arduino.keypad.PgmHold
# AND gates to drive PAUSE & RESUME
loadrt and2 count=2
addf and2.0 servo-thread
addf and2.1 servo-thread
# assign nets to AND gate
net pgmRunning halui.program.is-running => and2.0.in0
net buttonPause => and2.0.in1
net pauseThePgm halui.program.pause <= and2.0.out
net pgmPaused halui.program.is-paused => and2.1.in0
net buttonPause => and2.1.in1
net resumeThePgm halui.program.resume <= and2.1.out
#.......................................................
Please Log in to join the conversation.
2 years 2 months ago #308272
by Aciera
Replied by Aciera on topic Delay or debounce
Maybe try this:
linuxcnc.org/docs/html/man/man9/debounce.9.html
linuxcnc.org/docs/html/man/man9/debounce.9.html
Please Log in to join the conversation.
2 years 2 months ago #308285
by slowpoke
I de-bounced only the input to the resume gate, so quick stops, slow starts. Works perfectly.
Thank you Aciere,
Replied by slowpoke on topic Delay or debounce
Maybe try this:
linuxcnc.org/docs/html/man/man9/debounce.9.html
I de-bounced only the input to the resume gate, so quick stops, slow starts. Works perfectly.
Thank you Aciere,
Please Log in to join the conversation.
Time to create page: 0.998 seconds
