Basic instruction set and programming methods of PLC programming languages
2026-04-06 06:00:39··#1
I. Basic Instruction System Characteristics Compared to general computer languages, PLC programming languages have distinct characteristics. They differ from both high-level languages and general assembly languages, requiring ease of both writing and debugging. Currently, there is no single programming language compatible with all manufacturers' products. For example, Mitsubishi products have their own programming language, and OMRON products have their own. However, regardless of the PLC model, its programming language shares the following characteristics: 1. Graphical Instruction Structure: Programs are expressed graphically, with instructions composed of different graphical symbols, making them easy to understand and remember. System software developers have compiled the independent operational functions required in industrial control into symbolic graphics. Users can combine these graphics according to their needs and fill in appropriate parameters. In the logic operation section, almost all manufacturers use ladder diagrams similar to relay control circuits, which are easily accepted. For example, Siemens also uses control system flowcharts, which use binary logic element graphical symbols to express control relationships, making them very intuitive and easy to understand. More complex arithmetic operations and timing/counting are generally represented using ladder diagrams or logic element diagrams. Although less symbolic than the logic operation section, they are still popular with users. 2. Clearly defined variables and constants: Graphical symbols are equivalent to opcodes, specifying the operation function. Operands are filled in by the user, such as K400, T120, etc. The variables and constants in the PLC and their value ranges are clearly defined, determined by the product model, and can be found in the product catalog. 3. Simplified program structure: The program structure of a PLC is usually very simple, typically a block structure. Different blocks perform different functions, giving the programmer a clear understanding of the overall control function and control sequence. 4. Simplified application software generation process: Programming with assembly language and high-level languages requires three processes: editing, compiling, and linking. However, using a programming language only requires editing one process, with the rest automatically completed by the system software. The entire editing process is conducted through human-machine interaction, requiring no advanced software design skills from the user. 5. Enhanced Debugging Methods: Debugging both assembly language and high-level language programs is a headache for programmers. PLC program debugging provides complete support. Using a programmer, leveraging the buttons, displays, and internal editing, debugging, and monitoring functions on the PLC and programmer, and with software support, diagnostic and debugging operations are very simple. In short, PLC programming languages are user-oriented, requiring no advanced knowledge or extensive specialized training. II. Programming Language Forms This textbook uses the two most commonly used programming languages: ladder diagrams and mnemonic language tables. Ladder diagram programming is used because it is intuitive and easy to understand, but requires a personal computer and corresponding programming software. Mnemonic language tables facilitate experimentation because they only require a simple programmer, eliminating the need for expensive graphical programmers or computers. Although some high-end PLCs also have computer-compatible C language, BASIC language, dedicated high-level languages (such as Siemens' GRAPH5 and Mitsubishi's MELSAP), and Boolean logic languages, general-purpose computer-compatible assembly languages, etc. Regardless, each manufacturer's programming language is only applicable to their own products. Programming Instructions: Instructions are codes or symbols that instruct the PLC to do something and how to do it. Essentially, instructions are just binary code, which is exactly the same as a regular computer. However, PLCs also have a compilation system that can compile text symbols or graphic symbols into machine code. Therefore, the PLC instructions that users see are generally text codes or graphic symbols, not machine code. Commonly used mnemonic phrases use abbreviations of English words (multiple languages can be used) and numbers to represent the corresponding instructions. Commonly used graphic symbols are ladder diagrams, which are similar to electrical schematics and are easily understood by electrical workers. Instruction Set: The complete set of instructions possessed by a PLC is called its instruction set. It includes the number of instructions, what each instruction can do, and represents the PLC's functionality and performance. Generally speaking, a PLC with powerful functions and high performance will have a rich instruction set and be able to perform more tasks. Before programming, we must understand the PLC instruction system: an ordered set of PLC instructions that the PLC runs to perform corresponding tasks. This program refers to the PLC's user program. User programs are generally designed by the user and are not provided by the PLC manufacturer or distributor. Programs expressed in statements are not very intuitive and have poor readability, especially complex programs, so most programs are expressed using ladder diagrams. A ladder diagram is a connected graph that links the ladder diagram symbols of PLC instructions together to represent the PLC instructions used and their sequence. It is very similar to an electrical schematic diagram. There are two types of connections: busbars and internal horizontal and vertical lines. Internal horizontal and vertical lines connect individual ladder diagram symbols into instruction groups. This instruction group usually starts with a load (LD) instruction, followed by several input instructions (including LD instructions) as needed to establish logical conditions. Finally, there are output instructions to implement output control, or instructions for data control, flow control, communication processing, monitoring, etc., to perform corresponding tasks. Busbars are used to connect instruction groups. The following diagram is a simple example of a ladder diagram for Mitsubishi's FX2N series products: It has two groups. The first group is used for start and stop control. The second group has only one END instruction to end the program. Correspondence between ladder diagrams and mnemonics: There is a strict correspondence between mnemonic instructions and ladder diagram instructions, and the connections in the ladder diagram can show the order of the instructions. Generally speaking, the order is: input first, then output (including other processing); up first, then down; left first, then right. With a ladder diagram, it can be translated into a mnemonic program. The mnemonic program in the diagram above is: Address instruction variable 0000 LD X000 0001 OR X010 0002 AND NOT X001 0003 OUT Y000 0004 END Conversely, the corresponding ladder diagram can also be drawn based on the mnemonic. Relationship between ladder diagrams and electrical schematic diagrams: If only logic control is considered, a certain correspondence can also be established between ladder diagrams and electrical schematic diagrams. For example, the output (OUT) instruction in a ladder diagram corresponds to the relay coil, while input instructions (such as LD, AND, OR) correspond to contacts, and interlock instructions (IL, ILC) can be seen as the main switch, and so on. In this way, the original relay control logic can be converted into a ladder diagram, and further converted into a statement list program. With this correspondence, representing relay logic with a PLC program is easy. This is also the inheritance of traditional relay control technology by PLC technology.