Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 2 out of 5     Rate this Document

Can I Use an Analog Input for a Count Edges or Encoder Task Using DAQmx?

Primary Software: Driver Software>>NI-DAQmx
Primary Software Version: 7.1
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Development Systems>>Base Package
Hardware: Multifunction DAQ (MIO)

Problem:
I need to create a count edges or an encoder task but I do not have any available counters. Can I use an analog input (or resolver signal) to create a task for counting edges or for reading an encoder?

Solution:
You can analyze data from an analog input task to count edges or read an encoder, however using a counter is preferred if one is available. Counters perform hardware edge detection/counting which provides better accuracy than the solution discussed in this document.

The analog input method described below may be beneficial in the following situations:
  1. Your encoder or pulse train signal levels are not TTL
  2. No counters are available and it is not feasible to obtain additional hardware.

To count the edges of your signal, first set up a continuous buffered acquisition analog input task. You will want to sample as quickly as possible to obtain a clear representation of the signal. Compare each sample to a set threshold to analyze for edge detection. When the signal crosses the threshold (sequential samples lie on either side of the threshold), increment or decrement your count value depending on the specified count direction.
In the attached LabVIEW example, count direction is software controlled, however it can be easily modified for external control using another analog input (for example if you want to connect a quadrature encoder).

Note: there are two limitations when using this software method:
  1. Detection is done via software, which has the potential to miss edges if sampling is not fast enough. To ensure that you do not miss an edge, the sampling rate must be at least twice the frequency of the pulse which is being counted. Ideally you will want to sample much faster. See the specifications for you DAQ device to determine the maximum sampling rate for your board. Using a counter, which is typically clocked at a much higher rate, will enable you to accurately count much faster signals.
  2. Neither synchronized or buffered measurements are implemented.


Related Links: KnowledgeBase 2I5DAAXA: Is It Possible to Count Non-TTL Pulses with an E Series Data Acquisition Board?

Attachments:


Counter_with_AI_LV_7_1.vi


Report Date: 03/12/2007
Last Updated: 09/25/2007
Document ID: 47B5TIMK

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit