Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxRegisterEveryNSamplesEvent for MultipleChannel

Hi,
 
We are developing DataAcquisition project using NiDaqmx(NIPCI-6221) on VC++.
We need to read data from VoltageReadTask having more than one channel and need to display the data as live graph.For that we used
DAQmxRegisterEveryNSamplesEvent along with it's CallBack method.We are quite confusing with passing parameters ,usage of
DAQmxCfgSampClkTiming etc.,.I am also placing some part of I am using..
 
"g_VReadTaskHandle" is voltageread task handle which is having 3 channels
"NVRead" is a variable that holds number of channels
"AnalogBuf" is the Buffer which is sent to CallBack method to hold data.
 
we passing 10000 for Sampling rate.
 
 
AnalogBuf = new float64[NVRead*SamplingRate];
 
 //Set the sample clock timing
 DAQmxErrChk(DAQmxCfgSampClkTiming(g_VReadTaskHandle,"OnboardClock",(SamplingRate*NVRead), DAQmx_Val_Rising,DAQmx_Val_ContSamps ,(long)(SamplingRate/NVRead)));
 //Register Callback event 
 DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(g_VReadTaskHandle,DAQmx_Val_Acquired_Into_Buffer,(unsigned long)(SamplingRate),0,VoltageRead,(double*)AnalogBuf));
 DAQmxErrChk (DAQmxStartTask(g_VReadTaskHandle));
 
 
This is CallBack method we are using...
 
 
int32 CVICALLBACK VoltageRead(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
 int count =0;
 int32       error=0;
 int32       read;
 char        errBuff[2048]={'\0'};
 
 DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,nSamples,10.0,DAQmx_Val_GroupByChannel, (double*)callbackData,nSamples,&read,NULL));
 
Error:
 if( DAQmxFailed(error) )
 {
  DAQmxGetExtendedErrorInfo(errBuff,2048);
  CleanupTask(taskHandle);
  CString cst1;
  cst1.Format("DAQmx Error: %s\n",errBuff);
  AfxMessageBox(cst1);
 }
 return 0;
}
 
Thanks in Advance..
 
 
 
 
 
 
 
 
 

 
Message 1 of 2
(3,087 Views)

Greetings Brahma,

Any confusion with functions and their associated parameters can be aided by the NI-DAQmx C Reference Help document.  This is a truly awesome document that explains all of the NI-DAQmx functions, their purpose, parameters, and return values, as well as NI-DAQmx Concepts and Properties.  The document can be found from your Start menu at Programs » National Instruments » NI-DAQ » NI-DAQmx C Reference Help. 

Please take a look at this help file and let me know if you still have any questions...

Regards,

Nicholas B, National Instruments

0 Kudos
Message 2 of 2
(3,063 Views)