Linking multiple signals/pins together
- Walkahz
- Offline
- Junior Member
Less
More
- Posts: 36
- Thank you received: 7
29 Sep 2024 12:10 #311021
by Walkahz
Linking multiple signals/pins together was created by Walkahz
Hi all.
Been stumbling around classic ladder learning the basics to add functions to my mill.
I have a question. How do you go about linking a pin to multiple signals or the inverse?
I have a spindle break button as a momentary switch on my control panel which I would like to turn on and off the spindle brake. I have been unsuccessful so far at the pin on the mesa card is already driven by another signal coming from HAL
There must be a way to do this as plenty of people have physical buttons as well as buttons inside the gui.
Thanks in advance.
Been stumbling around classic ladder learning the basics to add functions to my mill.
I have a question. How do you go about linking a pin to multiple signals or the inverse?
I have a spindle break button as a momentary switch on my control panel which I would like to turn on and off the spindle brake. I have been unsuccessful so far at the pin on the mesa card is already driven by another signal coming from HAL
There must be a way to do this as plenty of people have physical buttons as well as buttons inside the gui.
Thanks in advance.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23558
- Thank you received: 4858
30 Sep 2024 23:50 #311104
by andypugh
Replied by andypugh on topic Linking multiple signals/pins together
I don't know anything about Classic Ladder. But if you want to connect multiple things together in HAL then I can probably help.
You can connect one input to several outputs simply by using the same signal name.
net signal output1 input1 input2 input3 ...
Is one structure. where "output1" is a "writer" pin that supplies a numerical value, and all the input* pins get set to that value.
As long as you use the same signal name, you can split is across lines, and between HAL files. So the example above could equally well be written:
net signal input3
net signal input1
net signal output1 input2
Or any other order/combination as long as all the connections that need to take the same value share the same "signal"
You can give "signal" any name you want. But the inputs and outputs need to be HAL pins that exist at the time that you connect them.
You can connect one input to several outputs simply by using the same signal name.
net signal output1 input1 input2 input3 ...
Is one structure. where "output1" is a "writer" pin that supplies a numerical value, and all the input* pins get set to that value.
As long as you use the same signal name, you can split is across lines, and between HAL files. So the example above could equally well be written:
net signal input3
net signal input1
net signal output1 input2
Or any other order/combination as long as all the connections that need to take the same value share the same "signal"
You can give "signal" any name you want. But the inputs and outputs need to be HAL pins that exist at the time that you connect them.
The following user(s) said Thank You: abdulasis12
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5009
- Thank you received: 1443
01 Oct 2024 15:20 - 01 Oct 2024 15:31 #311117
by Todd Zuercher
Replied by Todd Zuercher on topic Linking multiple signals/pins together
To expand on what Andy said:
If you want to influence a hal signal with multiple hal output pins, then you must use some kind of hal logic components, because only one hal output pin can be connected to any one signal name.
So for your example where I shall assume your spindle brake is already connected to the hal output pin "spindle.0.brake". You will have to add a logic component. If you want to say add a physical physical button to override your spindle brake. If your config were a parallel port config with the spindle brake connected to pin 14 and the button to pin 12, your hall file might look something like this:
With the above, the spindle brake would be on only if both pins "spindle.0.brake" and "parport.0.pin-12-in-not" are true. If either one or both are false then the brake should be turned off.
If you want to influence a hal signal with multiple hal output pins, then you must use some kind of hal logic components, because only one hal output pin can be connected to any one signal name.
So for your example where I shall assume your spindle brake is already connected to the hal output pin "spindle.0.brake". You will have to add a logic component. If you want to say add a physical physical button to override your spindle brake. If your config were a parallel port config with the spindle brake connected to pin 14 and the button to pin 12, your hall file might look something like this:
loadrt and2 count=1
addf and2.0 servo-thread
net spindle-brake <= spindle.0.brake => and2.0.in0
net spindle-brake-override <= parport.0.pin-12-in-not => and2.0.in1
net spindle-brake-out <= and2.0.out => parport.0.pin-14-out
With the above, the spindle brake would be on only if both pins "spindle.0.brake" and "parport.0.pin-12-in-not" are true. If either one or both are false then the brake should be turned off.
Last edit: 01 Oct 2024 15:31 by Todd Zuercher. Reason: Stupiid screwed up forum editor
The following user(s) said Thank You: abdulasis12
Please Log in or Create an account to join the conversation.
- Benb
- Offline
- Premium Member
Less
More
- Posts: 136
- Thank you received: 50
02 Oct 2024 03:58 - 02 Oct 2024 04:02 #311144
by Benb
Replied by Benb on topic Linking multiple signals/pins together
First off all, Linuxcnc hal is a very powerful PLC language. You do not need classic ladder, python, c/c ++…
You can control a cnc machine using hal only + a dumb ui that can send and display hal signals such as pyvcp and/or hardwired panel.
To expand further on Andy and Todd explanations, and since this question about connecting hal signal confuses new hal users, I am adding block diagram to show how to connect hal signals (You can think of hal signals as wire that connects hal components pins together).This block diagram for very simple example to show how to connect hal signals together. It has a push button input on the operator control panel and one pyvcp widget push button on the screen. If either push button is pushed the brake is energize and the pyvcp led on the screen lights up.From the diagram you notice that the two inputs from mesa 7i77 and pyvcp are not tied together but rather connected through a hal component in this case it’s an OR component. However, the output from the OR component is tied to two separate pins, Mesa digital output and pyvcp led widget.We can conclude that two separate hal input pins cannot be tied together and require a hal component. For outputs, two separate hal pins can be tied together. Of course, in both cases the signals data must be the same type. You cannot connect a floating-point signal with an S32 … Another important point regarding hal, you need to understand the difference between a hal pin name and hal signal name.
reference:
linuxcnc.org/docs/2.4/html/hal_basic_hal.html#r1_1_4
netlisting for above diagram:
loadrt or2 count= 1
addf or2.0 servo-thread
# signal/wire Pins that are connected together
#===+===============+=========================================
net turn-brake-on-pb or2.0.in0 hm2-7i92.0.7i77.0.0.input-00
net turn-brake-on-ui pyvcp.di-00 or2.0.in1
net brake-is-on or2.0.out hm2-7i92.0.7i77.0.0.output-00 pyvcp.do-00
You can control a cnc machine using hal only + a dumb ui that can send and display hal signals such as pyvcp and/or hardwired panel.
To expand further on Andy and Todd explanations, and since this question about connecting hal signal confuses new hal users, I am adding block diagram to show how to connect hal signals (You can think of hal signals as wire that connects hal components pins together).This block diagram for very simple example to show how to connect hal signals together. It has a push button input on the operator control panel and one pyvcp widget push button on the screen. If either push button is pushed the brake is energize and the pyvcp led on the screen lights up.From the diagram you notice that the two inputs from mesa 7i77 and pyvcp are not tied together but rather connected through a hal component in this case it’s an OR component. However, the output from the OR component is tied to two separate pins, Mesa digital output and pyvcp led widget.We can conclude that two separate hal input pins cannot be tied together and require a hal component. For outputs, two separate hal pins can be tied together. Of course, in both cases the signals data must be the same type. You cannot connect a floating-point signal with an S32 … Another important point regarding hal, you need to understand the difference between a hal pin name and hal signal name.
reference:
linuxcnc.org/docs/2.4/html/hal_basic_hal.html#r1_1_4
netlisting for above diagram:
loadrt or2 count= 1
addf or2.0 servo-thread
# signal/wire Pins that are connected together
#===+===============+=========================================
net turn-brake-on-pb or2.0.in0 hm2-7i92.0.7i77.0.0.input-00
net turn-brake-on-ui pyvcp.di-00 or2.0.in1
net brake-is-on or2.0.out hm2-7i92.0.7i77.0.0.output-00 pyvcp.do-00
Attachments:
Last edit: 02 Oct 2024 04:02 by Benb.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- Walkahz
- Offline
- Junior Member
Less
More
- Posts: 36
- Thank you received: 7
02 Oct 2024 10:29 #311165
by Walkahz
Replied by Walkahz on topic Linking multiple signals/pins together
Thanks all
still a bit lost but the above answers a lot of questions.
currently my Hal looks like the below, i will keep using the spindle brake as it is a good example.
most of the below was created by the pncconf Wizard and i am using GMOCAPY
So would my new lines look something like
Then i have the additional complication of my brake button only being momentary but that might be where classic ladder comes in.
still a bit lost but the above answers a lot of questions.
currently my Hal looks like the below, i will keep using the spindle brake as it is a good example.
most of the below was created by the pncconf Wizard and i am using GMOCAPY
# --- SPINDLE-BRAKE ---
net spindle-brake => hm2_7i96s.0.ssr.00.out-02
setp hm2_7i96s.0.ssr.00.invert-02 true
net spindle-brake <= spindle.0.brake
net spindle-brake-button classicladder.0.in-02 hm2_7i96s.0.7i84.0.0.input-20
So would my new lines look something like
# --- SPINDLE-BRAKE ---
net spindle-brake => hm2_7i96s.0.ssr.00.out-02 and2.0.in0
setp hm2_7i96s.0.ssr.00.invert-02 true
net spindle-brake <= spindle.0.brake and2.0.out
net spindle-brake-button and2.0.in1 hm2_7i96s.0.7i84.0.0.input-20
Please Log in or Create an account to join the conversation.
- timo
- Offline
- Premium Member
Less
More
- Posts: 83
- Thank you received: 27
02 Oct 2024 12:26 #311171
by timo
Replied by timo on topic Linking multiple signals/pins together
@Benb: Classic ladder is fantastic for seeing what is going on. I find it nice for experimenting.
If someone already is proficient with phython, I guess they will prefer that. I found it interesting that I could obviously integrate some phython script. (nice to know)
@walkahz
I am not sure if I understood the problem correct?
You have a physical button and not matter what you want to slamm the spindle brake in, when the button is pressed?
I am reasonably sure that you do not have to give up on classic ladder and it can be done!.
If someone already is proficient with phython, I guess they will prefer that. I found it interesting that I could obviously integrate some phython script. (nice to know)
@walkahz
I am not sure if I understood the problem correct?
You have a physical button and not matter what you want to slamm the spindle brake in, when the button is pressed?
I am reasonably sure that you do not have to give up on classic ladder and it can be done!.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5009
- Thank you received: 1443
02 Oct 2024 13:19 - 02 Oct 2024 13:27 #311175
by Todd Zuercher
Replied by Todd Zuercher on topic Linking multiple signals/pins together
True ClassicLadder is not necessary. Virtually any simple logic function that you might need can be performed in hal using logic components. But if you are used to programming PLCs or for some very complicated logic it may be simpler to us CL.
If you'd prefer to do your logic within ClassicLadder instead of using an and2 component that would be fine as well, and would make sense if you are already bringing your button signal through CL However I probably wouldn't bother adding CL to a config just to do a few ors and ands. (That said I do like CL and am using it on at least one machine.)
To do that you would need to separate your existing spindle brake signal from the halpin for the brake's io on the Mesa card, then connect each to an input and output from CL.
If you'd prefer to do your logic within ClassicLadder instead of using an and2 component that would be fine as well, and would make sense if you are already bringing your button signal through CL However I probably wouldn't bother adding CL to a config just to do a few ors and ands. (That said I do like CL and am using it on at least one machine.)
To do that you would need to separate your existing spindle brake signal from the halpin for the brake's io on the Mesa card, then connect each to an input and output from CL.
# --- SPINDLE-BRAKE ---
net spindle-brake <= classicladder.0.out-01 => hm2_7i96s.0.ssr.00.out-02
#(this setp may or may not be nessisary, as you could also do the logic inversion in CL.)
setp hm2_7i96s.0.ssr.00.invert-02 true
net motion-spindle-brake <= spindle.0.brake => classicladder.0.in-03
net spindle-brake-button <= hm2_7i96s.0.7i84.0.0.input-20 => classicladder.0.in-02
Last edit: 02 Oct 2024 13:27 by Todd Zuercher. Reason: modified code for easier reading.
Please Log in or Create an account to join the conversation.
- timo
- Offline
- Premium Member
Less
More
- Posts: 83
- Thank you received: 27
02 Oct 2024 14:00 #311178
by timo
Replied by timo on topic Linking multiple signals/pins together
Haha, OP is asking for a way to do it in classic ladder! (Me thinking why not ordering parts from a machine shop ? )
We can also hook up hmi or hal pins to the inputs and outputs of classic ladder. e.g.
To hook up one of the halui elements might be very easy, if you want to just replicate a (mouse klick button)
Greetings Timo
We can also hook up hmi or hal pins to the inputs and outputs of classic ladder. e.g.
net clickbutton1 classicladder.0.in-00 <= halui.spindle.0.is-on
net clickbutton2 classicladder.0.in-01 <= halui.spindle.0.brake-is-on
To hook up one of the halui elements might be very easy, if you want to just replicate a (mouse klick button)
Greetings Timo
Please Log in or Create an account to join the conversation.
- timo
- Offline
- Premium Member
Less
More
- Posts: 83
- Thank you received: 27
02 Oct 2024 16:54 - 02 Oct 2024 17:06 #311189
by timo
Replied by timo on topic Linking multiple signals/pins together
deleted, because editor messes everything up
Attachments:
Last edit: 02 Oct 2024 17:06 by timo. Reason: what a mess, fixing one or two typos messes up the complete post!
Please Log in or Create an account to join the conversation.
- timo
- Offline
- Premium Member
Less
More
- Posts: 83
- Thank you received: 27
02 Oct 2024 17:09 - 02 Oct 2024 17:11 #311190
by timo
Replied by timo on topic Linking multiple signals/pins together
Recent test:
7i95
The input-04 is just any that was not yet used in the *.hal.
The out-07 was as well one that was not yet used.
I can switch off the brake with the mouse on the Axis screen
As soon as the Input 4 on my mesa card gets activated, the %I4 is active and coil %Q7 is activated.
The %Q7 is linked with the halui and does the same as a checking the box on Axis screen with my mouse.
Greetings Timo
7i95
net brakeButton classicladder.0.in-04 <= hm2_7i95.0.imux.00.input-04
net spindleBrake classicladder.0.out-07 => halui.spindle.0.brake-on
The input-04 is just any that was not yet used in the *.hal.
The out-07 was as well one that was not yet used.
I can switch off the brake with the mouse on the Axis screen
As soon as the Input 4 on my mesa card gets activated, the %I4 is active and coil %Q7 is activated.
The %Q7 is linked with the halui and does the same as a checking the box on Axis screen with my mouse.
Greetings Timo
Attachments:
Last edit: 02 Oct 2024 17:11 by timo.
Please Log in or Create an account to join the conversation.
Time to create page: 0.106 seconds