Run/Step Hold/Resume Buttons

More
30 Dec 2017 17:22 - 30 Dec 2017 18:19 #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: 30 Dec 2017 18:19 by JackBerkhout.
The following user(s) said Thank You: DanMN

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

More
04 Dec 2018 00:22 #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.

More
06 Dec 2018 17:22 #121964 by andypugh
You might also like to look at LUT5, this is a HAL component that can define an output (boolean) for every possible state of 5 inputs. It is good for interlocks and such.
One thing that can make it even more useful is to feed the output back to one of the inputs. Then it can be used as a flip-flop. for example).

In your example you could wire cycle-start, halui.program-is-paused, door interlock, etc into a LUT5 and get a specific output for each combination.

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

More
18 May 2019 09:26 #134127 by phoenix
its not working at all u moron
at least test something before posting

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

More
18 May 2019 09:28 - 18 May 2019 09:29 #134129 by pl7i92
Replied by pl7i92 on topic Run/Step Hold/Resume Buttons
Mr Bushan
posting in 4 Different treads the same question is not the best behavior

i gave a advice in the tred external start

with clear pinnaming

this workes on all versions of linuxcnc

it is only one line
to be added
Last edit: 18 May 2019 09:29 by pl7i92.
The following user(s) said Thank You: phoenix

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

More
18 May 2019 09:34 #134131 by phoenix
the all i am asking to you guys is which line and where to add it thats it

i just want start button

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

More
18 May 2019 10:20 - 18 May 2019 10:21 #134152 by bevins
Replied by bevins on topic Run/Step Hold/Resume Buttons

Bhushan wrote: its not working at all u moron
at least test something before posting

the all i am asking to you guys is which line and where to add it thats it

i just want start button


He told you what to do. You didnt do what he said, then you call him a moron. lol

Do exactly what he said, then open halshow and look at your pin and make sure you are getting your input.
Last edit: 18 May 2019 10:21 by bevins.
The following user(s) said Thank You: tommylight

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

More
18 May 2019 10:24 #134153 by phoenix
listen u ###### i dont know how to connect hal pins to signals or components
if u can help just help or just dont do anything

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

More
18 May 2019 10:47 #134156 by tommylight

Bhushan wrote: listen u ###### i dont know how to connect hal pins to signals or components
if u can help just help or just dont do anything

Calling names and screaming at people who are helping you will not help, reading the thread again will help.

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

More
18 May 2019 11:05 #134166 by andypugh

Bhushan wrote: listen u ###### i dont know how to connect hal pins to signals or components
if u can help just help or just dont do anything


I am suspecting that LinuxCNC might not be the right solution for you.

Have you read the HAL documentation ?
The following user(s) said Thank You: Mike_Eitel

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

Time to create page: 0.126 seconds
Powered by Kunena Forum