The I/O daemon (iod) is a daemon that is running on Stack. Toggle and is responsible for handling all I/O.
The I/O on Toggle is organized in chains, modules and channels.
Stack.Toggle has 3 chains:
Reader can consider chains like an interface, similarly to Ethernet interface. Chains are always preset even, if nothing is connected to them.
Chains are called this way because modules are connected to them in series fashion. EtherCAT and EtherCAT P chains can have up to 16 modules connected to them, however, due to power limitations of Stack.Toggle it is advised to use no more than 4 modules.
Module numeration starts form 1.
GPIO can't have any modules connected to it, but implicit module number 1 should be used when addressing GPIO chain.
Each module can have up to 16 digital I/O channels. Beckhoff modules usually have 8 channels. Channels on module are numbered from 1 to 16. Channels can be dedicated inputs or dedicated outputs or both. Perineal I/O is connected to channels.
GPIO has 2 dedicated input channels and 2 dedicated output channels.
For I/Os to be used they need to be configured. For more information about configuration see IO.
Configuration can also define common names for I/Os (example, 'button1', 'button2', 'led1', 'led2', etc.). Then common name can be used to address I/O with high level (HL) API.
For setting and getting I/O state iod provides NATS API.
To set I/O output to specific value (high or low) or to change its value to opposite (toggle), send a request to NATS operation subject. See NatsIodHlOperationSub and NatsIodOperationSub. Examples:
# Set output of named channel to 1:
nats req io.214000000028.iod.operation.set.a1 ""
# Set output of named channel to 0:
nats req io.214000000028.iod.operation.clear.a1 ""
# Toggle output of named channel:
nats req io.214000000028.iod.operation.toggle.a1 ""
# Set output of GPIO chain Output 2 channel to 1:
nats req io.214000000028.iod.operation.set.0.1.4 ""
# Set output of EtherCAT P chain module 1 channel 1 to 1:
nats req io.214000000028.iod.operation.set.2.1.1 ""
To get event of I/O input transition from high to low or low to high subscribe to NATS transition subject. See NatsIodHlTransitionSub and NatsIodTransitionSub. Examples:
# Subscribe to all I/O state transitions:
nats sub "io.214000000028.iod.transition.>"
# Subscribe to all I/O state transitions of named channels:
nats sub "io.214000000028.iod.transition.*.*"
# Subscribe to I/O state transitions to 1 of named channels:
nats sub "io.214000000028.iod.transition.*.1"
# Subscribe to all I/O state transitions of channel named "a1":
nats sub "io.214000000028.iod.transition.a1.*"
# Subscribe to all I/O state transitions of EtherCAT chain module 1:
nats sub "io.214000000028.iod.transition.1.1.*.*"
To get the current state of I/O input or output use a GET operation on NatsIodOperationSub or NatsIodHlOperationSub. Examples:
# Request:
nats req io.214000000028.iod.operation.get.a1 ""
# Response:
{"error": false, "errorMsg": "", "value": 0}
# Request:
nats req io.214000000028.iod.operation.get.0.1.3 ""
# Response:
{"error": false, "errorMsg": "", "value": 1}
Note: in case error is true, ignore value field.
Iod sends heartbeat messages to NATS heartbeat subject. See NatsHeartbeatSub.
Iod publishes metrics about return trip time (RTT) of I/O chains and metrics about current of power inputs and outputs. See NatsIodMetricSub.
There is a mechanism implemented to auto-discover and confirm detected modules. By confirming the detected modules they will be added/removed/overwritten in the configuration. This is useful when IO chains are altered and the user wants to commit the changes to the configuration.
First get the list of detected modules by sending an empty NATS request to the topic NatsIodDetectedModulesSub. The response IodDetectedModules will indicate both detected and configured modules for EtherCAT and EtherCAT P chains as well as possible actions that can be taken IodDetectedModulesActions.
To commit the detected modules and update configuration send a request to NatsIodConfirmModulesSub with the action the user chose to take in the body of the request IodConfirmModulesPayload.
Generated using TypeDoc