Sei sulla pagina 1di 56

Automation

and Controls
A guide to Automation, Controls, PLCs and PLC
Programming
By Nick Dawkins



























2014
Nick Dawkins
All Rights Reserved

Contents
INTRODUCTION
PROGRAMMABLE LOGIC CONTROLLERS OR PLCS
BACKGROUND
SELECTION OF A PLC
Cost
Complexity of the process
Speed of Processing
Input and Output Requirements
Communication Requirements
Interface Requirements
TYPES OF PLCS
LOGIC CONTROLLERS
ALL IN ONE
MODULAR PLC
MAKES AND IDES
COMMON MANUFACTURERS AND PROGRAMMING ENVIRONMENTS
HOW DOES A PLC WORK?
SIGNAL TYPES
DIGITAL SIGNALS
ANALOGUE SIGNALS
PLC INPUT DEVICES
TYPICAL INPUTS
DIGITAL SENSORS
Reflective or Retro-Reflective Sensors.
Capacitive
Inductive
Colour/Contrast
ANALOGUE SENSORS
Thermocouples
PT100s
Load Cells
Potentiometers
ENCODERS
Incremental Encoders

Absolute Encoders
TYPICAL OUTPUTS
Lamps
Motors
Contactors
Relays
COMMUNICATION
HMIS


PLC SOFTWARE
PROGRAMMING METHODS
Examples of each type of programming
Program Flow
IL (Instruction List)
SFC (Sequential Function Chart)
LD (Ladder Logic)
FBD (Function block diagram)
ST (Structured Text)
REAL TIME MONITORING
PROGRAM STRUCTURE
FAIL SAFE
BUILDING EXPERIENCE
END

Introduction
The whole world has an insatiable desire for manufactured products and devices, so
manufacturers have to be able to build and produce things quickly, and in great numbers.
The solution is to build them using automated production machines. As these machines
have grown ever more complex, so has the field of Automation and Control.
Controls Engineers are always in high demand and the pay can be very good for an
experienced engineer. It can also be very rewarding designing the software, and
automating a process that is tailored to a clients needs and machinery. Controlled systems
are everywhere in factories making anything from cars to mobile phones. If youre
looking for a career in this field or just have an interest, then this guide can give you a
glimpse into how these automated systems actually work.
Id like this book to grow more, so please feel free to contact me if you would like
something expanded upon, clarified or included in the book. I can then either help you
directly, or add the information to the book itself if it would prove popular.
My controls background started while working at a large container and refrigeration port,
before moving onto pharmaceutical manufacturing and high speed packaging and
labelling machines. I then worked on robotic pick and place machines building mobile
phones for a Japanese multinational. Im currently a controls engineer, working on
machine protection systems of a large particle accelerator.
nickdawkins@gmx.com

Programmable Logic Controllers or PLCs


Automated machines are controlled and monitored by using a varied combination of
electrical devices that that provide inputs and take outputs to and from a central
controlling computer. In such machines these computers are called PLCs, which stands
for Programmable Logic Controllers. These are very robust pieces of equipment that are
extremely reliable and rarely crash. They also allow engineers to monitor the controlling
software of a machine as it actually runs, check for faults and enable engineers to expand a
machines capabilities further if it needs to be updated or have the process changed in some
way.
PLC stands for Programmable Logic Controller
They are used for throughout industry to control automated systems such as:
Traffic Lights
Packaging Machinery
Robots
Automated Production Lines
Pick and Place Assembly Lines
Airport Baggage Handling
Automated Warehouses

Background
Before PLCs were invented, automation was very limited, and was accomplished with
relay logic. This was a hard wired system of switched relays and timers, used to achieve
an automated task. The wiring was extremely complicated, and fault finding was very time
consuming, causing lots of production delays. It was also very difficult to modify the
wiring if the process needed changing.

An example of Relay Logic


The first PLC was commissioned by General Motors, who wanted to reduce complicated
hard wired relay logic and timers into a single electronic unit, thereby speeding up their
production lines and reducing downtime.
The first PLC was made in 1968 by Bedford Associates and called the 084 because it
was Bedford Associates eighty-fourth project.

The 084 PLC

Selection of a PLC
There are several types of PLC, and their selection is based on several things:
1.
2.
3.
4.
5.
6.

Cost
complexity of the process
Speed of Processing
Input and Output Requirements
Communication Requirements
Interface Requirements

Cost
PLCs range in price from around fifty pounds, up to models costing thousands.
Complexity of the process
If the task is very simple, there is no need to buy a flashy top of the range PLC.
Speed of Processing
Some tasks require a very fast PLC. It may need to use a sensor to count high speed
motor revolutions for instance. A slow PLC would not be able to process these signals fast
enough.
Input and Output Requirements
If the system the PLC will control has lots of sensors, switches and motors, the PLC will
need to have lots of Input and Output options.
Communication Requirements
Does the PLC have to interface to other PLCs or a central computer? Does it need a serial
link or Ethernet link?
Interface Requirements
Does the machine just have a few stop and start switches, or is it a complex system
requiring a touch screen?

Types of PLCS
Logic Controllers
The simplest PLC is called a logic controller. These are very cheap items to control a very
simple process. They are not really considered a true PLC, but a halfway house that has
the ability to control small pieces of equipment that only require a few timers or counters
and simple logic.

This is a simple Logic Controller


All in One
These are true PLCs that come as one complete compact unit. They have a fixed amount
of inputs and outputs, both digital and analogue, and can be fully programmed to run
complex tasks. They are generally not very expandable, so a larger one than necessary
must be bought if future changes are planned.

An All in One PLC

Modular PLC
This type of PLC is built up out of modules, as required for the process. They normally are
built from left to right starting with a power supply module, then the CPU module. After
that you could have Input modules, output modules, communication modules, analogue
modules and counter modules to name but a few.
You can even have remote modules far away from the main PLC rack to save on cabling
costs.

A modular PLC built into a crate



Modular PLCs are the most common in industry, because they are expandable, and if a
fault develops, only the faulty module would need replacing instead of the whole
PLC.

Makes and IDEs


There are many manufacturers of PLCs such as the ones listed below. They all offer
similar capabilities, but some can be easier to program than others. PLC programmers all
tend to prefer certain systems over others. In my opinion, some can give an easier learning
curve, such as an Omron or Mitsubishi PLC, and some can be quite difficult to learn such
as Siemens. A lot depends on the complexity of the process.
The manufacturers sell the programming software or IDE (Integrated Development
Environment).
Each IDE will usually program most of those manufacturers models of PLCs but you
should always check compatibility before purchasing. Manufacturers IDEs are not
interchangeable. You cant program a Mitsubishi PLC using Omron software for example.

Common Manufacturers and Programming Environments


Omron Programmed using the CX-One IDE
Siemens Programmed using the Step 7 IDE or the newer TIA Portal IDE
Mitsubishi Programmed using the GX Developer IDE
Allen Bradley Programmed using the RSLogix IDE

How does a PLC work?



The following section will describe what signals a PLC can process and what types of
devices can be connected to it.

Signal Types
Most signalling to and from a PLC in a modern machine is done using low voltage signals
such as 24V DC voltage, and low analogue voltages and current signals. Its not very
common to switch mains voltages at the PLC itself. High voltage equipment is usually
segregated somewhere else in the control panel. This ensures that no electrical noise can
affect signal cables connected to the PLC.

Digital Signals
These are usually 24VDC signals that are either on or off (true or false). They can be
things such as switch outputs or sensor signals into the PLC and relay and contactor
signals or indicator lamps out of the PLC.

Analogue Signals
These are variable voltage signals such as 0 to 10V, -10V to +10V, 0 to 5 V or variable
current signal such as 0 to 20mA or 4 to 20mA. These can represent speeds or positioning
signals both into and out from the PLC, or a motor speed setting or valve position.

PLC Input Devices


Typical Inputs
Aside from simple switches providing inputs to a PLC, you can also connect a range of
sensors.

Digital Sensors
Reflective and Retro-Reflective Sensors
These types of sensor emit a beam of invisible light, and look for reflected signals back
when an object blocks the beam. Reflective sensors bounce the beam off of the object
being detected. A retro Reflective sensor bounces a light off of a reflector mounted
opposite the sensor, perhaps on the other side of a conveyor belt, and detects the absence
of the reflection to tell if an object is in the way.
Their range is usually only a few centimetres, but can be a lot more depending on the
sensor used.

A Retro Reflective Sensor and a Reflector

Capacitive
These types of sensors are good for detecting items made of insulating materials such as
plastic jars. They emit an invisible electric field which is distorted by an object passing
past which then triggers the sensor.

Two Capacitive
Sensors



Inductive
These sensors are similar to capacitive sensors but work better on non insulating materials
such as metal. They are very good at detecting a notch in a spinning cam for example.

Inductive Sensors


Colour/Contrast
These are good for detecting colour differences such as a detecting a missing label from a
bottle.

Colour/Contrast Sensor
Sensors usually have to be set-up to see an object when fitted. Many have an adjustable
screw in the top to adjust the sensitivity. Some have a digital readout showing the signal
level for a given object. You can then adjust a threshold level that will then trigger the
sensor.
They also can be wired in several ways. Some are only two wires, others can be four or
more. Their output type also has to match the PLC input connection. Inputs can be
sinking or sourcing otherwise known as PNP or NPN. PNP provides a positive signal,
such as 24VDC back to the PLC to trigger the input. NPN provides a 0V or GND back to
the PLC to trigger the input.

Analogue Sensors
Thermocouples
Thermocouples are used to measure temperatures. They come in many types depending
on the temperature range that needs to be measured.

A typical Thermocouple

Thermocouples need to be wired with special compensating cable throughout the whole
circuit. This cable is colour coded for different temperature ranges. Different countries
sometimes use different colour cables:

The most common thermocouple type is a K type as it spans the most common
temperatures being measured.

PT100s
PT100s also measure temperatures but do not required special cabling. They come in
three forms, each with a different number of connections, namely 2, 3 and 4 wire versions.
As a general rule, the further away the sensor is from the PLC, the sensor with more wires
is better.
A platinum resistance temperature detector (RTD) PT100 is a device with a typical
resistance of 100 at 0C. It changes resistance value as its temperature changes
following a positive slope with the resistance increasing when temperature rises.
They have been used for many years to measure temperature in laboratory and industrial
processes, and have developed a reputation for accuracy, repeatability, and stability. A
RTD can typically measure temperatures up to 850 C. The relationship between
resistance and temperature is relatively linear as shown below:


The sensors measure temperatures by detecting a change in the resistance of the sensor. As
long cables have a built in resistance which can affect sensor accuracy, using a 3 or 4 wire
sensor negates changes in temperature due to long cable resistances.
A PT100 Probe

Load Cells
Load cells measure weight or the force of a load. They work by measuring resistance
changes within a strain gauge. The higher load, the bigger the resistance change.

A Load Cell

Potentiometers
A potentiometer is a variable resistor that changes is resistance depending on its position.
They are very useful for ascertaining positions. They come in rotary or linear forms.
Rotary models can have one turn or several, and linear can be from around 5cm to around
50cm. A potentiometer connected to a PLC would typically have a 0 Ohm to 10KOhm
resistance depending on its position. These can be connected to analogue input modules
where their resistance can be scaled to a voltage range which can be used to calculate a
position.

A Rotary Potentiometer

Linear Potentiometers

Encoders
An encoder is usually mounted onto a motor or shaft to give a rotational position. They do
come in linear forms as well, but these are less common.
Incremental Encoders
Incremental encoders emit digital pulses every time their shafts rotate. The number of
pulses per degree of rotation is dependent on the encoders resolution. A high resolution
encoder would detect a smaller movement that a low resolution version. As the encoder
rotates the PLC can count these pulses and work out how far something has moved. As
this count can get forgotten, or things can move, the machine would need to move slowly,
or jog, to a known position on powering up before it can run at full speed. This is called
homing, and enables the PLC to reset the counters and count from a known safe position.

Incremental Encoders
Absolute Encoders
Absolute encoders always know there rotational position and do not need homing like
their incremental versions. This means the PLC would know a machines position at all
times regardless of whether things have moved whilst the power is switched off. The
downside is that they normally require more inputs on the PLC.

Absolute Encoder

Typical Outputs
Lamps
These can be easily switched on or off from a single PLC output, for operational
indicators.

Lamps
Motors
A motor drives different parts of a machine such as a conveyor belt, scroll drives or
carousels which carry items around inside the machine. There are many types of motors
used in industry, but typical ones are usually just activated via a contactor. More complex
types are servo motors or stepper motors which can be moved by a fixed rotational
distance for accurate control.

A Typical AC motor

Contactors
A contactor enables a low voltage output to directly switch a very large current device on
or off, such as a motor or heating element. A contactor has a coil which needs to be
compatible with a PLCs output, which is usually 24VDC. The main switch in the coil
needs to be able to stand the current load of the attached device.

A Contactor




Relays
A relay is a small contactor designed for switching smaller current loads. They usually
plug into relay bases, so can be swapped over quickly without the need to disconnect any
cabling.

A Relay and Relay Base


Communication
PLCs can communicate with many other systems if they have the correct modules fitted.
Most CPUs are now fitted with Serial RS232, USB or Ethernet connections. Other
connections are RS485, Profibus (for data transfer between PLCs) Device-net and many
more.

Serial Port Module

Ethernet Module

HMIs
HMI stands for Human Machine Interface. It allows a machine operator to control a
machine very easily. They can be very simple LCD screens with a few buttons, right up to
a colour touchscreen device. HMIs are programmed using the manufacturers software.
Sometimes this is a separate package that must be purchased, and sometimes it comes as
part of the PLC programming IDE.
They can also have password protected levels, so you would have a simple screen for an
operator to control a machine, but also an expert screen on the same device for helping
engineers to fault-find technical problems.

LCD Panel

Touchscreen Panel

PLC Software
Programming Methods
Most proper PLCs can be programmed in five different ways, or even a combination of
ways.
In the distant past PLCs had to be programmed in mnemonics which was similar to
machine code. This was very hard to read, and understand. This was replaced by a
programming method called Ladder Logic. This was designed to look similar to electric
circuits, so a programmer could see a signal flow through his code. Ladder Logic is still
very popular as it is arguably the easiest to learn and understand. As time moved on and
systems became more complicated, an industry standard was accepted which consisted of
the programming methods listed below:
The International standard IEC 61131-3 has become popular, and currently defines five
programming languages for programmable control systems:
IL (Instruction List or Statement List)
SFC (Sequential Function Chart)
LD (Ladder Diagram, or Ladder Logic)
FBD (Function block diagram)
ST (Structured Text)

Examples of each type of programming
Well go into each type of programming method in a moment, but first its a good idea to
know how a PLC runs its program.
Program Flow
A PLC usually runs through its program from start to finish, and then repeats this loop. At
the start, the PLC examines the state of every input. It then saves all these input states as
an input memory image. This image of all the inputs is then fixed until the whole program
has completed one cycle. As the program then runs, the logical conditions within the
program are applied and any output changes are saved in an output image. No physical
outputs are switched on or off at this point.
Only when the whole program has completed one cycle, does the output image get
transferred in one go, onto the physical outputs. This happens very quickly, with one scan
usually only taking 2 or 3 milli-seconds. Once the output image has been transferred, the
whole cycle begins again.
Its very important to understand this because the scan cycle can make things confusing if
the PLC is programmed poorly. For instance, if you want the machine to start, you would
have the relevant output be switched ON or set to TRUE. However, if later in the same
program an OFF or FALSE condition sets this bit back to zero, the later command would

override the first command and the machine would never start. The diagram below shows
the whole cycle.


A typical Program has 2.5ms scan period depending on the length of the program and
CPU speed. The scan time can reach 50ms or more if the program is large or it could be
micro-seconds with a fast PLC.

IL (Instruction List)
Instruction List was first used years ago when laptops did not exist. Engineers had to
scroll through PLC code line by line with a hand-held programming unit. This made
debugging and fault finding extremely difficult and writing programs even harder.

A Hand-held Programming Unit




This example shows Statement List on a Siemens PLC

SFC (Sequential Function Chart)


Sequential Function Charts are very good for repeating sequences, such as traffic lights or
a manufacturing process that is the same every time. In the process below, two pistons are
controlled.
Step 1 waits for the start condition to be made, probably a start button
Step 2 Turns output Q0.2 ON which is Piston As solenoid. It then waits until the now
energized Piston A has extended, by detecting INPUT I0.3 which is probably a magnetic
reed switch on the side of the piston.
Step 3 Keeps Piston A ON, and also extends Piston B, and again waits for it to be fully
extended.
Step 4 Maintains both Piston position until a 3 second timer has elapsed before starting
the next step.
Step 5 Turns OFF Piston B but leaves Piston A extended, until Piston B has fully
retracted.
Step 6 Wait for Piston A to retract before starting the whole sequence again.

LD (Ladder Logic)
Ladder Logic gives a good visual representation of what it is controlling. Here is a simple
example of a start and stop control for a motor relay.
Inputs and outputs are given memory addresses within the PLC. Here are the addresses for
this circuit:
Address 0.00 Turns ON whenever the machine Start Button is Pushed
Address 1.00 Turns ON whenever the machine Stop Button is Pushed
These two addresses would be PLC Digital Inputs.
Address 2.00 is a Digital Output which would trigger the Motor Relay to start the motor.

At the beginning, the Start Button is not made so is in a FALSE state.
The symbol below 1.00 is called a NOT gate. Because the Stop button has NOT been
pushed, this condition is TRUE.
The Motor Relay 2.00 is also FALSE because the Output is off.


Now look what happens when someone pushes the Start Button. Because 1.00 is TRUE
(The Stop Button has NOT been pushed), the circuit is made right up to the output coil
2.00.
This coil then becomes TRUE, turning the motor ON.



Now the operator has let go of the Start Button, the circuit maintains because the Start
Button contact has a parallel contact of the Motor Relay next to it. This allows the motor
to stay on when the Start Button has been released.

If this parallel coil was not there, the Motor Relay would turn off as soon as the Start
Button was released, thereby turning OFF the motor. This is what is called a latching
circuit because the Output itself holds the circuit in a TRUE condition.


So look what happens when the operator pushes the Stop Button. Coil 2.00 then becomes
FALSE and breaks the latch, turning the motor off.

The above is a very simple example of Ladder Logic. As seen below, it can get rather
complicated if the logic needed is complex.


Quite complex ladder code can be written using only basic commands as shown
previously.
Ladder Logic can also be used for many complicated tasks, and the Omron software for
example, has over 430 different Ladder commands covering the following areas:



FBD (Function block diagram)
FBD is a good method of programming too, as it can show lots of information in one view.
Below it is showing the logical conditions necessary for output Q1.1 to turn ON or
become TRUE.
The code is run left to right.
The first two blocks are compare statements. These are asking if one value is greater than
(>) another. In this case address MD214 would contain a number. If this number was
greater than 5.00, this condition would be TRUE.
The block below that, checks if MD22 has a value greater than 29.00.
If both these conditions are TRUE, we move onto the next block.
This next block is an AND gate. It needs all its Inputs to be TRUE before it has an Output.
In this case it needs Q0.6 to be TRUE, M101.04 to be OFF, or NOT TRUE which is
denoted by the small circle.
It also needs to two Inputs from the previous compare blocks.
And it finally needs M10.1 to be NOT TRUE or OFF.
Once ALL these conditions are met, this AND gate will Output to the next block.
The next block means is one or more Inputs TRUE?
If the above blocks Output is TRUE the next block is activated, which is a SET/RESET
Latch. If ALL the previous conditions are made this block would RESET making its
Output FALSE even if the SET side was TRUE.
If the previous conditions are FALSE and M11.0 ( the SET condition) is TRUE, then the
Output from the SET/RESET Latch would be made.
The next block is a simple AND gate, so if the Output from the SET/RESET Latch is
TRUE AND M14.3 is TRUE then finally Q1.1 would be activated by the Output from the
previous AND gate!



ST (Structured Text)
Structured Text is very much like computer programming on your PC. You wouldnt
normally write a whole program in this way, but it is very good for writing Functions
(pieces of software that do a specific task, called from the main program), or for writing
complex mathematical calculations which would be difficult and hard to read in Ladder
Logic. The program below is a portion of code I wrote in order to calculate the Median
value of several variables representing temperatures in a bank of computer racks. If the
temperature increased above a set Median alarm level it would activate additional cooling.

Real Time Monitoring


As shown previously in the Ladder examples and below, a PLCs program can be
monitored in real time on a laptop by plugging into the PLC, or even remotely if the
communications to the PLC is enabled. This is very useful and enables an engineer to
track down problems, or see what is stopping an output from being energised. The green
lines show the logical trail enabling problems to be found very quickly. The bottom right
shows a watch window. This is where the status of several variables can be seen changing
in real time as the program runs.

Program Structure
In modern PLCs the program can be divided into sections to make it easier to navigate the
whole program more easily and find things quicker. Ideas for program sections are given
below:
Housekeeping A section for initial start-up code.
Input Conditioning Perhaps scaling analogue inputs here or adding a de-bounce to
inputs.
Main Program The main logic of your code that sets memory bits to enable devices.
Device Drivers Where all the outputs are handled or triggered by memory bits.
Communication A section for all the communication to and from the PLC

Fail Safe
If the PLC is controlling something that could injure or kill someone, you need to make
sure the PLC is failsafe. This ensures any loss of power to the PLC would not create any
danger to the user. All drives and moving parts should stop in the event of a fault. If a
sensor fails that could cause danger, the PLC should be programmed to detect this and
trigger an alarm. If machine guarding is opened, the machine must be designed so that it
stops immediately.

Building experience
The best way to learn PLC programming is to buy a small All in One compact PLC and
just play with it. Or, there is even software available that can simulate a PLC and
automated equipment, so you can practise for very little cost if you prefer that option.
Some PLC IDEs software can be hundreds or even thousands of pounds, but many also
sell Lite or trial versions of their software, with some things removed that you wouldnt
need to begin with anyway such as networking and data sharing.
A good source of used PLCs is E-Bay, where you could buy a cheap modular PLC and
then buy further modules as you become more proficient. Another option is a cheap
hobbyist type controller such as the Arduino, a small programmable controller built on a
single PCB. This comes with a free IDE and has been used for controlling many hobbyist
devices. Arduinos are less that 30 and great value, though rarely used in industrial
processes, they can give you a feel for automation.
Good luck exploring the world of automation!

End

Potrebbero piacerti anche