4. INITIAL PROGRAMMING
SpecialVariablesPrg();
IF isFirstCycle THEN
StartPrg();
isFirstCycle := FALSE;
ELSE
UserPrg();
END_IF;
MainPrg call other two POUs of program type, named StartPrg and UserPrg. While the UserPrg is always called, the
StartPrg is only called once in the PLC application start.
To the opposite of MainPrg program, that must not be modified, the user can change the StartPrg and UserPrg programs.
Initially, when the project is created from the wizard, these two programs are created empty, but the user might insert code in
them.
4.14.2. StartPrg Program
In this POU the user might create logics, loops, start variables, etc. that will be executed only one time in the first PLC’s
cycle, before execute UserPrg POU by the first time. And not being called again during the project execution.
In case the user load a new application, or if the PLC gets powered off, as well as in Reset Origin, Reset Cold and Reset
Warm conditions, this POU is going to be executed again.
4.14.3. UserPrg Program
In this POU the user must create the main application, responsible by its own process control. This POU is called by the
main POU (MainPrg).
The user can also create additional POUs (programs, functions or function blocks), and called them or instance them inside
UserPrg POU, to ends of its program instruction. Also it is possible to call functions and instance function blocks defined in
libraries.
4.14.4. GVL System_Diagnostics
The System_Diagnostics GVL contains the diagnostic variables of the CPU, of the communication interface (Ethernet and
PROFIBUS) and of all communication drivers. This GVL isn’t editable and the variables are declared automatically with type
specified by the device to which it belongs when it is added to the project.
ATTENTION
In System_Diagnostics GVL, are also declared the diagnostic variables of the direct repre-
sentation MODBUS Client/Master Requests.
Some devices, like the MODBUS Symbol communication driver, doesn’t have its diagnostics allocated at %Q variables
with the AT directive. The same occurs with newest communication drivers, as Server IEC 60870-5-104.
The following picture shows an example of the presentation of this GVL when in Online mode.
51