User`s guide

164
11
Counter Boards
Introduction
This chapter provides details on using counter/timer boards in conjunction with the Universal Library. Boards
released after the printing of this user‘s guide are explained in Readme files on the Universal Library
installation disk.
Visual Basic signed integers
When reading or writing ports that are 16-bits wide, be aware of the following issue using signed integers
(which is required when using Visual Basic):
On some boards, such as the CIO-CTR10 count register or AUXPORT digital ports, the ports are 16-bits wide.
When accessing the data at these ports, the digital values are arranged as a single 16-bit word. Using signed
integers, values above 0111 1111 1111 1111 (32767 decimal) can be confusing. The next increment, 1000
0000 0000 0000 has a decimal value of -32768. Using signed integers, this is the value that is returned from a
16-bit counter at half of maximum count. The value for full count (just before the counter turns over) is -1.
Keep this in mind if you are using Visual Basic, since Visual Basic does not supply unsigned integers (values
from 0 to 65535) or unsigned longs (values from 0 to 4,294,967,295). Refer to "16-bit values using a signed
integer data type" on page 16 for more information.
The Universal Library provides functions for the initialization and configuration of counter chips, and can
configure a counter for any of the counter operations. However, counter configuration does not include
counter-use, such as event counting and pulse width. Counter-use is accomplished by programs which use the
counter functions. The Universal Library provides the cbCFreqIn() function for counter use, while the
Universal Library for .NET provides the CFreqIn() method. Other functions and methods may be added for
counter use to later revisions.
Read the counter chip's data sheet
To use a counter for any but the simplest counting function, you must read, understand, and employ the
information contained in the chip manufacturer's data sheet. Technical support of the Universal Library does
not include providing, interpreting, or explaining the counter chip data sheet.
To fully understand and maximize the performance of the counter/timer boards and their related function
calls, review the following related data sheet(s):
Counter/Timer
Data Sheet
82C54
82C54.pdf is located in the Documents installation subdirectory, and is also available from our
web site at www.mccdaq.com/PDFmanuals/82C54.pdf.
AM9513
9513A.pdf is located in the Documents installation subdirectory, and is also available from our
web site at www.mccdaq.com/PDFmanuals/9513A.pdf.
Z8536
The data book for the Z8536 counter chip is included with the product that employs this chip.
LS7266
LS7266R1.pdf is located in the Documents installation subdirectory, and is also available from
our web site at www.mccdaq.com/PDFmanuals/ls7266r1.pdf.
Counter chip variables
UL counter initialization and configuration functions include names for bit patterns, such as ALEGATE, which
stands for Active Low Enabled Gate N. In any case where the UL has a name for a bit pattern, it is allowed
to substitute the bit pattern as a numeric. This will work, but your programs will be harder to read and debug.