Best hal Practices ?
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
21 Mar 2023 22:50 #267258
by my1987toyota
Best hal Practices ? was created by my1987toyota
The title may be a little misleading. What I am trying to figure out is, What is best practice for hal writing?
Is it writing multiple hal files each for a specific thing or writing 1 or 2 large hal files say a main hal
and the other being the custom hal?
Is it writing multiple hal files each for a specific thing or writing 1 or 2 large hal files say a main hal
and the other being the custom hal?
Please Log in or Create an account to join the conversation.
21 Mar 2023 23:41 #267262
by rodw
Replied by rodw on topic Best hal Practices ?
I think everybody develops their own style over time. When I started, I just had it all in one hal file but now I break it up into seperate files based on functions. eg If I write code for a pendnt, I will have it all in pendant.hal and include it from my ini file.
This makes it easier to maintain and also to share code. (often when I've written a custom component)
Also don't be frightened of using unlinkp. This might be more applicable to specific configs but if you start say with a working qtplasmac build, you might need to do this if you want to change things around.
This makes it easier to maintain and also to share code. (often when I've written a custom component)
Also don't be frightened of using unlinkp. This might be more applicable to specific configs but if you start say with a working qtplasmac build, you might need to do this if you want to change things around.
The following user(s) said Thank You: tommylight, my1987toyota
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19203
- Thank you received: 6437
22 Mar 2023 00:52 #267269
by tommylight
Replied by tommylight on topic Best hal Practices ?
I agree with ROD, i like to keep things tidy (yeah, riteee ) so i do multiple hal files, although i tend to group stuff, so on my Mazak i have
Mazak connections.hal >>> Mesa 7i77 and one 7i84 inputs and outputs, both located in the left side in the control box
Mazak panel connections.hal >>> front panel inputs and outputs on the second 7i84, MPG and switches and stuff.
Main hal file with 7i77 servo stuff.
Mazak connections.hal >>> Mesa 7i77 and one 7i84 inputs and outputs, both located in the left side in the control box
Mazak panel connections.hal >>> front panel inputs and outputs on the second 7i84, MPG and switches and stuff.
Main hal file with 7i77 servo stuff.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
22 Mar 2023 09:58 #267287
by my1987toyota
Replied by my1987toyota on topic Best hal Practices ?
That's good to know. I have been working on my Pick and Place switching it over to 2.9 and the amount of files
that have to be utilized was starting to increase the time it took for linuxcnc to load.
That caused my to wonder if the multiple . hal files was causing me to go in the wrong direction.
that have to be utilized was starting to increase the time it took for linuxcnc to load.
That caused my to wonder if the multiple . hal files was causing me to go in the wrong direction.
Please Log in or Create an account to join the conversation.
22 Mar 2023 12:51 #267303
by spumco
Replied by spumco on topic Best hal Practices ?
No expert, but I too break things up in to multiple files. Also name the files in a logical (to me) way:ad nauseum.
Any signals that span files are commented at both ends of the span.
ALL 'loadrt' and 'addf' statements go in the first/main hal file, and all the 'addf' statements are commented with the function they support.
I tend not to rename components, but leave the 'stock' name with sequential numbering. I've had to dig through many user hal examples in the the past year or two while learning LCNC and it's really annoying to try to figure out what a component does when it's been renamed from 'mux16.0' to 'cuppa-joe' by the author. If I do (rarely) rename something, the underlying comp name remains:
Finally, I don't put multiple pin & signals on the same line. I simply can't read/follow this - likely a personal failing. All net command lines get one signal and one pin:
Only exception is when a signal is going to two pins in the same direction and it's easy to follow:
Hope this helps a bit.
01_main.hal
02_spindle.hal
03_io.hal
04_atc.hal
Any signals that span files are commented at both ends of the span.
[01_io.hal]
net BTN-BLA-BLA <= some.button.01-in #connected in mpg.hal
[06_mpg.hal]
net BTN-BLA-BLA => some.indicator.02 #connected in io.hal
ALL 'loadrt' and 'addf' statements go in the first/main hal file, and all the 'addf' statements are commented with the function they support.
addf or2.1 servo-thread #FRO
addf or2.2 servo-thread #ORIENT
I tend not to rename components, but leave the 'stock' name with sequential numbering. I've had to dig through many user hal examples in the the past year or two while learning LCNC and it's really annoying to try to figure out what a component does when it's been renamed from 'mux16.0' to 'cuppa-joe' by the author. If I do (rarely) rename something, the underlying comp name remains:
pid.x
pid.atc
mux2.rro
mux16.jog
Finally, I don't put multiple pin & signals on the same line. I simply can't read/follow this - likely a personal failing. All net command lines get one signal and one pin:
net SIGNAL <= pin.0.in
net SIGNAL => pin.1.out
Only exception is when a signal is going to two pins in the same direction and it's easy to follow:
net JOG-SPEED <= knob.something.out
net JOG-SPEED => halui.axis.jog-speed => halui.joint.jog-speed
Hope this helps a bit.
The following user(s) said Thank You: EW_CNC, my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
22 Mar 2023 13:07 - 22 Mar 2023 13:27 #267304
by my1987toyota
Replied by my1987toyota on topic Best hal Practices ?
Yes that does help. I really like the numbering idea. Thank you
Last edit: 22 Mar 2023 13:27 by my1987toyota.
Please Log in or Create an account to join the conversation.
Time to create page: 0.072 seconds