Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write different buffer sizes to different AO channels for continuous generation?

Hello,

I'm trying to generate multiple analog outputs waveforms with user controlable frequency in ANSI.  This problem seems trival in labview, however; much more harder to understand in ANSI C.  I'm stuck in how to arrange the data for each channel and how to write the buffered data (each AO channel has different amount of samples).

With ANSI C, is it possible to arrange the output buffer data for different buffer sizes per channel.  For example, 100 samples for A01 buffer and 200 samples for AO2 buffer.
Can this be done with an Array of different sized arrays?

How do I write the  DAQmxWriteAnalogF64 function in C to emulate the Labview DAQmx Write (Analog 1D Wfm NChan NSamp) VI? 

Thanks in Advance,

Francis
0 Kudos
Message 1 of 4
(3,213 Views)
 Hi Francis,

 Have you seen the ANSI C examples for text based?
 When you install DAQmx you have the option to include support for text based environments such as LabWindows/CVI, Measurement Studio etc.

 The examples for ANSI C  are installed with support for LabWindows/CVI.
  The Analog Output Voltage example you should look at is here:
    C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Cont Gen Volt Wfm-Int Clk

 You will be limited to a single output rate per analog output task for multifunction DAQ cards, as there is a single timing engine available. You could generate
  rates effectively less than that by creating your data array's appropriately.

Have a great week!

 MatthewW
 Applications Engineer
 National Instruments
 

0 Kudos
Message 2 of 4
(3,190 Views)
HI Matthew,

Thanks for your reply.  I have looked at many examples but I can't figure out how to arrange/write the data so that it will work.

Here's the example:
The sample rate is 50kHz
I want to have a sine wave on A0 at 60.0Hz and a sine wave on A1 at 60.1Hz. 
To have an integer amount of cycles, the number of samples for A0 is 50000 samples, and for A1 is 46589 samples.
When write the 96589 samples to  buffer, A0 looks fine, but the A1 waveform has a bunch of zero samples before it is regenerated.

The Labview DAQmx Write instance of (Analog 1D Wfm NChan NSamp) seems to handle this no problems.  However, there seems to be no paralell C Write function that handles different shaped buffer sizes.

The Labview DAQmx Write instance of (Analog 1D Wfm NChan NSamp) expects the data to be a 1D array of waveforms.  Is that the same as a array of arrays of float64 in C?

Thanks Again,

Francis


0 Kudos
Message 3 of 4
(3,183 Views)

Hello Francis,

I would use an example (Help >> Find Examples >> Hardware Input and Output >> DAQmx >> Analog Generation >> Voltage >> Cont Gen Voltage Wfm-Int Clk-On-Board Regeneration.vi) to help understand how to write a waveform through an analog output channel.  Change the physical channel control to accommodate for both AO0 and AO1 (e.g. “Dev1/ao0:1”).  Change the DAQmx Read to accommodate for a 1D array of waveforms.  Then build a 1-D array with two waveforms and wire the output of the array into the DAQmx

Most DAQ boards have a limited onboard memory or First In First Out FIFO (e.g. 622X has 8,191 Samples).  If you want to only use the onboard memory, make sure that your samples for each channel is less than 4,095 samples per channel.  If you want to use more samples than 8,191 total both channels, then you would want to wire a false constant into the property node (AO.UseOnBrdMem).

What is the acquisition mode for both channels?  If you set it to continuous, then you will have to start writing samples to the FIFO before you execute the start task.  Otherwise, you should get an error. 

Respectfully,

Rob F
Test Engineer
Condition Measurements
National Instruments
0 Kudos
Message 4 of 4
(3,170 Views)