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

What Options Do I Have for Hardware-Timed Digital I/O on my M Series DAQ Device?

Hardware: Multifunction DAQ (MIO)

Problem:
I am using an M Series Multifunction DAQ device to acquire or generate digital signals.  I know that my device does not have an onboard timing engine for digital I/O.  Therefore, I will have to use some other clock source to time the digital I/O on my M Series device.  What options do I have for hardware timed digital I/O?

Solution:
The following options are available to perform hardware timed digital I/O with an M Series device.  Note: Do not exceed the digital I/O Sample Clock Frequency given in the specifications for your device. This is the maximum clock speed allowed regardless of the clock source. Doing so will not cause a software error, but it may result in under-sampled data.   
  • Use one of the onboard counters to generate a sample clock for your task.  To do this, you will need to complete the following steps:
    1. Create a counter output task that will generate a digital pulse train at the desired clock frequency for the digital input or digital output task.
    2. Create a digital input task or digital output task and specify the source for the sample clock as the internal counter output of the counter that is configured to generate a pulse train.
    3. Start the digital input or digital output task.
    4. Start the counter task when you are ready for the digital task to start acquiring or generating.

Here are two example programs demonstrating how to implement this option:
NI Developer Zone Example: M Series Correlated Digital Input with Counter Clock Generation in ANSI C
NI Developer Zone Example: M Series Hardware-Timed DIO with Counter Clock Generation

  • Use an external sample clock for your task.  To do this, you will need to have an external clock signal available that can be used to time your digital I/O task.  Keep in mind that the maximum clock frequency you can use is 1 MHz.  The external clock signal can be connected to any of the following external pins:

    • PFI <0..15>
    • RTSI <0..7>
    • PXI_STAR
    • Analog Comparison Event (an analog trigger)

  • Use the analog input sample clock, analog input convert clock, or the analog ouput sample clock as the sample clock for your digital task.  This is a good option if you want to synchronize analog I/O and digital I/O.  This option also works well if you do not need to use either the analog input or the analog output on your device.  Keep in mind that if you use this option you must clock your digital I/O at the same rate as either your analog input or analog output (depending on which clock you use).  Here are the steps you must complete to use the analog input sample clock, analog input convert clock, or the analog output sample clock to time your digital task:
    1. Configure an analog input task or analog output task.  Set up the timing such that the analog task's clock will run at the rate desired for your digital I/O task.  Even if you do not want to perform any analog I/O, you still must configure this task as a "dummy task".
    2. Configure a digital input or digital output task.  Specify the source for the sample clock as either /<NI-DAQmx Device Name>/ai/SampleClock, /<NI-DAQmx Device Name>/ai/ConvertClock, or /<NI-DAQmx Device Name>/ao/SampleClock.
    3. Start the digital input or digital output task.
    4. Start the analog input or analog output task.  Starting the analog task will start the sample clock for your digital task.

Here are three examples demonstrating this concept:
NI Developer Zone Example: M Series: Correlated Digital Output with Analog Output Sample Clock
NI Developer Zone Example: M Series Correlated Digital Input with Analog Input Sample Clock in ANSI C
NI Developer Zone Example: Performing Correlated Digital IO with an M Series Device in LabVIEW

  • Use the device's onboard frequency generator to provide a sample clock for your digital task.  Each M Series device has a frequency generator which produces a pulse train by dividing down the 10 MHz or 100 kHz onboard timebase by an integer divisor n = 1, 2, ..., 16.  Using the onboard frequency generator limits the sample clock frequencies available to you but is a good option if you do not have an external clock available and are using all of the counters and analog clocks for other independent tasks.  To use the frequency generator as the sample clock for your digital task, complete the following steps:
  1. Create a counter output task that will generate a digital pulse train at the divided down rate of the frequency generator.
  2. Specify the channel name of the counter output task to be <NI-DAQmx Device Name>/freqout.
  3. Create a digital input task or digital output task and specify the source for the sample clock as /<NI-DAQmx Device Name>/FrequencyOutput.
  4. Start the digital input or digital output task.
  5. Start the frequency output task when you are ready for the digital task to start acquiring or generating.

For more information about the frequency generator, refer to page 7-23 of the M Series User Manual.  For an example of programming the frequency generator, refer to the following example:
NI Developer Zone Example: Programming the FREQ_OUT Pin with NI-DAQmx for M Series



Related Links:
Product Manuals: M Series User Manual
KnowledgeBase 4CM6E5T3: Can I Use Different Sample Clocks for Correlated DI and DO?
NI Developer Zone Example: M Series Correlated Digital Input with Counter Clock Generation in ANSI C
NI Developer Zone Example: M Series Hardware-Timed DIO with Counter Clock Generation
NI Developer Zone Example: M Series: Correlated Digital Output with Analog Output Sample Clock
NI Developer Zone Example: M Series Correlated Digital Input with Analog Input Sample Clock in ANSI C
NI Developer Zone Example: Performing Correlated Digital IO with an M Series Device in LabVIEW
NI Developer Zone Tutorial: Generating a Pulse Train with a Counter
NI Developer Zone Tutorial: Period Measurement with a Counter
NI Developer Zone Example: NI-DAQmx: Frequency Measurements Using Counters
NI Developer Zone Example: NI-DAQmx: Continuously Measure Counter Frequency (Buffered-Large Range)
NI Developer Zone Example: Measure High Frequency 2 Counter Method
KnowledgeBase 4CM6E5T3: Can I Use Different Sample Clocks for Correlated DI and DO?
NI Developer Zone Tutorial: Digital Change Detection in NI-DAQmx
NI Developer Zone Example Program: NI-DAQmx Events: M Series Change Detection



Attachments:





Report Date: 12/26/2007
Last Updated: 08/28/2008
Document ID: 4GPG2U9S

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