Digital InputHardware UCMVirtual UCM
The digitalin library provides an interface for controlling digital inputs.
The digitalin library is available for:
- ENP-DI7, using 7 hardware ports,
- ENP-DI10 M2, using 10 hardware ports,
- Virtual UCM on Welotec Arrakis Mk3/Mk4 with DIO module installed, using 4 hardware ports,
- Virtual UCM on any PC using Generic IO interface.
digitalin.new
-- @param connection_uri string Connection URI
-- @return object|nil, string|nil
function digitalin.new(connection_uri)
end
Creates a new digital input client. The connection URI should specify the desired digital input device.
Use port schema to access hardware ports. On Virtual UCM you may also use gio schema for Generic IO.
On failure, it returns nil and an error message string.
Example
local client, err = digitalin.new("port://di-1")
if err ~= nil then
enapter.log("Failed to create digitalin client: " .. err, "error")
end
Constants
digitalin.LOW— low state of input.digitalin.HIGH— high state of input.
client Object
client:get_state
-- @return digitalin.HIGH|digitalin.LOW, string|nil
function client:get_state()
end
Returns the current state of the digital input. The state is digitalin.LOW when the input is open, or digitalin.HIGH when the input is closed.
On success, the function returns an input state and nil. On failure, it returns an nil and an error message string.
client:read_counter
This feature is available on Virtual UCM using Welotec Arrakis Mk3/Mk4 hardware ports. The function always returns an error.
-- @return number, string|nil
function client:read_counter()
end
Gets the current value of impulse count on the digital input.
On success, the function returns number and nil. On failure, it returns an nil and an error message string.
client:reset_counter
This feature is not available on Virtual UCM using Welotec Arrakis Mk3/Mk4 hardware ports. The function always returns an error.
-- @return string|nil
function client:start_counter()
end
Resets the impulse counter of the digital input to zero.
On success, the function returns nil. On failure, it returns an error message string.