Run/Step Hold/Resume Buttons

More
10 years 1 month ago #79929 by andypugh

OT-CNC wrote: That's a good thing. We don't want broken taps. B)

How do I add the stop button? I found the example somewhere but can't find it again. Actually it would be nice to have the external stop button stop all motion in program run and mdi mode. I want to stop the spindle and the servos with a momentary push button.


Maybe motion.enable ?

linuxcnc.org/docs/2.7/html/man/man9/motion.9.html

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #87919 by jensor
Replied by jensor on topic Run/Step Hold/Resume Buttons
I think I found the problem of run/step not working consistently. I have run the file and only one time it ran as expected and unfortunately I have not had it do again. I find that the pin "halui.program-is-paused" goes true when initially pausing, however after a step is made it toggles false which prevents the next step command from getting through the "and" gate. I don't know why it does this, but it looks like that is the problem.
I hope that sometime the file runs as it should and then I can check on what that pin is doing.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #87925 by rodw
Replied by rodw on topic Run/Step Hold/Resume Buttons

jensor wrote: I think I found the problem of run/step not working consistently. I have run the file and only one time it ran as expected and unfortunately I have not had it do again. I find that the pin "halui.program-is-paused" goes true when initially pausing, however after a step is made it toggles false which prevents the next step command from getting through the "and" gate. I don't know why it does this, but it looks like that is the problem.
I hope that sometime the file runs as it should and then I can check on what that pin is doing.


I'm pretty sure that if you have problems, it will be in your implementation. When I installed this example, it worked perfectly from the very beginning. Could one of the logic and2's be in use by another part of your hal file or something like that?

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #87928 by jensor
Replied by jensor on topic Run/Step Hold/Resume Buttons
I am attaching a logic diagram of what I implemented. I think it is

Your browser does not support embedded PDFs. Please download the file here: Download PDF.

the same logic.

Please Log in or Create an account to join the conversation.

More
8 years 10 months ago - 8 years 10 months ago #103861 by JackBerkhout
Thank you very much for this!!!

I added the Stop button, and the buttons have LED indicators, which I also use.
So we have:
'Run/Step' (Green)
'Pause/Resume' (Yellow)
'Stop' (Red)
Note I use a different MESA board...
And I used an AND in my 'home.hal', so here it counts from 1 instead of 0.

But Initially, when I pressed 'Stop', I got this error:
"can't do that (EMC_TRAJ_SET_TELEOP_ENABLE) in auto mode with interpreter idle"
But if I first pressed 'Pause', it worked without that error.
So to solved that, I added an OR (output to pause) and perform a pause, just before stop.

The code (my filename: 'run_step_pause_resume_stop.hal'):

# Run/Step Pause/Resume Stop Buttons
# forum.linuxcnc.org/47-hal-examples/13201...-hold-resume-buttons
# This is how they function:
# Pressing Run/Step will begin executing a program.
# Pressing Pause/Resume while a program is running will pause the program.
# Pressing Run/Step while a program is paused will single step the program.
# Pressing Pause/Resume while a program is paused will return it to normal run mode.
# Pressing Stop while a program is running or paused will stop the program.

# TB6.00 = INPUT00 - Push-button 'Run/Step' (Green)
# TB6.01 = INPUT01 - Push-button 'Pause/Resume' (Yellow)
# TB6.02 = INPUT02 - Push-button 'Stop' (Red)
# TB6.00 = OUTPUT00 - LED Indicator Green 'Run' in 'Run/Step' push-button
# TB6.01 = OUTPUT01 - LED Indicator Yellow 'Paused' in 'Pause/Resume' push-button
# TB6.02 = OUTPUT02 - LED Indicator Red 'Stop' in 'Stop' push-button

#loadrt and2 count=4 (Only allowed in one place: done in home.hal)
loadrt or2 count=2
loadrt toggle count=1
loadrt toggle2nist count=1

addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread
addf or2.0 servo-thread
addf or2.1 servo-thread
addf toggle.0 servo-thread
addf toggle2nist.0 servo-thread

# External Program Pause/Resume, Run/Step, and Stop Buttons

# Run/Step Section
# This is your Run/Step input
# The contact is NO - Normally Open, the button is connected between Field Power and the input
#net run-step-btn and2.3.in0 and2.4.in0 <= hm2_7i76e.0.7i76.0.0.input-00-not
net run-step-btn and2.3.in0 and2.4.in0 <= hm2_7i76e.0.7i76.0.0.input-00
net idle-on and2.3.in1 <= halui.program.is-idle
# net pause.on and 2.3.in1 <= halui.program.is-paused
# and2.4.in1 was added in the net pause-on statement in Pause/Resume Section
net run-sig halui.mode.auto halui.program.run <= and2.3.out
net step-sig halui.program.step <= and2.4.out

# Pause/Resume Section
# This is your Pause/Resume input
# The contact is NO - Normally Open, the button is connected between Field Power and the input
#net pause-resume-btn and2.1.in0 and2.2.in0 <= hm2_7i76e.0.7i76.0.0.input-01-not
net pause-resume-btn and2.1.in0 and2.2.in0 <= hm2_7i76e.0.7i76.0.0.input-01
net pause-on toggle2nist.0.is-on and2.1.in1 and2.4.in1 <= halui.program.is-paused
net run-on and2.2.in1 <= halui.program.is-running
net pause-sig or2.0.in0 <= and2.1.out
net resume-sig or2.0.in1 <= and2.2.out
net toggle-ok toggle.0.in <= or2.0.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon or2.1.in0 <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off

# Stop Section
# This is your Stop input
# The contact is NO - Normally Open, the button is connected between Field Power and the input
#net stop-btn <= hm2_7i76e.0.7i76.0.0.input-02-not
net stop-btn <= hm2_7i76e.0.7i76.0.0.input-02
net stop-btn => or2.1.in1
# I had to pause before stop, to avoid this error:
# can't do that (EMC_TRAJ_SET_TELEOP_ENABLE) in auto mode with interpreter idle'
# So I used an OR because halui.program.pause is activated from two places now, here and in rthe previous section
net program-pause or2.1.out => halui.program.pause
net stop-btn => halui.program.stop

# LED Indicator Section (LED indicators in the push-buttons)
# The LED indictors are connected bewteen outputs and GND
# Green LED Indicator in Run/Step push-button (halui.program.is-running)
net run-on => hm2_7i76e.0.7i76.0.0.output-00
# Orange LED Indicator in Pause/Resume push-button (halui.program.is-paused)
net pause-on => hm2_7i76e.0.7i76.0.0.output-01
# Red LED Indicator in Stop push-button (halui.program.is-idle)
net idle-on => hm2_7i76e.0.7i76.0.0.output-02

I use several hal files, to separate things that belong together.
However instructions like 'loadrt and2 count=4' should only be done in one place it appears.
Maybe, I need to create a script for just those, like 'my_one_place_to_loadrt.hal'?
Anybody has a great solution for that?

Any comments are welcome.

Kind regards,
Jack.
Last edit: 8 years 10 months ago by JackBerkhout.
The following user(s) said Thank You: DanMN, Lethal69GTO

Please Log in or Create an account to join the conversation.

More
7 years 10 months ago #121788 by naborskid
hello
if you don't mind i would like to add my code for cycle start and feed hold buttons.
it functions like fanuc control ,"cycle start" button starts program ,"feed hold" pauses program ,"cycle start" resumes program
maybe it will help someone with a basic parallel port setup

addf and2.10 servo-thread
addf and2.11 servo-thread

net remrun parport.1.pin-11-in
net remrun and2.11.in0 and2.10.in1
net remidle halui.program.is-idle and2.10.in0
net remgo and2.10.out halui.mode.auto halui.program.run
net remstop halui.program.is-paused and2.11.in1
net remresume and2.11.out halui.program.resume
net remstart halui.program.pause <= parport.1.pin-10-in halui.program.pause
net coolant-flood <= halui.program.is-running
net coolant-flood => parport.1.pin-14-out
The following user(s) said Thank You: vmihalca

Please Log in or Create an account to join the conversation.

Time to create page: 0.381 seconds
Powered by Kunena Forum