Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple AO in DAQmx - CVI

Hope someone can help. I am trying to set multiple AO channels of a PCI-6704 using the DAQmx library, LabWindows 9.

 

I have previously been able to set a single analog output, with the following code...

 

DAQmxErrChk (DAQmxCreateTask("AnalogMXtask",&taskHandle)); 
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle, Analog[index].portName, Analog[index].name, -10.0, 10.0, DAQmx_Val_Volts, ""));
/* DAQmxWriteAnalogScalarF64 writes a floating-point sample to a task that contains a single analog output channel. */ DAQmxErrChk (DAQmxWriteAnalogScalarF64 (taskHandle, 1, 10.0, analogValue, NULL));

 

I would like to know if it is possible (and how) to create a task, add a selection of channels and the outputs to be set, and THEN start the task. I am sure starting and stopping a new task for each individual channel is inefficient.

 

The transition from Traditional DAQ to DAQmx tutorial has been no help really.

 

Trying a prototype, something like...

 

// Create DAQmx task for performing the analog outputs
DAQmxErrChk (DAQmxCreateTask("AnalogOutTask",&taskHandle));
// Add 2 channels + values to them DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle, "Dev2/ao3", "First chan", -10.0, 10.0, DAQmx_Val_Volts, NULL));
valToSet = 1.1; DAQmxErrChk (DAQmxWriteAnalogF64 (taskHandle, 1, 0, 10.0, DAQmx_Val_GroupByChannel, &valToSet, &nSamplesWritten, 0));
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle, "Dev2/ao6", "Second chan", -10.0, 10.0, DAQmx_Val_Volts, NULL));
valToSet = 2.2; DAQmxErrChk (DAQmxWriteAnalogF64 (taskHandle, 1, 0, 10.0, DAQmx_Val_GroupByChannel, &valToSet, &nSamplesWritten, 0));
// Set all analog inputs... DAQmxStartTask(taskHandle);

 

gives an error telling me I need to configure the timing type.

 

When I use...

 

DAQmxSetTimingAttribute (taskHandle, DAQmx_OnDemand_SimultaneousAOEnable, DAQmx_OnDemand_SimultaneousAOEnable);

 I get the error that no devices are in task.

 

Do I need to repeat the task create, create channel, write analog scalar (with auto start), stop task  for each AO, or can I configure all channels + their values before the task is started ? I am not understanding some fundamental here obviously

 

Thanks

0 Kudos
Message 1 of 2
(3,273 Views)
0 Kudos
Message 2 of 2
(3,259 Views)