Appendix
05/06 AWB2724-1584GB
66
Example program for PLC START/STOP using external
switch
The SysLibPlcCtrl.lib library contains the function
SysStartPlcProgram required for the start, and the function
SysStopPlcProgram required for the stop.
In this case, the startup behaviour of the controller must be set to
WARM START in the PLC configurator under <Other Parameters l
Settings>!
Function
The POU “StartPrg”, which is called once on every PLC start is
used to register the function “FuncCalledWhenPlcIsInStop” on the
“event”
“EVENT_TASKCODE_NOT_CALLED”-. This registration causes the
function FuncCalledWhenPlcIsInStop to be called via the “event”
“EVENT_TASKCODE_NOT_CALLED” if the PLC is in STOP state.
The “StartStopFunction” function is used to monitor the status of
the input and call the function for starting or stopping the PLC if
there is a status change.
As the POU “StartPrg” is called only once, there should be no
outputs or parameters set in this POU. User programs should be
programmed in separate POUs.
X Activate the system event “Start” and name the Called “POU
Startprg”.
X Open a new POU with the name “Startprg” in the POUs folder
and program the function “SysCallbackRegister” which
“presents” the Start/Stop functions to the operating system.
X Declare the following global variables.
X Enter the program for PLC_PRG as shown in figure 84 . It is
important that the user program and the POU calls are inserted
as shown in figure 84.
X Enter the function “FuncCalledWhenPIcInStop” and
“StartStopFunction”.
Figure 81: Activating a system event
Figure 82: “Startprg” function
Figure 83: Declaring global variables
Figure 84: Scanning START/STOP
Figure 85: Call of the function FuncCalledWhenPlcIsInStop
Figure 86: Function that monitors the input