You are on page 1of 57

ENGG3490-PLC L4

PLCs Ref. [3]; 1. Programming Timers 2. P Programming C i Counters t

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Timers
There are very few industrial control systems that do not need at least one or two timed functions. They are used to activate or de-activate a device after a preset interval of time. time
Time delay relays and solid-state timers are used to provide a time delay. They may have displays, pots or other means of operator interface for time settings and electromechanical or solid state outputs.

Time Delay Relay

Solid State Solid-State Timer

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

On-Delay Timing Relay


Operating coil NO Instantaneous contacts NC Nontimed contacts are controlled directly by the timer coil, as in a th ti il i general-purpose control relay.

ENGG3490: Mechatronics W07.

When the coil is energized, the timed contacts are prevented from opening or closing NO until the time delay period has elapsed. Time control However, when the coil is contacts de-energized, the timed NC contacts return Time adjustment instantaneously to their Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 3 normal state.

Timed Contact Symbols


On-Delay Symbols

Normally open, timed closed contact (NOTC) Contact is open when relay coil is de-energized

Normally closed, timed open contact (NCTO) Contact is closed when relay coil is de-energized

When relay is energized, When relay is energized, there is a time delay in there is a time delay in closing Mechatronics W07. Adapted From Programmable Logic Controllers ByopeningMcGraw-Hill ENGG3490: F. D. Petruzella, 4

Timed Contact Symbols


Off Delay Symbols
Normally open, timed open contacts (NOTO). Contact is normally open when relay coil is de-energized. No Normally closed, timed y c osed, ed closed contacts (NCTC). Contact is normally closed when relay coil is de-energized.

When relay coil is When relay coil is energized, contact closes i d t t l energized, contact opens i d t t instantly. instantly. When relay coil is deWhen relay coil is deenergized, there is a time energized, there is a time delay before the contact delay before the contact ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 5 opens. closes.

On-Delay Relay Timer Circuit (NOTC Contact)


L1 S1 L2

Sequence of operation S1 open, TD de-energized, TD1 open L1 is off open, off.

L1

10 s 10 s

S1 closes, TD energizes, timing period starts, TD1 still open, L1 is still off. After 10 s, TD1 closes, L1 is switched on.
ON

Input OFF

S1 is opened, TD deenergizes, TD1 opens Output instantly, L1 is switched off.6 Timing Diagram ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

On-Delay Relay Timer Circuit (NCTO Contact)


L1 S1 L2

Sequence of operation S1 open, TD de-energized, TD1 closed, L1 is on. closed on S1 closes, TD energizes, timing period starts, TD1 is still closed, L1 is still on. After 10 s, TD1 opens, L1 is switched off.

L1 10 s

10 s Input Output

S1 is opened, TD de-energizes, TD1 closes instantly, L1 is switched on. Timing Diagram Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07. 7
Off

On

Off-Delay Relay Timer Circuit (NOTO Contact)


L1 S1 L2

Sequence of operation S1 open, TD de-energized, TD1 open L1 is off open, off.

L1

10 s 10 s Input On Output Off Timing Diagram

S1 closes, TD energizes, TD1 closes instantly, L1 is switched on. S1 is opened, TD de-energizes, timing period starts TD1 is starts, still closed, L1 is still on. After 10 s, TD1 opens, L1 is switched off.
8

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Off-Delay Relay Timer Circuit (NCTC Contact)


L1 S1 L2

Sequence of operation S1 open, TD de-energized, TD1 closed, L1 is on. closed on


L1

10 s 10 s

S1 closes, TD energizes, TD1 opens instantly, L1 is switched off. S1 is opened, TD de energizes, timing de-energizes, period starts, TD1 is still open, L1 is still off. After 10 s, TD1 closes, L1 is switched on.
9

Input Output On Off Timing Diagram

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Programmed Timer Instructions


PLC timers are output instructions that provide the same functions as timing relays and solid state timers.
Some advantages of PLC timers: their settings can be altered easily the number of PLC timers used can be increased or decreased by programming changes without wiring changes timer accuracy and repeatability are extremely high
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 10

RSLogic Timer Commands


TON

Timer/Counter

Command

Name Timer On-Delay

Description Counts time base intervals when the instruction is true

TON

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

11

RSLogic Timer Commands


TOF

Timer/Counter

Command

Name Timer Off-Delay

Description Counts time base intervals when the instruction is false

TOF

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

12

RSLogic Timer Commands


RTO RES

Timer/Counter

Command

Name Retentive Timer ON

Description
Counts time base intervals when the instruction is true and retains the accumulated value when the l h th instruction goes "false" or when power cycle occurs

RTO

RES
ENGG3490: Mechatronics W07.

When this instruction is "true" it resets the count Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 13 of the RTO counter

Reset

Quantities Associated with the Timer Instruction


Preset Time Represents the time duration of the timing circuit. For example, if a time delay of 10 s is required, the timer will have a preset of 10 s. Accumulated Time Represents the amount of time that has elapsed from the moment the timing coil became energized. Time Base Timers can typically be programmed with several different time bases: 1 s, 0.1 s, and 0.01 s are typical time bases. For example, if you enter 0.1 for the time base and 50 for the preset time the timer would have a 5 s delay (50 x 0.1 s = 5 s).
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 14

Coil-Formatted Timer Instruction


Contact determines rung continuity The timer assigned an address The type of timer XXX is specified
TON

Preset value PR:YYY Time base 0.1 s Accumulated value AC:000 When th ti Wh the timer rung h l i continuity, the timer's has logic ti it th ti ' accumulated value increases. When accumulated value equals the preset value, the output is energized and and the timed output contact associated with the output is closed. The timed contact can be used as many times as you wish throughout the ENGG3490: Mechatronics W07. Adapted From Programmable Logic 15 program as a NO or NC contact. Controllers By F. D. Petruzella, McGraw-Hill

Generic Block-Formatted Timer Instruction


Timers are most often represented by boxes in a ladder logic.
Control line controls the actual timing operation of the timer. Whenever this line is true the timer will time. Wh hi li i h i ill i Retentive timer block
Preset time Time base Accumulated time

Reset line resets the the timer's accumulated value to zero.


ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 16

Generic Block-Formatted Timer Instruction


Timers are most often represented by boxes in a ladder logic.

Retentive timer block


Preset time Time base Accumulated time

Output line

The timer continuously compares its accumulated time with its preset time. Its output is logic 0 as long as the accumulated time is less than the preset time. When the two become equal the output ENGG3490: Mechatronics W07. 17 changes to logic 1. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

On-Delay Timer Instruction


The on-delay timer operates so that, when the rung containing the timer is true, the timer time-out period commences.
Timer Sequence Rung condition Timed period False True The timed output becomes true sometimes after the timer rung becomes true; hence the timer is said to have an on delay.
18

Input

Timer

On delay time duration True False

Timed output bit

ON OFF Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07.

Allen-Bradley On-Delay Timer Instruction


Allen-Bradley PLC-5 and SLC-500 controller timer elements each take three data table words: the control word, preset word, and accumulated word. ,p , The control word uses three control bits: Enable (EN) bit, Timer-Timing (TT) bit, and Done-Bit (DN). TIMER TABLE /EN T4:0 0 /TT 0 /DN 0
19

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Allen-Bradley On-Delay Timer Instruction


The Enable (EN) bit is true (has a status of 1) whenever the timer instruction is true. When the timer instruction is false, the enable bit is false (has a status of 0)
Enable bit false
TON TIMER ON DELAY Timer T4:0

EN

T4:0 EN

Enable bit true


20

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

10

Allen-Bradley On-Delay Timer Instruction


The Timer-Timing (TT) bit is true whenever the accumulated value of the timer is changing, which means the timer is timing.
TON TIMER ON DELAY Timer T4:0 Preset 50 Accumulated 10 T4:0 TT

EN

Timer-Timing bit true

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

21

Allen-Bradley On-Delay Timer Instruction


The Done-Bit (DN) changes state whenever the accumulated value reaches the preset value. Its state depends on the type of timer being used.
TON TIMER ON DELAY Timer T4:0 Preset 50 Accumulated 10 50 T4:0 DN

EN DN

Done-bit changes state

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

22

11

Allen-Bradley On-Delay Timer Instruction


The preset value (PRE) word is the set point of the timer, that is, the value up to which the timer will time. The accumulated value (ACC) word is the value that increments as the timer is timing. The accumulated value will stop incrementing when its value reaches the preset value. TIMER TABLE /EN T4:0 0 /TT 0 /DN 0 .PRE 0 .ACC 0
23

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Allen-Bradley On-Delay Timer Instruction


The information to be entered includes:
TON TIMER ON DELAY Timer Time base Preset Accumulated

T4:0 1.0 15 0

EN DN

Timer number which must come from the timer file. Time base which is expressed in seconds. Preset value which is the length of the time delay. Accumulated value which is normally entered as 0.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 24

12

On-Delay Timer Program


Ladder Logic Program L1
Input A Input A TON TIMER ON DELAY Timer Time base Preset Accumulated Output B G

L2

T4:0 1.0 10 0 10

EN DN

Output C

T4:0 EN T4:0 TT T4:0 DN

Output B Output D Y

Output C

Output D

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

25

On-Delay Timer Program


Timing Diagram On Input condition A Timer-enable bit Timer-timing bit Off On O Off On Off On Timer-done bit Off 4s 10 s

Timer accumulated 0 value


ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 26

13

On-Delay Timer Program


Timers are 3-word elements
Word EN TT DN Internal use Preset value PRE Accumulated value ACC Word 0 is the control word Word 1 stores the preset value Word 2 stores the accumulated value
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 27

0 1 2

On-Delay Timer With Instantaneous Output


Relay Ladder Schematic Diagram
L1 Stop Start 1TD L2

1TD-1 (instantaneous contact)

M 1TD-2 (5 s) (timed contact)

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

28

14

On-Delay Timer With Instantaneous Output


Programmed Circuit
Ladder logic program Inputs L1 Stop Motor Start Internal relay Timer PR: 5 TB: 1 s Motor M M Stop Start Internal relay Output L2

Output line
29

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Start-Up Warning Signal Circuit


Relay Ladder Schematic Diagram
L1 Start-up PB1 Reset PB2 CR1 L2

CR1-1 1TD CR1-2 Horn CR1-3 1TD-1 (10 Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07.s)
30

15

Start-Up Warning Signal Circuit


Programmed Circuit
Inputs p Ladder logic program Output PB1 PB2 TON TIMER ON DELAY Timer T4:0 Time base 1.0 Preset 10 Accumulated 0 10 Horn

Start-up
PB1

EN DN Horn

Reset
PB2

T4:0 EN T4:0 T4 0 DN T4:0 T4 0

EN

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

31

Timed Closed Solenoid Valve Program


Input L1 Switch S itch SW_1 SW_1 SW 1 TON Timer On Delay Timer timer_1 Preset 12000 Accumulated 12000 0 EN DN Ladder logic program Output L2

Valve

timer_1.dn

Valve

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

32

16

Automatic Sequential Control System


L1

Relay Ladder Schematic Diagram

Stop PB1

Start PB2

L2 Lube oil pump motor M1 OL

M1-1 PS1

Main drive motor M2

OL

(lube oil pressure switch)

1TD OL M3

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

1TD-1 (15 s)

Feed motor

33

Automatic Sequential Control System


Programmed Circuit
Ladder logic program Inputs PB1 M1 PB2 PS1 PS1 M2 M2 OL M3 TON TIMER ON DELAY Timer T4:0 Time base 1.0 Preset 15 15 Accumulated 0 T4:0 DN M3 PB1 PB2 M1 Outputs OL M1 OL

EN DN

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

34

17

Off-Delay Programmed Timer


The off-delay timer (TOF) operation will keep the output energized for a period after the rung containing the timer has gone false.
Input L1 S1 I:1.0/0 TIMER Time base Preset Accumulated T4:3/DN T4:3 1.0 15 0 15 I:1.0/0 TOF TIMER OFF DELAY EN DN O:2.0/1 PL Ladder logic program Output L2

O:2.0/1

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

35

Off-Delay Programmed Timer


Timing Diagram
True Input condition S1 False

Timed period Off delay timed duration

True (logic 1) Timed output O:2.0/1 Preset value = accumulated value


36

False (logic 0)

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

18

Off-Delay Timer Used To Switch Motors Off


Input L1 Ladder logic program Output L2

5000

10000

15000

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

37

Pneumatic Off-Delay Timer


L1 L2

Relay Ladder Schematic Diagram

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

38

19

Programmed Pneumatic Off-Delay Timer


Equivalent Programmed Circuit
Input L1 Ladder logic program Outputs L2

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

39

Fluid Pumping Process

Operation Before starting, PS1 must be closed. When the pump start button is pressed, the pump starts. The button can then be released and the pump continues to operate. When the stop button is pushed, the pump stops. PS2 and PS3 must be closed for 5 s after the pump starts. If either PS2 or PS3 opens, the pump will shut off and will not not be able toMechatronics W07. Adaptedfor Programmable Logic14 s. By F. D. Petruzella, McGraw-Hill start again From another Controllers ENGG3490: 40

20

Fluid Pumping Process Program


Ladder logic program

Inputs L1

Output L2

5 0

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

41

Retentive Timer
A retentive timer accumulates time whenever the device receives power, and maintains the current time should power be removed from the device. Once the device accumulates time equal to its preset value, the contacts of value the device change state. The retentive timer must be intentionally reset with a separate signal for the accumulated time to be reset.
Electromechnical Retentive Timer
Once power is applied, the motor starts turning the cam. The positioning of the lobes determines Cam operated contact the time it takes to activate the contacts. If power is removed from the motor, the shaft stops but does Motor-driven Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 42 cam not reset.

ENGG3490: Mechatronics W07.

21

Retentive On-Delay Timer Program


The PLC-programmed RETENTIVE ON-DELAY timer (RTO) operates in the same way as the nonretentive ondelay timer (TON), with one major exception. There is a retentive timer reset (RTR) instruction. instruction
Unlike the TON, the RTO will hold its accumulated value when the timer rung goes false and will continue timing where it left off when the timer rung goes true again. This timer must be accompanied by a timer reset Same address (RES) instruction to reset the accumulated value of the Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 43 timer to zero.

ENGG3490: Mechatronics W07.

Retentive On-Delay Timer Program

0 9 3

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

44

22

Retentive On-Delay Timing Chart


Enable bit is reset when input pushbutton PB1 is opened

Accum value retained when rung goes false

Accum = Preset

ENGG3490: Mechatronics W07.

When reset PB2 is closed, the T4:2/DN bit is reset to 0. Accumulated value is reset and held at zero until the reset pushbutton is Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 45 opened.

Retentive On-delay Alarm Program


Ladder logic program L1 L2

60000 0

The purpose of the RTO timer is to detect whenever a piping system has sustained a cumulative overpressure condition of 60 s. At that point, a horn is sounded automatically. You can silence the alarm by switching the key switch to the By F. D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers rest position. 46

23

Bearing Lubrication Program


Sequence Of Operation
To start the machine, the operator turns SW on.

Before the motor shaft starts to turn, the bearings are supplied with oil by the pump for 10 s. The bearings also receive oil when the machine is running. When the operator turns SW off to stop the machine, the oil pump continues to supply oil for 15 s. A retentive timer is used to track the total running time of the i i i d k h l i i f h pump. When the total running time is 3 h, the motor is shut down and a pilot light is turned on to indicate that the filter and oil need to be changed. A reset button is provided to reset the process after the filter and ENGG3490: Mechatronics W07. Adapted From 47 oil have been changed. Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Bearing Lubrication Program

10 0

15

10800
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 48

24

Cascading Timers
The programming of two or more timers together is called cascading. Timers may be interconnected, or cascaded to satisfy any required control logic.
Relay Schematic Diagram Three motors started automatically in sequence with a 20-s time delay between each motor startup.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 49

Equivalent Time-Delayed Motor-Starting Program

20000

20000

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

50

25

Annunciator Flasher Circuit


Two timers can be interconnected to form an oscillator circuit. The oscillator logic is basically a timing circuit programmed to generate periodic output pulses of any duration. They can be used as part of an annunciator system to indicate an alarm condition.
The oscillator circuit output is programmed in series with the alarm condition. If the alarm condition is true, the appropriate output indicating light will flash.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 51

Annunciator Flasher Circuit

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

52

26

Cascading of Timers for Longer Time Delays

30000

12000

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

53

Control of Traffic Lights in One Direction


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

Control of Traffic in One Direction Sequence of Operation

Red 30 s

Green 25 s

Amber 5s

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

54

27

Control of Traffic Lights in One Direction

30

25

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

55

ENGG3490-WEEK9-11 L4
PLCs Ref. [3]; 1. Programming Timers 2. P Programming C i Counters t

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

56

28

Counters
Common applications of counters include keeping track of the number of items moving past a given point, and determining the number of times a given action occurs. g g

A preset counter can control an external circuit when its counted t t l matches th t d total t h the user-entered preset limits.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

57

Mechanical Counters
Programmed counters can serve the same functions as mechanical counters.

ENGG3490: Mechatronics W07.

Every time the actuating lever is moved over the counter adds one number, number while the actuating lever returns automatically to its original position. Resetting to zero is done with a pushbutton located on the side of the unit. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 58

29

Electronic Counters
Electronic counters can count up, count down, or be combined to count up and down. They are dependent on external sources, such as parts traveling past a sensor or actuating a limit switch for counting.

Counter Applications

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

59

Coil-Formatted Counter Instruction


The coil is assigned an address as well as being identified as a counter

Increments counter by 1 for every false-to-true transition

Like the timer, preset and accumulated values are included

When the accumulated count equals the preset count, the output is energized and the counter output is closed. The counter contact can be used as many times as you wish throughout the program as an NO or By F. D. Petruzella, McGraw-Hill NC contact. ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers

60

30

Coil-Formatted Counter And Reset Instruction

Same address

Resets counter when true

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

61

Block-Formatted Counter Instruction


Count line Type of counter Preset value Reset line Accumulated value Output line

PLC counters operate or count on the leading edge of the input signal. The counter will either increment or decrement whenever the count input transfers from an "off" state to an "on" state. The counter will not operate on the trailing edge, or on-to-off transition of the input condition.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 62

31

Counter Counting Sequence


PLC counters are normally retentive. Whatever count was contained in the counter at the time of a processor shutdown will be restored to the counter on power-up. The counter may be reset, however, if the reset condition is activated at the time of power restoration.

PLC counters can be designed to count up to a preset value or to count down to a preset value.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 63

Counter Counting Sequence


The up-counter is incremented by 1 each time the rung containing the counter is energized.

The counter will increment until the accumulated value is equal to or greater than the preset value, at which time an output will be produced.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

64

32

Counter Counting Sequence


The down-counter decrements by 1 each time the rung containing the counter is energized.

A counter reset is always provided to cause the counter accumulated value to be reset to a predetermined value.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 65

Simple Up-counter Program

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

66

33

Up-counter Program Timing Diagram

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

67

C5 Counter Data File


Each counter address is made of a 3-word element

Bit 0-9: Internal Use Bit 10: UA - Update accumulation value. value Bit 11: UN - Underflow bit. Bit 12: OV - Overflow bit. Bit 13: DN - Done Bit 14: CD - Count down is enabled. Bit 15: CU - Count up is enabled.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 68

34

C5 Counter Data File


Each counter address is made of a 3-word element

Specifies the l S ifi th value, which th counter must reach b f hi h the t t h before th controller the t ll sets the done bit. When the accumulated value becomes equal to or greater than the preset value, the done status bit is set. You can use this bit to control an output device.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

69

C5 Counter Data File


Each counter address is made of a 3-word element

This is the number of times of false to true transitions that have occurred since the counter was last reset.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

70

35

PLC-5 And SLC 500 Count-Up Counter Instruction

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

71

ControlLogix Count-Up Counter Instruction

The counter address in the PLC-5 and SLC 500 is a data table address, whereas in the ControlLogix it is a predefined structure of the data type. In the PLC-5 and SLC 500, the max value for the preset and accumulated values is 32,767 and the min value is 32,768; for the ControlLogix controller the max value is 2,147,438,647 and the min value is 2,147,438,648.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 72

36

RSLogic Counter Commands

Command

Name

Description Increments the accumulated value at each false-to-true transition and retains the accumulated value when power cycle occurs
73

CTU

Count-Up

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

RSLogic Counter Commands

Command

Name

Description

CTD

Decrements the accumulated Count-Down value at each false-to-true transition and retains the accumulated value when power cycle occurs
74

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

37

Parts Counting Program


Counter C5:2 counts the total number of parts coming off an assembly line for final packaging

Each package must contain 10 parts When 10 parts are detected, counter C5:1 sets bit B3/1 to initiate the box closing sequence Counter C5:3 counts the total number of packages filled per day A pushbutton is used to restart the total part and package count from zero daily
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 75

Parts Counting Program

10 09

9 10

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

76

38

One-Shot, Or Transitional, Contact Program


The transitional or one shot contact program can be used to automatically clear or reset a counter. The program is designed to generate an output pulse that, when triggered, goes on for the duration of one program scan and then g p g goes off.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

77

One-Shot, Or Transitional, Contact Program


The transitional or one shot contact program can be used to automatically clear or reset a counter. The program is designed to generate an output pulse that, when triggered, goes on for p g goes off. the duration of one program scan and then g

The one-shot can be triggered from a momentary signal, or one that comes on and stays on for some time. From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07. Adapted

78

39

Types Of Transitional Contacts


Off-To-On Transitional Contact
On Off

Symbol
Off

On One scan

Is programmed to provide a one-shot pulse when the referenced trigger signal makes a positive (off-to-on) transition

On-To-Off Transitional Contact


On Off

Symbol
Off

On

One scan

Is programmed to provide a one-shot pulse when the referenced trigger signal makes a negative (on-to-off) transition
79

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Conveyor Motor Circuit That Uses A Programmed One-Shot Reset Circuit


Proximity switch

Sequential Task: The start button i pressed is to start the conveyor motor Cases move pass the proximity switch and increment the counter's accumulated value

Case

Conveyor motor Start/Stop t ti St t/St station

Count reset button

After a count of 50, the conveyor motor stops automatically and the counter's accumulated value is reset to zero The conveyor motor can be stopped or started manually at anytime without loss of the accumulatedPetruzella, McGraw-Hill ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. count 80

40

Conveyor Motor Circuit That Uses A Programmed One-Shot Reset Circuit

50

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

81

One-Shot Rising (OSR) Instruction

Triggers a one-time event. The OSR instruction is a retentive input instruction that triggers an event to occur only one time. Use the OSR instruction when an event must start based on change of state of the rung from false to true true. When the input instruction goes from false to true, the OSR instruction conditions the rung so that the output goes true for one scan. The output goes false and remains false for successive scans until the input makes another false to true transition. ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

82

41

Alarm Monitor Program

The alarm is triggered by the closing of liquid level switch LS1 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 SS1 The light will operate in the steady mode when the alarm trigger condition exists but has Logic Controllers By F. D. Petruzella, McGraw-Hill been acknowledged ENGG3490: Mechatronics W07. Adapted From Programmable

83

Alarm Monitor Program

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

84

42

Down-Counter
The down-counter output 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 downcounter is used in conjunction with the up counter to form an up/down counter.

ENGG3490: Mechatronics W07.

Generic up/down counter program 85 Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Up/Down Counter Timing diagram

Preset Value = 3

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

86

43

Parking Garage Counter Program

As a car enters, it triggers the up-counter output instruction and increments the accumulated count by 1. As a car leaves, it triggers the down-counter output y instruction and decrements the accumulated count by 1. Since both the up- and down-counters have the same address, the accumulated value will be the same in both. Whenever the accumulated value equals the preset value, the counter output is energized to light Controllers By F.Lot Full sign. up the D. Petruzella, McGraw-Hill ENGG3490: Mechatronics W07. Adapted From Programmable Logic 87

Parking Garage Counter Program

50 38 150

50 150 38

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

88

44

PLC-5 And SLC-500 Count-Down Counter Instruction

ENGG3490: Mechatronics W07.

If the accumulation value is below the minimum range then the underflow (UN) bit By F. D. Petruzella, McGraw-Hill Adapted From Programmable Logic Controllers will be true. 89

Up/Down-Counter Program

1 10

1 10 When the CTU instruction When the CTD instruction When the accumulated value is true, C5:2/CU will be true is true, C5 2/CD will because t true Input CC5:2/CD equal to the going or will t isi greateroutputtrue ill b true than causing output A to be true causing B to be both value, C5:2/DN will be presetcounter instructions to reset true, causing output C to be true

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

90

45

In-Process Monitoring System

Before start-up, the system is completely empty of parts, and the counter is reset manually to zero.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 91

In-Process Monitoring System

5 8

8 5

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

92

46

Counter Speed
The maximum speed of transitions you can count is determined by your program's scan time. Any counter input signal must be fixed for one scan time to be counted reliably.
If the input changes faster than one scan period, the count value will become unreliable because counts will be missed. When this is the case you need to use a high-speed counter.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 93

Cascading Counters

Depending on the application, it may be li ti b necessary to count events that exceed the maximum number allowable per counter instruction. One way of accomplishing this is by interconnection, or cascading, two counters.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

94

47

Counting Beyond The Maximum Count

15000

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

95

Counting Beyond The Maximum Count

The status bits of both counters are t programmed in series to produce an output

The output of the first counter is programmed into the input of the second counter These two counters allow twice as many counts to be measured
96

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

48

Cascading Counters For Extremely Large Counts

500 0

Whenever counter C5:1 reaches 500, its done bit resets counter C5:1 and increments counter C5:2 by 1

ENGG3490: Mechatronics W07.

The output light turns on after 500 x 500, or 250,000 transitions of the count Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill input 97

24 Hour Clock Program


The timer times for a 60 s period, after which its done bit is set. This, in turn cases C5:0 to increment 1 count. On the next processor scan, the timer is reset and begins timing again. Whenever C5:0 reaches its preset value of 60, its done bit is set. This, in turn causes it to reset itself and C5:1 to increment 1 count. Whenever C5:1 reaches its preset value of 24, its done bit is set to reset itself.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

98

49

Program For Monitoring The Time Of An Event

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

99

Incremental Encoder
An incremental encoder creates a series of square waves as its shaft is rotated.
The encoder disk interrupts the light as the encoder shaft is rotated to produce the square wave output waveform.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

100

50

Incremental Encoder
The number of square waves obtained from the output of the encoder can be made to correspond to the mechanical movement required.

To divide a shaft revolution into 100 parts, an encoder could be selected to supply 100 square wave cycles per revolution. By using a counter to those cycles, we could tell how far the shaft has rotated.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 101

Cutting Objects To A Specific Size

The object is advanced for a specific distance and measured by encoder pulses to determine the correct length for cutting.
ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 102

51

Counter Used For Length Measurement


Count input pulses generated by the magnetic sensor, which detects passing teeth on a conveyor drive sprocket. If 10 teeth per foot of conveyor motion pass the sensor, the accumulated count of the counter would indicate feet in tenths tenths.

The photoelectric sensor monitors a reference point on the conveyor. When activated, it prevents the unit from counting, thus permitting the counter to accumulate counts only when bar ENGG3490: Mechatronics 103 stock is moving.W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

Counter Used For Length Measurement

10

Photo sensor activated, therefore, accumulated count remains at 10

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

104

52

Combining Counter And Timer Functions


When the start button is pressed, conveyor M1 begins running. After 15 plates have been stacked, p , 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. y The done bit of the timer resets the timer and counter, and provides a momentary pulse to Automatic Stacking Process automatically restart conveyor M1. ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill 105

Automatic Stacking Program

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

106

53

Motor Lock-Out Program


Designed to prevent a machine operator from starting a motor that has tripped off more than 5 times in an hour.
The normally open (OL) relay contact momentarily closes each time an overload current is i sensed. d Every time the motor stops due to an overload condition, the motor start circuit is locked out for 5 min.

ENGG3490: Mechatronics W07.

If the motor trips off more than 5 times in an hour, the motor start circuit is permanently locked out and cannot be started until the Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill reset button is actuated.

107

Motor Lock-Out Program P

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

108

54

Product Flow Rate Program


Parts

This program is designed to indicate how many parts per minute pass a given p process p point.

Sensor

When the start switch is closed, both the counter and timer are enabled. The counter is pulsed for each part passing the sensor. The counting begins and the timer starts timing through its 1-min time interval. At the end of 1 min, the timer done bit causes the counter rung to go false. Sensor pulses continue but do not affect the PLC counter. The number of parts for the past minutes are represented by the accumulated Controllers ByofD.the counter. ENGG3490: Mechatronics W07. Adapted From Programmable Logic value F. Petruzella, McGraw-Hill 109

Product Flow Rate Program

60

28

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

110

55

Timer Driving A Counter For Long Time-Delay Period

0 10,000

Each timer T4:0 input closes for 10,000 s, its done bit resets itself and increments C5:0 by 1. C5 0 b 1

ENGG3490: Mechatronics W07.

The output light turns on 10,000 x 100, or 1,000,000 seconds after the timer input contact closes. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

111

Assignments

Chapter 7 and 8 (PLC) book: Problems See PLC-Problem-Set2 pdf file on the course PLC Problem Set2 web page.

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

112

56

ENGG3490: Mechatronics W07. Adapted From Programmable Logic Controllers By F. D. Petruzella, McGraw-Hill

113

57