Lua Inputs & Outputs

 INFORMATION:
 Upgrade to Professional
 View upgrade Instructions

Inputs and Outputs

Lua scripting in MASSO includes a dedicated set of Lua Inputs and Lua Outputs.


These are separate from the controller’s standard Auxiliary Inputs and Outputs.

 

 


Overview

MASSO provides 16 Lua Inputs and 16 Lua Outputs that can be monitored and controlled directly from Lua scripts.

 

These act as virtual I/O channels for custom automation, machine monitoring, and process control, without interfering with normal machine wiring or signals.

 

Lua Inputs (0–15)
Used to read digital signals or logical conditions.

 

Lua Outputs (0–15)
Used to activate or control devices, signals, or automation logic.

 


Key Features

 

  • Each Lua Output can be mapped to any physical output pin on the MASSO controller.

  • Lua I/O can be used for:

    • Custom automation and logic control

    • Safety interlocks and process validation

    • Tool or fixture management

    • External device signalling (e.g. lights, pneumatic valves)

  • Lua I/O operates independently of G-code and can run in the background or be triggered by event

 

 

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

 


Mapping Lua Outputs to Physical Outputs

Lua Outputs are virtual outputs and must be mapped to a physical output before they can control hardware.

 

This allows Lua scripts to control real-world devices connected to MASSO.

 

How to Map Lua Outputs:

 

  1. Open the F1 – Setup screen on the MASSO controller.

  2. Go to the Output Settings page.

  3. Select the physical output you want to control.

  4. In the Function dropdown menu, select Lua Output X (0–15).

  5. Save the settings and restart the controller.

 

After mapping, when a Lua script sets  LUA Output X HIGH or LOW, it will control the mapped physical output pin.

 


Example: 

 

If Output 5 is mapped to Lua Output 3, the following Lua command will activate physical Output 5:

 

M.io.set_output(3, true)

 


Tool Changer Inputs and Outputs

When writing scripts for an Automatic Tool Changer (ATC), use the dedicated Tool Changer Inputs and Tool Changer Outputs, not the general Lua I/O.

 

These I/O channels are reserved for tool changer control and provide safer and more predictable operation.

 

Typical examples include sensors such as:

 

  • Tool Clamp

  • Arm Home

  • Magazine Ready

     


Examples

 


Example 1: Setting a Lua Output

 

This example turns a Lua Output ON, waits for 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)

 


Example 2: Reading a Lua Input

 

This example reads the state of a Lua Input and prints the result.

 

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

 


Example 3: Conditional Control

 

This example turns an output ON only when a specific input 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