5 program, Program, Drive plc developer studio – Lenze DDS v2.3 User Manual
Page 18: Introduction, 1 program example

Drive PLC Developer Studio
Introduction
2-6
l
DDS EN 2.3
Declaration part:
Instruction part:
PROGRAM test
VAR
quad: BOOL;
instanz: fub;
value: INT:=0;
IL
CAL instanz(par1:=5,par2:=5)
LD instanz.varout2
ST quad
LD instanz.varout1
ST value
END_VAR
ST
instanz(par1:=5,par2:=5);
quad:=instanz.varout2;
value:=instanz.varout1;
FBD
2.2.5
Program
A program is an organization unit that returns one or several values on execution.
•
A program declaration starts with the keyword PROGRAM.
•
Programs are known globally throughout the entire project.
•
Programs can be called by programs and function blocks. Program calls in a function are not
allowed. Programs do not have instances.
•
If an organization unit calls a program, thus changing program values, these changes remain
active for the next program call, even if the program is called by another organization unit.
Tip!
Only the values in the associated instance of a function block are changed on function block call.
These changes are significant only if the same instance is called.
2.2.5.1
Program example
Example of a program in IL:
Examples of calling the program shown on the left:
IL
CAL PRGexample
LD PRGexample.par
ST result
ST
PRGexample;
result:=PRGexample.par;
FBD
Example of a possible call sequence from a main program:
LD 0
ST PRGexample.par (* par is preset with 0 *)
CAL AWLexample (* result in AWLexample = 1 *)
CAL STexample (* result in STexample = 2 *)
CAL FUPexample (* result in FUPexample = 3 *)
•
If the variable par of the program PRGexample is initialized with 0 from the main program, and programs are then called successively
by means of the above program calls, the result will have the values 1, 2, and 3 in the programs.
•
Changing the call sequence will also change the values of the associated result parameters.
Note!
The string length is limited by the applied automation system.
Show/Hide Bookmarks