PLC programming generally employs an intuitive approach, meaning it's based on the circuit designer's own learning experience and is relatively subjective and direct. It requires a period of trial and error, like blind men feeling an elephant, before the program can meet the required functions or actions. Therefore, the designed program varies from person to person, and users or maintenance personnel, apart from the original programmer, may find the operational flow difficult to understand, resulting in lower program readability.
However, there are some underlying principles to follow in programming, though these are rarely mentioned in books. With a humble attitude, I will now share my insights, using a three-phase induction motor fault alarm control circuit as an example, to briefly discuss the process of converting a traditional electrical diagram into a ladder diagram. I believe this will provide a useful understanding for future circuit conversions or programming projects.
1. Traditional electrical diagrams
The conventional electrical diagram of a known three-phase induction motor fault alarm control circuit is shown in Figure 1.
Figure 1. Fault alarm control circuit diagram of a three-phase induction motor
2. Action Description 1
When the power supply is normal, only the green indicator light (gl) is on, and the motor does not move.
2
Press the start button pb1, the electromagnetic contactor mc will activate, the motor will start running immediately, the indicator light rl will light up, and the green light gl will turn off.
3
Pressing the stop button PB2 de-energizes the electromagnetic contactor MC, stops the motor, turns off the indicator light RL, and turns on the green light GL.
4
When the motor is running, if overload or other faults cause the heat-accumulating relay to activate, the motor will stop running, the buzzer will sound an alarm, the indicator light will turn off, and the green light will turn on.
5
Press button switch PB3, the buzzer BZ stops the alarm, the white light WL lights up, the green light GL lights up, and the red light RL goes out.
6
After troubleshooting, press the reset lever for the heat accumulation relay. The white light WL will turn off, the green light GL will turn on, and the red light RL will turn off, allowing you to restart the motor.
3i/o encoding
Using a PLC means replacing hardware wiring with software programs. In traditional electrical diagrams, the main circuit cannot be replaced by a PLC; the part that a PLC can replace is the control circuit. The first step in converting a traditional electrical diagram into a ladder diagram is I/O encoding, which involves determining the corresponding external input/output terminal numbers for the input/output components in the traditional electrical diagram within the PLC, and specifying whether the external input components use A/B contacts.
As shown in Table 1.
(a): External wiring uses contact a.
(b): External wiring uses the b-contact method.
4PLC external wiring diagram
After the input/output components are encoded using I/O and the external input components are determined to use A/B contact wiring, the external wiring diagram of the PLC is shown in Figure 2. The figure shows the Fengwei Vigor-VB series PLC, which uses NPN wiring, that is, the 24V terminal and the S/S terminal are connected in parallel.
Figure 2 PLC external wiring diagram
5 PLC ladder diagram
The programming steps for converting a traditional electrical diagram into a ladder diagram are as follows:
1
The control circuit in the electrical diagram is directly converted into the corresponding ladder diagram. Because the PLC ladder diagram specifies that the contacts come first, the output coil must be at the end of the circuit. Therefore, the electrical diagram must first be redrawn, with appropriate changes to the positions of the contacts and output coil to meet the requirements of the PLC ladder diagram. The redrawn electrical diagram is shown in Figure 3.
Figure 3. Redrawn electrical diagram
2
Replace the input/output components in the electrical diagram with the component numbers after I/O encoding. Note that the CA and CB contacts of the Th-RY should be separated and each become a control loop, as shown in Figure 4.
Figure 4 shows the electrical diagram after I/O encoding.
3
Rotate the electrical diagram shown in Figure 4 90° to the left, then flip it vertically (upside down) to obtain a PLC ladder diagram. However, because:
a . y1, x0 contact
b . The output coils y1 and y2 do not conform to the general programming software format, so they need to be corrected appropriately, as shown on the right side of Figure 5.
Figure 5. Step diagram after appropriate flipping and correction
If you are using Visio to draw electrical diagrams, it becomes very easy to rotate 90° to the left and then flip vertically.
4
The staircase diagram drawn using programming software, as shown in Figure 6, is exactly the same as the staircase diagram after appropriate flipping and correction.
Figure 6. Ladder diagram drawn by programming software
6 instructions
Converting the ladder diagram into instructions results in the following:
7PLC conversion wiring and ladder diagram
The PLC external input/output wiring and ladder diagram after complete conversion from traditional electrical diagrams. The PLC external input/output wiring and ladder diagram after replacing hardware wiring with software programs are shown in Figure 7 below.
Figure 7 shows the PLC after replacing hardware wiring with software programs.
8. Conclusion
The purpose of PLC development is to replace sequential control based on relays, that is, to use software programs to replace hardware wiring. Therefore, by simply changing the software program, the control sequence can be changed, and different control requirements can be easily met.
Typical PLCs are developed based on traditional relay control circuits, symbolizing the relay contacts and coils. Once converted into a general ladder diagram or instruction, control can be achieved. However, the control circuits completed in this way are based on the circuit designer's own learning experience, which is relatively subjective and direct. General users often find it difficult to understand the operation flow, that is, the program readability is low.