Dear all,
I would like to continuously and synchronously read data from two devices mounted on
two E6034 (6 differential AI channels by device). I use the C API for DAQmx (no Labview or
measurement studio). The RTSI bus is registered with MAX.
My initial idea was to read from the second device simply by extending the list of
channels specified in DAQmxCreateAIVoltageChan. Here is the idea:
DAQmxCreateTask("",&task);
DAQmxCreateAIVoltageChan(task,"Dev1/ai0:5,Dev2/ai0:5","", // physical channels belong to both devices
DAQmx_Val_Diff,minVal,maxVal,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(task,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,sampsPerChan);
DAQmxExportSignal(task,DAQmx_Val_SampleClock,"Dev2/ai/SampleClock"); // to synchronize sample clock ???
DAQmxStartTask(task);
while(!done) {
DAQmxReadAnalogF64(task,DAQmx_Val_Auto,timeout,DAQmx_Val_GroupByScanNumber,
buffer,bufferSize,&sampsPerChanRead,NULL);
// display data in buffer
}
DAQmxStopTask(task); DAQmxClearTask(task);
This works when reading from one device. However, I did not succeed making this
program for reading from both devices. I don't seem to be able to create
virtual channels with DAQmxCreateAIVoltageChan from different devices (if true,
where is this info documented?). Also, I am not sure if exporting the SampleClock
signal with DAQmxExportSignal in this way would work.
From Fig 10 in
http://zone.ni.com/devzone/conceptd.nsf/webmain/2638A8DA4E4CFD1F86256D250070C093
I infer that I need to define TWO tasks. Therefore, the program skeletton should be
DAQmxCreateTask("",&task1);
DAQmxCreateAIVoltageChan(task1,"Dev1/ai0:5","",DAQmx_Val_Diff,minVal,maxVal,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,sampsPerChan);
DAQmxCreateTask("",&task2);
DAQmxCreateAIVoltageChan(task1,"Dev2/ai0:5","",DAQmx_Val_Diff,minVal,maxVal,DAQmx_Val_Volts,NULL);
// synchronization is obtained by specifying the
DAQmxCfgSampClkTiming(task2,"/Dev1/ai/SampleClock",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,sampsPerChan);
DAQmxStartTask(task1); DAQmxStartTask(task2);
while(!done) {
DAQmxReadAnalogF64(task1,DAQmx_Val_Auto,timeout,DAQmx_Val_GroupByScanNumber,
buffer1,bufferSize,&sampsPerChanRead,NULL);
DAQmxReadAnalogF64(task2,DAQmx_Val_Auto,timeout,DAQmx_Val_GroupByScanNumber,
buffer2,bufferSize,&sampsPerChanRead,NULL);
// display data in buffer1 and buffer2
}
DAQmxStopTask(task1); DAQmxClearTask(task1);
DAQmxStopTask(task2); DAQmxClearTask(task2);
Is it the correct approach? I would much prefer to read all virtual channels in a
single DAQmxReadAnalogF64 call because I would have to manage a single buffer. Here,
it is possible that more data get acquired in the second call.
Is there anyway to make the first approach work?
Thanks,
Gabriel
Message Edited by gavril on 06-07-2005 01:54 PM