Assigning 2 funcitons to one button

More
03 Aug 2017 13:36 - 03 Aug 2017 14:08 #96974 by czerech
Hello all!

I have a problem, and maybe you will be able to help me.

I got on free input pin on my LPT board. Is it possible to use it like that.

1. I would like to have one button on machine cassing that will do 2 things.
2. If machine is OFF, button will set machine to "on" mode
3. If machine is ON , then that button will will star the program "remrun"

Right now I have it like that, but I need to make it on one input pin :(

net remrun halui.mode.auto <= parport.0.pin-12-in
net remrun => halui.program.run
net machine-on <= parport.0.pin-15-in
net machine-on => halui.machine.on

Thanks in advance for help!

Best regards,
Czerech
Last edit: 03 Aug 2017 14:08 by czerech.

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

More
03 Aug 2017 19:47 #96983 by Todd Zuercher
This is something like what you will need to add to your hal file(s).
To use parallel port pin 15 for the on/run button.
loadrt oneshot count=1
loadrt and2 count=1
addf oneshot.0 servo-thread
addf and2.0 servo-thread

setp oneshot.0.rising false
setp oneshot.0.falling true
setp oneshot.0.width 2

net machine-on <= oneshot.0.out => halui.machine.on
net machine-is-on <= halui.machine.is-on => and2.0.in0  #If halui.machine.is-on is already used somewhere just link this and2 to that signal.
net on-run-btn <= parport.0.pin-15-innet => oneshot.0.in => and2.0.in1
net remrun <= and2.0.out => halui.mode.auto => halui.program.run
The following user(s) said Thank You: czerech

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

More
03 Aug 2017 19:49 #96984 by Todd Zuercher
It is possible you may also need to debounce your parallel port input.
The following user(s) said Thank You: czerech

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

More
04 Aug 2017 07:08 #96994 by czerech
Thank you very much!!!!

I will test that next monday and let you know how did it go.

regards,
Piotr

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

More
07 Aug 2017 23:28 #97133 by andypugh
There is also this HAL module. (does something a bit different to what you asked for, the and2 + oneshot way is better for what you asked for
linuxcnc.org/docs/2.7/html/man/man9/multiswitch.9.html
or
linuxcnc.org/docs/2.7/html/man/man9/multiclick.9.html
The following user(s) said Thank You: czerech

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

More
17 Aug 2017 13:15 #97622 by czerech
I didn't have time to check it :(
I'm going tommorow to do it, but I dont know if I added debounce properly.
loadrt debounce cfg="1"	

addf debounce.0 base-thread

setp debounce.0.delay 10

loadrt oneshot count=1
loadrt and2 count=1
addf oneshot.0 servo-thread
addf and2.0 servo-thread

setp oneshot.0.rising false
setp oneshot.0.falling true
setp oneshot.0.width 2

net machine-on <= oneshot.0.out => halui.machine.on
net machine-is-on <= halui.machine.is-on => and2.0.in0
net on-run-btn <= parport.0.pin-15-in => oneshot.0.in => and2.0.in1
net remrun <= and2.0.out => halui.mode.auto => halui.program.run
net debounce-in <= parport.0.pin-15-in => debounce.0.0.in
net debounce.0.0.out => oneshot.0.in
net debounce.0.0.out => and2.0.in1

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

Time to create page: 0.135 seconds
Powered by Kunena Forum