Note: NI released the next series of multifunction DAQ devices, NI M Series. The M Series devices, based on the NI-STC 2 system timing controller, provide NI-TIO counter features such as quadrature encoder support; anti-dithering circuitry; and 32-bit, 80 MHz flexible counter/timers. This allows quadrature encoder use without the aid of an external quadrature clock converter.
While the DAQ-STC includes a number of features useful for a large variety of timing and counting applications, its up/down counting feature is particularly convenient for encoders.
When using the DAQ-STC in event-counting mode, connect the pulse signal to be counted to the SOURCE input. When armed, the DAQ-STC count register increments (or decrements) on each transition at the SOURCE input (configurable for rising or falling edges). In addition, you can configure the DAQ-STC to count up, count down, or count up or down as determined by the state of the UP_DOWN input.
When using quadrature encoders with the DAQ-STC, you have two choices. First, for simple applications, you can connect the encoder directly to the DAQ-STC, without any extra logic or signal conditioning. Although simple to implement, this configuration has the disadvantage of not being able to discern between stationary vibration of the encoder and real rotation. Second, you can interface the encoder to the DAQ-STC using a using a quadrature clock converter IC. This method prevents errors due to jitter and debouncing, and provides higher measurement resolution. These two methods are described in the following sections.
Note on Signal Levels
The DAQ-STC, as well as the quadrature clock converter described here, provides TTL and CMOS compatible inputs and outputs. If your encoder provides outputs that are a different signal level—24 V for example—then you may damage your equipment by connecting it directly to the DAQ-STC or clock converter. Therefore, you must either use an encoder that outputs TTL/CMOS signals, or use appropriate signal conditioning to convert the signal level and isolate the TTL/CMOS circuitry from high voltages. In either case, you may want to optically isolate your A and B signal lines to protect your DAQ board, PC, and operator from accidental application of high voltages.
Method 1 – Direct Connection to DAQ-STC (No Signal Conditioning)
For simple applications, you can connect quadrature encoders to the DAQ-STC counter/timer available on NI E Series DAQ boards. By taking advantage of the UP_DOWN control input, you can use the DAQ-STC to count up or down depending on the direction of shaft rotation.
To connect the encoder to the DAQ-STC, wire Channel A output of the encoder to the SOURCE input of the DAQ-STC and wire Channel B output of the encoder to the UP_DOWN input. Figure 4 illustrates these connections for an AT-MIO-16E-2 board. Notice that the UP_DOWN input is accessed on the P0.6 pin for counter 0 or P0.7 for counter 1.
Figure 4. Direct (Unconditioned) Encoder Connection to E Series DAQ Board
In this configuration, the counter will increment on state transitions (default low-to-high) on Channel A. When a Channel A low-to-high transition occurs, the state of Channel B will be high or low, depending directly on the direction of rotation. Therefore, the DAQ-STC counter will increment when the encoder rotates in one direction and decrement when the encoder rotates in the opposite direction.
Limitations of Method 1
While the configuration described above is very simple to implement, this method has a couple of potentially serious drawbacks. If the encoder disk is not rotating, but is vibrating enough back and forth to cause active transitions on Channel A, then each movement will be incorrectly counted. The effect of this dither motion is illustrated in Figure 5. As the encoder disk moves back and forth across A2, Channel B remains low but the DAQ-STC counter continues to increment the count, resulting in an incorrect position reading. The quadrature clock converter device described in the next section solves this problem.
Another problem results when encoder outputs include noise or jitter that is large enough to be erroneously counted as a valid state transition. You can solve this problem with lowpass filters on the A and B signal outputs.
Figure 5. Dithering Effect of Vibration
Method 2 – Using Clock Converter with DAQ-STC for Reliable Measurements
You can greatly improve the reliability and quality of encoder measurements by using a clock converter device that conditions the encoder signals to prevent errors due to vibration, noise, and jitter. For example, the Encoder Signal Conditioner from Wineman Technology Inc. converts the A and B signals from an encoder into a clock and an up/down signal that you can connect directly to the DAQ-STC. The WTI Encoder Signal Conditioner also provides optical isolation and anti-dithering circuitry to protect measurement systems and prevent false counts due to mechanical vibration. For additional information, the WTI Encoder Signal Conditioner’s data sheet can be viewed at the end of this document.