Introduction to PLC Basics: Understanding the Principles of Sequential Control

Introduction to PLC Basics: Understanding the Principles of Sequential Control

After years in automation, I find it unbearable to deal with newcomers who can’t even grasp the basics of sequential control. Just the other day, I encountered a novice in electrical engineering whose Siemens sequential control program was a complete mess, and after running it for a long time, nothing was accomplished, which made me want to curse.

Sequential control is essentially a control logic that executes step by step, and it is the foundation of PLC programming. Think about it, those robotic arms, conveyor belts, valves, and pumps in factories need to execute one action after another, right? Such a simple principle, yet some people just can’t understand it.

I remember in 2018 at a cardboard factory in Suzhou, a folding machine’s control system just wouldn’t work, and the client was extremely anxious. A so-called “technical director” came in, waving his textbook theories around, and what happened? The equipment moved erratically like it was possessed, almost blowing up the machine. In the end, it was me who spent the whole night debugging the code to find out that this guy had reversed the startup sequence of the step conveyor and the main motor. If the sequence is wrong, the entire control logic is completely useless!

1

Old Tricks of Sequential Control

For sequential control, I have always used the S7-300 and S7-1200; these old Siemens models are really reliable. However, many people are chasing the latest trends and start using those flashy domestic PLCs, they’re cheap, but you just can’t trust them. By the way, I use Siemens purely out of habit, not that AB is bad; their ControlLogix is also quite powerful.

Back to sequential control, the core is three points: condition judgment, step execution, and state switching. Many people complicate simple problems, insisting on using a bunch of flashy variables and jumps, resulting in code that looks like crap, making maintenance a headache.

The most basic sequential control is done using a stepping method; take a look at this piece of code:

// Stepwise sequential control ladder diagram example
IF Step = 0 AND Start_Button THEN
    Step := 1;
END_IF;

IF Step = 1 THEN
    Motor1 := TRUE;
    IF Sensor1 THEN Step := 2; END_IF;
END_IF;

It’s that simple! Set the steps, and when conditions are met, switch to the next step, there’s no need to complicate things. In 2020, I encountered a problem at an automotive factory in Chongqing where their programmers insisted on using some state machine model, creating a bunch of flags, and as a result, during debugging, it went haywire, taking three days to find the bugs! If I had used my old-fashioned method, I could have pinpointed the error in no time.

2

Pits to Avoid in Sequential Control

After a long time, I’ve realized that the biggest pitfall in sequential control isn’t the program itself, but the adaptation to the on-site environment. No matter how powerful the program is, it can’t withstand a bunch of bizarre situations on-site.

I remember last summer, a paper factory in Hebei had a production line that kept stopping for no reason. My colleague Liu (the intern who always clings to theoretical books) couldn’t figure out the cause. I crawled around on the ground for a long time and found out that the photoelectric sensor was blocked by paper scraps, causing intermittent signals. In such cases, sequential control needs to add debouncing and timeout handling; otherwise, it will fail.

I usually write it like this:

// Sensor detection with timeout and debouncing
Timer := Timer + 1;
IF NOT Sensor_Signal AND Timer < TIMEOUT THEN
    // Waiting for sensor signal, not timed out
ELSIF Sensor_Signal THEN
    IF Debounce_Counter < DEBOUNCE_TIME THEN
        Debounce_Counter := Debounce_Counter + 1;
    ELSE
        // Signal stable, execute subsequent steps
        Step := Step + 1;
        Timer := 0;
    END_IF;
ELSE
    // Timeout handling
    Alarm := TRUE;
END_IF;

This may look complex, but it just adds a waiting time and a debouncing count. The industrial environment is so harsh, how can we not handle it this way? Those who only know how to talk theory don’t understand at all.

By the way, speaking of sequential control, there’s another thing. At the beginning of 2021, I went to a pharmaceutical factory to help them with the control of a sterilizer, and the boss’s wife insisted on saving money by buying a domestic PLC from Hangzhou. As a result, it blew up on the first day, and she was furious… I told her countless times, you can’t skimp on critical equipment! The worst thing about sequential control is losing state after a power outage; that thing can’t recover after a power cut, which forced me to add a UPS and a power loss protection program, which was a hassle.

3

Practical Tips

By the way, a little trick I often use in sequential control is to design each step with specific actions and clear end conditions, then add a timeout alarm. This way, if any step gets stuck, you know immediately. I also like to number the steps in tens, like 10, 20, 30, leaving gaps for adding steps. This isn’t some profound theory; it’s just a summary of years of experience.

Another practical trick on-site is to enforce a manual stepping function during debugging, allowing the machine to execute step by step manually. I usually use M area variables in Siemens to create a debugging mode switch. This trick has saved my life countless times, especially when the equipment gets stuck at some step for no reason.

I remember last year when I took over the renovation of an old packaging line; the sequential control written by the previous programmer was a disaster, full of GOTO jumps, messy as hell. Without a second thought, I deleted everything and rewrote it. I used a standard stepping structure and even subdivided sub-steps, making it much clearer. You wouldn’t believe it, but after the modification, the efficiency of that line increased by 30%, and the boss gave me a nice bonus.

To be honest, many people can do PLC sequential control, but very few can do it well. Many just memorize textbooks, and when faced with real problems, they are dumbfounded. This field really relies on experience… Last year, a fresh graduate claimed to have perfect scores in control theory, but after half a day in the factory, he couldn’t even figure out a simple motor start-stop sequence, what’s the use of learning so much theory?!

Forget it, too much talk brings tears. If you want to master sequential control, stop clinging to books and simulation software; getting hands-on experience is the way to go. Making mistakes is fine, just don’t keep making the same ones.

By the way, tomorrow I have to go to a textile factory to check that convoluted winding control system, and I bet it’s another sequential control issue… Sigh, being an electrical engineer these days is really tough!

Introduction to PLC Basics: Understanding the Principles of Sequential Control

Before you go, remember to click Looking~

Leave a Comment