Soft relay
Some programming elements in the PLC ladder diagram follow the name of the relay, such as input relays, output relays, internal auxiliary relays, etc., but they are not real physical relays, but some storage units (soft relays), each soft relay Corresponds to a memory location of the image register in the PLC memory. If the storage unit is in the "1" state, it means that the coil of the corresponding soft relay in the ladder diagram is "energized", the normally open contact is closed, and the normally closed contact is open, and the state is called "1" of the soft relay. " or "ON" status. If the memory cell is in the "0" state, the state of the coil and the contact corresponding to the soft relay is opposite to that described above, and the soft relay is said to be in a "0" or "OFF" state. These "soft relays" are often referred to as programming elements in use.
2. Energy flow
There is a hypothetical "concept current" or "power flow" that flows from left to right, which is consistent with the order of the logical operations when executing the user program. Energy flow can only flow from left to right. Using the concept of energy flow can help us better understand and analyze ladder diagrams.
3. Busbar
The vertical common line on either side of the ladder diagram is called the busbar. When analyzing the logic relationship of the ladder diagram, in order to borrow the analysis method of the relay circuit diagram, it can be imagined that there is a left-right and a negative DC power supply voltage between the left and right busbars (left and right busbars), and there is "power flow between the busbars". "Flow from left to right. The right busbar can be drawn.
4. The logical solution of the ladder diagram
According to the state and logical relationship of each contact in the ladder diagram, the state of the programming element corresponding to each coil in the figure is obtained, which is called the logic solution of the ladder diagram. The logic solution in the ladder diagram is performed from left to right and top to bottom. The result of the solution can be used immediately by the subsequent logic solution. The logic solution is based on the value in the input image register, not on the state of the instantaneous external input contact.
PLC ladder programming basic rules
Since the ladder diagram is a form of program representation, not a control circuit composed of hardware, when drawing a ladder diagram, attention should be paid to the difference from the ordinary control circuit. The following basic principles should be followed when programming plc:
(1) The logic contacts of external input/output relays, internal relays, timers, counters, etc. can be reused multiple times without complicated programming structures to reduce the number of contacts used.
(2) Each line of the ladder diagram starts from the left bus and the coil is connected to the far right. The contacts cannot be placed on the right side of the coil, and in the relay contactor control circuit, the contacts can be applied to the right side of the coil, which is not allowed in the ladder diagram of the PLC. As shown in Figure 1 (a). It is not difficult to see from the figure that the programmer's intention is that when the contacts 0.00, 0.01, 0.02 are both closed, the coil 10.00 is driven electrically. However, in the ladder diagram, since the contacts cannot be connected to the right busbar, the pattern shown in Fig. 1(b) is converted into the format shown in Fig. 1(b), which satisfies both the above functions of the program and the programming rules of the ladder diagram.
Figure 1 Conversion of the coil to the right busbar (or contact to the right busbar)
(a) Ladder diagrams that do not meet programming specifications; (b) Ladder diagrams that meet programming specifications
(3) The coil cannot be directly connected to the left bus. It is not difficult to see from Fig. 2(a) that the programmer's intention is to cause the program to be driven by running a 10.00, 10.01 coil. To achieve this, you can use a normally closed contact of an internal relay (such as 200.00) that is not called in the program or a normally open contact of a special relay 253.15 (normal relay) to drive them. The functional requirements do not violate the ladder programming rules, as shown in Figure 2(b).
(4) The coil of the same number is used twice in the same main program as the double coil output of the same name. The output of the double-coil of the same name is easy to cause uncertainty in the output result. When programming, the output of the same name double coil should be avoided as much as possible. How to avoid the double-coil output of the same name can refer to the scheme shown in Figure 3.
Figure 2: Conversion of the coil directly to the left busbar
(a) Ladder diagrams that do not meet programming specifications; (b) Ladder diagrams that meet programming specifications
Figure 3 The same name double coil output and its solution
(a) original ladder diagram; (b) operational effects;
In the ladder program, the double-coil output of the same name should be avoided as much as possible, because this will cause uncertainty in the output result. As shown in Figure (a), the ladder diagram of the same name double-coil is shown. In the programming grammar, the ladder diagram does not violate the regulations, but in actual operation, the results sometimes differ greatly from the programmer's expectations. It is not difficult to see that (a) the intent of the programmer in the figure is that when the contacts 0.00, 0.01 in the branch 1 are closed, or when the contacts 0.02, 0.03 in the branch 2 are closed, or in the two branches When all the contacts are closed, the coil 10.00 can be driven. However, in actual implementation, when the contacts 0.00, 0.01 in the contact branch 1 are closed, and the contacts 0.02, 0.03 in the branch 2 are disconnected, the coil 10.00 is not electrically charged, and the result is shown in Figure (b). . This is because the PLC uses a cyclic scan processing method. After input sampling, the central processor operates on the ladder from top to bottom. When the first-order circuit is operated, the coil 10.00 is driven to be powered, but when it is operated to the second-order circuit, the coil 10.00 is not driven because the contacts 0.02, 0.03 are turned off. At the time of I/O refresh, the output is performed based on the result of the last calculation, and thus the coil 10.00 at this time is in a de-energized state.
(5) The ladder program must conform to the principle of sequential execution, that is, from left to right and from top to bottom. If the ladder program does not conform to the order execution principle, the programming software cannot be input. As shown in the ladder diagram of the bridge structure shown in Fig. 4(a), it is not difficult to see that the programmer's intention is that when all the contacts of the branch 1 are closed, or all the contacts of the branch 2 are closed, or When all of the contacts of the way 3 are closed, or when all of the contacts of the branch 4 are closed, the coil 10.00 is driven electrically. However, if such a ladder diagram cannot be input into the programming software or the handheld programmer due to non-compliance with the programming rules, it should be converted to Figure 4(b) to be written into the PLC memory using the programming software or the handheld programmer. .
Figure 4 Bridge circuit conversion
(a) bridge circuit diagram; (b) converted ladder diagram
(6) The number of times the series and parallel contacts are used in the ladder diagram is not limited and can be used indefinitely, as shown in Fig. 5.
(7) Two or more different numbers of coils in the same program can be output in parallel, as shown in Figure 6.
Figure 5: Unlimited use of contacts
Figure 6 multiple coils of different numbers are connected in parallel
PLC counter program ladder diagram programming example
After the photoelectric sensor detects 10 products, the robot will start packing. When the action is completed, the robot and counter will be reset.
The number required for plc input
X0 – Photoelectric sensor used to count products. When detecting the product, X0=ON.
X1 – Robotic action completes the sensor. After filling, X1=ON,.
PLC output required number
Y0 – robot
Number of PLC counters required
C0–Counter: 16-bit number (general)
Plc programming ladder
PLC programming ladder diagram description:
When the photo sensor detects the product, X0 changes from off to on. C0 is counted once. When C0 reaches 10, the normally open contact C0 is closed, Y0=ON, and the robot starts to pack the product.
When the packaging is completed, the sensor of the detecting robot is activated, X1 is changed from off to on, the RST instruction is executed, Y0, C0 is reset, and the next counting is prepared.
Wireless Router Module,Arm Core Module,5G Module,Router Core Board
Shenzhen MovingComm Technology Co., Ltd. , https://www.movingcommiot.com