Example Code

Programmatically Implement an Auto Zero for SCXI Voltage Acquisition

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
Demonstrates on programmatically implement an Auto-Zero for the SCXI voltage acquisition and set the delay between samples to account for the additional settling time when using a filter.

Description
This VI allows the user to program autozero SCXI voltage measurements using LabVIEW and it is intended to be used as a SubVI in line with other DAQmx VIs in your program.  Measured DC Offset is the output of this VI.
When the VI is called, it connects all inputs to GND and bundles the current timing parameters into a cluster. Specified number of samples will be taken from each and average value of these samples will be computed.  
The expected GND value (typically 0 V) will be subtracted from the calculated average. Finally, the inputs and the timing parameters will be set back to their initial values.
Many SCXI modules have a built-in autozero function, but they don't give the user access to adjust the delay time to compensate for the settling  that the filters can introduce.  

Requirements:

  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible.

Instructions:

  1. Place this VI in line with the DAQmx VIs in your code, before the Start Task VI.
  2. Run the Main VI.


Block Diagram Steps:

  1. Connects inputs to GND. Specifies the coupling for the channel and how often to measure ground. NI-DAQmx subtracts the measured ground voltage from every sample.
  2. Reads from the previously configured timing parameters and bundles them to a cluster. The configuration includes:
    i. whether the task acquires or generates a finite number of samples or if it continuously acquires or generates samples.
    ii. the number of samples to acquire or generate.
    iii. the sample timing type.
    iv. sample clock rate.
    v. sample clock source.
    vi. sample clock active edge.
  3. Sets number of samples per channel, sample mode and sample rate.
  4. Programs the hardware as much as possible according to the task configuration.
  5. Sets the delay time.
  6. Transitions the task to running state to begin measurement.
  7. Reads the data.
  8. Computes the mean of the values in the input sequence X.
  9. Stops the task and returns it to the state it was in before the DAQmx Start Task VI ran.
  10. Disconnects inputs from GND
  11. Loads original task timing.
  12. Programs the hardware as much as possible according to the task configuration.
  13. Sets the delay time.

BD.PNGFP.PNG
 

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

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