CEI / IEC 1131-3 programming languages
Return to Introduction  Previous page  Next page

 

CEI / IEC 1131, Part 3, specifies the semantics and syntax of a unified suite of five programming languages for PLCs. These languages can be grouped into two categories: textual and graphical. Graphical languages are based upon graphical representation, that is, lines, boxes and text to represent specific relations among inputs and outputs. Appropriate quantities flow along lines between elements according to well defined rules. There are three graphical programming languages: Ladder Logic, Sequential Function Charts, and Functional Block Diagrams. Ladder logic is the most common of PLC languages and is discussed in the following section of this appendix. Sequential function charts can be used as a simple language, but their most important function is to integrate modules written in other languages into a single higher level program. Function Block Diagrams uses block diagrams to interconnect the function.

Textual languages consist of a defined set of characters, rules for combining characters with one another to form words or other expressions, and the assignment of meaning to some of the words or expressions. There are two textual languages defined in the standard: Instruction List (IL) and Structured Text (ST). IL is a very low-level language, and may be considered as a standard Assembly Language for PLCs. Structured text is a textual programming language using assignment, sub-program control, and selection and iteration statements to represent the application program for a PLC. ST, as distinguished from IL, is the high-level text-based language for PLCs. Much of its syntax is derived from Pascal.

The models of execution, program organization, and variable handling of all CEI / IEC 1131-3 languages are based on a common hierarchical architecture consisting of Configurations, Resources, Tasks, and Programs.

Configurations are the highest level at which Global variables and Directly Represented Variables may be shared and accessed. A Configuration may often correspond to a single PLC unit, but certain types of PLC Network Architectures as well as multi-processor PLCs also meet this definition. A Configuration is composed of one or more Resources. Each Resource corresponds to a signal processing function, its associated man-machine interface functions, and sensor-actuator interface functions. A single-processor stand-alone PLC Configuration would have but a single Resource. A Configuration composed of a dozen processors capable of sharing the defined global variables and directly represented variables, on the other hand, would have 12 Resources associated with it.

Each Resource may have Global Variables (which are limited in scope to that Resource), zero or more defined Tasks, and Programs associated with those Tasks. Tasks may be defined as periodic, in which case they are defined with a specified periodicity, or as non-periodic, in which case they are executed upon the detection of the rising edge of a boolean variable. Tasks may also be assigned an execution priority. Tasks may also be scheduled pre-emptively, or non-preemptively. A Program not assigned to a Task will execute repetitively at the lowest priority level.

Programs in the IEC 1131-3 architecture begin with a variable declaration section, followed by the program statements themselves. Programs may contain calls to Functions, which return a single value, or Function Blocks, which return one or more values. Each Program, Function, or Function Block is written in one of the five IEC 1131-3 defined languages. Multi-language programming is accomplished by calling a Function or Function Block written in one language from a Program, Function, or Function Block written in another.

Variables in IEC 1131-3 languages may be either Symbolic Variables, or Directly Represented Variables. Directly Represented Variables provide a standard nomenclature for direct access to specific addresses of the I/O and internal memory map of the PLC. All Directly Represented Variables begin with a '%' character, followed by a location prefix, a size prefix, and then a sequence of numbers to indicate the actual location. Some examples of these and their meanings:

 

%QX75 Output (Q) Bit (X) number 75
%IW215 Input (I) Word (W) number 215
%MW48 Internal (M) Word (W) number 48

 

The precise meaning of the hierarchy of location numbers is not defined, so it is possible to have constructs like the following, taken from an actual PLC architecture:

 

%MW3.23.8.12.2.4,

 

which corresponds in this particular case to, from right to left, the 4th Internal 16 Bit Integer Word located in Module subsection 2 of module 12 of Rack 8, of the unit at drop 23 of MODBUS® Network 3. Directly Represented Variables do not have to be declared. Their use is legal only in Programs and Configurations.

Symbolic Variables do need to be declared. In the case where Symbolic Variables refer to actual input and output points, the declaration assigns them to these points by associating them with the appropriate Directly Represented Variables. Symbolic Variables that do not refer to I/O points need not be assigned a Directly Represented Variable - the IEC 1131-3 language system will assign these an address at compile time.