Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple AO channel write

I want to output two continuous analog waveforms with USB 6353 board.

I tried this example for a single channel and it worked.

----------------------

AoTask = new Task();
AoTask.AOChannels.CreateVoltageChannel("Dev1/ao0",
"", -10.0, 10.0, AOVoltageUnits.Volts);
AoTask.Control(TaskAction.Verify);

FunctionGenerator fGen1 = new FunctionGenerator(
AoTask.Timing, "200", "1768", "1", "Sine Wave", "1.0");
AoTask.Timing.ConfigureSampleClock("", fGen1.ResultingSampleClockRate,
SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1000);
AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(AoTask.Stream);

writer.WriteMultiSample(false, fGen1.Data);
AoTask.Start();

-----------------------------------------------------------

To use two AO channel,  I tried use two AO tasks.  But it only start the first one channel.

It seems we pnly allowed to use only one AO task for each DAQ board?

My question is how can I configure and write waveform data to buffer(FIFO) that is used by two AO channels (dev1/ao0 and /dev1//ao1)?

My pseudo code will be like this

--------------------

AoTask = new Task();
// create two AO channels, ao0 and ao1
AoTask.AOChannels.CreateVoltageChannel("Dev1/ao0",
"", -10.0, 10.0, AOVoltageUnits.Volts);

AoTask.AOChannels.CreateVoltageChannel("Dev1/ao1",
"", -10.0, 10.0, AOVoltageUnits.Volts);
AoTask.Control(TaskAction.Verify);

 

// generate waveform data

Generate_waveform_data(&Data);

// write Data to onboard buffer/FIFO
AnalogmultipleChannelWriter( Data);
//start AO task
AoTask.Start();

------------------------------

my question is, "What are the corresponding functions in DAQmx API should I used for Generate_waveform_data() and AnalogmultipleChannelWriter() pseudo functions?

 

 

 

0 Kudos
Message 1 of 3
(1,080 Views)

Yes, almost all DAQ cards support only one active AO Task and you've to include all the AO channels you wish to control into the same task for simultaneous control.

 

This documentation page lists the writer functions - https://www.ni.com/docs/en-US/bundle/ni-daqmx-.net-framework-4.5.1-class-library-getting-started/pag...

 

Here is an example,

 

C#

// Given a Task instance "myTask", 
// Initialize the data
AnalogWaveform<double>[] data = new AnalogWaveform<double>[2];
data[0] = new AnalogWaveform<double>(100);
data[1] = new AnalogWaveform<double>(100);
// Create the writer and attach it to the stream
AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(myTask.Stream);
// Perform the write
writer.WriteWaveform(true, data);

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 3
(1,069 Views)

Hi Santo_13,

 

  Thanks for your code example. 

 

 

0 Kudos
Message 3 of 3
(1,043 Views)