NoJo wrote: I cannot grasp how the signal, pins, etc integrate and till I manage that, there is no way I could read or change a HAL file without simply hacking.
Let me try a high-level overview.
To a large extent the HAL file is a way to map the values that come out of the
motion module
to physical pins on the interface and a way for physical pin values to be interpreted by the motion module. [1]
Consider the X axis on a stepper system.
First the HAL file will load the motion module. On being loaded the module sets up a lot of internal connections and configures itself by reading values from the INI file.
Code:
loadrt motmod ...{config options}...
The important pin here is (typically) joint.0.motor-pos-cmd. This is a double-precision floating point number.
The HAL file needs to create a signal to refer to this value by. We will choose to call it "this-is-my-X" to stress that the signal names can be anything.
Code:
net this-is-my-X joint.0.motor-pos-cmd
If we want, we can add an arrow for human readers. But LinuxCNC pays no attention to them.
Code:
net this-is-my-X <= joint.0.motor-pos-cmd
We need a pair of digital step/dir outputs rather than a floating point number. This is what the stepgen components do. I say "components" as there are a few of them. There is a software one for parallel ports, and integrated ones for Mesa, Pico, Pluto etc.
The Mesa / Pluto / Pico output the physical pulses on pins that are defined by their internal firmware. So here we will use the software stepgen as the example. Note that the output of the software stepgen does not _have_ to go to the parallel port. That is one of the strengths of HAL. You could set up a quadrature stepgen to drive an encoder counter. I don't know why you would want to, but you could.
So, we load a
stepgen
. Actually we will load 4, 3 in position mode and one in velocity mode.
Code:
loadrt stepgen ctrl_type=p,p,p,v
And connect the motor position command to the appropriate pin..
Code:
net this-is-my-X => stepgen.0.position-cmd
We would then use further "net" commands to wire the bit-type step/dir signals to appropriate IO
Code:
net this-is-my-X-step stepgen.0.step => parport.0.pin-00-out
And, that, is basically, all that HAL does. It takes numerical or logical values, optionally converts them to other types of values, and transfers them to other moduels, and eventually out into the real world.
I don't know if this was any help. I just took a guess at where the conceptual block might be.
I recommend skimming through all the HAL modules listed here:
linuxcnc.org/docs/2.8/html/
under the headings "Commands and userspace components" and "Realtime components and kernel modules". Just to get a feel for the sorts of signal manpulations that HAL can do.
[1]This is the typical situation. The motion module is not always loaded, and there is not always any physical interface, but those are special cases.