Lua Inputs & Outputs

Lua scripts have their own 16 Lua Inputs and 16 Lua Outputs – virtual I/O channels for custom automation, monitoring and process control, separate from the standard auxiliary I/O.

Lua Inputs
0–15
Lua Outputs
0–15, mappable to physical outputs
Functions
M.io.get_input M.io.set_output

Lua inputs and outputs

1. What Lua I/O is for

Lua Inputs read digital signals or logical conditions; Lua Outputs activate or control devices, signals or logic. Typical uses:

  • Custom automation and logic control
  • Safety interlocks and process validation
  • Tool or fixture management
  • Signalling external devices such as lights or pneumatic valves

Lua I/O runs independently of G-code, in the background or triggered by events, without interfering with normal machine wiring or signals.

WARNING
Heavy or complex Lua code in background loops can reduce controller performance or cause timing problems. Keep scripts short, efficient and event-based wherever possible.

2. Map a Lua Output to a physical output

Lua Outputs are virtual – map one to a physical output before it can control hardware.

1
On the F1-Setup screen, open the Output Settings page.
2
Select the physical output and set its Function to Lua Output X (0–15).
3
Save the settings and restart the controller.

For example, with physical Output 5 mapped to Lua Output 3, this turns Output 5 on:

M.io.set_output(3, true)

3. Tool changer scripts

CAUTION
For automatic tool changer scripts, use the dedicated Tool Changer Inputs and Outputs, not general Lua I/O. They are reserved for tool changer control and give safer, more predictable operation – for example for tool clamp, arm home and magazine ready sensors.

4. Examples

Set a Lua Output

Turns Lua Output 3 on, waits 2 seconds, then turns it off.

-- Set LUA output 3 to HIGH
M.io.set_output(3, true)
-- Wait for a short period (for example, 2 seconds)
M.sys.delay(2000)
-- Set LUA output 3 to LOW
M.io.set_output(3, false)

Read a Lua Input

Reads Lua Input 5 and prints its state.

-- Read the state of LUA input 5
local input_state = M.io.get_input(5)
-- Check the input state and display the result
if input_state then
  print("LUA Input 5 is HIGH")
else
  print("LUA Input 5 is LOW")
end

Conditional control

Turns Lua Output 4 on only while Lua Input 2 is active.

-- Read LUA input 2
local input_state = M.io.get_input(2)
-- If input 2 is HIGH, turn on output 4
if input_state then
  M.io.set_output(4, true)
  print("Input 2 is active - Output 4 turned ON")
-- Otherwise, turn it OFF
else
  M.io.set_output(4, false)
  print("Input 2 is inactive - Output 4 turned OFF")
end