- Posts: 3
- Thank you received: 0
Assigning 2 funcitons to one button
9 years 2 months ago #96974
by czerech
Assigning 2 funcitons to one button was created 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
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
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
9 years 2 months ago #96983
by Todd Zuercher
Replied by Todd Zuercher on topic Assigning 2 funcitons to one button
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.
To use parallel port pin 15 for the on/run button.
Code:
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
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
9 years 2 months ago #96984
by Todd Zuercher
Replied by Todd Zuercher on topic Assigning 2 funcitons to one button
It is possible you may also need to debounce your parallel port input.
Please Log in to join the conversation.
9 years 2 months ago #96994
by czerech
Replied by czerech on topic Assigning 2 funcitons to one button
Thank you very much!!!!
I will test that next monday and let you know how did it go.
regards,
Piotr
I will test that next monday and let you know how did it go.
regards,
Piotr
Please Log in to join the conversation.
9 years 2 months ago #97133
by andypugh
Replied by andypugh on topic Assigning 2 funcitons to one button
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
linuxcnc.org/docs/2.7/html/man/man9/multiswitch.9.html
or
linuxcnc.org/docs/2.7/html/man/man9/multiclick.9.html
Please Log in to join the conversation.
9 years 2 months ago #97622
by czerech
Replied by czerech on topic Assigning 2 funcitons to one button
I didn't have time to check it 
I'm going tommorow to do it, but I dont know if I added debounce properly.
I'm going tommorow to do it, but I dont know if I added debounce properly.
Code:
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 to join the conversation.
Time to create page: 0.100 seconds
