You are on page 1of 67

Basics of PLC System

Introduction To Programmable Logic Controller

Eng. Ebrahim Abdel Hadi Ebrahim


Mechanical Engineering Department
Mechatronics Spec.
Revision On Section 1,2,3(PLC)
Programming Software
Programming Software

- SIEMENS TIA PORTAL (Totally Integrated Automation )


- Factory I/O For Simulation
Ladder Diagram Programing
Timers

 Types of plc timers


1- Pulse timer
2- on-delay timer
3- off-delay timer
4- retentive on delay timer
ON-Delay timer (TON)

The on-delay timer (TON)

is the most commonly used timer. The operation of that timer can be summarized as follows:

• The timer is activated by input


• The preset time for this timer is PT, at which time output will be energized.
• When input(1), the timer becomes true and the timer begins counting and counts
until the accumulated time equals the preset value; the output is then energized(true).
• If the input signal is removed(0) before the timer is timed out, the accumulated time is automatically reset to 0.
• This timer configuration is termed nonretentive because any loss of continuity to the timer causes the timer
instruction to reset..
ON-Delay timer (TON) timing diagram

IN: input signal


PT: preset timer value
Q : is the output signal from the timer
ET: is the current value

Note,
PT is the Duration of the on-delay, The
value of the PT parameter must be
positive.

Reset to ‘0’ Reset to ‘0’


1- automatic sequential control example

• Timers are often used as part of automatic sequential control


systems. The following Figure shows how a series of motors can be
started automatically with only one start/stop control station.
• The operation of the circuit can be summarized as follows:

According to the relay ladder schematic, lube-oil pump motor starter coil
M1 is energized when the start pushbutton PB2 is momentarily actuated.
• As a result, M1-1 control contact closes to seal in M1, and the lube-oil
pump motor starts.
• When the lube-oil pump builds up sufficient oil pressure, the lube-oil
pressure switch PS1 closes.
• This in turn energizes coil M2 to start the main drive motor and energizes
coil TD to begin the time delay period.
• After the preset time-delay period of 15 s, TD-1 contact closes to energize
coil M3 and start the feed motor.
OFF-Delay timer (TOF)

The OFF-Delay timer (TOF)

The off-delay timer (TOF) operation will keep the output energized for a time period after the rung containing
the timer has gone false.
If logic continuity is lost, the timer begins counting time-based intervals until the accumulated time equals the
programmed preset value. Then the output becomes”0”
If +ve edge is detected then the timer reset to zero and waits until negative
edge is detected to start counting till PT is detected

Reset to ‘0’ On 1st


Reset to ‘0’ on the
+ve edge
next +ve edge
Program for switching 3 motors off at 5 s intervals

On pressing on start button the marker bits(M1,2,3) is set on and so the


output coil q0.0,q0.1,q0.2 immediately.
On release start button, the timers start count on time base and if the timer
reaches PT value the bit marker is reset to 0
Retentive On-Delay timer (TONR)

The instruction "Time accumulator" is used to accumulate time


values within a period set by the parameter PT. When the signal
state at the IN input changes from "0" to "1" (positive signal
edge), the instruction is executed and time PT starts.
While the time PT is running, the time values are accumulated
that are recorded when the IN input has signal state "1". The
accumulated time is written to the ET output and can be queried
there. When the duration PT expires, the output Q has signal
state "1". The Q parameter remains set to "1", even when the
signal state at the IN parameter changes from "1" to "0"
(negative signal edge).

The R input resets the ET and Q outputs regardless of the signal


state of the start input.
Pulse Timer (TP)

You can use the "Generate pulse" instruction to set the output Q for a programmed
duration. The instruction is started when the result of logic operation (RLO) at input IN
changes from "0" to "1" (positive signal edge).

The timer
generates pulse of
width “TP” when
it detects the +ve
edge of the input

Reset to ‘0’
Traffic lights control sequence

A typical application for PLC timers is the control of traffic lights(uk).


The ladder logic circuit of Figure 7-34 illustrates a control of a set of traffic lights in
one direction. The operation of the program can be summarized as follows:

1- Red >>14sec
2- Red &Amber >> 8sec
3- Green >> 10sec
4- Yellow >> 8sec
on pressing start button(i0.0),
1- timer0 starts and at the same time red is on for 14sec.
2- at the end of PT of timer0,M0.0 becomes (1)
3- when M0.0 becomes(1) yellow is on and timer1 starts
counting(yellow&red are on for 8sec)
4- at the end of timer1 m0.1 becomes (1) Which turns
(red&yellow)off and opens green, at the same time the timer2
starts and green is on for 10seconds
5- at the end of timer2 m0.2 is now on, green is off and returns to
open yellow led, at the same time timer 3 is on (yellow is on for
8 seconds) till m0.3 is on .
6- at m0.3 is on (turns off all timers)
7- when all timers are off >> m0.3 becomes off and the cycle is
repeated .
Counters Programmed counters can serve the same function as mechanical
counters. Figure (1) shows the construction of a simple 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.
1- Up-Counter(CTU)
2- Down- Counter(CTD)
3-UP-Down Counter(CTUD)
1- Up-Counter(CTU)

• 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 Input
CU
instruction and then trigger an event after a required number of
counts or transitions. Q

Q
CU:counting input signal
R :Reset the counter RR
PV:preset Value
Q :output signal when the counter is dine
CV: counting value PV

CV
On each +ve edge in CU from I0.0 The counter is
incremented by 1 till the CV>=PV
Q becomes “1”
On supplying signal at reset address ( R )the counter is reset
and the output signal is removed
2- Down-Counter(CTD)

• 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.
• Normally the down-counter is used in conjunction with the up-counter to
form an up/down-counter.

• When the signal state at the CD input changes from "0" to "1" (positive signal
edge), the instruction is executed and the current counter value at the CV output
is decremented by one.
CD:counting input signal
• Each time a positive signal edge is detected, the counter value is decremented
LD :Load input
until it reaches the low limit of the specified data type (INT).
PV :preset Value
• When the low limit is reached, the signal state at the CD input no longer has an
Q :output signal when the cou
effect on the instruction.
CV : counting value
• You can query the counter status in the Q output. If the current counter value is
less than or equal to zero, the Q output is set to signal state "1". In all other cases,
the Q output has signal state "0". You can also specify a constant for the
parameter PV.
On each +ve edge in CD from I0.3 The counter is
decremented by 1 till the CD<=0
Q becomes “1”

Cv here is the modified


initial value
On supplying signal at Load Input (LD) address the counter is
reloaded by its PV and the output signal is removed
Note, when using down counters the initial value of the timer by default is zero , so
you need to apply signal on “LD” so as to reload the counter or you should change the
initial value of the down-counter from its data block as shown,

Change it to the Preset value e.g ” 7”


3- Up-Down Counter(CTUD)

• You can use the "Count up and down" instruction to increment and decrement the counter value at the CV output.
• If the signal state at the CU input changes from "0" to "1" (positive signal edge), the current counter value is
incremented by one and stored at the CV output.
• If the signal state at the CD input changes from "0" to "1" (positive signal edge), the counter value at the CV
output is decremented by one.
• If there is a positive signal edge at the CU and CD inputs in one program cycle, the current counter value at the
CV output remains unchanged
When the counter When the counter
value is “0” the value is “5” the
output Qd =true output Qu =true
Parking garage counter.

One application for an up/down-counter is to keep count of the cars


that enter and leave a parking garage.
The Figure shows a typical PLC program that could be used to
implement this.
The operation of the program can be summarized as follows:
• As a car enters, the enter switch triggers the up counter output
instruction and increments the accumulated count by 1.
• As a car leaves, the exit switch triggers the down counter
output instruction and decrements the accumulated count by 1.
• Because both the up- and down-counters have the same address,
C5:1, the accumulated value will be the same in both instructions as
well as the preset.
• Whenever the accumulated value of 150 equals the preset value of
150, the counter output is energized by the done bit to light up the
Lot Full sign
Automatic stacking program.

Many PLC applications use both the counter function and the timer function. The Figure illustrates an automatic
stacking program that requires both a timer and counter.
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. The operation of the program can be summarized
as follows:
• 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 done bit of the timer resets the timer and the counter and
provides a momentary pulse to automatically restart conveyor M1.
Intro to Factory I/O Simulator
System construction

Inputs: outputs:
Start Button conveyor
Stop Button
Diffuse sensor
Writing plc program on
Tia Portal

Start Simulator in
tia Portal
Connect Factory i/o with
tia portal
Run Simulation on
Factory I/O

Manipulate your
simulation using start-
and sop buttons
Queue of items on the
roller conveyor

Inputs:
• Item Ready retroreflective sensor
(NC).(not used in that task)
• entry retroreflective sensor (NC).
• at exit retroreflective sensor (NC).
Output
• (entery roller conveyor motor)
• (buffer roller conveyor motor)
All plc Tags
1- on start, entry conveyor is set on to move items to
the next stage.
1- entery sensor detects the items.
2- at detection of items up counter counts .
3- on passing entry sensor, the buffer conveyor
is turned on till the signal is removed by the
sensor(box gets away of the sensor signal)
4- after counting up to 3 boxes, the entery
conveyor is stopped and the buffer conveyor is
turned on until al items are removed from the
exit sensor.
5- on counting in exit sensor (3 boxes) counters
are reset and resets the input counter and the
cycle starts again
Simple Sorting By Height
Example
Inputs & Outputs
All plc Tags
on pressing Start Button, conveyor
motor is latched and start led is on,
Warning light is on.
If the correct height is detected by
diffuse sensor, the pusher works to push
away that box as seen, if not it allows
the item to pass.
Simple Sorting By Height Example) supply conveyor)
controlling the sequence of the operation
Add that function block before simulation of
Factory IO with S7 1200

You might also like