Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY
This function block controls and diagnoses a sourcing DO.
Diagnostic is done using:
measured output current
over current protection status provided by firmware
output's digital input status (library version 1.3.2.5 or later)
Init method is used to initialize the necessary static calculation parameters for the function block instance.
The method shall be called at least once before the actual function block can be called, i.e. at the application initialization phase.
The method checks the validity of input parameters. However, none of the function block outputs are affected by the initialization.
|
A parameter error is diagnosed if:
|
The G_DO_MAX_DIAG_DELAY constant is the hardware specific maximum value for diagnostic delay.
Parameter |
Data type |
Unit |
Range |
Description |
S_i_BrokenCircuitCurrentLimit |
SAFEDINT |
mA |
>= 0 |
Limit for undercurrent diagnosis. |
S_i_OverCurrentLimit |
SAFEDINT |
mA |
> 0 |
Limit for overcurrent diagnosis. |
S_i_DiagnosticDelay |
SAFEUINT |
ms |
0 - G_DO_MAX_ DIAG_DELAY |
Delay time for diagnostics. |
i_pEventCode |
POINTER TO EventCode |
- |
≠ 0 |
Pointer to application variable which is type EventCode. |
TRUE: All initialization parameters ok. |
FALSE: Error in initialization parameter(s). |
The output o_DOState follows the input S_i_DOControl if:
• The control is enabled, i.e. i_Enable is TRUE, AND
• No fault (including initialization) has been diagnosed
When S_i_DOControl is TRUE, the output o_DOState is set to FALSE after given diagnostic delay time S_i_DiagnosticDelay
if the measured output current exceeds limit given with S_i_OverCurrentLimit OR
if the measured output current falls below limit given with S_i_BrokenCircuitCurrentLimit OR
if the digital input status (i_DOStatus) is FALSE
When S_i_DOControl is FALSE and i_Enable is TRUE, the external voltage error is diagnosed after given diagnostic delay time S_i_DiagnosticDelay if i_DOStatus is TRUE.
The output o_DOState is set to FALSE immediately if i_Enable is FALSE, or i_OverCurrentProtectionStatus is TRUE.
|
Parameter error during normal operation is diagnosed if i_OutputCurrent is out of range. |
Input variable name |
Data type |
Unit |
Range |
Description |
i_Enable |
BOOL |
- |
- |
Enable POU operation |
S_i_DOControl |
SAFEBOOL |
- |
- |
DO control request |
i_OutputCurrent |
DWORD |
mA |
0 – 2147483647 |
Measured current value of DO pin |
i_OverCurrentProtectionStatus |
BOOL |
- |
- |
Overcurrent protection status of firmware |
i_DOStatus |
BOOL |
- |
- |
Output digital status input |
Output variable name |
Data type |
Range |
Description |
o_DOState |
BOOL |
- |
DO state after diagnostics |
o_Status |
Status |
- |
Status of output value. See Status struct. |
Input variable name |
Data type |
Unit |
Range |
Description |
i_Enable |
BOOL |
- |
- |
Enable POU operation |
S_i_DOControl |
SAFEBOOL |
- |
- |
DO control request |
i_OutputCurrent |
DINT |
mA |
- |
Measured current value of DO pin |
i_OverCurrentProtectionStatus |
BOOL |
- |
- |
Overcurrent protection status of firmware |
i_DOStatus |
BOOL |
- |
- |
Output digital status input |
Output variable name |
Data type |
Range |
Description |
o_DOState |
BOOL |
- |
DO state after diagnostics |
o_Status |
Status |
- |
Status of output value. See Status struct. |
See Diagnostic Interface library description of error status and event code functionality.
Conditions |
o_DOState |
o_Status. OutputValid |
o_Status error status |
Event code FunctionID |
Event code EventID |
i_Enable TRUE AND parameter error AND i_pEventCode valid |
FALSE |
FALSE |
ParameterError |
DO_CONTROL |
PARAMETER_ERROR |
i_Enable TRUE AND init parameter error AND |
FALSE |
FALSE |
ParameterError |
- |
- |
i_Enable rises AND parameters ok AND S_i_DOControl = TRUE |
FALSE |
FALSE |
StartupError |
DO_CONTROL |
STARTUP_ERROR |
i_Enable rises AND init parameters ok AND input valid |
S_i_DO Control |
TRUE |
- |
NO_FUNC |
NO_ERROR |
i_Enable TRUE AND parameters ok AND o_DOState TRUE AND i_OutputCurrent < S_i_BrokenCircuitLimit |
FALSE |
FALSE |
BrokenCircuit |
DO_CONTROL |
INPUT_TOO_LOW |
i_Enable TRUE AND parameters ok AND i_OutputCurrent > S_i_OverCurrentLimit |
FALSE |
FALSE |
OverCurrent |
DO_CONTROL |
INPUT_TOO_HIGH |
i_Enable TRUE AND parameters ok AND i_OverCurrentProtectionStatus TRUE |
FALSE |
FALSE |
OverCurrent |
DO_CONTROL |
INPUT_TOO_HIGH |
i_Enable TRUE AND parameters ok AND o_DOState TRUE AND i_DOStatus = FALSE |
FALSE |
FALSE |
Shortcut |
DO_CONTROL |
INPUT_TOO_LOW |
i_Enable TRUE AND parameters ok AND S_i_DOControl = FALSE AND i_DOStatus = TRUE |
FALSE |
FALSE |
External Voltage |
DO_CONTROL |
INPUT_TOO_HIGH |
|
Used I/O variables must be mapped to I/O-interface. |
|
I/O variables and configuration are provided by MultiTool Creator code template. See also How to control DO & DO ECO |
IO variables: |
|
X1_32_CurrentFeedback: DWORD; // DWORD mA Current feedback X1_32_DO_State: BOOL; // BIT DO control state X1_32_Overcurrent: BOOL; // BOOL OC status from firmware (Status flags bit 2) X1_32_DOS: BOOL; // BOOL output's digital input status
|
Safety Definitions: |
Result: EPEC_SYSTEM.SYSTEM_ERROR_CODES:= EPEC_SYSTEM.SYSTEM_ERROR_CODES.FW_ERR_OK;
PIN_1_32_DO: EPEC_SHWD.S_DOControlAndDiagnostics; PIN_1_32_DO_Status: EPEC_SHWD.Status; PIN_1_32_DO_Control: BOOL := FALSE; PIN_1_32_DO_EC: EPEC_DITF.EventCode; |
Safety Init: |
(* Set IO driver to configuration state *) IF EPEC_SYSTEM.SYSTEM_ERROR_CODES.FW_ERR_OK = Result THEN Result := EPEC_IODRV.IoDrvSetState(i_State:=EPEC_IODRV.IoDrvStates.IODRV_STATE_CONFIGURATION); END_IF
(* Configure pin X1-32 to PWM/DO *) IF EPEC_SYSTEM.SYSTEM_ERROR_CODES.FW_ERR_OK = Result THEN Result := EPEC_IODRV.IoDrvPWMSetMode( EPEC_HW.IO_Channels.PIN_1_32_PWFM, EPEC_IODRV.IoDrvModes.IODRV_MODE_PWM_DO ); END_IF
(* Set IO driver to run state *) EPEC_IODRV.IoDrvSetState(EPEC_IODRV.IoDrvStates.IODRV_STATE_RUN);
(* Init control POU *) PIN_1_32_DO_EC.DeviceID := BYTE#1; PIN_1_32_DO_EC.ChannelID := BYTE#32; PIN_1_32_DO_EC.FunctionID := EPEC_DITF.FunctionIDs.NO_FUNC; PIN_1_32_DO_EC.EventID := EPEC_DITF.ErrorIDs.NO_ERROR;
PIN_1_32_DO.Init( S_i_BrokenCircuitCurrentLimit := DINT#30, // Under current 30 mA S_i_OverCurrentLimit := DINT#300, // Over current 300 mA S_i_DiagnosticDelay := EPEC_HW.Constants.G_DIGITAL_OUTPUT_DIAGNOSTIC_DELAY, i_pEventCode := ADR(PIN_1_32_DO_EC) );
|
Safety Code: |
PIN_1_32_DO( i_Enable := TRUE, S_i_DOControl := PIN_1_32_DO_Control, i_OutputCurrent := X1_32_CurrentFeedback, i_OverCurrentProtectionStatus := X1_32_Overcurrent, i_DOStatus := X1_32_DOS, o_DOState => X1_32_DO_State, o_Status => PIN_1_32_DO_Status );
|
Source file topic100438.htm
Last updated 21-Feb-2025