Catto / Topic Map · Industrial Electronics II Year 7
Industrial Electronics II · 120 h · Topic 1 of 8

Automation and programmable logic controllers

To automate is to make a process run by itself, in a repeatable and verifiable way. The programmable logic controller (PLC) is the tool that turned this from a relay panel impossible to modify into a program.

Closed loop Hardwired logic PLC Scan cycle

01What an automatic system is

ControllerActuatorProcesssetpointvariabledisturbanceOpen loopThe controller acts without checking the result. Any disturbance turns directly into error, andnobody notices.−sensorClosed loopThe variable is measured and compared with the setpoint; action is taken on the difference: the systemcorrects itself.Feedback costs a sensor and some complexity, and in return gives stable, repeatable behavior.
Figure 1. Open loop and closed loop, animated. Without feedback, the system acts “blindly” and any disturbance turns into error. With feedback, the error is measured and corrected.
Open loop

The action is applied without checking the result: a timer that opens a valve for thirty seconds, a motor that runs as long as there is a run command.

It is simple and cheap, and it works when the process is very repeatable. If something changes—the pressure, the load, the ambient temperature—the result changes and nobody notices.

Closed loop

The variable is measured, compared with the setpoint, and action is taken on the difference. The system corrects itself in the face of disturbances and wear.

It costs a sensor and some complexity, and in return it gives stable, repeatable behavior. It is the basis of all process control, and it is developed in PID controllers.

Part of the systemFunction
ProcessWhat is to be controlled: an oven, a conveyor, a filling line.
Sensors and transducersConvert the state of the process into electrical signals the controller can read.
Control unitDecides what to do. It can be a contactor, a pneumatic timer, a microcontroller or a PLC.
ActuatorsApply the action to the process: motors, valves, heating elements, cylinders.
Operator interfacePushbutton panel, signaling, display. It is where a person gives commands and sees what is happening.
SafetyEmergency stops, interlocks and protections. Independent of the control.

02What can be used to automate

TechnologyWhen it makes senseLimits
Hardwired logic with relays and contactorsVery small, fixed automation: a direct-on-line start, a reversal of rotation.Any change means rewiring. Difficult diagnosis and a lot of mechanical maintenance.
Pneumatics and pneumatic logicEnvironments with explosion risk, high humidity, or where compressed air is already available.Slow, noisy and hard to modify. It is developed in pneumatics and hydraulics.
Hardwired electronicsFixed, fast functions, or very high production volumes.Little flexibility. Redesigning means redoing the circuit board.
MicrocontrollerA product of your own, made in series, where cost per unit rules.You have to design everything: inputs, outputs, protections, enclosure. It suits a product, not a plant.
PLCIndustrial automation: rugged I/O already solved, standard programming, maintenance by third parties.High cost per unit. For ten pieces, it is the wrong tool.
Industrial PC and SCADASupervision, historical logging, complex processes and many variables.Less deterministic and more expensive. It always relies on PLCs below it.
When a PLC is not the answer

For three inputs and two outputs on a one-off machine, a couple of relays or a microcontroller cost a fraction and work just as well. A PLC is justified when there are many signals, when the automation is going to change, when the plant has already standardized on a brand, or when the maintenance will be done by someone who did not design it. That last point is the one that weighs most in real industry.

03The programmable logic controller

Where it came from

In 1968, General Motors asked for a replacement for its relay panels: every model change meant rewiring thousands of contacts and stopped the line for weeks. The request was clear: a reprogrammable device that would withstand the industrial environment and that the same electricians could maintain, without knowing how to program.

The first PLCs came out of that, and from that last requirement came the ladder diagram: a language drawn just like the relay schematics that plant personnel already knew how to read. That is why it is still, almost sixty years later, the most widely used language in industry.

Advantage over hardwired logicWhere it shows
FlexibilityChanging the automation means changing the program, not the wiring.
SpaceA small PLC replaces dozens of relays and timers.
DiagnosticsYou can see the state of every input and output online, and why an output does not activate.
FunctionsTimers, counters, calculations, communication and logging, without adding hardware.
ReliabilityNo moving contacts in the logic that can stick or pit.
DocumentationThe commented program is the documentation, and it travels with the machine.
FormatTypical I/OUse
Nano or micro8 to 20Simple machines, pumps, gates, small panels. Everything in one block.
Compact20 to 60With the option of adding expansion modules. It is the most common.
ModularhundredsRack with power supply, CPU and modules of your choice. Large plants and processes.

04The scan cycle

ReadinputsExecuteprogramWriteoutputsSystemtasksReadinputsPhase 1The physical state of all the inputs iscopied to the process image.ExecuteprogramPhase 2It runs from start to end, always readingfrom the image, never from the physical terminal.WriteoutputsPhase 3The output image is transferred all at once to thephysical terminals.SystemtasksPhase 4Communication, self-diagnosis and thewatchdog timer. Then it starts over.Typical scan time: 1 to 10 msBetween an input changing and the output responding, up to twice the scan time can elapse.If an output is written in two places in the program, the last one wins: it is the one left in the image.And throughout the cycle the inputs do not change: the program works on a consistent snapshot.
Figure 2. The scan cycle, animated. The PLC does not react to changes instantly: it reads all the inputs, runs the whole program with that snapshot and only then writes the outputs. And it starts over.
PhaseWhat happens
1Reading inputs: the physical state of all the inputs is copied to an area of memory, the process image.
2Program execution: it runs from start to end, always reading from the image, never from the physical terminal.
3Writing outputs: the output image is transferred all at once to the physical terminals.
4System tasks: communication, self-diagnosis, watchdog timer. Then back to phase 1.
The three consequences of the cycle
  1. There is a delay: between an input changing and the output responding, up to twice the scan time can elapse. With scan times of 1 to 10 ms that is enough for almost everything, but not for a 200 µs pulse: that needs a fast input or an interrupt.
  2. Order matters: if an output is written in two places in the program, the last one wins, because it is the one left in the image at the end of the cycle. It is the most common mistake of people coming from hardwired logic, where everything happens at once.
  3. The inputs do not change during the cycle: the logic works on a consistent snapshot, which avoids erratic behavior and makes the program predictable.
Example · Is the scan time enough?

A conveyor carries parts at 0.5 m/s and a sensor detects each part to trigger an ejector. The parts are 40 mm long. The PLC has a scan time of 8 ms.

  • Each part covers the sensor for 0.040 m / 0.5 m/s = 80 ms.
  • The worst case for detection is two cycles: 16 ms. There is plenty of time.
  • But if the conveyor sped up to 4 m/s, the pulse would last 10 ms and could be missed between two readings. At that point a fast input with hardware capture is needed.

That calculation—event duration against scan time—is the first check for any automation, and the one most often forgotten.

05In the lab

Lab 1 · The same automation, twice

Solve a start-stop circuit with a holding contact, first with relays and then with a PLC. Time how long each setup takes and, above all, how long it takes to modify the operation afterwards: adding a second stop pushbutton and a pilot light. The difference is the case for the PLC.

Lab 2 · Measuring the scan time

Write a program that toggles an output on every scan and measure its frequency with the oscilloscope: the period is twice the scan time. Add blocks to the program and watch how it grows. Compare with the value reported by the PLC itself.

Lab 3 · Missing a pulse

Generate shorter and shorter pulses on an input and check from what duration the PLC stops detecting them. Compare the result with the measured scan time and with the configured input filter.

Lab 4 · The output written twice

Deliberately write a program in which the same output is activated in one place and deactivated in another. Observe that only the last instruction counts, and verify it online with the program monitoring. It is the mistake that wastes the most time.

06Common mistakes

MistakeConsequence
Thinking of the program as if everything happened at onceThe PLC executes in order, from top to bottom. What is written last is what counts.
Writing the same output in several placesOnly the last one acts: the output seems “not to work.”
Ignoring the scan timeFast events are lost and the diagnosis points at the sensor, which is fine.
Putting the emergency stop only in the programIf the CPU fails, there is no stop. It must cut the power by hardware.
Choosing a PLC for an automation with three signalsUnjustified cost compared with a few relays or a microcontroller.
A program without comments or namesNobody can maintain it, and the program was precisely the documentation.
Confusing open loop with closed loopThe system is expected to correct disturbances that it actually never measures.

07Self-assessment

What is the difference between open loop and closed loop?

In open loop the action is applied without checking the result; in closed loop the variable is measured, compared with the setpoint, and action is taken on the difference, so that disturbances correct themselves.

Why did the PLC appear?

Because in 1968 General Motors needed to replace relay panels that had to be rewired at every model change. It asked for a reprogrammable device, rugged and maintainable by electricians with no training in programming.

Where does the ladder diagram come from?

From that last requirement: it was designed to look just like the relay schematics that plant personnel already knew how to read. That is why it is still the most widely used language.

List the four phases of the scan cycle.

Reading the inputs into the process image, program execution, writing the outputs, and system tasks.

What is the maximum delay between an input and its output?

Up to two scan times: one if the change arrives just after the reading, plus the full cycle until the output is written.

If an output is written in two places in the program, which one counts?

The last one executed, because it is the one left in the output image when the cycle ends.

With a 5 ms scan time, can a 3 ms pulse be detected?

Not reliably: it can fall between two readings. You need a fast input with hardware capture, or a longer pulse.

When is a PLC not a good choice?

When there are very few signals and the automation is fixed, or when it is a product made in series where cost per unit rules: relays or a microcontroller go there.

Why can’t the emergency stop be only in the program?

Because if the CPU fails or the program hangs, there would be no stop. It must cut the power to the actuators by hardware, with positive-opening contacts.

What diagnostic advantage does a PLC give?

It lets you see online the state of every input, every output and every rung of the program, so you can tell exactly why an output does not activate.

Development of the topic “Automation” of Industrial Electronics II (Year 7), based on the “Curriculum Proposal – Second Cycle of the Technical-Vocational Track, Secondary Education – Electronics,” Ministry of Education of the Province of Córdoba, DGETyFP. Back to the Topic Map · catto.ar