For this section, consider an example using the NI cDAQ-9178 chassis and the NI 9401 C Series digital I/O module. The procedure is similar when using a different measurement instrument or device.
Figure 8. NI cDAQ-9178 Chassis and NI 9401 Digital I/O Module
The NI 9401 has a DSUB connector that provides connections for the eight digital channels. Each channel has a digital I/O pin to which you can connect a digital input or output device. Access to the four counters of the CompactDAQ chassis is available in any of the slots of the chassis; if you are using the cDAQ-9172, access to its two counters is only available through slots 5 and 6, therefore insert the 9401 in slot 5. Figure 9 shows the pinout for this configuration, and Table 1 shows the default counter terminals.To use your quadrature encoder with your DAQ card, connect channels A, B, and Z to the counter's SOURCE, AUX, and GATE pins, respectively. To find the pinout specific to your DAQ card, right-click the card in NI MAX and select Device Pinout. Refer to the guide Connecting Quadrature Encoders to a DAQ Device for step-by-step instructions for wiring and configuring your NI DAQ device for quadrature encoder measurements.
Figure 9. NI 9401 Pinout (Slot 5)Table 1. Default Counter Terminals
According to these specifications, Wire A is connected to Pin 14, Wire B is connected to Pin 17, “5 VDC Power” is connected to any unused digital line set to “high,” and “Ground” is connected to any COM terminal.
Now that you have your encoder connected to the measurement device, you can use Measurement & Automation Explorer to confirm it's operation. To do so, go to the Data Neighborhood section of Measurement & Automation Explorer, and right-click on the NI-DAQmx Global Virtual Channels entry and select Create New NI-DAQmx Channel...Figure 10. Create New NI-DAQmx Channel...From the prompt, expand the Acquire Signals category, followed by the Counter Input category, and then the Position category. Select the Angular Position channel type.Figure 11. Selecting the Angular Position Channel TypeSelect the counter you wish to use on your hardware for this operation and press Next. Finally, give your virtual channel a name and then select Finish.You can now modify your Global Virtual Channel's configuration attributes to match your specific encoder, and test its operation by clicking the run button in the measurement pane above the configuration pane.
Figure 12. Configuring the Channel Attributes to Match Your Encoder and Test the Encoder
Now that you have your encoder connected to the measurement device and confirmed its operation in Measurement & Automation Explorer, you can use NI LabVIEW and the DAQmx driver to transfer the data into the computer for visualization and analysis.Table 1 shows an example of displaying the edge count and the corresponding position increments inside the LabVIEW programming environment.
An example of this can be found in the DAQmx Counter Input shipped examples found in <National Instruments>\LabVIEW xxxx\examples\DAQmx\Counter Input. Specifically, the Counter - Read Encoder example.Figure 13. LabVIEW Front Panel Showing Measurements
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.