LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

usb 6009 AI raw data format

I'm using USB 6009 to acquire audio in the form of a sine wave via analog inputs. My goal is to acquire the audio and determine the Fundamental frequency and THD+N of the signal much like the SignalExpress tool does when using the Analysis->Frequency-Domain measurements->Distortion block. I'm using the C API calls in a C++ program. My first question, are there C API calls to get the Distortion measurements?

My other issue is that when I perform a DAQmxReadRaw, I expected a 16 bit integer representation of a sine wave but the values are all over the place, representing more of jagged sawtooth than a sine wave. Maybe I'm handling the data wrong? I'm passing a char array into the ReadRaw call and getting what looks to be valid data although I'm not sure of the raw data format for the device.  Maybe I'm setting up the timing / sampling params wrong. SignalExpress has no problems, so it must be something I'm doing. Here's my very simple setup of the task:

 

DAQmxErrChk (DAQmxCreateTask("",&taskHandle));

DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_RSE,-2,2,DAQmx_Val_Volts,NULL));DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,

"OnboardClock",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));

DAQmxDisableStartTrig( taskHandle );

DAQmxErrChk (DAQmxStartTask(taskHandle));

DAQmxErrChk (DAQmxReadRaw( taskHandle, -1, 10.0, Samples, 1000*2, &SamplesRead, &NumBytesPerSample, NULL));

 

Thanks for any suggestions,

 

Patrick

0 Kudos
Message 1 of 3
(2,998 Views)

Hi Patrick,

 

Everything seems to be configured correctly although I was wondering why you chose to read the raw values from the device. For a simple aquisition, you may want to start with the more common read functions. I also noticed that you are sampling at a rate of 10kHz so if you are sampling a signal around 5kHz, it will look like a triangle wave. You may want to check how everything was being sampled in LabVIEW SignalExpress and make sure you are sampling everything at the same rates. Here is some more information about sampling if you are interested.

 

Regards,

Kent

Applications Engineer

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

Thanks Kent. I've actually made some headway on this since I posted to this thread. I also posted to the Multifunction DAQ thread and received some very useful information:

http://forums.ni.com/ni/board/message?board.id=250&thread.id=42382

 

Basically, I'm capturing a 997Hz sine wave whose amplitude is ~-1.25 to ~1.25 volts. When I do a DAQmxReadAnalogF64 call, I get back float data that corresponds to the sine wave on the analog input. However, When I make a DAQmxReadBinaryI16 call  my 16 bit integer data is -14000 to -19000. The integer values do not respresent the sine wave on the analog input as far as the scale, although it is a clean sine wave when the values are graphed, it's greatly attenuated and offset. The explanation in the thread link above has to do with the way the ADC handles single ended connections internally. Please take a look at the link, maybe you have some ideas.

 

Thanks!  

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