Ladder logic is usually the most widely used graphical programming language for PLCs , but other languages may be more suitable for certain specific programming applications.
In the United States, most people involved in programmable logic controller (PLC) programming and maintenance tend to believe that ladder logic is the only programming language for PLCs. This perception is largely due to the history of PLCs and the fact that the US industrial control market is dominated by brands that primarily use ladder logic as their programming language.
Before computers and portable computers were widely used for PLC programming, handheld programmers were often used to input programs into PLCs. Prior to this, it was usually necessary to draw electrical diagrams for different instructions. This is similar to how primitive relay logic was connected before the advent of PLCs. On handheld devices, different instructions are sometimes represented by symbols, but behind the graphical design lies a text-based language.
In 1994, the International Electrotechnical Commission (IEC) developed a standard, IEC 61131-3, for defining and standardizing PLC programming systems. In addition to formally defining instructions such as timers and counters, the standard also defines five programming languages.
Instruction lists (IL) are text-based languages, and ladder logic is often translated into the same language. Some vendors use them merely as a transition to machine code, which is eventually compiled into a language that executes in the processor. Other vendors use instruction lists as the primary language and add other instructions that cannot be represented by ladder logic (such as statement lists).
Figure 1: Instruction lists are typically used for complex mathematical tasks and searches.
Ladder logic (LAD) is the most widely used graphical programming language for PLCs. It evolved from relay logic circuit diagrams. Ladder logic simplifies the symbols used in common relay and contactor logic control, and is characterized by its visual appeal, intuitiveness, and practicality.
Figure 2: Ladder logic is the most commonly used PLC programming method and is most similar to relay circuit diagrams.
Function block diagrams (FBDs) are another graphical programming language used in some controllers, including PLCs and distributed control systems (DCS). They use different types of blocks (such as AND, OR, comparison, mathematical calculations, timers, and counters) to describe the functionality between input and output variables. Inputs are fed into a module from the outputs of devices or other modules; outputs pass data to the next block or variable.
Figure 3: Functional block diagrams are ideal for safety circuits/safety PLCs
Structured Text (ST) is a high-level language similar to computer languages (such as Pascal). Expressions in ST consist of operators and operands. Operands can be constants, variables, function calls, or other expressions. Expressions are evaluated by executing operators with different precedence. The operator with the highest precedence is executed first, followed by operators of the next highest precedence, and so on, until all operators have been processed. Operators with the same precedence are executed from left to right.
Figure 4: Structured text can help complete complex mathematical tasks and searches.
Sequential Function Chart (SFC) language is based on an older logic language called Grafcet, which is based on binary Petri networks. It can be used to write complex sequential control programs, also known as state transition diagrams or function charts. It is a graphical representation of the control process, function, and characteristics of a control system, and a tool for designing sequential control programs. It is a block-based language called a step, with related logical conditional switching. Steps in the language can be active or inactive, and logic can run in parallel. Using this advanced programming method, even beginners can easily write complex sequential control programs, greatly improving work efficiency and providing significant convenience for debugging and trial operation.
Figure 5: Sequential function charts are very useful for segmented logic.
A few years ago, I had a sudden inspiration: it would be very interesting to write a short piece of code in all five languages and compare them. The logic establishes automatic and manual modes, then activates a "loop" bit after 3 seconds. It's general-purpose, but based on the PLC platform I'm using (Figures 1 to 5). The syntax and code display will vary depending on the software brand and platform.
Instructions and comments are typically color-coded for ease of reading. Language packs are usually sold separately or included in the "professional" version of the programming software.
Different languages have different uses. Ladder diagrams are still suitable for direct "bit manipulation" logic. Instruction lists and structured text are often used for more complex mathematical tasks and searches. Function block diagrams are well-suited for safety circuits/safety PLCs. Sequential function charts are useful for segmented logic.
The next time you write a complex program, try using some "other" type of PLC language, as this may make the job easier.
Disclaimer: This article is a reprint. If it involves copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.