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.
M.io.get_input M.io.set_output
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.
2. Map a Lua Output to a physical output
Lua Outputs are virtual – map one to a physical output before it can control hardware.
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
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")
endConditional 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