Click the blue text to follow!
Old Li Talks Technology: PLC Function Blocks Make Automation Debugging Painless
1
The Emergency Repair in the Workshop
Last Thursday, the automated production line in the injection molding workshop had another issue. Xiao Wang rushed to find me: “Old Li, the No. 3 injection molding machine has stopped, the system is alarming, and we won’t meet the production schedule!” I put down my work, grabbed my toolbox, and headed to the workshop.
When I arrived on site, the display was flashing “Sensor Signal Abnormal.” The young man was frantically flipping through a thick manual, and I smiled and waved my hand: “Don’t worry, let’s first check if it’s an old problem.” After a few minutes of inspection, I found that the temperature sensor’s signal was fluctuating abnormally, causing the PLC program to misjudge and the system to shut down urgently.
“Xiao Wang, this kind of fault looks scary, but it’s actually easy to solve. The key is to understand how PLC processes analog signals, which is the foundation of the automation system.”
plc1
PLC Analog Signal Processing
I opened the control cabinet and pointed to the PLC module to explain to Xiao Wang: “You see, our system uses the Siemens S7-1200, and the analog module converts the 4-20mA current signal from the sensor into a digital signal that the PLC can understand. The temperature sensor is not broken; the issue occurred in the signal processing stage.”
Xiao Wang looked confused: “But with so many logics in the program, how do we know where the problem is?”
I smiled: “This is what I want to teach you, using function block diagram programming to debug complex logic. Traditional ladder diagrams are intuitive, but when it comes to complex logic like analog signal processing and PID control, they become inadequate.”
I opened the programming software and brought up the function block view: “Look here, the temperature control uses a PID function block, with the input being the temperature sensor value and the output controlling the heater power. But did you notice that the sensor input is missing a filtering process? The signal is too jittery, causing the PID control to adjust erratically, forcing the system to shut down for protection.”
2
Old Li’s Practical Experience
I quickly added a low-pass filter function block in the program: “Remember, signals in industrial sites must be filtered before processing, this is a hard lesson! In the past, a production line in a chemical plant had to shut down urgently three times in a month because filtering was not done properly, almost giving the plant manager a stroke.”
Xiao Wang pondered: “So how do we use this filter block? How do we set the parameters?”
“This is the trick! Different signal types require different filtering strategies. For slow variables like temperature, you can set a larger time constant, such as 0.5-2 seconds; for fast variables like pressure, it might need around 0.1 seconds. But there’s a shortcut: let’s first set a medium value, like 0.3 seconds, then observe the system response. If it’s too slow, reduce it; if too fast, increase it. A few adjustments will definitely work.”
After modifying the program, we restarted the system, and it ran normally. Xiao Wang finally breathed a sigh of relief: “Old Li, your skills are amazing! If I had followed the manual, it would have taken me half a day!”
“Experience cannot be learned from books. Remember, function blocks are the ‘building blocks’ of PLC programming. If you connect them correctly, you can achieve complex control, and it’s easier to locate problems when they arise.”
3
The Three Steps to Using Function Blocks
While the equipment was running normally, I gave Xiao Wang a “temporary lesson”:
“First, choose the right function blocks. PLCs from major manufacturers like Siemens, Mitsubishi, and Schneider come with a rich library of function blocks. Use TON/TOF for timing, CTU/CTD for counting, SCALE/NORM for data processing, and directly call PID_Compact for PID control to save us from writing algorithms ourselves.”
“Second, parameter settings must be reasonable. Take PID for example, if the proportional gain P is too high, the system may oscillate; if too low, the response will be too slow; if the integral time I is too short, it will cause overshoot, and if too long, it will reduce accuracy; the derivative time D is generally set small to avoid excessive sensitivity to disturbances. Remember, it’s better to be conservative than aggressive.”
“Finally, debugging requires patience. Don’t expect to get it right the first time; ensure safety first, then pursue accuracy, and speed comes last. Our factory’s constant temperature system took a week to achieve ±0.1℃ accuracy, which is normal.”
4
How to Improve Efficiency
Xiao Wang asked: “Isn’t it too time-consuming to debug like this every time? Is there a more efficient method?”
I nodded: “Good question! Now we can use automation simulation technology to validate programs in advance. For example, Siemens’ PLCSIM allows you to simulate real working conditions from the office, discovering 80% of issues in advance, so you won’t be caught off guard on site.”
“Another trick is to properly encapsulate and reuse function blocks. Create a function block for temperature control that includes signal filtering, range conversion, and PID control. After testing it successfully, save it for future similar needs, just modify the parameters. Why reinvent the wheel?”
Xiao Wang suddenly understood: “No wonder you debug so quickly; you reuse previous experiences!”
“Exactly! In our factory, electricians are not the ones who learn the most theory but those who are skilled at ‘working smart’ who excel. Good programmers are masters of reuse, and we PLC engineers are no different.”
5
Old Li’s Advice
Before leaving, I patted Xiao Wang on the shoulder: “Do you remember the keywords from today’s lesson? Signal filtering, function block programming, parameter tuning, simulation testing, and module reuse. Master these, and you can avoid the detours I took in my early years.”
“Got it, Old Li! Next time I want to try function block programming too.”
“Go ahead, and feel free to ask me anytime if you have questions. Remember, equipment doesn’t fail for no reason; every fault has a cause. As maintenance personnel, we need to develop a keen eye to see through appearances and find the essence!”