Skip to main content

Programming example for Basic Level

The example "Two-hand control with EDM" from the document "PLCopen – Technical Committee 5 Safety Software Technical Specification Part 2: User Examples Version 1.01 – Official Release" is used as a CODESYS Safety Extension programming example for a program in the Basic Level and illustrated as a CODESYS Safety Extension FBD implementation.

Tip

For more information about programming in the Basic Level, see the document "PLCopen - Technical Committee 5 Safety Software".

Functional description of the safety functions

The following safety functions are used in this example:

  • When the emergency stop button is pressed, all dangerous movements must be stopped (via SF_EmergencyStop)

    Emergency stop has the highest priority. After releasing the EStop pushbutton, a reset via S0 reset is required.

  • The safety output is activated by pressing both pushbuttons of the two-hand control. Releasing any of the two-hand pushbuttons deactivates the safety output and stops the hazardous movement via the switching devices K1 and K2 (via SF_TwoHandControlTypeII)

  • The basic state and the operating state of the connected switching devices are monitored. If an error is detected, then the safety output cannot become operational. (via SF_EDM)

  • After switching on the safety or functional application, or after an emergency stop condition, the two-hand control has to be released and actuated again to reactivate the safety output (via SF_OutControl). To ensure this for the functional restart, the process signal of the functional application is connected to the Activate input of the two-hand control FB THC_S2_S3. (If the application process is restarted while the two-hand control is activated, then the device goes to status C0003, which signals the error that both pushbuttons are pressed when activated and prevents a restart.)

In this example, only one operating state exists.

Figure 123. Variable declaration for programming example: Two-hand control with EDM
Variable declaration for programming example: Two-hand control with EDM


Figure 124. Implementation for programming example: Two-hand control with EDM
Implementation for programming example: Two-hand control with EDM


Table 105. Inputs:

Name

Data Type

Description

S1_S_EStopIn

SAFEBOOL

Emergency stop button S1

S2_S_Switch1

SAFEBOOL

Switch S2 connected with pushbutton 1 of two-hand control

S3_S_Switch2

SAFEBOOL

Switch S3 connected with pushbutton 2 of two-hand control

K1_S_EDM1

SAFEBOOL

Feedback external device K1

K2_S_EDM2

SAFEBOOL

Feedback external device K2

S0_Reset

BOOL

Reset by developer with switch S0 (derived from functional application)

Process

BOOL

Release of the movement by the process (derived from the functional application)



Table 106. Outputs:

Name

Data Type

Description

S_EDM_Out_EDM_K1_K2

SAFEBOOL

Controls the actuator via K1 and K2

Error_EStop_S1

BOOL

Error flag of EStop_S1

Error_THC_S2_S3

BOOL

Error flag of THC_S2_S3

Error_OC_K1_K2

BOOL

Error flag of OC_K1_K2

Diag_EStop_S1

WORD

Diagnostic code for EStop_S1,

16#8xxx: Regular operation,

16#Cxxx in case of error in EStop_S1

Diag_THC_S2_S3

WORD

Diagnostic code for THC_S2_S3,

16#8xxx: Regular operation,

16#Cxxx in case of error in THC_S2_S3

Diag_OC_K1_K2

WORD

Diagnostic code for OC_K1_K2,

16#8xxx: Regular operation,

16#Cxxx in case of error in OC_K1_K2



Additional notes

This example can also be used with SF_TwoHandControlTypeIII.

The input of Activate was set to TRUE for the sake of simplicity. This can be replaced by a variable in the application.

Table 107. Information about used FB parameters

Function Block

Input

Constant Value

Description

EStop_S1

S_StartReset

FALSE

No automatic reset when the S-PLC is started.

S_AutoReset

FALSE

No automatic reset, reset/confirmation by developer necessary

OC_K1_K2

S_StartReset

TRUE

Automatic reset is allowed when the S-PLC is started.

S_AutoReset

TRUE

Automatic reset, no reset/confirmation by developer necessary

Static Control

FALSE

A dynamic change of the Appl_Control signal (rising edge) is requested after function block activation or a triggered safety function (S_SafeControl to FALSE)

EDM_K1_K2

S_StartReset

FALSE

No automatic reset when the S-PLC is started.

MonitoringTime

T#200ms

The maximum response time of the two feedback signals

S_EDM1 and S_EDM2