LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get exactly the same number of samples every trial

Hi,

Here is what I want to do.I would like to show using an numeric indicator the expired time increase from 0 to 2 seconds. At the end of this two second period, I want a second numeric indicator to start incrementing from 0 to 3 seconds. I am using a USB 9237 DAQ. Sampling frequency of 2k Hz, and samples read of 500. So far, here is what I have put together. 23854i9F04436A83D7EABA23858i3FE4B9C28C41FBAB

 

The first problem I have is that the first indicator does not start at 0, it starts at .25. The only data I care about is the data during the 3 seconds of "Full force". For this reason, I multiply my signal by 0 except for during the "Full force" period. The problem I am having is that I am not consistently getting 6000 samples. Sometimes I get 5500. If however, there isn't exactly 4000 frames before the "full force" data, then my average will be off. I only start to write to .tdms when the "Start Trial" button is pressed

 

Is there a better way for me to get this 2 seconds then 3 seconds time setup?

 

Any help will greatly be appreciated.

 

Regards,

Johan

0 Kudos
Message 1 of 6
(3,225 Views)

JHendrik,

 

What version of LabVIEW are you using? What OS are you using?

 

I am running LabVIEW 2010 on Windows 7 and when I run your program the indicators start at 0 and not .25. That being the case, I changed your constant from 2.25 to 2 and it runs as one would expect 0-2 then immediatly 0-3.

 

Thoughts?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 2 of 6
(3,194 Views)

Hi,

I am running the student version of labview 2009, with Windows 7. When I run the timing setup by itself, it certainly does start at 0. When the timing setup is added in with the DAQ though, the "samples read" influences how the time is incremented. If I set the samples read at 1k, with a sampling frequency of 2k, then it increments in 0.5 second increments. If I set the samples read at 500, with a sampling frequency of 2k, then it increments in 0.25 seconds. I can kind of understand why the time increments in these intervals. But the fact that it doesn't start at 0, and that it doesnt increment in perfect intervals is a mystery to me.

Regards,

Johan

0 Kudos
Message 3 of 6
(3,186 Views)

JHendrik,

 

That increments you are seeing are due to DAQ code for sure. If ou are sampling at 2khz and want 500 samples, then it'll take .25 seconds to retrieve those samples. While that retreive is happening, your other code may not execute (depending on data flow) becaue it's waiting for the DAQ samples to be returned. By your description, I would guess that the Elapsed time VI is being read after you get your samples, which would be why you don't start at 0 seconds. Try fixing your data flow so that the elapsed time is read first.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 4 of 6
(3,166 Views)

Hi,

Thank you for the help, it certainly makes sense, but I am not sure how I would go about that. I tried a loop within a loop, but it didn't work. Any other suggestions?

Regards,

Johan

0 Kudos
Message 5 of 6
(3,148 Views)

Hi Everyone,

Thank you for all of your assistance, I managed to get around the problem. I really appreciate all the help.

Regards,

Johan

0 Kudos
Message 6 of 6
(3,139 Views)