one button multiple functions

More
03 Jul 2011 07:32 #11089 by kostas
I don't know if you finally found what you where looking for fabworx, but I was searching yesterday for the same thing and found that I could use the halui component.

For example, for connecting a button that will run the thing, I tried:
net halui-run hm2_7i43.0.gpio.016.in_not => halui.mode.auto halui.program.run

Same for other buttons. Need a "HALUI=halui" in your .ini file first.

It kind of works, but I think that I need a custom component to support all the necessary logic so that it works just as AXIS does. Or, better, I'll try to make something that does RUN/PAUSE/STOP on the same button. I was thinking something like doing a STOP action when pressed for more that one sec, or something.

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

More
03 Jul 2011 12:38 #11093 by BigJohnT
Take a look in the HAL Examples section of this forum for examples of one button toggles.

John

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

More
03 Jul 2011 12:53 #11097 by kostas
Thanks John. I saw the example and will study it. But I have come to the conclusion that, as Andy said earlier here, it will be much easier to create a custom component that will do what I want, since my setup will be somewhat complicated.

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

More
14 Dec 2011 18:50 #15688 by fabworx
hi john i have looked at the examples and have looked at the docs i cant figure out how to write the hal so that one button will do more the 2 functions as i want to use one momentary buttom on my pendant to cycle through my jog steps. i cant find an example any wheere with more then two functions. thanx for your help

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

More
14 Dec 2011 19:33 #15690 by BigJohnT
I don't know of any examples of doing more than toggling something like coolant on and off. I guess there might be a way but it is above my pay scale.

John

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

More
15 Dec 2011 01:13 #15695 by andypugh
fabworx wrote:

hi john i have looked at the examples and have looked at the docs i cant figure out how to write the hal so that one button will do more the 2 functions as i want to use one momentary buttom on my pendant to cycle through my jog steps. i cant find an example any wheere with more then two functions. thanx for your help


I think you probably need to use updown and select8
www.linuxcnc.org/docview/html/man/man9/updown.9.html
www.linuxcnc.org/docview/html/man/man9/select8.9.html

Your button would increment the counter (with wrap) and then the individual bits from select8 would perform the various functions.

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

More
15 Dec 2011 12:28 - 18 Dec 2011 11:03 #15700 by ArcEye
Hi

This is an example of a custom multi position switch component that combines the functionality of the components that Andy highlighted in one.

It has a pin toggle, which increments the count and sends the next pin true until it reaches its limit and it cycles back to off.

It is written very simply, so that it is easy to alter, you could use bitwise operators etc and considerably reduce the code size but at the expense of readablity.

If it is of use, borrow with pride

regards

NB Now at www.linuxcnc.org/index.php/english/compo...id=47&id=15803#15803
Attachments:
Last edit: 18 Dec 2011 11:03 by ArcEye. Reason: update

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

More
16 Dec 2011 19:22 #15745 by fabworx
thank you arceye however i have no idea how to impliment a component do i put it in my hal file or ini . also how do i connect a pin to the different jog scales and connect the hm2_5i20.0.062.in or what ever ithe phisical pin is the button on my pendent triggers.

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

More
17 Dec 2011 08:52 #15763 by ArcEye
Hi

This will tell you about building and installing a component using comp

linuxcnc.org/docs/html/hal_comp.html

I'll come back to you with with something re connections later, dashing out now.

Read the header of the .comp file for generic example connections to a parport and how to load the component in your hal file

regards

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

More
17 Dec 2011 17:49 #15777 by ArcEye
Hi again,

Having read the previous link you will have noted that to compile the component you just need

sudo comp --install multiswitch.comp from a directory with the multiswitch.comp file in it

That will compile multiswitch.ko and copy it to /usr/realtime-2.6.32-122-rtai/modules/emc2 on a vanilla install of Ubuntu 10.4 from Live CD.

To use the component, lets take Big Johns' Simple Remote Pendant as an example.
wiki.linuxcnc.org/emcinfo.pl?Simple_Remote_Pendant

First load the multiswitch component, set it to 3 positions (because we are using state0 as an unconnected off position).
Then set a button output linked to the multiswitch.0.toggle input, in this case input.0.btn-thumb.
Then just need to substitute the button outputs that were linked to the or2 components
for multiswitch.0.stateN output pins.

The result will allow cycling through the off/slow/med/fast jog speeds, just using the one button.

The below .hal file code shows this.
Compare it to the original code in the wiki and you should see the changes easily.
loadrt or2 count=2
loadrt mux4 count=1
 
loadrt multiswitch
addf multiswitch.0 servo-thread
setp multiswitch.0.positions = 3  

addf or2.0 servo-thread
addf or2.1 servo-thread
addf mux4.0 servo-thread

# set the jog speed for the joypad again use numbers that make sense for your machine
setp mux4.0.in0 0 # this one must be 0 to prevent motion unless a button is pressed
setp mux4.0.in1 25
setp mux4.0.in2 100
setp mux4.0.in3 200

##  defaults to off, press once for speed-slow, 2nd press gets medium, 
## next press for fast, press again and back to off

net toggle-signal multiswitch.0.toggle <= input.0.btn-thumb

net remote-speed-slow   or2.0.in0 <= multiswitch.0.state1 
net remote-speed-medium or2.1.in0 <= multiswitch.0.state2 
net remote-speed-fast   or2.0.in1   or2.1.in1   <= multiswitch.0.state3
 
net joy-speed-1 mux4.0.sel0 <= or2.0.out
net joy-speed-2 mux4.0.sel1 <= or2.1.out
net joy-speed-final halui.jog-speed <= mux4.0.out

Health warning:
This is just a back of an envelope example of the principle, not a cut and paste .hal file, you will have to tailor to your needs and
test it.
The component may need a delay built in to prevent cycling through the states, if the button is not just pressed momentarily.
If that is the case let me know and I will devise something.

regards

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

Time to create page: 0.258 seconds
Powered by Kunena Forum