Understanding hal components/pins

More
28 Aug 2017 15:33 #98091 by blazini36
I'm working with a programmer to get my system all together but I'm having trouble understanding the basic idea. Something just doesn't "click" as far as pins and components go. He wrote a component that adds pins but I don't understand their purpose.

His component creates pins that the only use for them is to connect hardware connections to. I'm using a Mesa 7i76e, and the way I understand it Hostmot2 is a driver or component for the board that is like the lowest layer that the board can be addressed at. It creates the pins for the physical connections as well as counters and stuff that is interpreted.

So where I get lost is AFAIK you can only connect a pin to a signal, you can't connect 2 pins together. So what is the purpose of a pin in a component if the actual hardware pin already has a HAL pin? Component creates signal, connects to component pin, but can't connect directly to the HM2 pin? The only way I see that working is if there was another signal connected in between. If that's the case is the signal just something that's made up and only exists in that hal file? Or am I completely misunderstanding this?

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

More
28 Aug 2017 16:36 #98097 by Todd Zuercher
It sounds like you are over thinking this.
Hal pins and component pins, hardware driver pins (in hal), Hostmot2 pins and HM2 pins, are all the same thing. They are all Hal pins.
Hal pins are created by components (programs). These are either "real time" or "user space" programs.
The Hostmot2 driver is a real time component that connects the Mesa hardware to Hal via the Hal pins it creates.

Pins in HAL are connected together by signals.

Yes, Signal names are just arbitrary names for the connections between hal pins. A new signal is created by hal every time a net command with a new signal name is listed in the hal file or net command in a Halcmd prompt.
The following user(s) said Thank You: blazini36, thefabricator03

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

More
28 Aug 2017 16:56 - 28 Aug 2017 17:41 #98098 by PCW
I think of signals as "wire names" or signal names in a netlist

This convention is standard in schematic capture/ netlist/EE field so its not surprising that it is done this way
since LinuxCNCs HAL was created by a EE

Sometimes I do think it might be nice to have anonymous signals generated if you connect two or more hal pins
with no signal specified. This would avoid having to make up signal names for say intermediate terms in
complex multi-component hal constructions. Schematic capture programs do this with unnamed wires
( generate non-colliding but normally hidden names like $$$1234 )
Last edit: 28 Aug 2017 17:41 by PCW.

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

More
28 Aug 2017 19:49 #98112 by blazini36

Hal pins are created by components (programs). These are either "real time" or "user space" programs.
The Hostmot2 driver is a real time component that connects the Mesa hardware to Hal via the Hal pins it creates.


Well the programmer was asking for actual pin names/designations (which I already sent to him just cuz). All I kept thinking is that he's under the impression that it's like an arduino or similar microcontroller that you write a program in C+ for and compile it to machine code with the IDE. I know the hm2.0.whatever.00... is just another software pin but I was just trying to affirm that this is as close to the actual pin as you get in HAL.

The thing that's really been throwing me off is that since I'm NOT a programmer, but from time to time have to modify a C+ or Python program you look for the rule that exists around this "signal". Like loading components and adding functions are usually placed at the top of the HAL file. So I look for a signal to be defined somewhere in the file and it's not. Then I realize "oh......it's just made up on the fly and you can carry it around". I realize some rules exist and some signals come from components.....which made sense but it threw me off when I was trying to figure out where random signals came from with no explanation.

I've heard that hal was designed by electrical engineers. On an electrical drawing it's obvious that somebody drew it, and thought up a name or number for that wire.....though it's not always intuitive. When I look at a hal file I'm looking for these signals to be defined or referenced to something. Makes a lot more sense when you know that's not the case.

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

More
28 Aug 2017 20:04 - 28 Aug 2017 20:09 #98113 by PCW
Signals do not come from components, only pins and parameters (and functions) are exported from components.
All signals are created by net commands ( or the obsolete newsig command )

So the basic hal file connection rules are that components make pins and the net command allows you to link
pins from component to component. Pins linked by a signal must be of the same type.

You could use completely arbitrary names for all the signals in a hal file or set of hal files and it would function properly
( though it might be quite difficult to read )
Last edit: 28 Aug 2017 20:09 by PCW.
The following user(s) said Thank You: blazini36

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

More
28 Aug 2017 23:02 #98115 by blazini36
As basic as it probably seems after it dawned on me I came home and wrote a semi working hal file. The component needs work but at least I'm getting somewhere.

they say to think of the signal as a wire but it's placement in the line and the name signal isn't really intuitive.

They should just call it a wire, or conduit or something. if it went between pins it would "look" more obvious.

The EE's probably intended each signal to be named like "A103" or "2103", something you'd see in an electrical drawing labeling a wire.

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

More
30 Aug 2017 12:20 #98197 by rodw
I think of a hal component as a blackbox acting independently from everything else. Lets say your component needs to know the current velocity which is found on the motion.current-vel pin. But you have several other components that need the same pin. So the solution is to save motion.current-vel to a signal and then each component needs to receive a copy of that signal.

This makes for a very modular approach to customisation and if one component crashes, the others should not be affected.

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

More
18 May 2019 09:18 #134124 by phoenix
Sir i need to make external start button using hal in axis will you please help me how can i do that
i tried these
net program-start-btn halui.mode.auto and2.0.in0 <= <your input pin>
net program-run-ok and2.0.in1 <= halui.mode.is-auto
net remote-program-run halui.program.run <= and2.0.out

but it says pin is not defined
will you kindly elaborate where to paste those line and why the and2 component doesnt loading pins

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

More
18 May 2019 09:22 #134125 by pl7i92
you need to di this with HALUI
not to the main HAL
as it is POSTGui after Linuxcnc has loaded the mashine
1000times per second reding the Button

so folow tha advice in the other post you opend
please
The following user(s) said Thank You: phoenix

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

More
18 May 2019 09:36 #134133 by phoenix
means i have to type those commmands in halui ??

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

Time to create page: 0.213 seconds
Powered by Kunena Forum