5 error handling and diagnostics, 1 diagnostics in the plc program, 5error handling and diagnostics – BECKHOFF CX210000x4 User Manual
Page 36
Error handling and diagnostics
5
Error handling and diagnostics
5.1
Diagnostics in the PLC program
For the analysis of the terminal bus (Kbus) the State register can be accessed via TwinCAT from a PLC
program.
The error analysis is presented as an example below.
A signal/variable is essentially required for the error analysis:
• State (indicates the state of the bus: 0 > no error)
External variables must similarly be created in the PLC program for this:
VAR
k_bus_state AT %IB2 : USINT;
END_VAR
The error can then be determined in the PLC program as follows (this is pseudo code, which is not directly
executable in this form)
....
IF k_bus_state != 0 THEN (* auf dem KBus ist ein Fehler aufgetreten *)
IF k_bus_state.1 = 1 THEN melde Fehler; (* Klemmenzustandsfehler *) END_IF
IF k_bus_state.2 = 1 THEN melde Fehler; (* Prozessdatenlänge ungültig *) END_IF
IF k_bus_state.8 = 1 THEN melde Fehler; (* keine gültigen Eingänge *) END_IF
IF k_bus_state.9 = 1 THEN melde Fehler; (* K_bus Input Update ist aktiv *) END_IF
IF k_bus_state.10 = 1 THEN melde Fehler; (* K_bus Output Update ist aktiv *) END_IF
IF k_bus_state.11 = 1 THEN melde Fehler; (* Watchdog Fehler *) END_IF
IF k_bus_state.15 = 1 THEN melde Fehler; (* Bus ist asynchron *) END_IF
END_CASE
k_bus_request := TRUE; (* Rücksetzen des Busses, wenn Fehler beseitigt, dann startet der Klemm
bus wieder *)
....
In order for the controller and the registers to cooperate, they must be linked in the System Manager.
CX210000x4
36
Version 1.0