Delay or debounce
- slowpoke
- Offline
- Elite Member
Less
More
- Posts: 180
- Thank you received: 25
21 Aug 2024 07:50 - 21 Aug 2024 07:55 #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
#.......................................................
Last edit: 21 Aug 2024 07:55 by slowpoke.
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 4059
- Thank you received: 1750
21 Aug 2024 09:14 #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 or Create an account to join the conversation.
- slowpoke
- Offline
- Elite Member
Less
More
- Posts: 180
- Thank you received: 25
21 Aug 2024 13:07 #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 or Create an account to join the conversation.
Time to create page: 0.063 seconds