The
PLC
Guy

  Controlling Your World One Contact At A Time  


AB to AD - Timers And Counters

Timers

Note: Aspects of the storage requirements of timers and counters have been stated before in this presentation. They are repeated here for emphasis.

Timers come in two timebases and two types. The timebases are .1 seconds and .01 seconds. The types are 'standard' which resets when the enable line turns off and 'accumulating' (or retentive) which holds its count when the enable turns off and picks back up again when it turns back on. The accumulating type is reset by a separate command. The standard timers expects a 1 V register (or 'K constant - see below) type preset. The accumulating type expects a 2 V register (or 'K' constant) type preset and utilizes 2 V registers for the accumulator. To make room for this the accumulating timer also takes up the next named timer's position. (e.g. TMRA4 also utilizes the space of TMR5). Mark this off in comments when you create an accumulating timer.

Standard Accumulating
.1 second timebase TMR TMRA
.01 second timebase TMRF TMRAF
Memory for preset or accumulated value 1 V Memory Register 2 V Memory Registers – also takes up
the next named timer position

Counters

Standard counters (CNT) work as you would expect, incrementing on each ON transition of the enable line. They have separate reset lines attached to the same graphic box. An Up/Down counter (UDC) accepts two separate count lines (Up and Down) plus a reset line. A special UDC is available for counting high speed pulses. I'll leave that one for the manual section on high speed counter operation. Finally there is the Stage Counter (SGCNT). Don't be really confused by this one. It's only a standard counter without a reset line attached to the main graphic. It is assumed that you may wish to use it to count in one stage but have its reset operation controlled in another stage. The standard (CNT) and Stage counters (SGCNT) assume a 1 V register (or 'K' constant) type preset (0 – 9999) and utilize 1 V memory for the accumulator. The UDC, like the accumulating timers above, expect up to a 2 V register (or 'K' constant) type preset (0 – 99999999) and utilize two V memories for the accumulator. Again, like the accumulating timer it takes up the next named counter's position.

V Memory Space for preset
or accumulated value
Attached Reset?
CNT 1 Yes
UDC 2 – Plus uses next
counter position also.
Yes
SGCNT 1 No


ALL PRESETS AND ACCUMULATOR VALUES ARE BCD – PERIOD.

The preset of a timer or counter is not part of a fixed 'timer' or 'counter' memory area like in Allen Bradley PLCs.

They can be a fixed number, a constant. Like other instructions which can accept a constant this consists of the letter 'K' followed by the appropriate numbers. Technically these are hexadecimal numbers but if the instruction expects a BCD number then you must limit each character to the numbers 0-9 (as in this case). These values, like constants ('K') elsewhere in the program, can only be changed by modifying the program itself and downloading.

The timer or counter preset can also be a variable value. To have a counter or timer with a variable preset then simply use any user data 'V' register (or a sequence of 2 registers for the timers and counters noted above which are expecting that.) The contents of the 'V' memory registers, for timers or counters, MUST contain a BCD value.

Status - Timers and Counters have JUST ONE status bit.

It is a contact with the same name as the timer or counter. Thus this status bit for timer T1 is ... T1. Got it? This is analogous to the Done (.DN) bit in AB. The creation of the equivalent of an Enable bit (.EN) or a Timing bit (.TT) if really needed is trivial.



Back To Introduction

Please email comments to me at the address below.





Copyright © 2005, 2006, 2007 Bernard Carlton
berniec@theplcguy.com