C.3 Example of a PROGRAM 329
LD Ress_Running (* CPU is running *)
ST DateTime.IN (* clock running if CPU is running *)
LD ActDateTime (* initial value Date/Time *)
ST DateTime.PDT (* initial value of clock is loaded *)
(* if there is a rising edge at IN *)
CAL DateTime (* start real-time clock)
...
LD TimeDiff (* interruption duration *)
LT t#50m (* less than 50 seconds? *)
JMPC Continue (* plant still warm enough ... *)
NOT
S Error (* set error flag *)
LD 16#000300F2
ST Err_Code (* store error cause *)
Continue:
LD EmergOff (* "emergency off“ pressed? *)
ST Edge.CLK (* input edge detection *)
CAL Edge (* compare input with edge flag *)
LDN Edge.Q (* edge at EmergOff recognized? *)
AND T_Start (* AND start flag set *)
ANDN Error (* AND no new error *)
AND ErrProc.Ack (* AND error cause repaired *)
ST ProgRun (* global "running“-condition *)
.... (* ...real instructions, calls of FUN/FBs... *)
LD Error (* error occurred? *)
AND %IX250.2
R ProgRun (* reset global starting condition *)
LD ProgRun
JMPNC End (* in the case of error: start error handler *)
CALC ErrProc(Code := Err_Code) (* FB with central error handling *)
LD ErrProc.Ack (* flag: error acknowledged *)
End:
LD ProgRun (* program not running *)
ST T_Failure (* set output parameter *)
RET (* return and/or end *)
(* end of program *)
END_PROGRAM
Example C.7. (Continued)
Edge detection is also employed in this program in order to find out whether the
Emergency Off
button has been pressed.
In the global data area, the variable
ProgRun
is declared, which is available to all
function blocks called under
MainProg
(as VAR_EXTERNAL). This is linked
with the starting condition provided
EmergOff
has not been pressed.
FB instance
ErrProc
can handle errors with error code
Err_Code.
When the error
has been corrected and acknowledged, the corresponding output is set to
TRUE.