Click the blue text to follow!
Old Li Talks Technology: Things About PLC Ladder Diagram Programming
Little Wang, last Friday our workshop’s packaging line suddenly stopped, it was urgent, and the production manager was stamping his feet beside me. I looked at the system alarm, and it was the photoelectric switch on the conveyor belt that was continuously triggered, causing the entire line to jam. Guess what? Upon inspection, it was just a piece of paper stuck on the sensor! But why did such a small issue cause the entire line to stop? It’s because the PLC program was written too simply and did not consider handling abnormal situations.
plc1
Why Learn PLC?
Don’t underestimate the PLC; it’s a small box, but it’s the “central nervous system” of the factory! PLC is a computer designed specifically to control machines in industrial settings. All the automation equipment in our workshop, from simple conveyor belts to complex assembly robots, has its presence behind it.
I remember when I first joined the factory, my mentor told me: “Old Li, if you want to stand firm in this industry, you must master PLC.” Back then, it was still the S7-200 generation, and the programming cable was serial, much more troublesome than the Ethernet ports we have now.
1
Basic Ideas of Ladder Diagram Programming
Little Wang, have you seen an electrician’s circuit diagram? The PLC ladder diagram is very similar; the left side is the power supply, the right side is the ground, and the middle represents various logical relationships. The ladder diagram essentially implements the logic of switches and relays using software.
Take our workshop’s simple elevator as an example; the operation is very simple: press the up button, the motor rotates forward; press the down button, the motor rotates backward; when it hits the upper or lower limit, it stops automatically. Such a simple logic can be achieved with ordinary relays, but what are the benefits of using PLC?
“Little Wang, remember, the biggest advantage of using PLC is that it’s easy to modify! If the client wants to add a function, I can just change a few lines of code, but if it’s hardware wiring, I have to disassemble and reconnect, which is time-consuming and prone to errors.”
2
Common Instruction Practical Applications
Come, let me tell you about a few of the most commonly used instructions:
1. Normally Open and Normally Closed Contacts: The Basics of PLC Programming This is like our switches; normally open contacts (X) are open by default and only conduct when there is a signal; normally closed contacts (X/) are connected by default and break when there is a signal. These two instructions combined can basically achieve various logics.
I remember once a device in the workshop kept starting for no reason, and after searching for a long time, I found out it was because I used a normally closed contact in the program when I should have used a normally open one. Such a small mistake almost caused a safety accident! So I always tell the new apprentices: “When drawing ladder diagrams, safety interlocks must use normally open contacts; this is a hard rule!”
2. Coil Output (Y) and Latching Circuit The coil is equivalent to the relay coil or the execution component of the device. There’s a trick, using a latching circuit can achieve both momentary and maintained control modes. For example:
“You press the start button, the device starts running, and when you release it, it continues to run until you press stop or a fault occurs. This requires latching, using Y0 in parallel after the start button to form a latching circuit.”
3. The Wonderful Use of Timers (T) Timers are like kitchen timers; they ring when the time is up. There are many types of timers in PLC, including TON for delay on, TOF for delay off, and TP for pulse timer.
Last month, Master Zhang’s injection molding machine had a problem; it took a long time to start every time. I looked at the program, and the timer was set with too long a delay! After adjusting it, the problem was immediately solved. Therefore, the time parameter settings for timers are crucial; it’s not about being longer for safety, but rather to be set according to the actual situation.
3
Practical Case: Conveyor Belt Fault Detection
Returning to the conveyor belt issue mentioned at the beginning, how did I modify it? I added a simple fault detection function:
The original program was simply: sensor triggered → stop conveyor belt. So once something got stuck on the sensor, the production line would stop indefinitely.
The improved program is as follows: sensor triggered → start timer (5 seconds) → if the sensor is still triggered after 5 seconds → alarm and stop → otherwise continue running.
This way, brief disturbances won’t affect production; only when there is a jam will it stop and alarm. When programming in industrial settings, one must consider various abnormal situations. This is experience, Little Wang!
4
Old Li’s Suggestions
Learning PLC is not difficult; the key is to practice more. If you can’t afford the equipment, it’s okay; many simulation software programs are available now. When I was young, I drew ladder diagrams on paper and made many mistakes, but after making many mistakes, I remembered them.
Also, don’t underestimate basic instructions. Those fancy function blocks are, after all, combinations of basic instructions. If you master the basic instructions, you can write any program!
Finally, let me give you a piece of advice: programs are meant to be read by people and executed by machines. When writing programs, be sure to standardize and add comments; otherwise, in a few months, even you won’t understand it. This is the experience I’ve summarized from my years of practice!
Alright, that’s it for today. Next time, I’ll talk to you about PLC communication; if you use the Modbus protocol well, you can save a lot of money!