Digital Input
The digitalin library provides an interface for controlling digital inputs.
The digitalin library is available for:
- ENP-DI7 (7 hardware ports),
- ENP-DI10 M2 (10 hardware ports),
- Virtual UCM using Generic IO interface,
- Virtual UCM on Welotec Arrakis Mk3/Mk4 with DIO module installed (4 hardware ports).
digitalin.new
-- @param connection_uri string Connection URI to the digitalin device
-- @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.
On success, the function returns the client object and nil. 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— logial low state.digitalin.HIGH— logical high state.
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.