Skip to content

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.

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.

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-override
addf spindle-override servo-thread
setp spindle-override.use-graycode 1
setp spindle-override.debounce-time 0.01
setp spindle-override.in00 10
setp spindle-override.in01 11
setp spindle-override.in02 12
setp spindle-override.in03 13
setp spindle-override.in04 14
setp spindle-override.in05 15
setp spindle-override.in06 16
setp spindle-override.in07 17
setp spindle-override.in08 18
setp spindle-override.in09 19
setp spindle-override.in10 20
setp spindle-override.in11 21
setp spindle-override.in12 22
setp spindle-override.in13 23
setp spindle-override.in14 24
setp spindle-override.in15 25
net input.spindle-override-sel0 => spindle-override.sel0
net input.spindle-override-sel1 => spindle-override.sel1
net input.spindle-override-sel2 => spindle-override.sel2
net input.spindle-override-sel3 => spindle-override.sel3
setp halui.spindle.0.override.direct-value 1
setp halui.spindle.0.override.scale 0.05
net spindle-override-pct spindle-override.out-s => halui.spindle.0.override.counts

With 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.

This example assumes the hardware driver already provides a reliable 0.0 to 1.0 float 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-scale
loadrt limit1 names=feed-override-limit
loadrt conv_float_s32 names=feed-override-counts
addf feed-override-scale servo-thread
addf feed-override-limit servo-thread
addf feed-override-counts servo-thread
setp feed-override-scale.gain 100
setp feed-override-scale.offset 0
setp feed-override-limit.min 0
setp feed-override-limit.max 100
net input.feed-override => feed-override-scale.in
net feed-override-scaled feed-override-scale.out => feed-override-limit.in
net feed-override-limited feed-override-limit.out => feed-override-counts.in
setp halui.feed-override.direct-value 1
setp halui.feed-override.scale 0.01
net feed-override-counts feed-override-counts.out => halui.feed-override.counts

Here, 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.

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 0
setp halui.feed-override.scale 0.05
net input.feed-override-increase => halui.feed-override.increase
net input.feed-override-decrease => halui.feed-override.decrease
net input.feed-override-reset => halui.feed-override.reset

Debounce 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.

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.