Error handling and diagnostics
CX2100-0004
38
Version: 1.2
7
Error handling and diagnostics
7.1
Diagnostics in the PLC program
For the analysis of the terminal bus (K-bus) 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 K-Bus 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