Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing problems during voltage measurement using DAQmx NI USB-6009

Solved!
Go to solution

Hello members,


despite of reading a lot of topics as well as the manuals i did not find something helpfull.


My problem:

I just want to measure multiple voltage signals on my NI USB-6009 with a given NI example in ANSI C called "ContAcq-IntClk.c" and until now i was not able to configure it correctly. Maybe it is a simple misunderstanding by my side! When i configure four channels with a sampling rate per channel of 12kS/s and set the sample count of the callback function to 48000 (4*12000) samples then i should normally get a callback every second, right? But in fact, I always get the callback every four seconds and I don't understand why.


I changed following configures in the ANSI C example "ContAcq-IntClk.c":
DAQmxCreateTask("",&taskHandle);
DAQmxCreateAIVoltageChan(taskHandle,"Dev2/ai0:3","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(taskHandle,"",12000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,960000);

DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,48000,0,EveryNCallback,NULL);
DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL);


In the callback function:
float64 data[48000]
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1,10.0,DAQmx_Val_GroupByScanNumber,data,48000,&read,NULL));


When i in turn configure it in the testpanel of the DAQmx measurement & automation explorer then it works.


What i'm doing wrong?


I would be very pleased when somebody could help me.


Best regards!

0 Kudos
Message 1 of 3
(672 Views)
Solution
Accepted by sethGecko

It's merely about terminology and the solution is to set your callback event to fire every 12000 samples instead of every 48000.  Under DAQmx terminology, 1 "sample" will contain an ADC conversion value for *each* channel in the task.  In your case, that's 4 ADC conversions.

 

In LabVIEW, this is made more clear because there are different DAQmx Read functions depending on whether you have single or multiple channels in the task and whether you're requesting single or multiple samples from the buffer.  Some functions return 1D arrays, some return 2D arrays, some return scalar values. 

    It appears that in C, you just send a pointer and let DAQmx fill the memory.  So you'll need to find out how your multi-channel multi-sample data is laid out.   I would guess that it would fill in time order so that data[0-3] would be the first sample from all the channels, data[4-7] would be the seconds sample, etc.  But I don't know that for sure, I never use the text API's.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 2 of 3
(652 Views)

Thank you very much! It works.

0 Kudos
Message 3 of 3
(644 Views)