Overrides
Physical override controls are optional. Ctrl provides digital controls for feed, rapid, and spindle override, and all three can remain controlled entirely from the touchscreen.
Add a physical control only when the machine needs one. Connect it to LinuxCNC through HAL; Ctrl reads the resulting LinuxCNC value so the number shown on screen follows the machine.
Tell Ctrl that hardware is in charge
Section titled “Tell Ctrl that hardware is in charge”When a physical control owns an override, set the matching Ctrl HAL pin true:
| Ctrl HAL pin | Effect |
|---|---|
ctrl.override-controls.feed-read-only |
Makes the feed override read-only on screen |
ctrl.override-controls.rapid-read-only |
Makes the rapid override read-only on screen |
ctrl.override-controls.spindle-read-only |
Makes the spindle override read-only on screen |
These pins only make the touchscreen control read-only. They do not change the LinuxCNC override. Connect the pot, encoder, or selector to the appropriate LinuxCNC HAL pins separately.
Leave an ownership pin false when the touchscreen should remain editable. Do not leave both hardware and the touchscreen in control of the same value; the override will jump or appear to fight the operator.
Selector switch example
Section titled “Selector switch example”A multi-position selector can set an override directly through LinuxCNC’s HALUI override pins. The example below controls spindle 0 through halui.spindle.0.override.*. A feed selector uses halui.feed-override.*, and a rapid selector uses halui.rapid-override.*.
This is an example, not a universal selector configuration. Contact coding, position order, active levels, and stable transition behavior vary between switches. Verify the switch’s truth table and electrical inputs before adapting the values below.
This spindle example uses LinuxCNC’s mux16 component with a four-bit Gray-code selector and 16 positions. It debounces the selector for 10 ms and maps its positions to 50–125% in 5% steps:
loadrt mux16 names=spindle-overrideaddf spindle-override servo-thread
setp spindle-override.use-graycode 1setp spindle-override.debounce-time 0.01
setp spindle-override.in00 10setp spindle-override.in01 11setp spindle-override.in02 12setp spindle-override.in03 13setp spindle-override.in04 14setp spindle-override.in05 15setp spindle-override.in06 16setp spindle-override.in07 17setp spindle-override.in08 18setp spindle-override.in09 19setp spindle-override.in10 20setp spindle-override.in11 21setp spindle-override.in12 22setp spindle-override.in13 23setp spindle-override.in14 24setp spindle-override.in15 25
net input.spindle-override-sel0 => spindle-override.sel0net input.spindle-override-sel1 => spindle-override.sel1net input.spindle-override-sel2 => spindle-override.sel2net input.spindle-override-sel3 => spindle-override.sel3
setp halui.spindle.0.override.direct-value 1setp halui.spindle.0.override.scale 0.05
net spindle-override-pct spindle-override.out-s => halui.spindle.0.override.countsWith direct-value mode enabled, LinuxCNC calculates the override as counts × scale. The first selector position therefore produces 10 × 0.05 = 0.50, or 50%; the last produces 25 × 0.05 = 1.25, or 125%. LinuxCNC’s configured override limits still apply.
Gray code is useful for a physical selector because adjacent positions change only one select bit. The debounce delay requires the selected code to remain stable before mux16 updates its output. Adapt the input signal names to the machine’s I/O and verify that the switch’s actual contact codes follow the expected Gray-code sequence.
The same pattern works for feed or rapid override by connecting out-s to that override’s counts pin and setting its matching direct-value and scale pins. When hardware takes ownership, also set the corresponding Ctrl read-only pin from the previous section.
Analog potentiometer example
Section titled “Analog potentiometer example”This example assumes the hardware driver already provides a reliable
0.0to1.0float value. Real analog inputs need calibration and explicit behavior for disconnection, out-of-range voltage, noise, and startup. Do not assume every potentiometer or analog input card has this range or polarity.
This feed-override example scales a normalized analog value to integer counts, limits it to 0–100%, and sends it to HALUI in direct-value mode. It uses LinuxCNC’s scale, limit1, and conv_float_s32 components:
loadrt scale names=feed-override-scaleloadrt limit1 names=feed-override-limitloadrt conv_float_s32 names=feed-override-counts
addf feed-override-scale servo-threadaddf feed-override-limit servo-threadaddf feed-override-counts servo-thread
setp feed-override-scale.gain 100setp feed-override-scale.offset 0setp feed-override-limit.min 0setp feed-override-limit.max 100
net input.feed-override => feed-override-scale.innet feed-override-scaled feed-override-scale.out => feed-override-limit.innet feed-override-limited feed-override-limit.out => feed-override-counts.in
setp halui.feed-override.direct-value 1setp halui.feed-override.scale 0.01net feed-override-counts feed-override-counts.out => halui.feed-override.countsHere, an analog value of 0.75 becomes count 75; HALUI applies the 0.01 scale and requests 75%. Change the gain, offset, and limits to match the required range. If the analog direction is reversed, use a negative gain and corresponding offset rather than reversing the meaning silently in the hardware driver.
Increase and decrease button example
Section titled “Increase and decrease button example”Momentary buttons can step an override without direct-value mode. This feed-override example changes the value by five percentage points on each new button press and provides an optional reset-to-100% button:
setp halui.feed-override.direct-value 0setp halui.feed-override.scale 0.05
net input.feed-override-increase => halui.feed-override.increasenet input.feed-override-decrease => halui.feed-override.decreasenet input.feed-override-reset => halui.feed-override.resetDebounce and condition the physical buttons before these HALUI inputs. The same pattern works with halui.rapid-override.increase and halui.rapid-override.decrease, or halui.spindle.0.override.increase and halui.spindle.0.override.decrease. Use each override family’s matching scale and reset pins.
Control choice
Section titled “Control choice”Choose hardware whose behavior is obvious to the operator:
- An absolute potentiometer should map position deterministically to an allowed percentage range.
- An incremental encoder should use bounded increase/decrease behavior and preserve the displayed LinuxCNC value.
- A selector switch should map every stable contact combination to one documented percentage.
Define scaling, limits, detents, broken-wire handling, and power-up behavior in the machine HAL or PLC. Test the LinuxCNC value first, then make the corresponding Ctrl control read-only.