Example Code

Change DAQmx Sampling Rate While Continuously Acquiring Data

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This example shows how to change the sampling rate while acquiring data.

 

Description

The sample rate is initialized at 1000 Hz.  In order to change the sampling rate while acquiring data, the task must be stopped, the sample clock must be reconfigured and then the task must run again. This VI achieves this through the advent of an event structure which performs this every time that the rate control experiences a value change.  After a timeout of 10ms, data is acquired continuously at this new sample rate, until another value change occurs at the rate control.

 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1. Configure the parameter for the right channel and device
  2. Connect your hardware appropriately
  3. Run the VI
  4. Chang the sample rate.
  5. Check the result.

 

Additional Information or References

The following image displays the event that occurs when a value change occurs on the rate control:

搜狗截图17年01月21日1750_5.png The following image displays the event that occurs when no value change occurs on the rate control:

搜狗截图17年01月21日1750_6.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,

Sara Lewandroski
Applications Engineer | National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
lukin.21
Member
Member
on

Is possible to do this without interrupting acquisition? Like use external sample clock on M series board? I try change AI sampling rate on the fly using external sample clock but it didnt work well thanks. 🙂

lgx
Member
Member
on

how about the time between stop and restart,

do I know if the interval of timing between the last point of fast sampled data and the first point of slow sampled data?

 

https://forums.ni.com/t5/Example-Programs/Change-DAQmx-Sampling-Rate-While-Continuously-Acquiring-Da...

 

from what I understand, the time stamp it the timing when computer read in the data. 

I am using USB-6002.

danielruetimann
Member
Member
on

Do you have any example on how to do this (change sampling rate) in C#? Thanks.