LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using DAQmx to Signal Average..HELP

Hi Everyone,

Here's the dealio, I'm reading in a signal with amplitude ~0.002 Vpp with frequency between 0.01 Hz - 2000Hz.  I am using the DAQmxReadAnalogF64 function to read in my signal on a 6024E MultiFunc Board.  In my experiment I want to dwell on a frequency and average the waveforms say 1000 times.  What I do is put the DAQmxReadAnalogF64 function in a loop in continuous sampling mode, and loop 1000 times.  The problem is that in order to average, I have to do calculations within the loop to average the wave with the wave from before and plot the result on the GUI.  This introduces a TIMING problem, because while I'm doing the calculations and plotting, the wave I'm reading in is still changing (but I'm not reading it in since the loop hasn't gone back to call DAQmxReadAnalogF64).  Obviously, I'm a beginner at data acquisition and I was just wondering:
    a.  Should I be using DAQmxReadAnalogF64 to begin with? (ie. is there another function I don't know about that works)
    b.  If I am stuck using this function how do I solve this timing problem?
    c.  References or any examples that would help.  HELP, plz help! (I know this kind of thing must be done)

Cheers,
tdk
0 Kudos
Message 1 of 4
(3,300 Views)
Hi, tdk.

Can you elaborate a little bit on the timing problem? Are you losing data? Is your graph not plotting the correct data? Is it slowing down your acquisition too much?

Also, you may want to check out the CVI Example Finder -- it's a nifty resource in CVI that has examples of a variety of different tasks. To find it, open CVI and select Help>>Find Examples. Then navigate to Hardware Input and Output>>DAQmx>>Analog Measurements>>Voltage. A variety of examples should be listed, so you may want to look at the descriptions on the right side of the screen to determine which one best applies to your situation.

Let me know how it's going! Have a nice afternoon.
Sarah K.
Search PME
National Instruments
0 Kudos
Message 2 of 4
(3,286 Views)
Hi Sarahk,

Thanks for the reply.  Here's more info about what I'm trying.

Background
First, I'll discribe what I'm trying to do.  I'm using CVI to control a laser modulator, and I'm using the NI 6024E DAQ card in tandem with a GPIB card.  We were using a high speed digitizer, which didn't work because we have to go to low frequency (~0.01 Hz).  The experiment is simple.  I am monitoring two signals: (1) Input to Modulator (control), and (2) Output of Detector.   For the control, I'm just doing a sign sweep from 0.01 Hz to ~2000Hz.  At each frequency I dwell for so many loops so that I can get a good average of signal (2) which is on the order of millivolts. 

CVI implementation
Right now I'm just working on reading in signal (2) at the extremes, low(0.01Hz) and high(2000Hz) frequencies.  To simulate signal (2) I'm just using a func generator.  Anyways, I built the CVI using example "ContAcq-IntClk.prj" since I want to use the clock on the DAQ board for the timing.  Since I am using this pre-built example, I assume that I am creating the task correctly (ie. creat, start, read, stop, clear).  The only modifications I made to the example were: Instead of looping continuously, I specify how many loops from the GUI (~500); After PlotY, I average the signal with the array from the previous loop (using a temporary array called data_temp[]).  Note, this works for freqencies that aren't near the extreme.  However, I get problems at the extremes.

Extremes
At 2000 Hz, I want my sample rate to be ~10 kS/s and store 1000 S.  This corresponds to ~ 4 periods.  However, when I run the code at these settings the execution returns an error "DAQmxReadAnalogF64 is trying to read data that is no longer in the buffer."  I need to fix this.  Could it be the CPU of my computer (I'm running it off of a Intel III)?

Sorry for the lengthy question, but if you can shed any insight plz do.

Thanks,
tdk
0 Kudos
Message 3 of 4
(3,284 Views)
i had a very similar problem, and it drove me nuts for a couple days til i realized what was up.

my card is the 6251.  it has a maximum sample rate of 1,250,000 samples per second.

so when i was trying to take 1000 samples per *cycle*, and the frequency of the sampled signal was 15kHz, i blew past the physical limitations of the device, and I recall it giving me the same error message that you described (attempting to read data not in buffer).  once i brought the rate back down, everything was fine.

i dont know about your card.  i should think that 20,000 samples per second is reasonable, but maybe you're exceeding its max?  or perhaps you are actually trying to read faster than you intended?     It's suspicious to me, since the error message you're getting is the same that i was getting.


0 Kudos
Message 4 of 4
(3,274 Views)