Overview
The programming language of the IEC 61131-3 standard is a set of global programming language specifications for industrial control systems, which was developed by the IEC working group based on the reasonable absorption and learning of the programming languages of PLC manufacturers worldwide. It is not only applicable to PLC systems, but also to a wider range of industrial control fields, making an important contribution to the global standardization of PLC programming languages.
The IEC 61131-3 standard includes five graphical and textual languages: LD, SFC, FBD, STL, and IL. However, IL, an instruction list language similar to assembly language, is becoming increasingly less used and will soon be removed from newer versions of IEC 61131-3. Meanwhile, object-oriented programming has been introduced into IEC 61131-3, and even high-level languages like C and C++ have become commonly used programming languages for PLCs.
The image below shows the results of a 2020 joint survey by an American website called automation.com and the PLCopen international organization, which confirms the above conclusion: the number of people using structured text programming is now the largest. Therefore, it is recommended that when learning PLC programming languages, you should distinguish between primary and secondary programming languages; it is quite normal for high-level programming languages to be integrated into automatic control systems.
I. Relay Ladder Diagram (LD)
Ladder diagram programming language is the primary and most widely used programming language for PLCs. It evolved from the schematic diagram of a relay control system and shares the same fundamental ideas, differing only in the symbols and expressions used.
Ladder logic programming is extremely popular among electrical engineers, and its advantages are self-evident. Firstly, the symbols used in ladder logic programming, developed by Bedford, are derived from the descriptions of sequential operations in electrical engineering. This allows electrical engineers and electricians to program PLCs using computers in a very easy-to-understand way. PLCs were originally designed for use by electrical technicians in factory workshops. To align with the mindset of relay control circuits, ladder logic, as the primary programming language used in PLCs, retains the style and conventions of relay circuit diagrams, becoming the most intuitive and widely used language among electrical engineers. Secondly, this language is one of the earliest examples of using a general-purpose computer as a tool to program industrial controllers. Its continued use today reflects the characteristic of "industrial software being primarily tool-based software," and it has undergone decades of refinement by electrical engineers and industrial automation professionals, and is widely adopted in all industrial settings.
(1) Some programming elements in PLC ladder diagrams use the term "relay," such as input relays, output relays, and internal auxiliary relays. However, these are not actual physical relays, but rather storage units (soft relays). Each soft relay corresponds to a storage unit in the image register of the PLC memory. If the storage unit is in the "1" state, it indicates that the coil of the corresponding soft relay in the ladder diagram is "energized," its normally open contact is closed, and its normally closed contact is open. This state is called the "1" or "ON" state of the soft relay. If the storage unit is in the "0" state, the state of the coil and contacts of the corresponding soft relay is the opposite of the above, and the soft relay is called the "0" or "OFF" state. In practice, these "soft relays" are often referred to as programming elements.
(2) Power flow has a hypothetical "conceptual current" or "power flow" that moves from left to right, a direction consistent with the order of logical operations when executing a user program. Power flow can only move from left to right. Using the concept of power flow can help us better understand and analyze ladder diagrams.
(3) The straight common lines on both sides of a ladder diagram are called busbars. When analyzing the logical connections of a ladder diagram, in order to borrow the analytical method of relay circuit diagrams, one can imagine that there is a DC power supply voltage with positive on the left and negative on the right between the left and right busbars (left busbar and right busbar), and there is an "energy flow" between the busbars from left to right. The right busbar can be omitted.
(4) The logic solution of a ladder diagram is based on the state of each contact and the logical connection in the ladder diagram to determine the state of the programming element corresponding to each coil in the diagram. This is called the logic solution of the ladder diagram. The logic solution of the ladder diagram is performed in a left-to-right and top-to-bottom order. The solution result can be immediately used by subsequent logic solutions. The logic solution is based on the value in the input image register, rather than on the state of the external input contacts at the moment of solution.
1. It corresponds to the electrical operation schematic diagram, providing intuitiveness and consistency;
2. Combined with existing relay logic control technology, it is easy for electrical technicians to grasp and learn;
3. The difference from the original relay logic control technology is that the power flow in the ladder diagram is not actual current, and the internal relays are not actual relays. Therefore, when using it, it is necessary to treat the relevant concepts differently from the original relay logic control technology.
4. It has a one-to-one correspondence with the instruction list programming language, which facilitates mutual conversion and program viewing.
II. Functional Block Diagram (FBD)
Function block diagrams use graphic symbols similar to digital logic gates, making them logically intuitive and easy to use. They contain instructions equivalent to contacts and coils in ladder diagram programming and can handle a wide range of logic problems.
(1) Taking functional modules as the unit, starting with control functions, the analysis and understanding of control plans become simpler;
(2) Functional modules describe functions in a graphical way, which greatly facilitates programming and configuration for designers and has good operability;
(3) For systems with a large control scale and complex control relationships, the programming and configuration time can be shortened and the debugging time can be reduced because the relationship of control functions can be expressed more clearly.
III. Sequence Function Diagram (SFC)
Sequential Function Chart (SFC), also known as a flowchart or state transition diagram, is a graphical functional description language specifically designed to depict industrial sequence control programs. It can be used to program systems with complex structures such as concurrency and selection.
(1) The program is organized around its functions, making it easy to understand and communicate the procedures.
(2) For large programs, the work can be divided and a more flexible program structure can be selected, which can save program planning time and debugging time;
(3) It is often used in situations where the system is large in scale and the program connections are complex;
(4) Only the commands and operations of the active step are executed, and the changes after the active step are scanned. Therefore, the scanning time of the whole program is much shorter than that of other programs.
IV. Instruction List (IL)
Instruction list programming languages are similar to mnemonic assembly languages in computers. They are the most basic programming languages for programmable controllers. Instruction list programming uses one or a few simple characters to represent a certain operation function of the programmable controller.
(1) Using mnemonics to indicate the operation function has the characteristics of being easy to remember and easy to master;
(2) The programmer's keyboard uses mnemonic symbols for easy operation, allowing programming to be performed even without a computer;
(3) It has a one-to-one correspondence with the trapezoidal diagram, and its features are fundamentally similar to those of the trapezoidal diagram language.
V. Structured Text (ST)
Structured Text (SCT) is a high-level text language used to describe functions, function blocks, and program behavior. It can also depict steps, actions, and changes in a sequence of functions (SQDs). Siemens refers to Structured Text programming as SCL, which is essentially the same language, just with a different name. While superficially similar to Pascal, Structured Text is a programming language specifically developed for industrial control applications. It boasts powerful programming capabilities for variable assignment, callback functions and function blocks, expression creation, conditional statements, and iterative programs. In recent years, Structured Text programming has become increasingly popular, with the number of users surpassing those using ladder logic, benefiting a large number of PLC engineers.
(1) Using a high-level programming language enables the completion of complex control operations;
(2) It requires certain knowledge of advanced computer programming languages and programming skills, and the technical requirements for programmers are high. Ordinary electrical personnel cannot complete it.
(3) Its intuitiveness and ease of operation are relatively poor;
(4) It is often used to implement some control functions that are difficult to complete in other languages, such as selecting function modules.