I. PLC Programming Language
1. Ladder Diagram Programming Language
Ladder diagrams follow the form of relay control circuits. They are simplified and evolved from the logic control of relays and contactors commonly used in electrical control systems, making them visual, intuitive, and practical.
The following three points should be noted when designing a ladder diagram:
(a) The ladder diagram is arranged from left to right and from top to bottom. Each logic line starts with the left busbar, followed by the series and parallel connections of the contacts, and finally the coil is connected to the right busbar.
(ii) The current flowing through each step in the ladder diagram is not a physical current, but a "conceptual current" that flows from left to right, with no power source at either end. This "conceptual current" is merely a figurative description of the conditions that the coil should meet during the execution of the user program.
(III) Input relays are used to receive external input signals and cannot be driven by the contacts of other relays within the PLC . Therefore, only the contacts of the input relays appear in the ladder diagram, not their coils. Output relays output the program execution results to external output devices. When the coil of the output relay in the ladder diagram is energized, a signal is output, but it does not directly drive the output device; instead, it must be achieved through a relay, transistor, or thyristor at the output interface. The contacts of the output relays can be used for internal programming.
2. Statement List Programming Language
Instruction statements represent a mnemonic programming method similar to computer assembly language, but are easier to understand and learn. An instruction statement consists of three parts: the step sequence, the instruction word, and the device number.
3. Control System Flowchart Programming Diagram
Control system flowcharts are a relatively new programming method. They represent a control process using a functional diagram similar to a control system flowchart, and the International Electrotechnical Commission (IEC) is currently developing this new programming standard.
II. Introduction to Basic Commands
The basic instructions are shown in the table.
Fetch Instruction
LD
I, Q, M, SM, T, C, V, S, L
Normally open contact logic operation start
Invert instruction
LDN
I, Q, M, SM, T, C, V, S, L
Normally closed contact logic operation start
Coil drive command
Q,M,SM,T,C,V,S,L
The output and command of the drive coil
I, Q, M, SM, T, C, V, S, L
Series connection of a single normally open contact
NAND instructions
AN
I, Q, M, SM, T, C, V, S, L
Series connection of a single normally closed contact
or instruction
I, Q, M, SM, T, C, V, S, L
Parallel connection of single normally open contacts
OR NOT instruction
ON
I, Q, M, SM, T, C, V, S, L
Parallel connection of a single normally closed contact
Set instruction
I, Q, M, SM, T, C, V, S, L
Keep the movement
Reset command
I, Q, M, SM, T, C, V, S, L
Keep reset
Positive jump
ED
I, Q, M, SM, T, C, V, S, L
Pulse output is generated on the rising edge of the input signal.
negative jump
EU
I, Q, M, SM, T, C, V, S, L
The falling edge of the input signal generates a pulse output.
No-operation instruction
NOP (No)
3. Perform an empty operation in the step sequence.
1. Standard contacts LD, A, O, LDN, AN, ON
LD, Fetch Instruction. Indicates a normally open contact instruction connected to the input bus, i.e., the start of normally open contact logic operation.
LDN, Invert Instruction. It represents a normally closed contact instruction connected to the input bus, i.e., the start of a normally closed contact logic operation.
A, AND instruction. Used for series connection of a single normally open contact. AN, AND NOT instruction. Used for series connection of a single normally closed contact.
O, or instruction. Used for parallel connection of a single normally open contact. ON, or no instruction. Used for parallel connection of a single normally closed contact.
2. Positive and negative transitions ED and EU
After detecting a positive transition (from OFF to ON), the ED enables the power flow for one scan cycle.
After detecting a negative transition (from ON to OFF), the EU enables the power flow for one scan cycle.
3. Output =
=, when an output instruction is executed, the specified parameter bit in the image register is turned on.
4. Set and Reset Commands S, R
When S executes the set (set to 1) instruction, N points starting from the address parameter specified by bit or OUT are set.
When R executes a reset (set to 0) instruction, N points starting from the address parameter specified by bit or OUT are reset.
The number of set and reset points can be 1-255. When using the reset instruction, if bit or OUT specifies T or C, then the timer or counter is reset and the current value is cleared.
5. No-operation instruction NOP
The NOP instruction does not affect the execution of the program, and the number of executions is N (1-255).
IV. Ladder Diagram Design Rules for Programmable Logic Controllers
1. Contact point arrangement
The contact points of a ladder diagram should be drawn on horizontal lines, not on vertical branches.
2. Processing of series and parallel connections
When several series circuits are connected in parallel, the series circuit with the most contacts should be placed at the top of the ladder diagram. When several parallel circuits are connected in series, the parallel circuit with the most contacts should be placed at the far left of the ladder diagram.
3. Coil Arrangement
The contact point cannot be drawn to the right of the coil; the coil can only be connected to the right of the contact point.
4. Dual-coil output is not permitted.
If the coil of the same component is used two or more times in the same program, it is called a double-coil output. In this case, the previous outputs are invalid, and only the last one is valid, so double-coil output should not occur.
5. Rearrange the circuit
If the circuit structure is complex, you can reuse some contacts to draw its equivalent circuit, and then programming it will be easier.
6. Programming order
For complex programs, you can first divide the program into several simple program segments. Each segment starts from the leftmost contact and is programmed from top to bottom to right. Then connect the program segments one by one.