Set_DO_Data
Overview
The Set_DO_Data function block is used to write output states to a Digital Output (DO) module.
💡 DO Channels
Each DO module provides eight output channels.
Module_ID := (USINT)
Ch0 := (BOOL)
Ch1 := (BOOL)
Ch2 := (BOOL)
Ch3 := (BOOL)
Ch4 := (BOOL)
Ch5 := (BOOL)
Ch6 := (BOOL)
Ch7 := (BOOL)
STS_Done => (BOOL)
STS_Failed => (BOOL)
STS_Fault_Code => (USINT)
Interface
Inputs
| Name | Type | Range / Units | Description |
|---|---|---|---|
| Module_ID | USINT | 1 - 15 | Unique identifier of the DI module. |
| Ch0 | BOOL | 0 / 1 | Logical output state for channel 0. |
| Ch1 | BOOL | 0 / 1 | Logical output state for channel 1. |
| Ch2 | BOOL | 0 / 1 | Logical output state for channel 2. |
| Ch3 | BOOL | 0 / 1 | Logical output state for channel 3. |
| Ch4 | BOOL | 0 / 1 | Logical output state for channel 4. |
| Ch5 | BOOL | 0 / 1 | Logical output state for channel 5. |
| Ch6 | BOOL | 0 / 1 | Logical output state for channel 6. |
| Ch7 | BOOL | 0 / 1 | Logical output state for channel 7. |
Outputs
| Name | Type | Range / Units | Description |
|---|---|---|---|
| STS_Done | BOOL | 0 / 1 | TRUE when all DO data has been successfully sent to the module. |
| STS_Failed | BOOL | 0 / 1 | TRUE if the DO data write operation failed. |
| STS_Fault_Code | USINT | # | Diagnostic code indicating the reason for failure. |
Fault Codes
| Code | Meaning | Description |
|---|---|---|
| 97 | Module Faulted | The DO module reported an internal fault. |
| 98 | Module Mismatch | The detected module type does not match the expected DO module. |
| 99 | Module Not Found | The specified Module_ID is not part of the current hardware configuration. |
Example
PROGRAM PROG_Write_DO
VAR
DO_Write : Set_DO_Data;
TON_Instance : TON;
Toggle : BOOL := FALSE;
END_VAR
TON_Instance(IN := TRUE, PT := T#3s);
IF TON_Instance.Q THEN
Toggle := NOT Toggle;
TON_Instance(IN := FALSE);
END_IF;
DO_Write(Module_ID := 3
,Ch0 := Toggle);
END_PROGRAM
CONFIGURATION Config0
RESOURCE PLC ON PLC
TASK Task_50ms(INTERVAL := T#50ms, PRIORITY := 1);
PROGRAM Write_DO WITH Task_50ms : PROG_Write_DO;
END_RESOURCE
END_CONFIGURATION