Example Code

Downsample Data Acquired From Multiple Channels Using the Sample Compression Express.vi

Code and Documents

Attachment

Overview

This example demonstrates how to downsample multiple analogue input (AI) channels using the Sample Compression Express VI. It also demonstrates how to log data continuously to a TDMS file.

Description

There is sometimes a requirement to downsample if you wish to acquire data at a lower rate that than is possible with your DAQ device. It is also useful if you require data to be logged at a much lower rate.

For example, if you had a NI-9229 within a cDAQ chassis, the minimum sampling rate possible will be 1.613 kS/s. Some applications may require data to be logged at rates as low as 2 S/s.

If this were the case, we would need to implement a reduction factor of approximately 800. This means we would take every 800th sample when building the new waveform.

In this example, the Sample Compression Express VI is used to downsample from 2 KS/s to 100 S/s, therefore a reduction factor of 20. The data is then logged to a TDMS file using the low level API functions.

Steps to Implement or Execute Code

1. Open the example and select the AI channels that will be acquiring data with your DAQ device.

2. Select the reduction factor you wish to use by configuring the Sample Compression Express VI.

3. Select a file path where the data saved to TDMS, will be stored.

4. Name the 'Group (s)' and 'Channel (s)' inputs of the TDMS Write.vi if required.

5. Run the VI from the front panel.

Front Panel

The front panel is very basic, with just a numeric control for the Sampling Rate and a boolean Stop Button.

The waveforms are displayed using two Waveform Graphs. It is shown below:

Front Panel.PNG

Block Diagram

The block diagram is very straight forward and has been commented for ease of replication. It is shown below.

Block Diagram 2.png

Requirements

Software

The software required is LabVIEW 8.5 or above. No special additional toolkits are required to access this express VI.

Hardware

You will require a data acquisition device to perform a DAQmx Analogue Input task.

Versions available

I have developed this example in LabVIEW 2012 but I have included a copy in the following previous versions:

2011, 2010, 2009, 8.6 and 8.5.

Enjoy the example and good luck with your applications.

Dom C

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

Contributors