From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Update Multiple Analog Output DAQmx Channels On-The-Fly

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 code shows how one might program a scalable number of analog output channels using NI-DAQmx to generate different waveforms or frequencies.

Description

This example demonstrates the ability of the NI-DAQmx API to take an incoming array of information and split it into individual parts that can be applied to different analog output channels. The sampling frequency of the waveform generation is set by the sampling frequency used for outputting data samples from the card so the chances of filling the output buffer are eliminated. The output waveforms have the ability to be updated during execution since the creation of the waveforms is done in the same loop as the analog write function. This example uses Non-Regeneration, meaning new data is constantly being written to the buffer (as opposed to looping the same data over and over again).  This gives two major benefits:

1.  We can generate frequencies that are non-integer divide downs of the sample clock,

2.  We can update waveform properties on the fly.

Requirements

Software

LabVIEW 8.6 or compatible

DAQmx 9.5 or comaptible

Hardware

Any Multifunction DAQ card or Analog Output Card which is supported by your version of NI-DAQmx

Steps to Implement or Execute Code

  1. Select which device you want to use for the example and configure the following parameters on the front panel:
    • Physical Channels
    • Minimum and Maximum Value

   2.  Configure the following timing parameters:

    • Sample Clock Rate

   3.  Configure the buffer parameter of Size(Samples)

   4.  Enter the Waveform characteristics of each of the waveforms you want to generate in the Wfm Info Array control

   5.  Run the VI


Additional Information or References

Block Diagram

Cont Analog Out Multi-Channel Non-Regeneration.png

Front Panel

community example front panel3.PNG

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

John Passiak

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

Comments
John_P1
Trusted Enthusiast
Trusted Enthusiast
on

Any LabVIEW 2009 users might consider modifying the code to use a parallel for loop to generate the waveforms.

John Passiak
John_P1
Trusted Enthusiast
Trusted Enthusiast
on

The version that Updates Phase is a little messy--I had originally used a feedback node which got butchered when I saved back to LV 8.2.

If you have any questions about the code don't hesitate to post.

John Passiak
John_P1
Trusted Enthusiast
Trusted Enthusiast
on

Went ahead and saved a version in LV 2010 that uses the feedback node instead of shift register.

John Passiak
Tinnotek
Member
Member
on

Great example for on-the-fly analog output waveform generation.

Thanks for sharing the example.

Contributors