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

NameTypeRange / UnitsDescription
Module_IDUSINT1 - 15Unique identifier of the DI module.
Ch0BOOL0 / 1Logical output state for channel 0.
Ch1BOOL0 / 1Logical output state for channel 1.
Ch2BOOL0 / 1Logical output state for channel 2.
Ch3BOOL0 / 1Logical output state for channel 3.
Ch4BOOL0 / 1Logical output state for channel 4.
Ch5BOOL0 / 1Logical output state for channel 5.
Ch6BOOL0 / 1Logical output state for channel 6.
Ch7BOOL0 / 1Logical output state for channel 7.

Outputs

NameTypeRange / UnitsDescription
STS_DoneBOOL0 / 1TRUE when all DO data has been successfully sent to the module.
STS_FailedBOOL0 / 1TRUE if the DO data write operation failed.
STS_Fault_CodeUSINT#Diagnostic code indicating the reason for failure.

Fault Codes

CodeMeaningDescription
97Module FaultedThe DO module reported an internal fault.
98Module MismatchThe detected module type does not match the expected DO module.
99Module Not FoundThe 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