TS-7180 Quadrature

From Technologic Systems Manuals

Quadrature Counters

The TS-7180 provides three independent quadrature counters. The associated inputs are shown in the table below.

Quadrature
Quad # INPUTS
Quad0 DIG_IN_1 + DIG_IN_2
Quad1 DIG_IN_3 + DIG_IN_4
Quad2 DIO_6_IN + DIO_7_IN


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
Quad0 96 97 98
Quad1 99 100 101
Quad2 102 103 104


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.


Edge-Counters, Period-counters


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.

Edge Counters
Input MSB LSB MSB Alias
DIG_IN_1 105 106 107
DIG_IN_2 108 109 110
DIG_IN_3 111 112 113
DIG_IN_4 114 115 116
DIO_6_IN 117 118 119
DIO_7_IN 120 121 122


Period counters are 32-bits wide, and their addresses are shown in the table below.

Period Counters
Input Byte 3 Byte 2 Byte 1 Byte 0
DIG_IN_1 131 132 133 134
DIG_IN_2 135 136 137 138
DIG_IN_3 139 140 141 142
DIG_IN_4 143 144 145 146
DIO_6_IN 147 148 149 150
DIO_7_IN 151 152 153 154

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