Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY
This section describes how to implement ON/OFF control and diagnose errors in the following ways:
DO mode: Normal ON/OFF control using DO output
DO ECO mode: ON/OFF control using PWM ratio to reduce current consumption
|
This example uses the following libraries: SafeSSeriesHardware library
|
|
Depending on hardware, the output group control needs to be activated before controlling outputs. See How to use S series and E series HW diagnostics for more information.
|
|
Hardware diagnostics can be used in S Series / E Series Control Units. It is also possible to control an output group and reference voltage output by an application. See How to use S Series and E Series HW diagnostics for more information.
|
|
Currently, the S Series and E Series control unit's code template S_Outputs / Outputs programs provide interface for all output related variables defined in Epec MultiTool Creator. All output related function blocks are implemented by the application.
For DO ECO mode this means that the ECO functionality needs to be implemented in the application. |
|
External voltage detection in output pins is provided by safety control unit's switch startup test. The startup test execution depends on used product:
After startup test the external voltage is monitored by application diagnostics. |
|
SafeSSeriesHardware 1.2.1.1 or older: Application level detection is required if external voltage needs to be monitored while operational (application functionality specific). See the following example code. |
|
Output digital input status (i_DOStatus) monitoring is available in SafeSSeriesHardware library's version 1.3.2.5 or later. |
|
The over current protection status (OCP) is a BOOL value provided by the firmware. The feedback current measurement (CM) is a DWORD (SP10)/DINT (SP19) value provided by the firmware. |
|
When the following example is used with non-safety I/O, the I/O variables are generated in Outputs program instead of S_Outputs. |
Example using SafeSSeriesHardware 1.2.1.1 or olderExample using SafeSSeriesHardware 1.2.1.1 or older
In the following example, the control and diagnostics of safety related DO Valve1 is defined in MultiTool Creator.
The example also contains an application FB ExternalVoltage, which monitors the external voltage when DO control is inactive.
Safe PRG:
|
|
Init method:
|
IF NOT initDone THEN initDone := TRUE; (*Parameters are application specific*) valve1Control.Init( S_i_OverCurrentLimit := DINT#700, (*mA*) S_i_BrokenCircuitCurrentLimit := DINT#20, (*mA*) S_i_DiagnosticDelay := UINT#30, (*ms*) i_pEventCode := ADR(eventCode_valve1) ); END_IF |
ExternalVoltage FB Definitions:
|
FUNCTION_BLOCK ExternalVoltage VAR_INPUT i_DOS_status: BOOL; i_ControlActive: BOOL; END_VAR VAR_OUTPUT o_StatusOK: BOOL; o_ExternalVoltage: BOOL; END_VAR VAR timer: Standard.TON; status_ok: BOOL; external_voltage: BOOL; END_VAR VAR CONSTANT DELAY: TIME := T#100MS; (*Application specific*) END_VAR
|
ExternalVoltage FB code:
|
IF i_ControlActive THEN status_ok := TRUE; external_voltage := FALSE; timer(IN:=FALSE,PT:=DELAY); ELSE (*Monitor error only when controls OFF*) timer(IN:=TRUE,PT:=DELAY); IF timer.Q THEN IF i_DOS_status THEN external_voltage := TRUE; status_ok := FALSE; ELSE external_voltage := FALSE; status_ok := TRUE; END_IF END_IF END_IF o_StatusOK := status_ok; o_ExternalVoltage := external_voltage; |
Example using SafeSSeriesHardware 1.3.2.5 or laterExample using SafeSSeriesHardware 1.3.2.5 or later
In the following example, the control and diagnostics of safety related DO Valve1 is defined in MultiTool Creator.
Safe PRG:
|
|
Init method:
|
IF NOT initDone THEN initDone := TRUE; (*Parameters are application specific*) valve1Control.Init( S_i_OverCurrentLimit := DINT#700, (*mA*) S_i_BrokenCircuitCurrentLimit := DINT#20, (*mA*) S_i_DiagnosticDelay := UINT#30, (*ms*) i_pEventCode := ADR(eventCode_valve1) ); END_IF |
|
When the following example is used with non-safety I/O, the I/O variables are generated in Outputs program instead of S_Outputs. |
Example using SafeSSeriesHardware 1.2.1.1 or olderExample using SafeSSeriesHardware 1.2.1.1 or older
In the following example, the control and diagnostics of the safety related DO ECO EcoControl is defined in MultiTool Creator.
The example also contains an application FB ExternalVoltage, which monitors the external voltage when DO control is inactive.
Safe PRG:
|
|
Init method: |
IF NOT initDone THEN initDone := TRUE; (*Parameters are application specific*) ecoControl.Init( S_i_ReducedControlDelay := UINT#2000, (*ms*) S_i_ReducedControlRatio := DINT#500, (*50,0 %*) S_i_OverCurrentLimit := DINT#700, (*mA*) S_i_BrokenCircuitCurrentLimit := DINT#20, (*mA*) S_i_DiagnosticDelay := UINT#30, (*ms*) i_pEventCode := ADR(eventCode_ecoControl) ); END_IF |
ExternalVoltage FB Definitions:
|
FUNCTION_BLOCK ExternalVoltage VAR_INPUT i_DOS_status: BOOL; i_ControlActive: BOOL; END_VAR VAR_OUTPUT o_StatusOK: BOOL; o_ExternalVoltage: BOOL; END_VAR VAR timer: Standard.TON; status_ok: BOOL; external_voltage: BOOL; END_VAR VAR CONSTANT DELAY: TIME := T#100MS; (*Application specific*) END_VAR
|
ExternalVoltage FB code:
|
IF i_ControlActive THEN status_ok := TRUE; external_voltage := FALSE; timer(IN:=FALSE,PT:=DELAY); ELSE (*Monitor error only when controls OFF*) timer(IN:=TRUE,PT:=DELAY); IF timer.Q THEN IF i_DOS_status THEN external_voltage := TRUE; status_ok := FALSE; ELSE external_voltage := FALSE; status_ok := TRUE; END_IF END_IF END_IF o_StatusOK := status_ok; o_ExternalVoltage := external_voltage; |
Example using SafeSSeriesHardware 1.3.2.5 or laterExample using SafeSSeriesHardware 1.3.2.5 or later
In the following example, the control and diagnostics of the safety related DO ECO EcoControl is defined in MultiTool Creator.
Safe PRG:
|
|
Init method: |
IF NOT initDone THEN initDone := TRUE; (*Parameters are application specific*) ecoControl.Init( S_i_ReducedControlDelay := UINT#2000, (*ms*) S_i_ReducedControlRatio := DINT#500, (*50,0 %*) S_i_OverCurrentLimit := DINT#700, (*mA*) S_i_BrokenCircuitCurrentLimit := DINT#20, (*mA*) S_i_DiagnosticDelay := UINT#30, (*ms*) i_pEventCode := ADR(eventCode_ecoControl) ); END_IF |
SafeSSeriesHardware library
Source file topic100381.htm
Last updated 21-Feb-2025