Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Output a Single Period of a Ramp Waveform on a USB-6008 / 6009 Using LabVIEW with DAQmx

Overview

This example will output a 0-5V ramp in 1.5s, then set the output back to 0V.  It is written using DAQmx and designed for a USB-6008 or USB-6009 but will work with any DAQ device that supports software timed analog output.

 

Description

The desired ramp output is generated by using a Sawtooth waveform with an amplitude of 2.5V, an offset of 2.5V, and a phase of -180 degrees.  The default sawtooth waveform with an amplitude of 2.5V goes from 0V to 2.5V, then jumps to -2.5V.  Therefore an offset of 2.5V is needed.  This changes the output to begin at 2.5, ramp to 5V, and jump down 0V. Adding a phase shift of 180 degrees starts the waveform halfway through, when it is at 0V, and then ramps to 5V.  See the images below for what each step looks like.

Default Sawtooth Waveform:

Default Sawtooth Waveform.png

 

Sawtooth Waveform with Offset:

Sawtooth with Offset.png

 

Sawtooth Waveform with Offset and Phase:

Sawtooth with Offset and Phase.png

 

Requirements

  • LabVIEW 2012 (or compatible)
  • DAQmx 12.0 (or compatible)

 

Steps to Complete

  1. Open the attached VI.
  2. Specify the desired Physical Channel and Min / Max Values (±5V for USB-6008/6009)
  3. Specify the desired Software Loop Time (in millisecond intervals)
  4. Specify the desired waveform signal type, frequency, amplitude, phase and offset.
  5. Specify the desired sampling information.  Fs must equal the inverse of the Loop Time.
  6. Run the VI

 

Additional Information or References

This example was designed to output a ramp from 0 to 5V in 1.5s, therefore the desired parameters are:

Frequency = 1/1.5 = 0.67 Hz

Amplitude = 2.5V

Offset = 2.5V

Phase = -180 degrees

Loop Time = 10ms

Fs = 100 Hz (1/Loop Time)

#s = 151

The number of samples (#s) is one more than the number of samples it takes to ramp up to 5V.  This is because the output needs to go back to 0 after finishing the ramp. It takes 1.50 seconds (150 samples @ 100 S/s) to ramp up to 5V, and need one more sample of the waveform to output zero as the last value.

 

VI Snippet

Software Timed Finite AO 2012 NIVerified.png

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

Eric S.
AE Specialist | Global Support
National Instruments
Comments
Member LManning
Member

How can you have  a s/w loop of 1 ms when the o/p rate of the 6009 is 150 per second?

Member smoores
Member

LManning,

You are correct.  With a software loop of 1ms the output rate is 1000 samples per second which is far too high for the USB-6009.  I've made some updates to the example where it instead uses a rate of 100 samples per second.