For any Halui examples to work you need to add the following line to the [HAL] section of the INI file.
HALUI = halui
1. Remote Start
To connect a remote program start button to LinuxCNC you use the halui.program.run
pin and the halui.mode.auto
pin. You have to ensure that it is OK to run first by using the halui.mode.is-auto
pin. You do this with an and2
component. The following figure shows how this is done. When the Remote Run Button is pressed it is connected to both halui.mode.auto
and and2.0.in0
. If it is OK for auto mode the pin halui.mode.is-auto
will be on. If both the inputs to the and2.0
component are on the and2.0.out
will be on and this will start the program.
The hal commands needed to accomplish the above are:
Notice on line one that there are two reader pins, this can also be split up to two lines like this:
2. Pause & Resume
This example was developed to allow LinuxCNC to move a rotary axis on a signal from an external machine. The coordination between the two systems will be provided by two Halui components:
-
halui.program.is-paused
-
halui.program.resume
In your customized HAL file, add the following two lines that will be connected to your I/O to turn on the program pause or to resume when the external system wants LinuxCNC to continue.
Your input and output pins are connected to the pins wired to the other controller. They may be parallel port pins or any other I/O pins that you have access to.
This system works in the following way. When an M0 is encountered in your G-code, the halui.program.is-paused
signal goes true. This turns on your output pin so that the external controller knows that LinuxCNC is paused.
To resume the LinuxCNC G-code program, when the external controller is ready it will make its output true. This will signal LinuxCNC that it should resume executing G-code.
Difficulties in timing
-
The "resume" input return signal should not be longer than the time required to get the G-code running again.
-
The "is-paused" output should no longer be active by the time the "resume" signal ends.
These timing problems could be avoided by using ClassicLadder to activate the "is-paused" output via a monostable timer to deliver one narrow output pulse. The "resume" pulse could also be received via a monostable timer.