Programs
With the above-mentioned basic building blocks, a program can be seen as a network of functions and function blocks. Each of them being written in any of the defined programming languages.
-
-
Programs and Subprograms can be reordered by drag-and-drop. Dragging an item up the list places it above the program you drop it on, while dragging down places it below.
Sub-programs
The list of programs is completed with "Sub-programs". Sub-programs are written in FBD"Function block diagram" A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks, FFLD, ST"Structured text" A high-level language that is block structured and syntactically resembles Pascal or IL"Instruction list" This is a low-level language and resembles assembly languages, and can be called by the programs of the application. Input and output parameters plus local variables of a sub-program are declared in the variable editor as local variables of the sub-program.
- A function type sub-program can call another function type subprogram.
- A UDFB"User Defined Function Block" UDFB can be used as a sub-function block in another program of the application. It is described using FBD, LD, ST or IL language. Input / output parameters of a UDFB (as well as private variables) are declared in the variable editor as local variables of the UDFB type sub-program can call another UDFB type subprogram or a function type subprogram
Unlike UDFB, local variables of a sub-program are not instantiated. This means that the sub-program always works on the same set of local variables. Local variables of a sub-program keep their value among various calls. The code of a sub-program is not duplicated when called several times by parent programs.
A sub-program cannot have more than 32 input parameters or 32 output parameters.
A good programming practice is to break up your programs into smaller modules.
See also Application Software Structure - Definitions.
Program Guidelines
An application is a list of programs. Programs are executed sequentially within the target cycle, according to the following model:
Begin cycle | exchange I/Os | execute first program | ... | execute last program | wait for cycle time to be elapsed End Cycle
Programs are executed according to the order defined by the user. All SFC"Sequential function chart" It can be used to program processes that can be split into steps. The main components of SFC are: - Steps with associated actions - Transitions with associated logic conditions - Directed links between steps and transitions programs must be grouped (it is not possible to insert a program in FBD, FFLD, ST or IL between two SFC programs). Each program is entered using a language chosen when the program is created. Possible languages are Sequential Function Chart (SFC), Function Block Diagram (FBD), Free Form Ladder Diagram (FFLD), Structured Text (ST) or Instruction List (IL). The maximum number of programs in an application is 32767.
Program Name
Programs must have unique names. The name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" FunctionA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. or function block. A program must not have the same name as a declared variable. The name of a program must begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a name. Naming is case-insensitive. Two names with different cases are considered as the same.
Child SFC Programs
You can define a hierarchy of SFC programs, entered as a tree in the list of programs. A child program is controlled within action blocks of the parent SFC program.
-
-
Even if you do not want to split your FFLD program, at least separate FFLD from SFC. Simply make a sub-program in FFLD called from the SFC step, and keep only the state machine in the SFC program. This makes everything simpler and more comfortable for editing and debugging.
Program Limitations
When creating your application you have to consider the following important limitations.
- Actions in SFC steps cannot be more than 32kB
- Condition in SFC transition cannot exceed 32kB
- Total PLC"Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events code size of the program cannot exceed 64kB
- Width of any network is limited to 255 columns
- Height of any network is limited to 255 rows
For any program, sub-program or UDFB written in other languages:
- Jump limit is 64kB
For example, in a Free Form Ladder program, if you create a UDFB or program which is over 64kB and then decide to add a jump to label in the first network to the last network, this jump reaches the limit. - Total PLC code size of the program, sub-program or UDFB cannot exceed 64kB