beautypg.com

Measurement Computing USB-4302 User Manual

Page 19

background image

USB-4302 User's Guide

Functional Details

19

For example, 0b1001 0001 0000 1001 equals 9109 in BCD (Binary Coded Decimal) mode, and equals 37,129

in binary mode. In BCD mode, the counter can only contain values from 0 to 9999 instead of 0 to 65,535 as in

binary counting.

The "Special" gate

When you enable the Special gate option, and specify gating, the gate can function as a hardware re-trigger of

the counting operation. When an active gate edge is received, the counter is reloaded from the Load register and

begins counting, even if the counter is already counting when the gate edge is received.

When you enable the Special gate option, and disable gating, the Gate pin associated with the counter being

configured can select the reload source for the counter. This requires the counter be in Load and Hold reload

mode. If the gate pin is low, the counter is reloaded from the Load register. If the gate pin is high, the counter is

reloaded from the Hold register.

Output control

You can configure the output pin associated with a counter to behave in five ways:

Inactive with high impedance to ground.

Inactive with low impedance to ground.

Generate an active high pulse when the associated counter reaches TC.

Generate an active low pulse when the associated counter reaches TC.

Toggle its value every time the counter reaches TC.

Example 1

Problem

: The application generates an active low pulse every time a button

1

is pressed.

You need a simple

event counter to count button presses.

Solution

: Any of the counters can be configured to do this fairly easily. Do the following:

1.

Connect the input signal to the counter input pin, and select that input pin as the source for the counter.

2.

Program the counter to:

o

Count negative edge transitions

o

Count up

o

No recycle

o

Count in binary mode

o

Reload from the Load register

o

Disable special gate

o

No gate control

o

Make output control inactive

3.

Load the Load register with a value of 0 to start counting.

1

For more information about debouncing mechanical switches, refer to the "Low pass to de-bounce inputs" section

in MCC's Guide to Signal Connections . This document is available on our web site at

www.mccdaq.com/signals/signals.pdf

.