02-21-2007 07:40 AM
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0:7","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",32000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,32000*60*8));
DAQmxErrChk (DAQmxStartTask(taskHandle));
while( 1 ) { //////// short *data =new short[32000*8*60] buffer for storing samples
DAQmxErrChk (DAQmxReadBinaryI16(taskHandle,32000*60,32000,timeout,DAQmx_Val_GroupByScanNumber,data,32000*60*8,&read,NULL));
if( read>0 )
{
// here i call another thread to encode samples in data buffer using lame library
}
}
when I execute this code , I get 1 minute sound file correctly and then start reading for next minute so after expiring timeout the application crashes.
so what should i do to acquire data with sample rate 32000.
thanx
02-22-2007 04:33 PM
02-23-2007 09:17 AM
Hi
Thanks for your response.
when I call the Read API of DAQmx (DAQmxReadBinaryI16) then it works fine for the
1st or 2nd minute (as i record/read sound data samples of 60 seconds at one time)
and the samples read by this API are correct. but when this API is called for 3rd time (minute)
then this API returns the error value (-200284) and the out parameter of this API (which is the
samples read per channel) is 0(means no samples are read).
int read; short *data=new short[32000*60*8]; while(true){
int retcode=DAQmxReadBinaryI16(taskHandle,32000*60,timeout,DAQmx_Val_GroupByScanNumber,data,32000*60*8,&read,NULL)); }
when this is called for 1st,2nd time then out parameters, data buffer=filled with samples of 8 channels
and the read =no of samples in 1 channel (1920000) and retcode is positive.
but when it is called for 3rd time then read value is 0. and retcode is -200284.
so what can be done to solve this problem.
thanx .
02-23-2007 10:07 AM
02-24-2007 10:23 AM
Hi Sir
I tried that example C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Voltage\Cont Acq-Int Clk.
it works fine but when I made diffrent changes to it as my Requirments
- continous data acquisition from 8 channels
- SampleRate = 32000 and Buffer size = 32000*60*8 (hold the samples in 60 seconds of 8 channels at 32000 SampleRate )
- timeout =60 (sec)
- change the reader API to DAQmxReadBinaryI16() also used short type for the buffer and assign memory at heap.
when I made these changes to this example then I see that it reads 1920000 samples in 1st minute,2nd and 3rd
after reading for 3rd time the application didnt crashed but didnt display the samples any more (means stops at that time).
when I used the timeout = -1 then it acquire data for 5 minutes but stops after that.
I also tried with same buffer but high samplerate then also after 4 or 5 minutes it stoped.
I suspect some problem with the buffer.
So Plz help me to find out the problem.
Thanx
02-26-2007 04:18 AM
02-26-2007 11:51 AM
02-27-2007 01:54 AM
}
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
printf("\n Closed the Handler\n");
printf("\n the Count is %d",totalRead);
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
return 1;
}
02-27-2007 04:07 PM
03-01-2007 02:36 AM