02-22-2011 03:47 PM
I've got two USB-6210 devices that I need to sync up so that they both gather data at exactly the same time. I've been told by NI support that I can send the clock out of Dev1/PFI4 and have both USB-6210s read the clock in via their own PFI0. I'd also like to trigger the data gathering for each device by sending a trigger out of Dev1/PFI6 and having both devices receive the trigger on PFI2.
All of my attempts to try this have been met with errors messages and my online searches seem to say that this isn't possible with USB devices on NI-DAQmx Base 3.4.0f2 on Linux.
I''ve tried using the ai example programs and those don't seem to work either for external clocks. Here's the code I tried:
#include "NIDAQmxBase.h"
#include <stdio.h>
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int main(void)
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
int32 i;
// Channel parameters
char chan[] = "Dev1/ai0";
float64 min = -10.0;
float64 max = 10.0;
// Timing parameters
char clockSource[] = "/Dev1/PFI7";
uInt64 samplesPerChan = 1000;
float64 sampleRate = 10000.0;
// Data read parameters
#define bufferSize (uInt32)1000
float64 data[bufferSize];
int32 pointsToRead = bufferSize;
int32 pointsRead;
float64 timeout = 10.0;
printf("Calling CreateTask...\n");
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
printf("Calling CreateAIVoltageChan...\n");
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
printf("Calling CfgSampleClkTiming...\n");
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));
printf("Calling StartTask...\n");
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
printf("Calling ReadAnalogF64\n");
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,bufferSize,&pointsRead,NULL));
printf ("Acquired %d samples\n", pointsRead);
// Just print out the first 10 points
for (i = 0; i < 10; ++i)
printf ("data[%d] = %f\n", i, data[i]);
Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if(taskHandle != 0) {
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}
if( DAQmxFailed(error) )
printf ("DAQmxBase Error %d: %s\n", error, errBuff);
return 0;
}
When I run the resulting program I see this:
$ ./acquireNScans-ExtClk
Calling CreateTask...
Calling CreateAIVoltageChan...
Calling CfgSampleClkTiming...
DAQmxBase Error -89136: <err>Specified route cannot be satisfied, because the hardware does not support it.
So, can a clock and a trigger be imported via one of the PFI lines using a USB-6210 on Linux with NI-DAQmx Base? Can a clock and a trigger be exported via one of the PFI lines?
If so, does anyone have example code showing how to do this or can you at least tell me the names of the lines ('Dev1/PFI0' or whatever) so I can try again?
Any clues or suggestions would be helpful.
Thank you,
-Tom
Solved! Go to Solution.
02-23-2011 12:42 PM
The clockSource in the example specifies an output channel rather than an input channel. Changing the source to "/Dev1/PFI0" solves the problem.
Please close this post.