Help to understand Net command

More
13 Oct 2023 10:56 - 13 Oct 2023 10:56 #282886 by karnalta
Hello all,

I am sorry to ask this, I know there is help file about it but I cannot get my mind around the net command...

Here is a working line from my HAL file :

net max-home-x joint.0.home-sw-in joint.0.pos-lim-sw-in <= hm2_7i96s.0.inm.00.input-00-not

max-home-x is the signal name and "<=" is unused, it's just for readability. That's easy to understand.

But what I am not sure about is how the command set what is output and what is input.

From that line, I guest "max-home-x" signal is outputted to "joint.0.home-sw-in" and "joint.0.pos-lim-sw-in" and get his value (input) from "hm2_7i96s.0.inm.00.input-00-not".

So how does it work ? The last parameter is always the input ?

What it does if I just set : 

net max-home-x hm2_7i96s.0.inm.00.input-00-not

or 

net max-home-x joint.0.home-sw-in joint.0.pos-lim-sw-in

Thank a lot for your help.
Last edit: 13 Oct 2023 10:56 by karnalta.

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

More
13 Oct 2023 14:53 - 13 Oct 2023 14:54 #282894 by PCW
Replied by PCW on topic Help to understand Net command
On a net command the order of pins is unimportant:

net signal pin pin pin pin

The inputs and outputs are handled automatically.
With one exception, you can only have one output pin
connected to a signal. The exception is tri-state pins

Note that hm2_7i96s.0.inm.00.input-00-not  is an output,
that is, it provides data to hal.

joint.0.home-sw-in  and joint.0.pos-lim-sw-in  are input
pins as they accept data from hal.
 
Last edit: 13 Oct 2023 14:54 by PCW.
The following user(s) said Thank You: tommylight, karnalta

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

More
13 Oct 2023 18:37 #282925 by beefy
Think of "net" as a command stating "make a group of connected signals".

Think of "max-home-x" as "the name of this group"

Anything after that are the signals which are all connected to each other, e.g. 
joint.0.home-sw-in
joint.0.pos-lim-sw-in
hm2_7i96s.0.inm.00.input-00-not

And as PCW explained, the order has nothing to do with whether they are input or output. That is unique to each signal and can be found in the docs (documentation).

Example joint.0.home-sw-in is part of the "motion" module.

Go to the docs main page:
linuxcnc.org/docs/

Select your Linuxcnc release and html:
linuxcnc.org/docs/2.9/html/

Scroll down the page to the heading "Man Pages", and then click on "motion"
linuxcnc.org/docs/2.9/html/man/man9/motion.9.html

In that document you'll find:
joint.N.home-sw-in IN BIT      Should be driven TRUE if the home switch for this joint is closed.

That tells you the signal is an input (IN) and it's a bit type (BIT).

Also you don't have to have all the signals written on the same line, so this:
net     max-home-x    joint.0.home-sw-in    joint.0.pos-lim-sw-in    <=    hm2_7i96s.0.inm.00.input-00-not

is the same as this:
net    max-home-x       joint.0.home-sw-in 
net    max-home-x       joint.0.pos-lim-sw-in    
net    max-home-x       hm2_7i96s.0.inm.00.input-00-not

And you don't even have to have those lines all together. They could each be 20 lines apart.

Look for Youtube videos by Swolebro and the Feral Engineer for some good teaching on hal.
 
The following user(s) said Thank You: tommylight, Clive S, karnalta

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

More
13 Oct 2023 18:42 #282927 by JPL
Replied by JPL on topic Help to understand Net command

So how does it work ? The last parameter is always the input ?
What it does if I just set : 
net max-home-x hm2_7i96s.0.inm.00.input-00-not
or 
net max-home-x joint.0.home-sw-in joint.0.pos-lim-sw-in


 

To elaborate on what PCW wrote...

If you write both lines, one after the other:
net max-home-x     hm2_7i96s.0.inm.00.input-00-not
net max-home-x     joint.0.home-sw-in joint.0.pos-lim-sw-in

The first line will create or use the net  'max-home-x' and connect it to 'hm2_7i96s.0.inm.00.input-00-not'.
Think of it as a wire that is connected on one side to something.

Then the second line will 'connect' the same 'wire' to 'joint.0.home-sw-in joint.0.pos-lim-sw-in'.
Effectively connecting it to 'hm2_7i96s.0.inm.00.input-00-not'

Those two lines are then the equivalent of:
net max-home-x     joint.0.home-sw-in joint.0.pos-lim-sw-in   <=    hm2_7i96s.0.inm.00.input-00-not

Which is also the same as
net max-home-x     hm2_7i96s.0.inm.00.input-00-not   =>  joint.0.home-sw-in joint.0.pos-lim-sw-in

You can then connect pins together via a net, one at a time or all of the on the same line  (net signal pin pin pin pin...). Results will be the same.

 
The following user(s) said Thank You: karnalta

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

More
13 Oct 2023 18:49 #282929 by JPL
Replied by JPL on topic Help to understand Net command

Look for Youtube videos by Swolebro and the Feral Engineer for some good teaching on hal.

 


... Was writing my answer at the same time as you

Here is a link to the first video of a series of five from Feral engineer:


 
The following user(s) said Thank You: tommylight

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

More
13 Oct 2023 19:03 #282930 by tommylight
@JPL
@Beefy
Thank you for everything you do on this forum.
The following user(s) said Thank You: karnalta

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

More
13 Oct 2023 19:24 #282934 by karnalta
Thank you all for all the information.

Make more sense that order as no impact on net command, I do understand better now.

I also have reverse my thinking about input/output, "we are" the mesa card, so an output is data going from the card to the HAL.

So, if a signal has to turn on "output pin" on the mesa controller, we are talking about an INPUT for the net command ? And it can have an unlimited amount of input ?

Only one board's pin can set value for a net signal but a net signal can turn on an unlimited amount of board pin/switch ?

One last thing, how does LinuxCNC recognize which pin is the output in a sequence of pin pin pin ... All boards definitions pins are hardcoded inside LinuxCNC ?

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

More
13 Oct 2023 21:57 #282944 by PCW
Replied by PCW on topic Help to understand Net command
Yes, one hal output pin can connect to any number of hal input pins
(well the number is limited only by the limit to the maximum number of pins)

As far as recognizing pin types, this is done when the hal file is parsed
Each hal pin has a type attribute and a direction attribute that the parser
can access so the proper data direction is established.

You can list these directions with halcmd:

For example to list all pins:

halcmd show pin

(typed in a terminal when linuxCNC is running)

To just list Mesa hardware pins:

halcmd show pin hm2

Here's a small sample:
cut
    35  bit   IN          FALSE  hm2_7i96s.0.outm.00.out-05
    35  bit   OUT         FALSE  hm2_7i96s.0.packet-error
    35  bit   OUT         FALSE  hm2_7i96s.0.packet-error-exceeded
    35  s32   OUT             0  hm2_7i96s.0.packet-error-level
    35  u32   I/O    0x00000000  hm2_7i96s.0.packet-error-total
    35  bit   IN          FALSE  hm2_7i96s.0.pwmgen.00.enable
    35  float IN              0  hm2_7i96s.0.pwmgen.00.value
    35  s32   OUT             0  hm2_7i96s.0.read-request.time

cut


Notice that there are different data types (bit, float,u32,s32)
and different directions (IN,OUT,I/O)
 
The following user(s) said Thank You: karnalta

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

More
14 Oct 2023 01:01 #282952 by tommylight
Maybe this makes it easier:
net this_is_my_signal_name => machine-is-enabled
net this_is_my_signal_name => hm2_7i96s.0.outm.00.out-05
That is the same as
net this_is_my_signal_name => machine-is-enabled => hm2_7i96s.0.outm.00.out-05
-
net <= think of it as a plug, so you are inserting wires "machine-is-enabled" and "hm2_7i96s.0.outm.00.out-05" into it and naming that plug "this_is_my_signal_name".
The following user(s) said Thank You: karnalta

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

More
14 Oct 2023 10:41 #282979 by karnalta
Things are way more clear now, thank you.

I hope this post will help others LinuxCNC newbies :)
The following user(s) said Thank You: tommylight

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

Time to create page: 1.134 seconds
Powered by Kunena Forum