Virus scan in progress. Please wait to download attachments.
Synchronize a Counter (Angular Encoder) task with an Analog Input task.
This VI will take data at the same rate from both a counter input task, set up here to be an angular encoder, and an analog input task. The Analog Input sample clock is used as the sample clock for both tasks, such that they will both acquire data at the same rate. This VI will also take the counter output and place it into a waveform with the same timing information as the analog data. This allows all the data to be plotted on the same graph.
*Note: The "Get Terminal Name With Device Prefix.vi" subVI automatically selects generates the full terminal name (such as Dev1/ai/sampleclock) and routes it to the sample clock source for the counter. If this subVI does not load, you can easily create a control for the counter's sample clock source and select DevX/ai/sampleclock where DevX is the device name of your DAQ card. The "Get Terminal Name With Device Prefix" VI simply does that behind the scenes rather than needing a user to select it
Requirements to Run
LabVIEW 8.6 or compatible
DAQmx 8.7.2 or compatible
Any NI analog DAQ device with a counter
Steps to Implement or Execute Code
Open "Get Terminal Name with Device Prefix.vi"
Open "Meas Angular Position-Buffered-Cont-Sync AI Sample Clk.vi"
Set parameters in the front panel of "Meas Angular... .vi"
Encoder Channel Parameters: configure the desired physical counter, decoding type, Z index value and Phase (if enabled), Pulses per Revolution, and Units
Analog Channel Parameters: configure the desired Physical Channel, Minimum Value and Maximum Value
Timing Parameters: set the Sampling Rate (Hz) and Samples to Read
Note that details on the code execution are listed in the block diagram.
Additional Information or References
**This document has been updated to meet the current required format for the NI Code Exchange.**
Eric S. AE Specialist | Global Support National Instruments
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.