counter the ctu ctd instruction counts upward & down wards over a range each time the rung goes...

23
Counter Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false-to-true. We can make an Up-Down counter by using a separate up and down counter instructions using the same address/structure

Upload: noel-thompson

Post on 29-Dec-2015

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

CounterCounter

The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false-to-true.We can make an Up-Down counter by using a separate up and down counter instructions using the same address/structure

Page 2: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Counter Data FileCounter Data File

• •        CU – count up enableCU – count up enable••        CD – count down enableCD – count down enable••        DN – done bitDN – done bit••        OV – overflow bitOV – overflow bit••        UN – underflow bitUN – underflow bit••        UA – update accumulated value (not used)UA – update accumulated value (not used)••        PRE – Preset value wordPRE – Preset value word••        ACC – Accumulated value wordACC – Accumulated value word

Page 3: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Word valuesWord values

••        Accumulator Value – Number of Accumulator Value – Number of false to true transitions that have false to true transitions that have

occurred since the counter was last occurred since the counter was last reset. reset.

••        Preset Value – Value which the Preset Value – Value which the counter must count up to until the PLC counter must count up to until the PLC

sets the done bit.sets the done bit.

PLC5PLC5

Values between -32,768 and 32,767 CONTROLOGIXCONTROLOGIX

Values between 2,147,483,647to -2,147,483,648

Page 4: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Address StructureAddress Structure

••The Counter uses the typical The Counter uses the typical element addressing scheme.element addressing scheme.••Examples:Examples:

• C5:0.ACCC5:0.ACC•  C11:33/C11:33/DNDN•  C5:2/OV C5:2/OV •  C12:4/UNC12:4/UN

•Counter.PRECounter.PRE

•Counter.ACCCounter.ACC

•Counter.DNCounter.DN

PLC 5 Contrologix

Page 5: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by
Page 6: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Counter UsesCounter Uses

Count the number of items being Count the number of items being produced or testedproduced or tested

Maintain the level in a tank by Maintain the level in a tank by counting the number of gallons in and counting the number of gallons in and draineddrained

Keeping track of very long duration Keeping track of very long duration time periods by combining a timer and time periods by combining a timer and countercounter

Counting frequency, encoder, Counting frequency, encoder, tachometer (pulses)tachometer (pulses)

Page 7: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Counter ExamplesCounter Examples

••        Straight counting in a processStraight counting in a process

••        Sum of two countsSum of two counts

••        Difference of two countsDifference of two counts

••        Timed interval starts when count Timed interval starts when count reaches reaches

preset valuepreset value

••        Count of events after fixed intervalCount of events after fixed interval

••        Rate is determined by dividing count Rate is determined by dividing count by by

time intervaltime interval

  

Page 8: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

TimerTimer 

The TON instruction is a non-retentive The TON instruction is a non-retentive timer that accumulates time when the timer that accumulates time when the

instruction is enabled (rung-condition-in instruction is enabled (rung-condition-in is true).is true).

 

The TOF instruction is a non-retentive The TOF instruction is a non-retentive timer that accumulates time when the timer that accumulates time when the

when enable goes false (rung-condition-when enable goes false (rung-condition-in is false).in is false).

  

The RTO instruction is a retentive timer The RTO instruction is a retentive timer that accumulates time when the that accumulates time when the

instruction is enabled.instruction is enabled.

Page 9: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer Data File ElementsTimer Data File Elements

EN EN –– timer enabled timer enabled

TT TT –– timer timing timer timing

DN DN –– done bit done bit

PRE PRE –– Preset value word Preset value word

ACC ACC –– Accumulated value word Accumulated value word

Page 10: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Word valuesWord values

Accumulator Value Accumulator Value –– Number of clock Number of clock cycles that have occurred since the cycles that have occurred since the

timer was enabled. timer was enabled.

Preset Value Preset Value –– Value which the timer Value which the timer must count up to until the PLC sets the must count up to until the PLC sets the

done bit.done bit.

Values between 0 and 32,767Values between 0 and 32,767

Page 11: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Time BaseTime Base

The timers have a time base by which The timers have a time base by which they are clocked.they are clocked.

Valid Time Bases are:Valid Time Bases are:

1 second1 second

0.1 seconds0.1 seconds

Page 12: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Address StructureAddress Structure

The Timer uses the typical element The Timer uses the typical element addressing scheme.addressing scheme.

Examples:Examples:

T4:0.ACCT4:0.ACC

T11:33/DNT11:33/DN

T4:2/TTT4:2/TT

T12:4/ENT12:4/EN

T15:56.1/0 = T15:56.PRE/0T15:56.1/0 = T15:56.PRE/0

T16:29.2/15 = T16:29.ACC/15T16:29.2/15 = T16:29.ACC/15

Page 13: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer On Delay (TON)Timer On Delay (TON)

Enable Enable –– Set whenever the input rung is Set whenever the input rung is truetrue

Timer Timing Timer Timing –– Set when enable is true Set when enable is true and accumulated value is less than the and accumulated value is less than the

preset value.preset value.

Done Done –– Set when the enable is true and Set when the enable is true and the accumulated value is greater than the accumulated value is greater than

or equal to the preset value.or equal to the preset value.

  

Page 14: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by
Page 15: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer Off Delay (TOF)Timer Off Delay (TOF)

Enable Enable –– Set whenever the input rung is Set whenever the input rung is truetrue

Timer Timing Timer Timing –– Set when enable goes Set when enable goes false and accumulated value is less false and accumulated value is less

than the preset value.than the preset value.

Done Done –– Set when the enable or timer Set when the enable or timer timing bit is truetiming bit is true

Page 16: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by
Page 17: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Retentive Timer (RTO)Retentive Timer (RTO)

Enable Enable –– Set whenever the input rung is Set whenever the input rung is truetrue

Timer Timing Timer Timing –– Set when enable goes Set when enable goes true and accumulated value is less than true and accumulated value is less than

the preset value.the preset value.

Done Done –– Set when the enable is true and Set when the enable is true and the accumulated value is greater than the accumulated value is greater than or equal to the preset value. Does not or equal to the preset value. Does not

reset accumulated value when enable is reset accumulated value when enable is false.false.

Page 18: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by
Page 19: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer UsesTimer UsesTONTONCreate a short pulse at the beginning Create a short pulse at the beginning of a longer input condition (of a longer input condition (.TT bit).TT bit)Delay the start of a function for Delay the start of a function for defined period of time from the start of defined period of time from the start of some other function (.DN some other function (.DN bitbit))

  

TOFTOFUsed to create longer output functions Used to create longer output functions derived from short input functions using derived from short input functions using (.DN bit)(.DN bit)Generate a short pulse at he end of a Generate a short pulse at he end of a long input function by using long input function by using (.TT bit)(.TT bit)

  

Page 20: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer UsesTimer Uses

RTORTO

Used to accumulate time for Used to accumulate time for maintenance functions or for diagnostic maintenance functions or for diagnostic programsprograms

Other UsesOther Uses

count time,count time, Extend push button inputs,Extend push button inputs, Delay inputs, De-bounce InputsDelay inputs, De-bounce Inputs

Page 21: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer Examples To TryTimer Examples To Try 

••Alternate on and off of two Alternate on and off of two outputsoutputs: Two alternately flashing lights. : Two alternately flashing lights. The time for the two lights could be The time for the two lights could be different.different.

••Multiple On DelayMultiple On Delay: Two different : Two different events start at different time intervals events start at different time intervals after an initial starting time reference after an initial starting time reference point.point.

••Multiple Off DelayMultiple Off Delay: Two different : Two different functions remain on for two different functions remain on for two different time intervals after a process is turned time intervals after a process is turned off.off. 

  

Page 22: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer Examples To TryTimer Examples To Try

••Interval time within a cycleInterval time within a cycle: We : We may require that an output come on 7.5 may require that an output come on 7.5 seconds after system seconds after system start upstart up, remain , remain on for 4.5 seconds, and then go off and on for 4.5 seconds, and then go off and stay off. The interval would then be stay off. The interval would then be repeated only after the system is shut repeated only after the system is shut off and then turned back on.off and then turned back on. 

••On DelayOn Delay: Output B comes on at a : Output B comes on at a specific set time after output A is turned specific set time after output A is turned on. When A is turned off, B goes off.on. When A is turned off, B goes off.

Page 23: Counter The CTU CTD instruction counts upward & Down wards over a range Each time the rung goes from false- to-true. We can make an Up-Down counter by

Timer Examples To TryTimer Examples To Try••Off DelayOff Delay: Both A and B have been : Both A and B have been turned on at the same time. Both are in turned on at the same time. Both are in operation. When A is turned off, B operation. When A is turned off, B remains on for a specific set time period remains on for a specific set time period before going off.before going off.

••Limited On TimeLimited On Time: A and B go on at : A and B go on at the same time. B goes off after specific the same time. B goes off after specific set time period, but A remains on.set time period, but A remains on.

••Repeat CyclingRepeat Cycling: An output pulses on : An output pulses on and quickly off at a constant preset time and quickly off at a constant preset time interval.interval.

••One-Shot OperationOne-Shot Operation: Output B goes : Output B goes on for a specified time after output A is on for a specified time after output A is turned on. Output B will run for its turned on. Output B will run for its specified time interval even if A is specified time interval even if A is turned off during the B timing interval.turned off during the B timing interval.