Here I go again. Thanks to anyone with the intestinal fortitude to look at my problem!
Using NI-DAQmx 1.4.0f2 Base on OS X 10.3.7, with a PCI-6014 DAQ board.
I'm trying to do a finite buffered edge count, but get error -200141, "Data was overwritten before it could be read by the system." from my call to DAQmxBaseReadCounterU32. I'm trying to use a very basic testing program modified from the shipping example, cntBufCont.
My test uses counter 1 to produce a continuous pulse train so that I have something to count, and it counts edges on counter 0. The pulse train specifies no output terminal; the default is pin 40. I specify "/Dev1/PFI9" as the source terminal. I have connected pin 40 to pin 3.
I have an LED connected to pin 40 and pin 3 as well, and I see it come on and go off. Naturally, I can't see it blinking.
The output from the program is:
DAQmxBase Error -200141 on line 8: Data was overwritten before it could be read by the system.
Samples read: 100
0: 0
1: 0
2: 0
3: 0
and more lines like this up to 100.
I can't see anything wrong with the program, but of course that doesn't mean there isn't something wrong! Should I be able to do this on OS X with a PCI-6014? The Read Me for DAQmx Base seems to indicate that I should.
Here's the code:
int main(void)
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
time_t startTime;
// Channel parameters
char chan[] = "Dev1/ctr0";
// Timing parameters
#define bufferSize 100
char clockSource[] = "/Dev1/PFI9";
uInt64 samplesPerChan = bufferSize;
float64 sampleRate = 10.0;
// Data read parameters
uInt32 data[bufferSize];
int32 samplesToRead = 100;
float64 timeout = 20.0;
int32 read;
// parameters for pulse generation
TaskHandle PulseTaskH = 0;
float64 freq = 1000.0;
float64 duty = 0.5;
float64 delay = 0.0;
char pulsechan[] = "Dev1/ctr1";
int i;
int line = 0;
DAQmxErrChk (DAQmxBaseCreateTask("",&PulseTaskH));
line = 1;
DAQmxErrChk (DAQmxBaseCreateCOPulseChanFreq(PulseTaskH,pulsechan,"",DAQmx_Val_Hz,DAQmx_Val_Low,delay,freq,duty));
line = 2;
DAQmxErrChk (DAQmxBaseCfgImplicitTiming(PulseTaskH,DAQmx_Val_ContSamps,1000));
line = 3;
DAQmxErrChk (DAQmxBaseStartTask(PulseTaskH));
line = 4;
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
line = 5;
DAQmxErrChk (DAQmxBaseCreateCICountEdgesChan(taskHandle,chan,"",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
line = 6;
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));
line = 7;
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
line = 8;
DAQmxErrChk (DAQmxBaseReadCounterU32(taskHandle,samplesToRead,timeout,data,samplesToRead,&read,NULL));
Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
DAQmxBaseStopTask(taskHandle);
DAQmxBaseClearTask(taskHandle);
}
if (PulseTaskH)
{
DAQmxBaseStopTask(PulseTaskH);
DAQmxBaseClearTask(PulseTaskH);
}
if( DAQmxFailed(error) )
printf("DAQmxBase Error %d on line %d: %s\n", error, line, errBuff);
printf("Samples read: %d\n", read);
for (i = 0; i < read; i++)
{
printf("%d: %d\n", i, data[i]);
}
return 0;
}
John Weeks
WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com