Factory automation / Article

What a PLC Does, and Why the Control Layer Decides Whether Your Line Scales

A programmable logic controller is the industrial computer that runs your machine in real time. It reads every sensor, applies your control logic, and drives every actuator, on a repeating cycle typically between 1 and 100 milliseconds. That is the textbook answer. The commercially important one is this: the PLC is the layer that decides what happens next on your line, so it also decides how expensive it is to add the next station. Plants that automate station by station without a coherent control layer end up with a floor full of machines that work individually and a line that does not. This article makes the invisible layer concrete, and shows what to ask before you buy the next cell.

The numbers at a glance

1 to 100 ms
Typical PLC scan cycle, set by program size, I/O count and processor
5
Programming languages defined by IEC 61131-3, three graphical and two textual
11%
Of revenue lost to unplanned downtime at the world's 500 largest companies
23%
Of unplanned downtime attributed to human error in a study of 100+ manufacturers

01 / The definition

A computer that promises to be on time

A PLC is an industrial computer engineered for deterministic real-time control. It has a processor that runs your program, non-volatile memory that keeps the program and retained values through a power cut, input modules that turn sensor signals into data, and output modules that drive solenoids, contactors, drives and lamps. Nothing about that description is exotic. What makes it a PLC rather than a computer is the promise about timing.

The promise is delivered by the scan cycle. Execution follows a fixed cycle: read all inputs into a process image, execute the program from first rung to last while updating internal variables and the output image, write the output image to the physical actuators, handle communications, and repeat, with cycle times typically ranging from 1 to 100 milliseconds.

The detail worth pausing on is the process image. Inputs are frozen into a snapshot at the start of the scan, so the logic sees one consistent picture of the machine for the whole pass rather than a sensor value that changes halfway through a decision. That is what makes machine behaviour repeatable, and repeatable behaviour is what lets you tune a cycle instead of chasing intermittent faults.

Why not just use a PC

Because a PC optimises for average speed and a machine needs consistency. As one practitioner's guide puts it, PLC coding optimises for determinism, where every scan cycle takes approximately the same time every time, and a 50 ms scan cycle with 5 percent jitter is unacceptable while the same cycle with 0.1 percent jitter is the goal. A press that closes 40 milliseconds late does not produce a slow part. It produces scrap, or a broken tool.

02 / The languages

Five languages, one standard, one reason to care

PLC programming is governed by an international standard, and this matters to you as a buyer rather than as an engineer. IEC 61131-3 defines the basic structure and elements of programming languages for controllers and allows programming in five language standards, of which three are graphical and two are textual, with the current third edition released in 2013.

01Ladder diagram  Looks like a relay wiring diagram. The default for discrete logic, motor control and simple sequencing, and the language most maintenance electricians can read at 3am.
02Function block diagram  Signal flow drawn as connected blocks. Natural for process control, analogue loops and anything that reads like a schematic.
03Sequential function chart  Steps and transitions. The clearest way to express a machine sequence with defined states, which is most assembly and packaging equipment.
04Structured text  Textual and close to conventional programming. Used for maths, data handling, recipes and anything that would be unreadable as ladder.
05Instruction list  Deprecated in the 2013 revision. You will only meet it in legacy code.

Mixing languages inside one project is normal and produces cleaner code than forcing everything into one. The commercial point is support. Logic written to the standard, structured into readable steps and properly commented, can be picked up by any competent automation engineer. Logic written as one thousand undocumented rungs by a contractor who has moved on is a hostage situation, and we have been called in to rescue several.

So when you buy a machine, ask who owns the source, whether you receive it, and whether it is written in a standard language with the sequence documented. That question costs nothing at purchase and saves a great deal at the first breakdown.

03 / The stack

Four layers, four different jobs

The control layer is one level of a standard structure, and most bad purchasing comes from confusing the levels. The reference model is ANSI/ISA-95, also published as IEC 62264. The layer separation is explicit: PLCs and sensors run machines in real time, SCADA supervises and visualises, MES manages production operations, and ERP handles business planning.

LayerWhat it doesTimescaleWhat it cannot do
Sensors and actuatorsDetect a condition, move somethingInstantDecide anything
PLCSequence, interlock, control the machineMillisecondsTell you if you hit schedule
SCADA and HMIVisualise, alarm, trend, operator controlSecondsRun the machine on its own
MESOrders, dispatch, traceability, OEEMinutes to hoursStop a press in time
ERPOrders, materials, costing, deliveryDaysKnow why line 3 stopped

Scroll the table sideways on a phone

The practical use of this table is to stop expensive category errors. A dashboard project does not fix a machine that jams. A new PLC does not tell you whether you will ship on Friday. We wrote the full version of this structure, including where the intelligence is currently moving, in what factory automation replaces, station by station.

04 / What the layer buys you

Sequenced, monitored, interlocked, from one place

Here is the description we use for our own work, and it is worth unpacking word by word: every actuator sequenced, monitored and interlocked from one control layer.

01Sequenced  The order of operations lives in one place, as defined steps with defined transitions, instead of being an emergent property of six machines each doing their own thing and hoping the timing works out.
02Monitored  Every movement has a sensor that confirms it happened. A cylinder that is commanded out and never confirms out raises a fault instead of letting the next step run into it.
03Interlocked  Conditions that must be true before something is allowed. No gripper release unless the part is over the nest. No conveyor index while the arm is inside. No machine cycle with the door open.
04From one control layer  One place that knows the state of the whole station, so a fault anywhere brings the station to a safe, known stop rather than a partial one.

Those four words are the difference between a cell that runs unattended and a cell that needs someone standing next to it. They are also the difference between a jam that stops the line and a jam that wrecks a fixture, because the machine that has no confirmation of position cannot know that it is about to close on something.

None of this is visible in a quotation. That is exactly why it is worth asking about. Two suppliers can quote the same robot, the same conveyor and the same gripper, and deliver very different machines, because one of them wrote the interlocks and the other one wrote the happy path.

05 / Why it decides scaling

Islands work. Islands do not add up

Most plants automate one station at a time, and that is the right way to do it. The failure mode is not the sequence, it is what gets skipped. If each station arrives with its own controller, its own logic conventions, its own idea of what a fault is, and no defined way of talking to the station on either side, you have bought islands. Each one works. Together they do not form a line.

The symptoms are recognisable. Somebody stands between two machines moving parts by hand because there is no handshake. The line runs at the speed of its slowest handoff rather than its slowest machine. Nobody can say why the line stopped, only that it did. Adding a third station costs more than the second one did, because it has to be interfaced to two different worlds.

A coherent control layer prevents that with unglamorous engineering: a common handshake between stations, a common state model, a common fault convention, and one place where the line sequence is defined. Set that up when you install the first cell and the second cell is an incremental cost. Skip it and you will pay for the integration three times.

Four questions that predict the answer

Ask these about your own floor. Can a new station be added without rewriting existing logic? Does every station report state and faults the same way? Is the line sequence defined in one place? Can you extract production and fault data without a bespoke integration per machine? Four yeses mean the next station is a purchase. Four noes mean it is a project.

06 / Downtime

The layer that knows why it stopped

Downtime is where the control layer either earns its keep or exposes itself. The scale of the problem is well documented. The Siemens True Cost of Downtime 2024 report found that Fortune Global 500 companies lose a combined 1.4 trillion US dollars per year to unplanned equipment downtime, 11 percent of their total revenues, up from 8 percent in 2019 and 2020.

Those are very large companies. The mid-size picture is more useful for most Malaysian plants: ABB's 2023 Value of Reliability survey of more than 3,200 plant maintenance decision-makers puts the cross-sector median at about 125,000 US dollars per hour, with a food and beverage median around 85,000. Your number will differ. The method for finding it is the same: production value per hour, plus the cost of recovery, plus whatever the missed delivery costs.

The part a control layer directly addresses is the cause mix. A global study of over 100 manufacturers found that 23 percent of unplanned downtime is attributed to human error. Interlocks, confirmed positions and enforced sequences remove a meaningful share of exactly that category, because they make the wrong action impossible rather than discouraged.

The second thing a good control layer gives you is first-fault capture. When a station stops, the useful question is not that it stopped but which condition failed first, because everything after that is a consequence. A properly written PLC program tells you that in a sentence on the HMI. A badly written one tells maintenance that the line is down, and leaves them to find out why while the clock runs.

07 / Buying it

What to specify before you sign

The control layer is easy to underspecify because it is invisible on a factory acceptance video. The machine runs, the part comes out, everyone is happy. The differences show up six months later when the product changes or the line is extended.

01Source code ownership  Do you receive the PLC and HMI programs, uncompiled and unlocked, with documentation? If not, every future change goes back to one supplier at their price and their schedule.
02Standard languages and structure  Written to IEC 61131-3, structured into steps, commented in English, with a documented sequence and I/O list.
03Fault handling  Named faults with first-fault capture, not a single generic alarm. Ask to see the alarm list before acceptance.
04Line interface  A defined handshake to the station upstream and downstream, agreed in writing, even if those stations do not exist yet.
05Data out  A way to read counts, cycle times, states and faults without a bespoke integration. This is what makes OEE and traceability possible later.
06Changeover  Recipe-driven where the product varies, so a change of variant is a selection rather than a rebuild.

None of these are exotic requests. All of them are cheap to specify at purchase and expensive to add afterwards. If a supplier resists the first one, that answer tells you most of what you need to know about the rest.

08 / On your floor

We build the layer before we build the line

CODETRACE designs and builds PLC-based control for tailor-made machines and turnkey lines, and the description is deliberately plain: every actuator sequenced, monitored and interlocked from one control layer. That is the part of the job that does not photograph well and decides whether the line works.

In practice that means the sequence is written and reviewed before the steel is cut, every movement gets a confirmation sensor rather than a timer, faults are named and captured, and the machine is run on your parts in our workshop until it behaves the same way a hundred times in a row. Then it is commissioned on your floor, where the real interruptions live, and your maintenance team is trained on the same documentation we used to build it.

The same layer is what makes the next step possible, whether that is a robot cell feeding the machine, an inspection station rejecting on a vision result, or a palletizer at the end of the line. Each of those is a station that has to be told what to do and has to report what it did.

Malaysia has funded the direction of travel. NIMP 2030 aims for 3,000 smart factories by 2030, with an estimated RM5 million per company amounting to a total requirement of around RM15 billion. Grants pay for equipment. They do not pay twice for a line that has to be re-integrated because the control layer was an afterthought. CODETRACE integrates on site from Shah Alam in Selangor and Batu Kawan in Penang, and is a member of the NVIDIA Inception program.

Buy the station. Specify the control layer. The second one decides what the first one is worth.

FAQ / PLCs and the control layer

Questions, answered.

01

What is a PLC in automation?

A programmable logic controller is the industrial computer that runs your machine in real time. It reads every sensor on the equipment, applies the control logic you specified, and drives every actuator: motors, valves, cylinders, conveyors, indicators. It does that on a repeating scan cycle typically between 1 and 100 milliseconds, and it is built to keep doing it for years in heat, dust and vibration. In practical terms the PLC is the layer that decides what happens next on your line, which is why it also decides how easily the line can be extended.

02

How does a PLC work?

On a fixed cycle with four steps. It reads every input at once into a snapshot, executes the program against that snapshot, writes the results to the outputs that drive the actuators, then services communications and resets its watchdog before repeating. Cycle times typically range from 1 to 100 milliseconds depending on program size, input and output count and processor speed. The snapshot matters: because inputs are frozen for the whole scan, the logic sees one consistent picture of the machine rather than a value that changes halfway through.

03

What is the difference between a PLC, SCADA and MES?

They sit at different levels and do different jobs. PLCs and sensors run the machine in real time, executing control logic in milliseconds. SCADA supervises and visualises those PLCs across a line, with operator screens, alarms and trends, on a timescale of seconds. MES manages production operations across the plant: orders, dispatch, traceability, OEE, on a timescale of minutes to hours. ERP sits above all of it with orders, materials and costing. Buying an MES will not fix a machine that stops, and a PLC will not tell you whether you are hitting your schedule.

04

What languages are PLCs programmed in?

IEC 61131-3 defines five: ladder diagram, function block diagram, sequential function chart, structured text, and instruction list, which was deprecated in the 2013 revision. Three are graphical and two are textual, and most real projects use two or three together, ladder for discrete logic and structured text for maths and data handling. What matters commercially is that the standard makes your logic readable by any competent automation engineer rather than only by the person who wrote it.

05

Do I still need a PLC if my station uses robots?

Almost always, yes. A robot controller runs the arm. It does not run the conveyor that feeds it, the sensor that confirms a part arrived, the gate that stops the next part entering while the arm is inside, the reject chute, the machine handshake or the alarm that tells maintenance why everything stopped. That coordination is the PLC's job. A robot without a control layer around it is a fast island in a slow line.

06

What is an interlock and why does it matter?

An interlock is a condition that must be true before something is allowed to happen. The gripper does not open unless the part is over the nest. The conveyor does not index while the arm is inside the envelope. The machine does not cycle while the door is open. Interlocks are how a line stays safe and how it avoids destroying product when something goes out of sequence. They live in the control layer, which is why an automation project with a weak control layer tends to produce both scrap and injuries.

07

How do I know whether my control layer will let the line scale?

Ask four questions. Can a new station be added without rewriting the existing logic? Does every station report its state and its faults in a consistent way? Is there one place where the sequence is defined, or is it spread across separate machine controllers that do not talk to each other? Can you get production and fault data out without a bespoke integration per machine? If the answers are no, the next station will cost more than the last one, and the one after that will cost more again.

Sources / Every figure in this article

Where the numbers come from

Scan cycle behaviour is taken from peer-reviewed research describing PLC execution semantics. The standard description comes from a technical reference on IEC 61131-3. Downtime figures are Siemens and ABB survey research reported through trade sources rather than read from the original reports, so they are labelled secondary.

01Formal verification research describing PLC architecture and the scan cycle  Fixed read, execute, write, communicate cycle; typical cycle times of 1 to 100 milliseconds.Academic
02Technical overview of IEC 61131-3  Five programming languages, three graphical and two textual; third edition published 2013.Technical reference
03Practitioner guide to industrial PLC programming  Determinism and scan jitter as the defining requirement; instruction list deprecated in 2013.Practitioner
04ISA-95 reference summary  Layer separation between PLC, SCADA, MES and ERP and the timescales each operates on.Vendor guide
05Trade reporting of Siemens True Cost of Downtime 2024  1.4 trillion US dollars per year across Fortune Global 500, 11 percent of revenue, up from 8 percent.Trade, secondary
06Compilation citing ABB Value of Reliability 2023  Cross-sector median of about 125,000 US dollars per hour from 3,215 respondents; food and beverage median about 85,000.Trade, secondary
07Analysis of manufacturing inefficiency costs  23 percent of unplanned downtime attributed to human error in a study of over 100 manufacturers.Trade, secondary
08Reporting on Malaysia's NIMP 2030 smart factory target  3,000 smart factories by 2030 at an estimated RM5 million per company, around RM15 billion in total.Regional press
09CODETRACE first-party: every actuator sequenced, monitored and interlocked from one control layer, on tailor-made machines and turnkey lines.First-party

Show us the line. We will show you the control layer it needs.

Talk to our engineers
Scroll to Top