M.io

The M.io functions switch Lua outputs and read Lua inputs and the two analog (ADC) inputs.

Applies to
MASSO G3 and MASSO G3 Touch
Available from
Software 5.13, API 1.0.0
Analog inputs
0–5 VDC, 12-bit
FunctionDoes
set_output(i, s)Turns a Lua output on or off
get_output(i)Reads a Lua output
get_input(i)Reads a Lua input
get_adc(i)Reads analog input ADC1 or ADC2

Digital outputs and inputs

M.io.set_output(i, s)

Sets the state of a Lua output.

Input: i (integer): Lua Output number, 1–16; s (boolean): state. Returns: nothing.

local b = M.io.get_output(i)

Reads the state of a Lua output.

Input: i (integer): Lua Output number, 1–16. Returns: integer: 1 = high, 0 = low.

local b = M.io.get_input(i)

Reads the state of a Lua input.

Input: i (integer): Lua Input number, 1–16. Returns: boolean.

Analog inputs

WARNING
MASSO G3 analog inputs accept a maximum of 5 VDC. Higher voltages can permanently damage the controller.
local v = M.io.get_adc(i)

Returns the reading of analog input ADC1 or ADC2.

Input: i (integer): 1 or 2. Returns: integer from 0 to 4095 (12-bit), covering 0–5 VDC.

-- Read raw ADC value from input channel 1
local raw = M.io.get_adc(1)

-- Convert to volts (12-bit ADC, 0-5 V range)
local volts = (raw / 4095) * 5.0

-- Display both values
message(string.format("Analog Input 1: %d (%.2f V)", raw, volts))