Basics of PLCs English Version Website Education PDF
Basics of PLCs English Version Website Education PDF
Basics of PLCs English Version Website Education PDF
Preface
PLCs in a glance
Basic PLC Operation
1- Processor Operating Cycle
2- Input modules
3- Output modules
4- Programming device
Ladder Diagrams
Hard-wired Control
Replacing hard-wired control with a PLC
The advantage of using a PLC as a controller
Different PLC models made by Siemens
1- SIMATIC S5
2-SIMATIC S7
3-LOGO!
MicroLogix 1500 PLC
Number system decimal & binary
Logic 0, Logic 1
Actuator
Discrete Inputs
Analog Inputs
Discrete Outputs
Analog outputs
CPU (Central Processing Unit)
Programming Languages
Ladder Logic programming
Reading Ladder Logic Diagrams
Function Block Diagrams (FBD)
Hardware
PLC memory size
1- RAM/ ROM / EPROM / Firmware
2- Memory structure
3- Program space
4- Data space
Software
Cables
S7-200 & A-B MicroLogix 1500 PLCs
PLC models
Optional cartridge
Expansion modules
07
07
07
08
08
08
09
10
11
11
12
12
12
13
13
14
15
16
16
18
18
18
19
19
20
21
22
23
23
23
24
24
24
25
26
26
27
28
28
28
29
30
31
32
32
32
33
33
33
33
34
36
38
1- AND function
2- OR function
3- Latch function
4- Inverse function
FBD (Function Block Diagram) programming language
STL (Statement List) programming language
Normally Open (NO) & Closed Contacts (NC)
Boolean Algebra PLC programming
Status Function
Force Function
Sequence
3 phase motor starter program
Wiring motor Starter circuit with PLC
Expanding the previous problem
Introduction to Analog signals
Analog Output signals
Introduction to A-B & Siemens S7-200 Timers
Hard-wired time Delay relay
A-B MicroLogix 1500 & SIMATIC S7-200 Timers
1-Timer On-Delay (TON)
2- Timer Off-Delay (TOF)
3- Timer Retentive On-Delay Timer (RTO)
An On-Delay timer programming examples & application
A-B Off-Delay timer
An Off-Delay (TOF) application example
A-B Retentive On-Delay Timer programming
SIEMENS SIMATIC S7-200 timers
1- SIMATIC On-Delay timer application example
38
39
40
40
41
41
42
43
45
46
47
48
50
51
53
54
55
56
56
56
56
56
57
57
58
59
60
61
61
61
62
63
64
66
66
66
66
66
66
66
68
69
70
71
72
72
PLCs in a glance
A PLC or a Programmable Logic Controller, is a programmable controller which
is considered as a member of computer family is mainly designed to be used in an
industrial field to sense different incoming signals, process them (or make decision) and
issue commands based on the special software program in its memory. This course is
designed to supply you with basic information on the functions and configurations of
PLCs.
Figure 1 illustrates Some I/O field devices connected to a Siemens S7-200 PLC
(Courtesy of Siemens Industrial Automation)
Figure 2
From figure 2, notice that a typical PLC system can be divided into four sections:
1-Programming Device
2-Micrrocessor + Memory Unit
3-Power Supply
3-Input/Output Sections
Input modules accept a variety of analog or digital signals from various sensors and
convert them to logic signals that can be used by the CPU.
The CPU makes decisions and executes control instructions based on the program in its
memory.
Output modules convert control instructions from the CPU into signals that can be used
to control various field devices
A programming device is used to install the instructions that determine what the PLC
will do in response to specific inputs
Processor Operating Cycle ~ in general
During each operating cycle, the PLC processor does the following continually:
1-Reads current input module statuses and updates Input Image Table.
2-PLC processor continually solves user Logic program based on current
Input Image Table statuses
3- PLCs processor updates Output Images Table statuses based on solution of user
Logic Program.
4- Based on the result on step # 3, PLC processor continually activates or deactivates
I/O module status according to Output Image Table status.
And then goes to the next rung. But if it is the end of the ladder logic program, and the
last statement is END instruction, it does some other tasks such as communication and
housekeeping tasks and then goes back to step 1 and continues executing ladder logic
program for the second time. It does so over and over until the time that the PLC is taken
off line or shut down manually.
Based on what is said, notice that a single operating cycle or scan which is illustrated in
figure 3, can be divided into two distinct parts- the I/O scan and the program scan.
Figure 3
The L1 and L2 designations refer to the two poles of a 120 VAC supply, unless
otherwise noted, L1 is the hot conductor, and L2 is the ground (neutral) conductor.
Typically in industrial relay logic circuits, but not always, the operating voltage
for the switch contacts and relay coils will be 120 volts AC. Lower voltage AC and even
DC systems are sometimes built and documented according to Ladder diagrams.
Ladder diagrams are used to describe the logic of electrical control systems.
There are differences in the way ladder logic was implemented in computerized form as
compared to hard-wired. The basic component of the control system is the control relay
which is a solenoid that operates a number of switches or contacts. The contacts come
normally open and normally closed, normal being when the relay is not energized. Relays
come in various breeds like time delay and latching types. Other components of the
control system are the field devices such as push buttons, limits switches, lights, and
controlled devices like motor starters and solenoid operated valves.
L1
L2
L3
M
O.L
M
2
3~
mo t o r
Hard-Wired Control
Prior to invention of PLCs, many control tasks were done with contactors and
relays hard-wired together. Circuits first had to be designed and drawn up. Then
components were specified and installed, and wiring list is created. Electricians would
then wire it all together. If something went wrong, the designers and electricians had to
rework the installation. If changes were made later, they could be time-consuming and
expensive. PLCs can perform the same tasks as hard-wired controls, and more complex
functions as well. The connections between field devices and relay contacts take place in
the PLC instead of with external wiring. Hard wiring, though still required to connect
field devices, is less extensive. Installations are easier to modify, since this often involves
changing only the PLC program.
6
The all above advantages caused the PLCs to win the war against the old way of
doing things with hardwired circuitry using bulky relays, timers and other field devices.
In short, the first PLCs were invented on 1968, and in year 1970 communicating circuitry
was added to them. In 1980 communication protocols were standardized and eventually,
in year 1990, programming languages were standardized (IEC1131).
IEC1131 standard
In year 1979, a group of experts under the name IEC (International Electrotechnical Commission) gathered to investigate ways to standard PLC parameters as long
as the hardware, software programming language and communication systems are
concerned. These studies and research took about 12 years and finally IEC1131 standard
was formed. IEC1131 standard is simply rules and regulations which must be considered
by PLC manufactures and cover different aspects of PLCs. IEC1131 suggests the
specifications set forward as long as the hardware design, programming language,
troubleshooting of hardware, installation and testing is concerned.
Different PLC models made by Siemens
Siemens categorizes its range of PLCs under the name SIMATIC . Some of
these PLCs are built in Compact form meaning the PLC box contains power supply,
CPU, input and output models. All these different part are located in plc box and
considered as a unit. On the other hand, the second model of PLC is built in Modular
form. In this form of application, the end user can choose which model he needs for his
particular need.
SIMATIC S5
These PLCs which are relatively older version of Siemens models. Some of the
models were built is compact form such as S5-90U or S5-95U with limited range of
application and functionality. The other models, such as S5-100U or S5-115U were built
in Modular form which could be used to control middle range of application. For broader
range of application, models S5-155U and 135U could be used from the same family.
Siemens STEP 5 software is used to program SIMATIC S5 PLCs.
SIMATIC S7 PLCs
SIMATIC S7 PLCs are next generation of controllers built after S5 series. S7
series come in three different models which are: S7-200 (compact), S7-300 (modular)
and S7-400 (also modular). S7-200 is used to control a relatively small system, The S7200 is ideal for smaller stand-alone applications such as elevators, car washes, or mixing
machines. It can also be used to advantage with more complex industrial applications,
such as bottling and packaging machines.
S7-300 for mid-range applications and finally S7-400 can be used for broader range of
control systems. These applications require a greater number of I/O points. Both the 300
and 400 are modular and expandable. The power supply and I/O functions are contained
in separate modules that connect to the CPU module. Choosing between the S7-300 and
S7-400 depends on the complexity of the task and on possible future expansion.
8
10
Figure 12
Sensors
A Sensor is a device, which responds to an input quantity by generating a
functionally related output usually in the form of an electrical or optical signal for use by
PLCs. Sensors are connected to the inputs of PLCs. One example is a pushbutton. An
electrical signal is sent from the pushbutton to a PLC input, indicating the condition of
the pushbuttons contacts which is either un-pressed or pressed (un-activated or
activated).
11
Figure 13
Actuator
An actuator is a transducer that accepts a signal and converts it to a physical
action. In other words, an actuator causes an action to occur relating to the data that was
sent to it. Actuators convert electrical signals from PLC outputs into physical conditions.
in our case, we use contactors as actuators which are activated any time PLCs output
terminal is 1 or ON and un-activated when output terminal is 0 or OFF.
Figure 14
Discrete Inputs
Discrete inputs are inputs to a PLC that require an on or off signal. Pushbuttons,
toggle switches, limit switches, proximity switches, and contact closures are examples of
discrete sensors. These discrete sensors may be connected to PLC discrete inputs. In the
ON condition, the state of a discrete input may be referred to as a logic 1 or ON or
High. In the OFF condition it is referred to as logic 0, or low.
12
Normally open switches are the type used to turn on or off when it is pressed or
un-pressed accordingly. When the switch is pressed, the circuit becomes closed and
functions. In the following figure, when the switch is not depressed, no voltage is present
at the PLC input. This is the OFF condition. When the button is depressed, 24 VDC is
applied to the PLC input. This is the ON condition. Hence, normally closed switches
perform just the opposite. When the switch is pressed, the circuit becomes open.
Figure 16
13
Analog Inputs
While a digital input can tell us about discrete changes in the physical world, such
as whether a lamp is on or off, there are times when this is not enough. Sometimes we
want to know how much is the weight of a load placed on a Force- sensitive resistors
(FSRs) that change resistance based on a changing force applied to the surface of the
sensor; thermistors that change resistance in response to changing heat; and many more.
To measure varying signals we need to have analog inputs. Typical analog inputs vary
from 0 to 20 milliamps, or 0 to 10 volts. In the accompanying example, a level
transmitter monitors the level of liquid in a tank. Depending on the type of level
transmitter, the voltage on the PLC input either increases or decreases as the liquid level
increases.
Figure 17
Discrete Outputs
The word discrete means a signal that has two states, ON and OFF. Therefore, a
discrete output, or a digital output, is either ON or OFF. Solenoids, contactor cols, and
lamps are examples of actuator devices normally connected to discrete outputs. In the
accompanying example, the lamp can be turned on or off by the PLC output.
Figure 18
Analog Outputs
The word analog means a continuously variable signal. Analog signals differ
from digital signals in that small fluctuations in the analog signal are meaningful. Hence,
an analog output signal varies continuously. The analog signal voltage level might be as
14
simple as a 0-10 VDC that drives an analog meter. Examples of analog meter outputs are
speed, weight, and temperature. The output signal may also be used on more complex
applications such as a current to pneumatic transducer that controls an air-operated flowcontrol valve.
Figure 19
CPU
PLCs are often defined as miniature industrial computers that contain hardware
and software that is used to perform control functions. A PLC consists of two basic
sections: the central processing unit (CPU) and the input/output interface system. The
CPU, which controls all PLC activity, can further be broken down into the processor and
memory system. The input/output system is physically connected to field devices
(switches, sensor, etc) and provide the interface between the CPU and the information
provider (inputs) and controllable devices (outputs). To operate, The CPU monitors the
inputs and makes decisions based on instructions held in its program memory. It performs
relay, counting, timing, data comparison, and sequential operations.
Programs are typically created in ladder logic, a language that closely resembles a relaybased wiring schematic, and are entered into the CPUs memory prior to operation and
changes only when a change is made to the control program.
Figure 20
Programming Languages
15
3456-
LD (Ladder Diagram)
ST (Structured Text)
SFC (Sequential Function Control)
CFC (Continuous Function Chart)
16
Figure 22
In a ladder logic program, the left vertical line represents the power of energized
conductor. The other end of all output elements or instructions represent the neutral or
return circuit path (the right vertical line that represents the neutral on hard-wired
diagrams is omitted). Ladder logic diagrams are read from left to right and from top to
bottom. The ladders rungs are referred to as networks. A network may have several
control elements, but only one output coil.
Figure 23
17
Figure 24
Figure 25
Software
PLC programs are typically written in a special application on a personal
computer, then it is downloaded by a direct-connection cable or over a network to the
PLC. The program is stored in the PLC either in battery-backed-up RAM or some other
non-volatile flash memory. Each PLC manufacture designees a special type of
programming software that can be used by end users to develop PLC control programs.
Often, a single PLC can be programmed to replace thousands of relays. As an example,
Siemens has developed S7 software for the S7 family of PLC. To program PLCs made by
Allen Bradley one might need to purchase software developed by Rockwell Automation.
Although in some cases, third party companies also developed and market software for
other manufactures brand of PLCs.
18
Hardware
Hardware is the actual equipment. The PLC, the Programming device, and the
connecting cable are examples of hardware.
Figure 26
Table in Figure 27
used in all computers. Information can be written into, or read from, a RAM chip, and it
is often referred to as read/write memory. Random access refers to the ability of any
location or address in the memory to be accessed or used. Ram is used for both the user
19
memory and storage memory in all PLCs. Since RAM is volatile, it must be battery
backup to retain or protect the stored program. RAM chips are manufactured with various
technology and CMOS-RAM is one of the most popular one. CMOS-RAM has very low
current drain when not being accessed (15 amperes!). So a CMOS-RAM can be battery
backed up with a lithium batter which is rated 2.95 V at 1.75 ampere/hours and normally
can hold or protect a program for 60 days!
Read Only Memory (ROM) is a common type of nonvolatile memory and it
means that the information stored in memory can be read only, and cannot be changed.
PLC manufacturer places information in the ROM for internal use and operation of the
PLC, and it is not supposed to be changed or altered.
Erasable programmable Read Only memory (EPROM) is other type of
nonvolatile memory. An EPROM is ideally suited when program storage is to be semi
permanent, or additional security is needed to prevent unauthorized program changes.
The EPROM chip has a quartz window over a silicon material that contains the electronic
integrated circuit. This window is normally covered by an opaque material, but when it is
removed, and the circuitry exposed to ultraviolet light, the memory content can be erased
and then it can be reprogrammed with a special equipment called EPROM
Programmer.
Firmware is user or application specific software programmed into special
memory contained in the hardware itself. In our case, it can be programmed into an
EPROM and delivered as part of the PLC hardware. It gives the PLC its basic
functionality.
Figure 28
Memory Structure
The memory of the most PLCs is divided into three areas:
1- Program space, data space, and configurable space.
2- Data space
3- Configurable space
Program space contains the ladder program instruction programmed by the user.
The instructions are entered either by a programming device, hand-held or desktop-type ,
or a system computer. This area of memory controls the way data space and I/O points
are used. LDA (Ladder logic) or STL (statement list) instructions are written using a
programming device and then loaded into this memory area.
20
Data space is where the status (ON or OFF) of all input and output devices is
stored. Numeric values timers and counters (preset and accumulated), numeric values for
arithmetic instruction, and the status of internal relays also are stored in this area of
memory.
Configurable parameter space stores either the default or modified configuration
parameters.
Figure 29
Figure 29 show how the written ladder logic program after being change to some
binary codes is transferred into the PLCs memory and is going to be executed by the
PLC at hand.
Minimum hardware and software Requirements to develop ladder logic control
programs
In order to modify or edit a program, you need the following.
1234-
PLC
Programming device
Programming software
Connector cable
A programming device (PG) is needed to enter, modify, and troubleshoot the
PLC programs, or to check the condition of the process. Once the program has been
entered and the PLC is running, the PG may be disconnected. It is not necessary for the
PG to be connected for the PLC to operate. A PG on the other hand can be used to
monitor the PLC program while the program is running. Programming devices come in
three types: hand-held, dedicated desktop, and computer.
Software
Many companies such as Siemens and Rockwell Software have developed
software for programming PLCs. A software program, running on a PC, may be used to
create a program for the PLC. This programming software is typically specific to one
PLC or family of PLCs. As an example, RSLogix software created by Rockwell
Software for programming the Allen-Bradley family of PLCs. This software in various
versions, can be used to program PLC-5, SLC 500, or the MicroLogix family of
21
processors. It is Microsoft Window based and very user friendly. The S7-200 also uses
a windows-based program called step 7-micro/Win32 , which may be installed on a PC
in the same way as any computer software.
Cables
A special cable is needed when a personal computer is used as the programming
device to download the developed programs into the PLCs memory. This cable, called a
PC/PPI cable, allows the serial interface of the PLC to communicate with the serial
interface of a PC. Some of these connecting cables have DIP switches on the PC/PPI to
select the appropriate speed (baud rate) for passing information between the PLC and
computer.
The S7-200 and Allen-Bradley MicroLogix 1500 Micro PLCs
Examples of basic programming techniques of typical PLCs are discussed and
illustrated in this section of this manual. For the sake of educational purposes, Many of
the examples used in the text are based on the Allen-Bradley MicroLogix as well as the
S7-200 micro PLC which the smallest member of the SIMATIC family of programmable
controllers . These two manufacturers are considered to have a large share of U.S.A and
Europe PLC market accordingly.
In both controllers, the CPUs are integral to the motherboards and inputs and outputs
connect them to the system being controlled. The inputs monitor field devices, such as
switches and sensors. Outputs control devices such as contactors, signal lamps or pumps.
The programming port is used to connect to the programming device.
22
PLC Models
There model descriptions published by manufacturer of any brand of PLC which
gives the end user information about the CPU types, power supplies available to model.
Model description also indicates the type of inputs / outputs (if they are relay type or
transistor ones, AC or DC.). Other features related to each PLC such as amount of
memory, data backup time, number of I/O and expansion modules available for each
model can also be obtained from the said documents.
23
Optional Cartridge
The S7-200 provides a super capacitor that maintains the integrity of the RAM
after power has been removed. Depending on the model of the S7-200, the super
capacitor can maintain the RAM for several days. The S7-200 also supports an optional
cartridge that extends the amount of time the RAM can be maintained after power has
been removed from the S7-200. The battery cartridge provides power only after the super
capacitor has been drained.
Expansion modules
S7-200 PLCs are expandable and various expansion modules are designed to give
these PLCs extra capacity to add additional digital/analog inputs, outputs and other
functions such as protecting over-voltage analog input modules.
Expansion modules are connected to the base unit with a ribbon connector.
The number of expansion modules that one can connect it to a PLC also depends on the
model of that particular PLC. For example for S7-200 CPU 224 the limit is maximum
number of 7 units and even then one needs to check the power budget to be sure he does
not overload the CPU power output. Check specification sheets when it comes to
expansion modules.
Understanding controller Status Indicators
The controller status LEDs provide a mechanism to determine current status of the
controller if a programming device is not present or connected. When yellow one is on, it
means CPU is in the STOP mode. When the mode is set t to RUN, the green RUN
indicator will be lit. Red led means system is in fault status. Activation of any terminals
of input or output will cause the related Green led to be turned on. Application of these
indicators is very useful when testing or debugging control logic ladder programs. See
figure 33.
Figure 33
24
PLCs usually can be installed inside of cabinets in one of two ways. The base
unit and expansion I/O DIN rail latches lock in the open position so that an entire system
can be easily attached to or removed from the DIN rail. Most PLCs also have holes on
panel which can be used to mount the PLC inside the any control cabinet.
Figure 34
Figure 35
25
Figure 36
I/O Numbering
The inputs and outputs are all identified by their addresses, the notation used
depending on the PLC manufacturer. These addresses are used by the CPU to determine
which inputs are present and which outputs need to be turned on or off. This is the
address of the input or output in the memory of the PLC. Siemens precedes input
numbers by I and outputs by Q. The first number in the designator identifies the byte, and
the second number the bit, of the I/O address. With the Siemens SIMATIC, the inputs
and outputs are arranged in groups of 8. Each 8 group is termed a byte and each input or
output with an 8 is term a bit Thus, Q2.0 means an output at bit 0 in byte 2. With larger
PLCs having several racks of input and output channels, the racks are numbered. With
the AB, the rack containing the processor is given the number 0 and the addresses of the
other racks are numbered 1, 2, 3, etc. according to how set-up switches are set. So, in
input address I:012/03 for example, I indicates an input, rack 01, module 2 and
terminal 03.
26
Inputs
Input devices, such switches, pushbuttons, and other sensor devices are connected
to the terminal strip under the bottom cover of the PLC. In figure 37, two pushbuttons,
proximity sensor and limit switch, all are considered as input devices.
Figure 37
Outputs
The output ports of a PLC are of the relay type or opto-isolator with transistor or
TRIAC types depending on the devices connected to them which are to switched on or off.
These output devices are connected to the terminal strip located under the top cover of
the S7-200 PLC. When testing a program, it is not necessary to connect output devices.
The LED status indicators on if an output is active. In the following figure, the red
signal lamp and the contactor to power motor are considered as output devices.
Figure 38
27
Super Capacitor
The Super capacitor is an electrochemical energy storage applied in power
industries. Compared with battery, a super Capacitor has one-tenth of energy, but delivers
over 10 times power due to ultra low ESR (Equivalent Series Resistance). They also have
a much higher power density than batteries or fuel cells. These capacitors can provide
backup power for maintaining charge for a long period of time and protect data stored in
PLCs RAM during power losses. The RAM is typically backed up for 50 hours on the
S7-221 and 222, and for 72 hours on the S7-224 and 226.
PLC Reference Manuals
A reference manual is a document often organized aphetically, designed as a
quick reference for experience users. A reference manual typically contains the most
frequently referenced subset of information including basic setup instructions,
troubleshooting for the most commonly encountered problems, and or prominent
features. Both Siemens and AB have lots of information in their websites regarding their
line of products.
www.ab.com
ab.rockwellautomation.com/Programmable-Controllers
www.siemens.com/
www.automation.siemens.com/_en/s7-200/index.htm
www.automation.siemens.com/.../simatic-s7.../s7-200/.../Default.aspx
28
Allen Bradley 2711-B5A2 PanelView 550 monochrome Terminal 5.5 inch, Keypad &
touch screen, DH-485 communication Ports, AC power, Series F. combination for
convenient and flexible operator input: RS232 printer port, alarms, alarm lists, triggered
messages, and triggered states of a multi state indicator, field-replaceable backlights.
AB 1201-HJ2 programming terminal LCD Display
Siemens LOGO! Text display 6ED1 055-4MH00-0BA0
The new LOGO! TD text display panel provides an affordable HMI for equipment
builders and their customers, even on the simplest relay control systems. By having a
display panel with built-in operator functions and diagnostic messages customized for
their process, end users can now make quick adjustment or easy troubleshoot.
Siemens TD200
The Siemens TD 200 is the proven HMI device for the SIMATIC S7-200. In
addition to the display of alarm texts, it enables interventions in the control program (e.g.
set point value changes) or the setting of inputs and outputs. The TD 200 is suitable for
simple operation tasks with the SIMATIC S7-200 PLC. The focus is on the display of
alarm texts. The low total height and device depth make it the unit of choice even in
cramped space conditions.
Computer network
A computer network is a collection of hardware components and computers
interconnected by communication channels that allow sharing of resources and
information. The SIMATIC S7-200 micro PLC provides a full range of communication
capabilities. The integrated RS485 interfaces can be operated at data transmission rages
from 1.2 to 187.5 k. baud. A total of 31 units can be interconnected using a
communication cable.
PROFIBUS connection
All CPUs from 222 upwards can be run via the EM277 communications modules
as a norm slave on a PROFIBUS DP network with a transmission rate of up to 12 Mbit/s.
the open feature of the S7-200 to higher level PROFIBUS DP control levels ensures you
can integrate individual machines into your production line. With the EM277 expansion
module, you can implement PROFIBUS capability of individual machines equipped with
S7-200.
Powerful AS-Interface connection
The CP 243-2 turns all CPUs from 222 upwards into powerful masters on the ASinterface network. According to the new AS-interface specification v 2.1, you can
connect up to 62 stations, making even analog sensors easy to integrate. With ASinterface, you can connect up to 62 stations, making even analog sensors easy to
integrate. With AS-interface, you can connect up to 248 DIs + 186 DOs in the maximum
configuration. The max, number of 62 stations can include up to 31 analog modules. The
configuration of the slaves and reading/writing of data is supported by the handy ASinterface Wizard.
29
Figure 39
Figure 40
30
Figure 41
Figures 42 & 43 show a few possible inputs & output devices accordingly. A few
possible inputs including (from left to right), proximity switch, limit switch, floater
switch, limit switch, 3 different types of pushbuttons.
Figure 42
Next figure shows a few possible output devices. A few possible outputs including (from
left to right), contactor, motor, solenoid valve, signal light, pump, and pneumatic valve.
31
Figure 43
Following are 2 representative examples of PLC programming using contacts and coils.
For these examples, both PLC and relay logic solutions are shown.
EXAMPLE 1
The first example is a simple circuit with one toggle switch as a contact and one output as
a Lamp. As the switch is pressed or not, the output goes on or off (figure 44). Next two
figures show the relay logic (45B) and ladder logic (45C) diagrams.
Figure 44
32
Figure 45
EXAMPLE 2
The second example is a start / stop seal-in circuit. When the start button is
pressed, the coil energizes. When the button is released, the coil remains on. It is held on
by a sealing contact that is in parallel with the start button. The seal contact closes when
the output coil goes on. If the stop button is pressed, the coil goes off and stays off. Also
if the control power goes off, the coil goes off too. The advantage of this example over
the first one is that when failed control power returns, stat pushbutton must be pressed to
reenergize the coil.
33
34
Figure 49
OR function
Figure 50
35
Latch Function
This function has lots of application. Lets assume we wish to have a circuit
that anytime inputs S1 and S2 to be activated, K1 > ON and if S1 = 0 (OFF), K1 stays
ON (activated). K1 becomes un-activated if S2 = OFF (open). This function is used to
start electric motors in industry fields. In practice, a normally open switch is used instead
of S1, and a normally closed switch instead of S2.
In figure 44 notice that Q2.0 is used as parallel contact to I0.1 or in motor circuit, K1 is
used as a parallel contact to switch S1. Usually, most contactors or relays, have some
extra contacts that could be used with the same name (of the contactor) in the circuit
diagrams. As an example, K1 represent a contactor coil which is activated with say
120/240 volt AC. It has also an extra contact which is parallel to S1 switch (which also
labeled as K1).
Notice that only one bit of memory is allocated to each contact (or addresses such as
Q2.0) anytime as an example I0.1 = 0 means it is OFF or I0.1 = 1, it is ON. Since any
PLC usually has many banks of memory, therefore, a large number of contacts are
available to a software developer to use.
Inverse function
36
Figure 53
The NOT gate is an electronic circuit that produces an inverted version of the
input at its output. It is also known as an inverter. If the input variable is A, the
with a bar over the top.
inverted, output is known as NOT A. This is also shown as
In ladder logic programming, we may use a normally close contact, to simulate the
Inverse function. Figure 53 displays the how contact I0.3 represents inverse function of K
in the given LDA or STL software program.
FBD (Function Block Diagram) programming language
Figure 54
37
Figure 56
A PLC can only scan its input ports and register if any of them it is HIGH or
LOW , but it has no way to know if a NO or NC pushbutton is connected to any of its
input port. As an example, in figure 57, if S1 in CKT 1 is depressed, light bulb turns on
and turns off if it changes its state.
In the second circuit, (CKT2) again if we download USER PROG. 1 and execute it and
then depressed SP, light bulb goes on and turns off if pushbutton is de-activated.
BUT notice if we download the second USER PROG. 2 and execute it, as soon as PLC
starts to execute the program, light bulb turn on and stays on as long as pushbutton is not
touched otherwise, it turn off. So the conclusion is that with the same pushbutton, (an
input device), we get different result just by changing the software and this is beauty of
using a PLC in control processing circuits.
38
Figure 57
Figure 58
A conversion example
The example is about a motor control circuit with two start and stop pushbuttons.
When any of the two start button is depressed, the motor runs. By sealing, it continues
to run even when the start button is released. Depressing any of the two stop
pushbuttons, causes the motor to stop running. Figures 59, 60, 61 and 62, illustrate the
solution in four different formats: (59) Gate logic (60) Boolean expression. (61) Relay
logic (62) PLC logic (LDA)
39
Figure 59
Figure 60
Figure 61
Figure 62
Example 1 is a start/stop seal- in circuit. When the start (I0.0) button is depressed,
the coil (LED in figure 1-48) turns on. When it is released, the coil remains on. It is held
on by a sealing contact that is in parallel with the start button. The seal contact closes
when the output coil goes on. If the stop button is depressed (I0.1), the coil goes off and
stays off. Also, if the control power goes off, the LED (coil) goes off. When failed power
returns, start button (I0.0) must be depressed to reenergize the coil. Figure 54 illustrates
the circuit in Gate Logic and LDA version of the given example1.
40
Figure 63
Figure 64
As it was mentioned previously, the origin of PLCs are in the use of relays to
perform automatic functions and the wiring diagrams for relay logic circuits witch
resembled a ladder. In fact, PLCs replace the physical relays with imaginary ones that
are part of the written control program being executed within a PLC. PLCs input/output
terminals are physically connected to a set of input/output field devices such as sensors or
switches and control the on or off status of the output contacts. The control program
within the PLC determines the way the inputs control outputs. As it was illustrated in
figure 21, there are few methods of programming a PLC and in this book we will use
LDA and FBD format of programming.
Status Functions
After a program has been loaded and is running in the PLC, the status of ladder
elements can be monitored using the STEP 7-micro/WIN32 software. The standard
method of showing ladder elements is in the de-energized or non-operated state. When
viewing ladder diagrams in status mode, control elements that are active are highlighted.
Figure 65
41
Figure 66
Force Function
Many PLCs have the capability to carry out a FORCE function. The function is
essentially an override control that is considered as another useful tool for program
debugging. When turned on, it can lead to feeding the process program with incorrect
information. It is used to temporarily override the input or output status of the
application during testing. It can be used to override discrete output points or to skip
portions of a program. The function must be used with utmost caution in conjunction with a
working process. Figure 67 shows in our test circuit, toggle switch is off, hence I0.0 =
off so Q0.0 = 0 or off.
Figure 67
Circuit in figure 68 shows the same circuit but this time by use of Force function, I0.0 is
turned on so the AND circuit consisting of I0.0 and I0.1 is set to 1 therefore, Q0.0 = 1
and the lamp which is wired to Q0.0 output is turned on or set to 1. As you noticed, in
figure 68 turning FORCE on, changed the statues of the contact (I0.0 = 1) on.
42
Figure 68
You noticed that turning FORCE function on, changes the status of a contact or
coil. Meaning If it is a normally open contact, it will close (turn on), and if it is normally
closed contact, it will open (turn off). If you force a coil or function, it will go on when
forced. See figure 69.
Figure 69
Sequence
For the simple lamp circuit, the following is the sequence of events. Using its
program, the CPU scans the inputs. When it finds the switch open, I0.0 receives a binary
0. This instructs Q0.0 to send a binary 0 to the output module. The lamp remains off.
When the switch is closed, I0.0 receives a binary 1, which instructs Q0.0 to send a binary
1 to the output module. This turns the lamp on.
43
Figure 70
Figure 71
Figure 72
44
of CR to close. See figure 73. Hence, when START pushbutton is released, motor is
going to continue being ON. See figure 74.
Figure 73
45
Figure 75
46
Figure 76
Figure 77 shows the circuit status when START toggle switch is activated.
Figure 77
As explained circuit in figure 77, when toggle switch is pressed, current flow through
AND circuit consisting I0.1, I0.0 and I0.2. All these three inputs are used in AND
configuration to control Q0.0. Also, a normally open set of contacts associated with Q0.0
is programmed to form an OR circuit. Output Q0.0 is used to control the motor starter.
Expanding the previous problem
Now that we have mastered writing Ladder Logic programming, lets do another
one with a little more number of inputs and outputs devices wired to our simple PLC.
There is a mach table which has three pushbutton switches S1, S2 and S3. Design circuit
diagram and control program such that if these switches be hit at the same time, only the
one which is hit first, to be turned on. Figure 78 shows the relay logic of the problem.
47
Figure 79 the related Ladder Logic program, and finally figure 80 the connection of field
devices to the PLC.
Figure 78
Figure 79
Figure 80
48
Application Example
Figure 81 shows that a typical expansion module is connected to a PLC via a flat
cable. RTD is a field device that can be used to measure a varying value that in our case
is current. Inside circuitry of the expansion device is such that it applies small amount
of voltage to RTD and measures the related current. It then based on the measurement,
calculates the temperature value. Based on the control ladder logic program, PLC make
to decision what to do based on the calculated temperature value.
49
Figure 81
Figure 82
50
Figure 83
According to the timing chart (On Delay timer), when switch is pressed, input
voltage I (enable signal (L1) is applied to timer TR1, timing delay t1 begins (next figure
b). Relay contacts T changes state after time delay is complete (lets assume
predetermined value for t1 = t2 = 10 seconds). Terminal # 1 connects to terminal # 3 and
lamp turns on (120 VAC is applied to the Lamp). Contacts T return to their shelf state
when input voltage T is removed. Lamp turns off. When I is applied again, after t2= 10
seconds, Lamp turns on and stays on as long as switch is pressed. Lamp turns off as soon
as switch is released.
51
Timers are represented by boxes in ladder logic. When a timer receives an enable signal,
it starts timing, and continuously compares its current time with a preset time. The
timers output is logic 0 as long as the current time is less than the preset time. When the
current time exceeds the preset time, the output changes to logic 1.
A-B Timer On- Delay (ladder logic symbol and function)
An on-delay timer will wait for a set amount of time (preset value e.g. 20 seconds
in above figure) after a line of ladder logic has been true (Timer on Delay input) before
turning its output on (EN), and it will stay on as long as the line of ladder logic stays at
its true status (as long as Timer On Delay = 1).
Figure 85 shows that the timer consists of a timing block containing TIMER address
T4:0, TIM BASE which is set to 1.0 second, the PRESET value which is 20 seconds
and finally ACCUM which is = 0.
T4:0 is the timer format in which.
T Identifies this as a timer file
4 This is timer file 4 (default file)
0 This means timer 0 in file 4 which can be any number from 0 to 255.
In this case, there are 256 timers available in file 4 for the programmer to use
52
Figure 87
In winter, you have noticed that any time electric heater is turned off (by the house
thermostat), the blower fan motor dos not turn off right away. Instead, it stays on for
about 5 more minutes after the motor is turned off already and then it is turned down
automatically by the external circuit.
This is a five-minute off delay timer. The 5 minute timing cycle begins when the
blower motor is turned off.
53
Figure 88 ladder logic program developed Using TON & TOF timers
54
Figure 89
55
The Siemens S7-200 PLC uses also three types of timers: On-Delay (TON),
Retentive On-Delay (TONR), and Off-Delay (TOF). They are provided with resolutions
of 1 millisecond, 10 milliseconds, and 100 milliseconds, making the maximum counts
32.767 seconds, and 327.67 seconds, and 3276.7 respectively.
The total number of these Timers is 256 with different resolution of 1 ms (4 timers), 10
ms (16 Timers), and 100 ms (236 Timers).
Figure 91
According to Timer table illustrated in above in figure 91, should we need a TON timer
with 10 ms resolution, we can use Timers with numbers T33 to T36, or T97 to T100.
S7-200 On-Delay Timer (ladder logic symbol and function)
According to the above figure, S7-200 timers are controlled with a single enabling input
and have a current value that maintains the elapsed time from the time that the timer was
enabled. The timers also have a preset time value (PT) that is compared to the current
value. A timer bit is set/reset based upon the result of this comparison. When the current
value is greater than or equal to the preset time value, the timer bit (T-bit) is turned on.
Otherwise, the T-bit is turned off. Timing stops when the current value reaches a
maximum value. When a timer is reset, its current value is set to zero, and its T-bit is
turned off.
56
Figure 93
According to the above figure, when the enabling input (I0.0) turns on, the timer
bit turns on immediately, and the current value is set to 0. When I0.0 turns OFF, the timer
counts until the elapsed time reaches the preset time (PT). When the preset value =
current value, the timer bit turns OFF and the current value stops counting.
57
Figure 95
S7-200 Retentive On- Delay Timer (ladder logic symbol and function)
Figure 96
TONR timer functions similar to TON timer except in the cases when an OnDelay timer current value is cleared when the enabling input is OFF, while the current
value of the Retentive On-Delay Timer is maintained when the input is OFF. Hence one
can use a TONR timer to accumulate time for multiple periods of the input ON. A Reset
instruction R is used to clear the current value of the TONR timer.
Exercise 1
Write a program that when S1 is activated, after elapse of 5 seconds, output of the TONR
timer Q0.0 = 1. I0.7 is a simple on-off switch.
According to Timer Table, T0 is a Retentive on delay timer with resolution = 1 ms.
Solution
58
Figure 97
Counters
A counter allows a number of occurrences of input signals to be counted. This
might be in a situation where items pass along a conveyor belt and a specified number
have to be diverted into a box. It might be counting the number of revolutions of a shaft,
or perhaps the number of people passing through a door.
A-B SLC 500 and Siemens S7-200 COUNTERS
Depending on the Counter application, we have two types of counters designed to
serve the same function as the mechanical counters.
Generally speaking, 2 types of counters are:
1- Up-counter (CTU)
2- Down-counter (CTD)
AB counters are programmed almost exactly like AB timers discussed previously.
There is counter number, a preset, and an accumulated value. The counters are numbered
similar to timers except it begins with a C instead of T. Allen Bradley SLC 500
and MicroLogix counter addressing is outlined as follows:
C5:3
C identifies the instruction as a counter file
5 the default file number (any unused file number from 10 to 255 can be assigned).
MicroLogix is limited to one counter file, which is default file 5. Hence, it is limited to
40 counters (0 to 39). SLC 500 can use files 0 to 255.
:3 : and number 3. Colon separates file number (5) from counter number which is # 3
this can be any number. There are 256 counters in each file number. In our case, C5:3 is
the forth counter from counter file 5. Each counter is an element and like timer, each
counter element is consists of 3 words:
59
Figure 98
Figure 99
2- Down-counter (CTD)
Count Down Enable Bit (CD)
CD >1 as long as counter rung is true. Hence with positive going edge of I0 (false
to true transition), notice that CD is also set to 1 and stays ON as long as the counter rung
60
is true. Leading edge of I0 sets CD > 0 or false. Also notice that anytime rest instruction
is executed by activating input device I1 (0 to 1 transition), ACC> 0.
Count Down Done Bit (DN) > 1 or true as long as Accumulated value > or = Preset
value. Count Down Underflow Bit (UN) >1 any time ACC exceeds lower limit of < 32,768. In this case, with the next activation of I0, UN is set to 1 and the next value of
ACC is going to be 37,767.
Count Down Enable Bit (CD)
CD > 1 as long as counter rung is true. Hence with positive going edge of I0
(false to true transition), notice that CD is also set to 1 and stays ON as long as the
counter rung is true. Leading edge of I0 sets CD > 0 or false. Also notice that anytime
rest instruction is executed by activating a reset input, (0 to 1 transition), ACC> 0.
61
62
Figure 102
Sample problem
In next figure, when CTU instruction receives 12 pulses on the rising edges of the CU
input (I0.0), C0 (counter bit) is activated and thus, Q0.0 = 1.
Figure103
Figure 104
63
Sample problem
In the next sample problem, CTD instruction counts down from the preset value
(PV = 12) on the each rising edges of CD input till it equals to 0. And when current value
equals to = 0, C0 (current bit) turns on and Q0.0 = 1. LD input is to reset the Counter.
Figure 105
Figure 106
Sample Problem
64
Figure107
Interrupt function
An interrupt is a signal that causes the PLC to stop the current program forcing it
to execute another program immediately regardless of where the scan currently is .
Meaning the PLC immediately stops what its doing and executes an interrupt routine.
After it is done executing the interrupt routine, it goes back to point where it left off and
continues on with the normal scan process. Hence, Interrupts are another example of
instructions that must be executed before the PLC completes a scan cycle.
65
Figure 108
Figure 109
66
In figure 109, top shows the average voltage applied to the Load with the shown duty
cycle. In the bottom, it shows how the output Q0.1 PWM voltage is amplified and applied
to the DC motor. Figure110 illustrates the equations to calculate the Average voltage,
duty cycle, period, and frequency.
Figure 110
Voltage of 110 VAC @ 60 HZ is with duty cycle of 20% is applied to a resistive load.
Calculate the average voltage and period of the voltage applied to the load.
Average voltage is = (20/100) 110 = 2/10 x 110 = 22 Volt
F = 1/Period 60 cycle /Second = 1/period
Period = 1/60 second = 1000 ms/60 = ~ 16.66 ms
Transmit function
The Transmit blocks send Modbus messages from a "master" PLC to multiple
slave PLCs or sends ASCII character strings from the PLCs Modbus slave port to
ASCII printers and terminals. The function can send these messages over telephone
dialup modems, radio modems, or simply direct connections. The Transmit blocks
perform general ASCII input functions in the communication mode including simple
ASCII and terminated ASCII. You may import and export ASCII or binary data into your
PLC. The block has built in diagnostics that checks to make sure no other Transmit
blocks are active in the PLC on the same port. Within the Transmit blocks, control inputs
allows you to control the communications link between the PLC and DCE (Data
Communication Equipment) devices attached to Modbus ports of the PLC. The Transmit
blocks do
NOT activate the port LED when transmitting data. Transmit allows communication with
external devices, such as modems, printers, and computers, via the serial interface.
Modbus is a serial communications protocol published by Modicon in 1979 for use with
its PLCs. Simple and robust, it has since become one of the de facto standard
communications protocols in the industry, and it is now amongst the most commonly
available means of connecting industrial electronic devices.
http://www.alamedaelectric.com/Modicon
http://kernow.curtin.edu.au/www/plc/3STANDAR.HTM
67
Figure 111
68
Figure 112
SIMATIC S7-200 from CPU 222 upwards has functionality as AS- interface master via
AS-interface module (AS-Interface master CP 243-2 max. 2 modules). Figure 113
illustrates an AS-I network of S7-200 PLC participating as a master module.
Figure 113
69
Definition of terms
What is a Sensor?
A Sensor is a device, which responds to an input quantity by generating a
functionally related output usually in the form of an electrical or optical signal.
During the past two decades, there has been an unprecedented growth in the number of
products and services, which utilize information gained by monitoring and measuring
using different types of sensors. The development of sensors to meet the need is referred
to as sensor technology and is applicable in a very broad domain including the
environment, medicine, commerce and industry.
What is an actuator?
An actuator is a transducer that accepts a signal and converts it to a physical
action. In other words, an actuator causes an action to occur relating to the data that was
sent to it. Data written to an actuator is held in an input register until the trigger is
received.
What is a TEDS?
A Transducer Electronic Data Sheet is known as a TEDS. It is a set of electronic
data in a standardized format stored in a chip that is attached to a transducer, therefore
allowing the transducer to identify and describe itself to the network, thereby easing
automatic system configuration. This self-identification capability for the transducer is
needed for maintenance, diagnostics, and to determine mean-time between failure
characteristics. The chip stores information such as manufacturer name, identification
number, type of device, serial number, as well as calibration data. The TEDS can be
uploaded to the system upon power up or request. It also serves as documentation for the
transducer.
What is a transducer?
A transducer basically converts a kind of energy or some kind of incoming energy
into some kind of electrical signal. Now the energy might be something like a movement
or sound or light, those are the kinds of energies we're talking about. Obviously the most
common ones which are used nowadays are the light sensitive components like photo
diodes, photocells. These directly convert the incident light into an electrical signal
which can be used to well for example detect how bright light is. A photo diode in a
camera detects how bright it is so that the camera's automatically set. You also have
sound sensing devices, these sound devices are often used again in for example an
automatic camera, an automatic recorder so that as the sound gets louder, it reduces the
amplification so that it doesn't make the sound particularly difficult to listen to.
Movement sensors obviously with many experiments in laboratories we like to detect
movement and movement can be detected either physically by using a sensor and
physically measuring the distance, it could be a distance sensor or it could be something
sensing that there is a movement and give you a signal accordingly.
70
Opto-isolator
Also called an optocoupler, photocoupler or optical isolator, is an electronic
device designed to transfer electrical signals by utilizing light waves to provide coupling
with electrical isolation between its input and output. Figure 114 displays an input
module in which two opto-isolators are used in its structure.Usually input signals are 24
VAC or VDC. Any of these signals go through a current limiter resistor, a LED and
finally connects to input of an Optocoupler (such as IC 4N25 made by VISHAY).
What is a TRIAC?
The TRIAC is a three terminal semiconductor device for controlling current. It is
effectively a development of the SCR or thyristor, but unlike the thyristor which is only
able to conduct in one direction, the TRIAC is a bidirectional device. Figure 115 displays
the TRIAC symbol. The symbol recognizes the way in which the TRIAC operates. Seen
from the outside it may be viewed as two back to back thyristors. This is what the TRIAC
symbol indicates.
Figure 115
What is a LED?
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as
indicator lamps in many devices and are increasingly used for other lighting. LEDs, are
real unsung heroes in the electronics world. They do dozens of different jobs and are
found in all kinds of devices such as numbers on digital clocks, transmit information
from remote controls, light up watches and tell you when your appliances are turned on.
71
Collected together, they can form images on a jumbo television screen or illuminate a
traffic light.
72