Counting modes – Measurement Computing USB-4302 User Manual
Page 18

USB-4302 User's Guide
Functional Details
18
Counting modes
Each of the five counters has two associated 16-bit registers which can be used to store count values — the
Load register and the Hold register.
The Load register is used to load the starting value for the counter.
The Hold register can be used to store a second counter value, or to save the current counter value.
Most applications only use the Load register. To start counting, configure the counter for the desired mode, and
then load the Load register with the starting value with which to start the counting operation.
Each counter can be configured to count up or to count down. The following sections explain the various
configuration options.
Reload
When the counter reaches TC it is always reloaded with a new value. This new value comes from one of two
sources:
Reload from the Load register. This mode can be used to generate constant frequency pulse trains.
Alternately load from the Load register and then the Hold register. This mode can be used for applications
that require delayed starts or to generate pulse trains with variable duty cycles.
Recycle
Each counter can be configured to count to TC and then stop counting, or to continue counting after reaching
TC. In either case, the counter is reloaded from the appropriate register when it reaches TC. However, if the
Recycle mode is set to stop counting at TC, and the reload mode is set to load from the Load and Hold registers,
it will count once to TC, reload from the Hold register, count again to TC, and then stop counting.
For example, if Counter 1 is configured as follows:
The Load 1 register contains the value 10,000
The Hold 1 register contains the value 5,000
Count down
Alternately load from the Load and Hold registers
Not recycle
The counter will count from 10,000 to 0, then start again at 5,000 and count to 0, and then stop. If you select an
edge gating option, and Recycle mode is active, the counter only resumes counting after TC when a new active
gate edge is received.
BCD/Binary mode
Most applications use the binary mode of counting. Binary mode causes the counter to always increment or
decrement by a value of 1. The counter can have a value from 0 to 65,535.
With binary mode, a 4-bit binary number is represented by the 16 decimal numbers 0 to 15: 0 = 0b0000,
1 = 0b0001,…, 9 = 0b1001, 10 = 0b1010,…, 15 = 0b1111. (0b is used to denote binary numbers). For the
numbers 0-9, there are four binary bits to represent one decimal digit, and from 10-15, there are four binary bits
to represent two decimal digits.
However, in some applications, it is useful to maintain the four-bit-to-one-digit correspondence, so the numbers
0-9 remain the same, but 10-15 and up to 99 are represented by eight bits—four for each digit. The numbers
100-999 are represented by 12 bits, and 1000-9999 are represented by 16 bits. This makes it easy to decode long
binary numbers.