100% found this document useful (1 vote)
253 views244 pages

Chapter 6 PLC Basics

plc presentation

Uploaded by

blackemmanuel591
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
253 views244 pages

Chapter 6 PLC Basics

plc presentation

Uploaded by

blackemmanuel591
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 244

Chapter 6

Programmable Logic
Controller
6.1 Introduction to Programmable Logic
Controllers
6.2 PLC Hardware
6.3 Fundamentals of PLC Programming
6.4 PLC Wiring Diagrams and Ladder Logic
Programs
6.5 Timers

6.6 Counters
SIMATIC STEP 7 Safety Advanced V15.1 –
TRIAL - ID: 109759618 - Industry Support
Siemens
6.1 Introduction to Programmable Logic Controllers

6.1.1 What is Programmable Logic Controller

A PLC is a special form of


microprocessor-based controller
that
uses programmable memory to
store instructions and
to implement functions such as
logic, sequencing, timing,
counting, and arithmetic in order to
control machines and processes.
Initially the PLC was used to replace relay logic

PLC is small and inexpensive compared to equivalent


relay-based process control systems .

Relay based control panel


Initially the PLC was used to replace relay logic

PLC based control panel


PLCs provide many other benefits including:
• Increased Reliability
• More Flexibility
• Lower Cost.
• Communications Capability.
• Faster Response Time.
• Easier to Troubleshoot.

• Easier to Test Field Devices.


6.1.2 Basic Functional Components of a PLC

Typical parts of a programmable logic controller.


Typical parts of a programmable logic controller.
Fixed I/O configuration.
Modular I/O configuration
Typical PLC scan cycle.
Typical PLC input/output (I/O) system connections.
Typical PLC input/output (I/O) system connections.
Typical PC software used to create a ladder logic program.
6.1.3 Principles Operation of PLC

Mixer process control problem


Process control relay ladder diagram.
Typical wiring connections for a
120 VAC modular configured input module.
Typical wiring connections for a
120VACmodular configured output module
Process control PLC ladder logic program with
typical addressing scheme.
Relay ladder diagram for the modified process.
PLC installed in an industrial environment.
Review questions

1. What is a PLC?
The term PLC stands for what?
2. Draw a block diagram showing in very
general terms the main parts in a PLC and
explain the main function of each part.
3. List six distinct advantages that PLCs
offer over conventional relay-based
control systems.
4.Answer the following with reference to the process control relay
ladder diagram of Figure :
a. When do the pressure switch contacts close?
b. When do the temperature switch contacts close?
c. How are the pressure and temperature switches connected with
respect to each other?
d. Describe the two conditions under which the motor starter coil
will become energized.
5. Answer the following with reference to the process control PLC ladder
logic diagram of Figure :
a. What field device is the number I/2 identified with?

b. What field device is the number O/1 identified with?

c. What two conditions will provide a continuous path from left to right
across the rung?

d. Describe the sequence of operation of the controller for one scan of the
program.
6. Given two single-pole switches, write a
program that will turn on an output when
both switch A and switch B are closed.
7. Given two single-pole switches, write a
program that will turn on an output when
either switch A or switch B is closed.
8. Given four NO (Normally Open)
pushbuttons (A-B-C-D), write a program
that will turn a lamp on if pushbuttons A
and B or C and D are closed.
9. Write a program for the relay ladder diagram shown in the
Figure.
Homework

Write a program for the relay ladder diagram shown in the


Figure.
6.2

PLC Hardware
Objectives
• • List and describe the function of the hardware
components used in PLC systems
• • Describe the basic circuitry and applications for
discrete and analog I/O modules
• • Explain I/O addressing
• • Describe the general classes and types of PLC
memory devices
• • List and describe the different types of PLC
peripheral support devices available
6.2.1 The I/O Section
The input/output (I/O) section of a PLC
is the section to which all field devices
are connected and provides the
interface between them and the CPU.
6.2.2 Discrete I/O Modules

Discrete input and


output devices.
Discrete AC input module block diagram.
Simplified diagram for a single input of a discrete AC input
module.
Discrete input modules perform four
tasks in the PLC control system :
1. Sense when a signal is received from a field
device.
2. Convert the input signal to the correct voltage
level for the particular PLC.
3. Isolate the PLC from fluctuations in the input
signal’s voltage or current.
4. Send a signal to the processor indicating which
sensor originated the signal.
Discrete AC output module block diagram.
Simplified diagram for a single output of
a discrete AC output module.
Discrete output modules are used to turn field output devices
either on or off.

These modules can be used to control any two-state device,

they are available in AC and DC versions and in various


voltage ranges and current ratings.

Output modules can be purchased with transistor, triac,


or relay output 。
Figure Relay, transistor, and triac switching elements

Transistor outputs can be used only for control of DC devices.

Triac outputs can be used only for control of AC devices 。

Relay outputs can be used with AC or DC devices 。


6.2.3 Analog I/O Modules

Analog devices represent physical quantities that can have


an infinite number of values.

Typical analog inputs and outputs :


0 ~ 20 mA;
4 ~ 20 mA;
0 ~ 10 V.

Common physical quantities measured by a PLC analog


module include temperature, speed, level, flow, weight,
pressure, and position.
Analog input and output to a PLC
Figure: Analog input module circuit
A transducer converts a field device’s variable (e.g., pressure,
temperature etc.) into a very low-level electric signal (current
or voltage) that can be amplified by a transmitter and then
input into the analog module.
The PLC controls the
amount of fluid
placed in a holding
tank by adjusting the
percentage of the
valve opening.
The analog output
from the PLC is
used to control the
flow by controlling
Figure: Typical analog I/O control
the amount of the
system.
valve opening.
As the fluid level in the tank approaches the preset point,
the processor modifies the output, which adjusts the valve
to maintain a set point.
6.2.4 Special I/O Modules
It is used to provide an
interface for applications
requiring counter speeds
that surpass the
capability of the PLC
ladder program.
It is used to count pulses
from sensors, encoders,
and switches that
operate at very high
High-speed counter module
speeds.
A typical count rate
available is 0 to 100
kHz.
Thumbwheel switch.

The thumbwheel module allows the use of thumbwheel


switches for feeding information to the PLC to be used in
the control program.
Encoder
An encoder-counter module allows the user to read the signal
from an encoder on a real-time basis and stores this
information so it can be read later by the processor.
Stepper-motor.
The stepper-motor module provides pulse trains to a stepper-
motor translator, which enables control of a stepper motor. The
commands for the module are determined by the control
program in the PLC.
6.2.5 The Central Processing Unit (CPU)
The CPU is built into single-unit fixed PLCs while modular types
typically use a plug-in module.
A processor module can be divided into two sections: the CPU
section and the memory section.
The CPU section executes the program and makes the
decisions needed by the PLC to operate and communicate with
other modules.
The memory section electronically stores the PLC program
along with other retrievable digital information.
The CPU executes the operating system, manages memory,
monitors inputs, evaluates the user logic (ladder program), and
turns on the appropriate outputs.
Sections of a PLC processor module
6.2.6 Memory
Memory is the element that stores information, programs, and
data in a PLC.

The user memory of a PLC includes space for the user program
as well as addressable memory locations for storage of data.

The program is stored in the memory as 1s and 0s.

Memory location refers to an address in the CPU’s memory


where a binary word can be stored.
Memory bit, byte, and word.
Input and output tables.
The memory of a PLC may be broken into sections that have
specific functions. Sections of memory used to store the status
of inputs and outputs are called input status files or tables and
output status files or tables.
Each bit is either a 1 or 0, depending on whether the input is
open or closed.
Memory Types
volatile
nonvolatile
Read Only Memory (ROM)
Random Access Memory (RAM)
Erasable Programmable Read-Only Memory
(EPROM)
Electrically erasable programmable read-
only memory (EEPROM)
Flash EEPROMs
6.2.7 Programming Terminal Devices

A programming terminal device is needed to enter, modify, and


troubleshoot the PLC program.
PLC manufacturers use various types of programming devices.

The simplest type is the hand-held type programmer.

The most popular method of PLC programming is to use a


personal computer (PC) in conjunction with the manufacturer’s
programming software .
Hand-held programming terminal
Personal computer used as the
programming device
6.2.8 Human Machine Interfaces (HMIs)

Human Machine Interface (HMI)

Human machine interfaces give the ability to the operator and


to management to view the operation in real time.
REVIEW QUESTIONS

1. What is the function of a PLC input interface module?


2. What is the function of a PLC
output interface module?
3.How does the processor identify the
location of a specific input or output device?
4. With reference to PLC discrete input
modules:
a. What types of field input devices are
suitable for use with them?
b. List three examples of discrete input
devices.
5.With reference to PLC discrete output
modules:
a. What types of field output devices
are suitable
for use with them?
b. List three examples of discrete
output devices.
6. With reference to the I/O image
tables:
a. What information is stored in PLC
input and
output tables?
b. What is the input status of a closed
switch
stored as?
c. What is the input status of an open
switch
stored as?
Homework

1. A personal computer is to be used to program


several different PLCs from different
manufacturers. What would be required?
6.3

Fundamentals of PLC Programming


6.3.1 Processor Memory Organization
The memory map for a PLC processor consists of
several areas, some of these having specific roles.

The memory space can be divided into two broad


categories: program files and data files.
Program files are the part of the processor memory that
stores the user ladder logic program.
The data files store the information needed to carry out
the user program.
I/O address format for the S7-200 family of PLCs
6.3.2 Program Scan
When a PLC executes a program, it must know—in
real time—when external devices controlling a
process are changing.

During each operating cycle, the processor reads


all the inputs, takes these values, and energizes or
de-energizes the outputs according to the user
program.

This process is known as a program scan cycle.


PLC program scan cycle
The time it takes to complete a scan cycle is called the
scan cycle time.

The scan time is a function of the following:


• The speed of the processor module
• The length of the ladder program
• The type of instructions executed
• The actual ladder true/false conditions
Overview of the data flow during the scan process
For each rung executed, the PLC processor will:
• Examine the status of the input image table bits.
• Solve the ladder logic in order to determine logical continuity.
• Update the appropriate output image table bits, if necessary.
• Copy the output image table status to all of the output
terminals. Power is applied to the output device if the output
image table bit has been previously set to a 1.
• Copy the status of all of the input terminals to the input
image table. If an input is active (i.e., there is electrical
continuity), the corresponding bit in the input image table will
be set to a 1.
Evaluating ladder logic rung conditions
• If the rung-condition-in to an input instruction is true, the
controller evaluates the instruction and sets the rung-
condition-out to match the results of the evaluation.
• If the instruction evaluates to true, the rung-condition-out is
true.
• If the instruction evaluates to false, the rung-condition-out
is false.
• If the rung-condition-in to an output instruction is true, the
rung-condition-out is set to true.
• If the rung-condition-in to an output instruction is false, the
rung-condition-out is set to false.
Scan process applied to a multiple rung program
Scanning can be vertical or horizontal.
S7-200 PLCs use the horizontal scan by rung
method. In this system, the processor
examines input and output instructions from
the first command, top left in the program,
horizontally, rung by rung.
6.3.3 PLC Programming Languages

The term PLC programming language refers to the method by


which the user communicates information to the PLC.

Standard IEC 61131 languages


associated with PLC programming.
Comparison of ladder diagram and
instruction list programming
Function block diagram equivalents to
ladder logic contacts
PLC ladder and equivalent function block diagram
Major elements of a sequential function chart program
PLC ladder and equivalent structured text program.
6.4 Bit-Level Logic Instructions

Normally open contact


Hardwired connections and
the associated instruction status
Normally closed contact ON
Hardwired connections and
associated instruction status.
Output-coil memory bit
Hardwired connections and
the associated instructions status.
Ladder logic diagram rungs
REVIEW QUESTIONS

1. a. What information is stored in the input


image table file?
b. In what form is this information stored?
2. a. What information is stored in the output
image table file?
b. In what form is this information stored?
3. Outline the sequence of events involved in
a PLC scan cycle.
4. List the five standard PLC languages as defined by
the International Standard for Programmable
Controllers, and give a brief description of each.
5. What instruction would you select for each of
the
following discrete input field devices to accomplish
the desired task? (State the reason for your
answer.)
a. Turn on a light when a conveyor motor is
running
in reverse. The input field device is a set of
contacts
on the conveyor start relay that close when
the motor is running forward and open when it is
running in reverse.
b. When a pushbutton is pressed, it operates a
solenoid.
The input field device is a normally open
pushbutton.
6. Write the ladder logic program needed to
implement each of the following (assume inputs
A, B, and C are all normally open toggle
switches):
a. When input A is closed, turn ON and hold ON
outputs X and Y until A opens.
b. When input A is closed and either input B or
C is open, turn ON output Y; otherwise, it should
be OFF.
c. When input A is closed or open, turn ON
output Y.
d. When input A is closed, turn ON output X and
7. Draw the equivalent ladder logic program
used to implement the hardwired circuit
drawn in Figure , wired using:
a. A limit switch with a single NO contact
connected to the PLC discrete input module
b. A limit switch with a single NC contact
connected to the PLC discrete input module
Homework

1. Assuming the hardwired circuit


drawn in Figure is to be
implemented using a PLC
program, identify
a. All input field devices
b. All output field devices
c. All devices that could be
programmed using internal relay
instructions
6.4

PLC Wiring Diagrams and

Ladder Logic Programs


6.4.1 Seal-In Circuits

Seal-in, or holding, circuits are very common in both


relay logic and PLC logic.
A seal-in circuit is a method of maintaining current flow
after a momentary switch has been pressed and
released.
The seal-in contact is usually in parallel with the
momentary device.
Hardwired and programmed seal-in circuit
Motor seal-in circuit implemented using a PLC
6.4.2 Electrical Interlocking Circuits

An electrical interlocking circuit is used to


prevent a piece of equipment from operating
under certain potentially hazardous or
undesirable conditions.
Sequential hardwired three motor relay control circuit
PLC program equivalent of the hardwired
sequential motor control circuit.
6.4.3 Motor Start and Stop Circuit

hard-wired motor start


and stop circuit
Motor Start
Motor Stop
Motor Starter Accomplished with
a PLC
The wiring and program
of Motor Starter
Motor Start with PLC
Motor Starter Include Indicator
The wiring and program of Motor Starter
Include Indicator
The wiring and program of Motor Starter
Include Indicator
Motor Starter Include
Limit Switch
The wiring and program
of Motor Starter Include
Limit Switch
The wiring and program of Motor
Starter Include Closed Limit Switch
6.4.4 Converting Relay Schematics into
PLC Ladder Programs
The best approach to developing a PLC program from a
relay schematic is to understand first the operation of
each relay ladder rung.
As each relay ladder rung is understood, an
equivalent PLC rung can be generated.

This process will require access to the relay schematic,


documentation of the various input and output devices
used, and possibly a process flow diagram of the
operation.
Relay schematic for the sequential process
Q0.0

I0.0

Q0.1

I0.1

Q0.2
I0.2

I/O connection diagram.


Output module
Input module Wiring connections
Wiring connections

Q0.0

I0.0

I0.1 Q0.1

I0.2

Q0.2

Sequential process PLC ladder logic program.


6.4.5 Writing a Ladder Logic Program Directly from
a Narrative Description
Steps in planning a program:
• Define the process to be controlled.
• Draw a sketch of the process, including all sensors
and manual controls needed to carry out the control sequence.
• List the sequence of operational steps in as much detail
as possible.
• Write the ladder logic program to be used as a basis for the
PLC program.
• Consider different scenarios where the process sequence
may go astray and make adjustments as needed.
• Consider the safety of operating personnel and make
adjustments as needed.
EXAMPLE
Figure shows the sketch of a drilling process that requires
the drill press to turn on only if there is a part present and the
operator has one hand on each of the start switches. This
precaution will ensure that the operator’s hands are not in the
way of the drill.
The sequence of operation requires that switches 1 and 2
and the part sensor all be activated to make the drill motor
operate.

Sketch of the drilling process.


Figure shows the ladder logic program required for the
process implemented using a S7-200 controller.

I0.0

Q0.0
Q0.0
I0.1

I0.2

Drilling process PLC program.


REVIEW QUESTIONS

1. a. Draw the schematic for an across-the-line AC magnetic


motor starter.
b. With reference to this schematic, explain the function
of each of the following parts:
i. Main contact M
ii. Control contact M
iii. Starter coil M
iv. OL relay coils
v. OL relay contact
2. Draw the electrical symbol used to represent each
of the following switches:
a. NO pushbutton switch
b. NC pushbutton switch
c. Break-make pushbutton switch
d. Three-position selector switch
e. NO limit switch
f. NC temperature switch
g. NO pressure switch
h. NC level switch
i. NO proximity switch
3. Design a PLC program and prepare a typical I/O connection
diagram and ladder logic program that will correctly execute the
hardwired control circuit in Figure .
Assume: Stop pushbutton used is an NO type.
Run pushbutton used is an NO type.
Jog pushbutton used has one set of NO contacts.
OL contact is hardwired.
4. Design a PLC program and prepare a typical I/O connection
diagram and ladder logic program that will correctly execute
the hardwired control circuit in Figure .
Assume: PB1 pushbutton used is an NO type.
PB2 pushbutton used is an NC type.
PS1 pressure switch used is an NO type.
LS1 limit switch used has only one set of NC contacts.
5. Design a PLC program and prepare a typical I/O connection
diagram and ladder logic program for the following motor
control specifications:
• A motor must be started and stopped from any one of three
start/stop pushbutton stations.
• Each start/stop station contains one NO start pushbutton and
one NC stop pushbutton.
• Motor OL contacts are to be hardwired.
Homework

1. Design a PLC program and prepare a typical I/O connection


diagram and ladder logic program for the following motor control
specifications:
• Three starters are to be wired so that each starter is operated
from its own start/stop pushbutton station.
• A master stop station is to be included that will trip out all starters
when pushed.
• Overload relay contacts are to be programmed so that an
overload on any one of the starters will automatically drop all of
the starters.
• All pushbuttons are to be wired using one set of NO contacts.
6.5

Timers
The most commonly used PLC instruction, after coils and contacts,
is the timer.
This chapter deals with how timers time intervals and the way
in which they can control outputs.
We discuss the basic PLC on-delay timer function, as well as
other timing functions derived from it,
and typical industrial timing tasks.
6.5.1 Timer Instructions
TON (Timer On Delay)—Counts time-based intervals when the
instruction is true.

TOF (Timer Off Delay)—Counts time-based intervals when


the instruction transitions from a true to false condition.

TONR (Retentive On Delay Timer)—Counts time-based intervals


when the instruction is true and retains the accumulated value
when the instruction goes false or when power cycle occurs.
6.5.2 On-Delay Timer Instruction

Principle of operation of an on-delay timer.


On-delay timer instruction.
PLC on-delay timer program.
Instantaneous contact instruction can be programmed
using an internally relay
Instantaneous contact instruction can be programmed
using an internally relay
Conveyor warning signal circuit.
Conveyor warning signal circuit.
Automatic sequential control system.
Automatic sequential control system.
Figure shows a ladder-logic diagram for the TON timer instruction. This
diagram assumes a normally open START push button (PB), a normally
closed
STOP push button, a timer preset (PT) value of 10 seconds, output
motor1
• The first network initially during the first scan, I0.0, is TRUE because the
STOP PB is wired high. Also, the START PB is FALSE because this switch is
normally open.
• Once the START PB is pressed, I0.1 becomes TRUE; this, in turn, makes
Q0.0 TRUE. Q0.0 is the output to MOTOR1 starter, which causes it to run.
The next scan, Q0.0, will latch the START PB and maintain the Q0.0 TRUE
status.
• The second network, Q0.0, is the input condition for the TON instruction,
which is TRUE. This timer has a preset time value of 10 seconds.
• The timer (TON) will start timing. After 10 seconds of delay, Q0.1 will turn
ON, causing MOTOR2 to run.
• Pressing the STOP PB at any time will cause MOTOR1 and MOTOR2 to
stop.
It also will stop the timer and reset its accumulated time register (ET).
This is a simple heat treat machine application.
The operator places a part in a fixture, then pushes the start
switch.
An inductive heating coil heats the part rapidly to 1500 degrees
Fahrenheit.
When the temperature reaches 1500, a discrete sensor’s output
becomes true.
The coil turns off, and a valve is opened which sprays water for 5
seconds on the part to complete the heat treatment (quench).
The operator then removes the part, and the sequence can begin
again.
Note there must be a part present or the sequence should not
start.
When the start button is pushed, the motor
will move from left to right. When LS2 is ON,
the Motor stops, delay for 5 seconds and then
moves back to Home. When LS1 is ON, Motor
cuts off, signifying that the sequence is
6.5.3 Off-Delay Timer Instruction

I0.0 Q0.0

Off-delay programmed timer.


Program for switching motors off at 5 s intervals.
Hardwired off-delay timer relay circuit with
both instantaneous and timed contacts
Equivalent PLC program of the hardwired off-delay
timer relay circuit containing both instantaneous and timed contacts
Figure shows a ladder-logic diagram for the TOF timer instruction.
This diagram assumes a normally open START push button (PB), a normally closed
STOP push button, a timer preset (PT) value of 10 seconds, output motor1
(Q0.0), and output motor2 (Q0.1).
The first network initially during the first scan, I0.1, is TRUE because the STOP
PB is wired high. Also, the START PB is FALSE because the switch is not yet
pressed.
Once the START PB is pressed, I0.0 becomes TRUE; this, in turn, makes Q0.0
TRUE, and motor1 runs. The next scan, Q0.0, will latch around the START
PB and maintain Network 1 TRUE status.
As shown in the second network, Q0.0 is the input condition for the TOF
instruction, which is now TRUE.
• The timer (TOF) will set the output Q0.1 ON, causing motor2 to turn ON. So
far the two motors are running after pressing the START PB.
• Once the STOP PB is pressed, motor1 loses power and goes OFF. This will
cause the TOF timer to start timing.
After the prespecified delay of 10 seconds is over, the timer output Q0.1 goes
OFF. This will cause motor2 to stop. Thus motor2 stops 10 seconds after
motor1 is OFF.
• The timer preset value is cleared when TOF is TRUE.
• Pressing the STOP PB at any time while the two motors are running stops
motor1, and 10 seconds later motor2 stops.
The program shows a simple process-control implementation using
three OFF-DELAY timer (TOF) instructions.
This network assumes a limit-switch tag name LS1 and three outputs: motor1
Q1.0, motor2 Q1.1, and motor3 Q1.2.
Timer preset values of 10, 20, and 30 seconds are used to sequence the
operation of the three motors.
When LS1 is TRUE, all three motors start running.
If LS1 changes from high to low (OFF state), motor1 turns off after 10
seconds, motor2 turns off after 20 seconds, and motor3 turns off after 30
seconds.
Once LS1 returns back to the TRUE state, the accumulated values of all
three timers are cleared.
6.5.4 Retentive Timer

Retentive on-delay timer program.


Retentive on-delay timer program.
Retentive on-delay timer alarm program.
Bearing lubrication program
6.5.5 Cascading Timers

Hardwired sequential time-delayed motor starting


circuit
Equivalent PLC program of the sequential
time-delayed motor-starting circuit
Annunciator flasher program
Cascading of timers for longer time delays
Star-Delta Reduced Voltage Starter Control
Control Purpose:
Usually the starting current of the three-phase AC asynchronous motor is
5 ~7 times larger than the rated current. To reduce the effect of the starting
current on the electrified wire fence, a star-delta reduced voltage starter
should be applied.
Starting process of a star-delta reduced voltage starter:
When the switch is turned on, the contactors of both motor starter and
“Star Reduced Voltage Starter” will be enabled first. After a 10 sec delay,
the contactor of “Star Reduced Voltage Starter” will be disabled. Finally,
the contactor of “Delta Reduced Voltage Starter” will be enabled after 1
sec, which operates the main motor circuit normally. The control purpose
in this process is to assure the contactor of “Star Reduced Voltage
Starter” is
disabled completely before the contactor of “Delta Reduced Voltage
Starter” is enabled.
REVIEW QUESTIONS

1. Draw the symbol and explain the operation of each of


the
following timed contacts of a mechanical timing relay:
a. On-delay timer—NOTC contact
b. On-delay timer—NCTO contact
c. Off-delay timer—NOTO contact
d. Off-delay timer—NCTC contact
2. Explain what each of the following quantities associated with
a PLC timer instruction represents:
a. Preset value
b. Accumulated time
c. Time base
.
. With reference to the relay schematic diagram in Figure ,
state the status of each light (on or off) after each of the following
sequential events:
Power is first applied and switch S1 is open.
. Switch S1 has just closed.
I. Switch S1 has been closed for 5 s.
V. Switch S1 has just opened.
. Switch S1 has been opened for 5 s.
. Design a PLC program and prepare a typical I/O connection
diagram and ladder logic program that will execute this
hardwired control circuit correctly.
4. Study the ladder logic program in Figure and answer the
questions that follow:
a. What type of timer has been programmed?
b. What is the length of the time-delay period?
c. What is the value of the accumulated time when power is first
applied?
d. When does the timer start timing?
e. When does the timer stop timing and reset itself?
f. When input LS1 is first closed, which rungs are true and which
are false?
g. When input LS1 is first closed, state the status (on or off) of
each output.
h. When the timer’s accumulated value equals the preset value,
which rungs are true and which are false?
i. When the timer’s accumulated value equals the preset value,
state the status (on or off) of each output.
Homework

1. Write a ladder logic program that will turn on a light, PL, 15


s after switch S1 has been turned on.

2. When the lights are turned off in a building, an exit door light is
to remain on for an additional 2 min, and the parking lot lights are
to remain on for an additional 3 min after the door light goes out.
Write a program to implement this process.
6.6

Counters
All PLCs include both up-counters and down-counters. Counter
instructions and their function in ladder logic are explained in
this chapter. Typical examples of PLC counters include the
following: straight counting in a process, two counters used to
give the sum of two counts.
6.6.1 Counter Instructions

Mechanical counter
Every time the actuating lever is moved over, the
counter adds one number; the actuating lever then
returns automatically to its original position. Resetting
to zero is done with a pushbutton located on the side
of the unit.
Electronic counters

Electronic counters can count up, count down, or


be combined to count up and down.
Block-formatted up-counter instruction.

The up-counter increments its accumulated value


by 1 each time the counter rung makes a false-to-
true transition. When the accumulated count
equals the preset count the counter output is
energized or set to 1.
Counter counting sequence.
6.6.2 Up-Counter

The up-counter is an output instruction whose


function is to increment its accumulated value on
false-to-true transitions of its instruction.

It thus can be used to count false-to-true transitions


of an input instruction and then trigger an event after
a required number of counts or transitions.

The up-counter output instruction will increment by


1 each time the counted event occurs.
Outputs L2

Q0.1

I0.0
Q0.0

I0.1

Simple up-counter program


This control application is designed to turn the red pilot
light on and the green pilot light off after an accumulated
count of 7.
PB1

Red PL

Green PL

PB2

C20

• Operating pushbutton PB1 provides the off-to-on


transition pulses that are counted by the counter.
• The preset value of the counter is set for 7.
• Each false-to-true transition of network 1 increases
the counter’s accumulated value by 1.
PB1

Red PL

Green PL

PB2

C20

• Output Q0.0 is energized as long as the accumulated value


is less than 7.
• After 7 pulses, or counts, when the preset counter value
equals the accumulated counter value, output C20 is
energized.
PB1

Red PL

Green PL

PB2

C20

• As a result, network 2 becomes true and energizes output


Q0.1 to switch the red pilot light on.
• At the same time, network 3 becomes false and de-
energizes output Q0.0 to switch the green pilot light off.
• The counter is reset by closing pushbutton PB2, and resets
the accumulated count to zero.
PLC counter program used to stop a motor from
running after 10 operations
• Up-counter C5 counts the number of on/off times the motor starts.
• The preset value of the counter is set to 10.
• A counter bit instruction is programmed in series with
the motor output instruction.
• A motor output instruction is used to increment the
accumulated value of the counter for each off/on
operation.
• After the count of 10 is reached the counter bit
instruction goes false preventing the motor from being
started.
• Closure of the reset pushbutton resets the accumulated
count to zero.
Can-counting program.
• Counter C52 counts the total
number of cans coming off an
assembly line for final
packaging.
• Each package must contain 10
parts.
• When 10 cans are
detected, counter C51 sets
bit M0.0 to initiate the box
closing sequence.
• Counter C53 counts the
total number of packages
filled in a day.
• A pushbutton is used to
restart the total part and
package count from zero
daily.
Alarm monitor program.
• The alarm is triggered by the closing
of float switch FS.

• The light will flash whenever


the alarm condition is triggered
and has not been
acknowledged, even if the
alarm condition clears in the
meantime.

• The alarm is acknowledged


by closing selector switch SS.

• The light will operate in the


steady on mode when the alarm
trigger condition still exists but has
been acknowledged.
6.6.3 Down-Counter

Block-formatted down-counter instruction.


The down-counter instruction will count down or
decrement by 1 each time the counted event occurs.
Each time the down-count event occurs, the
accumulated value is decremented.
Count-Down Counter
6.6.4 UP/Down-Counter

Block-formatted up/down-counter instruction


The Count Up/Down instruction (CTUD) counts up each time
the count up (CU) input makes the transition from off to on,
and counts down each time the count down (CD) input
makes the transition from off to on.
Generic up/down-counter program.
• Assuming the preset value of the
counter is 3, pulsing the count-up
input (PB1) three times will switch the
output light from off to on.
• This particular PLC counter keeps
track of the number of counts received
above the preset value. As a result,
three additional pulses of the count-up
input (PB1) produce an accumulated
value of 6 but no change in the output.
• If the count-down input (PB2) is now pulsed four times, the
accumulated count is reduced to 2 (6 – 4). As a result, the
accumulated count drops below the preset count and the
output light switches from on to off.

• Pulsing the reset input (PB3) at any time will reset the
accumulated count to 0 and turn the output light off.
Generic up/down-counter program.
Parking garage counter.
• As a car enters, the enter
switch triggers the up input of
the counter and increments the
accumulated count by 1.

• As a car leaves, the exit


switch triggers the down input
of the counter and
decrements the accumulated
count by 1.

• Whenever the accumulated value of 150 equals the


preset value of 150, the counter output is energized by
the counter bit to light up the Lot Full sign.
• A reset button has been provided to reset the
accumulated count.
6.6.5 Cascading Counters

Depending on the application, it may be necessary to


count events that exceed the maximum number
allowable per counter instruction. One way of
accomplishing this count is by interconnecting, or
cascading, two counters.
Cascading counters for extremely large counts.
• Counter C51 has a preset
value of 500 and counter C52
has a preset value of 500.
• Whenever counter C51
reaches 500, its bit resets
counter C51 and
increments counter C52
by 1.

• When the bit of counter C52


has turned on and off 500
times, the output light
becomes energized.
Therefore, the output light
turns on after 500 × 500, or
250,000, transitions of the
count input
6.6.6 Combining Counter and Timer Functions

Automatic stacking program


In this process, conveyor M1 is
used to stack metal plates onto
conveyor M2. The photoelectric
sensor provides an input pulse
to the PLC counter each time a
metal plate drops from conveyor
M1 to M2. When 15 plates have
been stacked, conveyor M2 is
activated for 5 s by the PLC
timer.
• When the start button is
pressed, conveyor M1
begins running.

• After 15 plates have


been stacked, conveyor
M1 stops and conveyor
M2 begins running.
• After conveyor M2 has been
operated for 5 s, it stops and
the sequence is repeated
automatically.
• The bit of the timer resets the
timer and the counter and
provides a momentary pulse to
automatically restart conveyor
M1.
24-hour Clock Operated by 3 Counters

Control Purpose:

 Using 3 counters together with SM0.5 (1s


clock pulse) to operate a 24-hour clock.
Control Program:
Program Description:
The key of operating a 24-hour clock is to use SM0.5
(1s clock pulse). When the program is
executed, C0 will count once per second. When the
counted number reaches 60(1 minute), C0 = ON. C1 will
count once, and C0 will be reset at the same time;
similarly, when the counted number in C1 reaches 60(1
hour), C1 = ON. C2 will count once, and C1 will be reset
at the same time. Furthermore, when the present value
in C2 reaches 24, C2 will be
reset, and the 24-hour counting process will start again.
The 24-hour clock operates by using C0 to count
“second”, C1 to count “minute” and C2 to
count “hour.”
In this clock, the value of “second”, “minute” and
“hour” can be read by C0, C1and C2
correspondingly.
When the set value of C2 is 12, the clock will be
a 12-hour clock.
Products Amount Calculation (Counting
Up/Down Counter)

Control Purpose:
 This program is used for monitoring the
product amount in the warehouse by
photoelectric sensors at both entry and exit.
When the amount reaches 30,000, the alarm will
Control Program:
Program Description:

 When I0.0 goes from OFF to ON C0 will


count up; when I0.1 goes from OFF to ON, C0
will count down.
 When the present value of C0 reaches
30,000, C0 = ON, and the alarm Q0.0 will be
enabled.
Product Mass Packaging

Control Purpose:
 Once the photoelectric sensor detects 10
products, the robotic arm will begin to pack up.
When the action is completed, the robotic arm
and the counter will be reset.
Control Program:
Program Description:

 Once the photoelectric sensor detects a


product, I0.0 will go from OFF to ON once, and
C0 will count for one time.
 When the present value in C0 reaches 10, the
Normally Open contact C0 will be closed.
Q0.0 = ON, and the robotic arm will begin to pack.
 When the packing is completed, the robotic arm
action completed sensor will be enabled.
I0.1 will go from OFF to ON. Q0.0 and C0 will be
reset for the next packing task.
REVIEW QUESTIONS

1. Name the three forms of PLC counter instructions,


and explain the basic operation of each.
2. Identify the type of counter you would choose for
each of the following situations:
a. Count the total number of parts made during each
shift.
b. Keep track of the current number of parts in a stage
of a process as they enter and exit.
3. Study the ladder logic program in Figure , and answer
the questions that follow:
a. What type of counter has been programmed?
b. When would output Q0.0 be energized?
c. When would output Q0.1 be energized?
d. Suppose your accumulated value is 24 and you lose
ac line power to the controller. When power is restored
to your controller, what will your accumulated value be?
e. When will the count be incremented?
f. When will the count be reset?
4. Design a PLC program and prepare a typical I/O connection
diagram and ladder logic program for the following counter
specifications:
• Counts the number of times a pushbutton is closed.
• Decrements the accumulated value of the counter each time a
second pushbutton is closed.
• Turns on a light anytime the accumulated value of the counter
is less than 20.
• Turns on a second light when the accumulated value of the
counter is equal to or greater than 20.
• Resets the counter to 0 when a selector switch is closed.
Homework
1.Write a program that will turn a light on when a count
reaches 20. The light is then to go off when a count of 30 is
reached.
2. Write a program to operate a light according to the
following sequence:
• A momentary pushbutton is pressed to start the sequence.
• The light is switched on and remains on for 2 s.
• The light is then switched off and remains off for 2 s.
• A counter is incremented by 1 after this sequence.
• The sequence then repeats for a total of 4 counts.
• After the fourth count, the sequence will stop and the
counter will be reset to zero.

You might also like