The TS-7180 provides three independent quadrature counters. The associated inputs are shown in the table below.
Each of the quadrature counters (which are in the FPGA) is 16-bits wide, and are accessed via i2c. The addresses are shown below.
|Quad #||MSB||LSB||MSB Alias|
For example, to read the MSB for Quad1:
tshwctl -r -a 99
The MSB aliases are used to detect 16-bit rollover. If the first reading of the MSB is not equal to the second, overflow/underflow was detected during the read.
For each input pin, there is an edge-counter, and a period-counter. The former counts the positive edges on an input pin, while the latter may be used to measure the elapsed time between N positive-edges.
Edge-counters are 16-bits wide, and their addresses are shown in the table below.
Period counters are 32-bits wide, and their addresses are shown in the table below.
|Input||Byte 3||Byte 2||Byte 1||Byte 0|
To use the period counters, it is first necessary to write N (for the number of edges to count) to address 155. This may be done like so:
tshwctl -a 155 -w N
As soon as address 155 is written, counting begins, clocked at 63MHz. After N edges have been detected, the period registers may be read. The frequency of the input may be calculated from the period, as shown here:
frequency = (N * 63000000) / period
Technologic Systems has provided a simple test program for accessing and displaying the values from the quadrature and edge-counters. Download the source tarball here: File:Test-edges.tar.gz