halui-examples.txt
1 [[cha:halui-examples]] 2 3 = Halui Examples 4 5 For any Halui examples to work you need to add the following line to the [HAL] 6 section of the ini file. 7 8 ---- 9 HALUI = halui 10 ---- 11 12 [[sec:halui-remote-start]] 13 14 == Remote Start 15 16 To connect a remote program start button to LinuxCNC you use the 17 `halui.program.run` pin and the `halui.mode.auto` pin. 18 You have to insure that it is OK to run first by using the 19 `halui.mode.is-auto` pin. You do this with an `and2` 20 component. The following figure shows how this is done. 21 When the Remote Run Button is pressed it is connected to 22 both `halui.mode.auto` and `and2.0.in0`. If it is OK for 23 auto mode the pin `halui.mode.is-auto` will be on. 24 If both the inputs to the `and2.0` component are on the 25 `and2.0.out` will be on and this will start the program. 26 27 .Remote Start Example 28 image::images/remote-start.png[alt="Remote Start Example"] 29 30 The hal commands needed to accomplish the above are: 31 32 net program-start-btn halui.mode.auto and2.0.in0 <= <your input pin> 33 net program-run-ok and2.0.in1 <= halui.mode.is-auto 34 net remote-program-run halui.program.run <= and2.0.out 35 36 Notice on line one that there are two reader pins, this can also be split 37 up to two lines like this: 38 39 net program-start-btn halui.mode.auto <= <your input pin> 40 net program-start-btn and2.0.in0 41 42 == Pause & Resume 43 44 This example was developed to allow LinuxCNC to move a 45 rotary axis on a signal from an external machine. 46 The coordination between the two systems will be 47 provided by two Halui components: 48 49 - halui.program.is-paused 50 - halui.program.resume 51 52 In your customized hal file, add the following 53 two lines that will be connected to your I/O to turn 54 on the program pause or to resume when the external 55 system wants LinuxCNC to continue. 56 57 net ispaused halui.program.is paused => "your output pin" 58 net resume halui.program.resume <= "your input pin" 59 60 Your input and output pins are connected to the pins 61 wired to the other controller. They may be parallel port 62 pins or any other I/O pins that you have access to. 63 64 This system works in the following way. When an M0 is 65 encountered in your G-code, the `halui.program.is-paused` 66 signal goes true. This turns on your output pin so that 67 the external controller knows that LinuxCNC is paused. 68 69 To resume the LinuxCNC gcode program, when the external controller 70 is ready it will make its output true. This will signal 71 LinuxCNC that it should resume executing Gcode. 72 73 Difficulties in timing 74 75 - The "resume" input return signal should not be 76 longer than the time required to get the g-code 77 running again. 78 79 - The "is-paused" output should no longer be active 80 by the time the "resume" signal ends. 81 82 These timing problems could be avoided by using 83 ClassicLadder to activate the "is-paused" output via a 84 monostable timer to deliver one narrow output pulse. 85 The "resume" pulse could also be received via a monostable timer. 86 87