LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

high frequency data sampling one at a time

Solved!
Go to solution

Hi,

 

I am using LabView 2011 to make resistance measurements.  The DAQ assistant express vi is placed in a while loop and it acquires 1 sample (on demand).

 

As each sample is acquired, it is compared to a set point. If the resistance value is greater than the set point, a task is performed. If not, no action is taken.

 

I would now like to increase the frequency of acquistion to say 5 kHz. As before, I would like the DAQ to give out each value as it is acquired and compare it with the set point.  However,  single point acquistion is limited by the speed of the while loop (which does not exceed a few Hz per second when I use the software-timer.    If I use 'continuous samples' at 5 kHz, the DAQ does not give out these samples one at a time.  It seems to acquire them until the buffer is full and then output several samples at once. This makes it impossible to compare with the set point.

 

Is there a way to acquire the data at high frequency and have it compare to the set point, one at a time?

 

 

0 Kudos
Message 1 of 11
(3,694 Views)

No.

 

You'll have to acquire multiple points at once.  You can do some  point by point VI's to search through the acquired arrays a point at a time.

0 Kudos
Message 2 of 11
(3,682 Views)

Thanks. 

 

Could you provide some more details on how to go about this?

0 Kudos
Message 3 of 11
(3,680 Views)

Grab N samples.  Feed that into a For Loop with autoindexing.

 

But since you want you just want to see if something is greater than a value.  Make the comparison on the array.  Then use OR Array Elements to see if any of the values are True.

0 Kudos
Message 4 of 11
(3,676 Views)

If I acquire the N samples at 5 kHz and feed them into the array, is it possible to also make the comparison at 5 kHz?  In other words, can the comparison be made at the same speed (or comparable speed) to the acquisition?

0 Kudos
Message 5 of 11
(3,669 Views)

What do you think?  Do you think you can compare as many as 5000 points to a constant in a second?  I have an idea -- write a little LabVIEW program that (a) generates 5000 random numbers and puts them in an array, then (b) compares each point to 0.5, creating a 5000-point boolean array if the "sample" point is >0.5.

 

Before you run this, make a guess how many seconds this will take (note that this is two 5000-point computations ...).

 

Run the test and draw your own conclusions.  After all, why ask us when you can figure it out for yourself.

 

Bob Schor

0 Kudos
Message 6 of 11
(3,664 Views)
Solution
Accepted by topic author kumv10

Simple enough code can do this.

 

But the problem all comes down to how fast all of the other code in the loop takes to run.

 

The first problem is you are using the DAQ Assistant, which provides a lot of extra overhead in the loop, particularly if you don't set it up properly.  (And we can't tell because no code is attached for us to look at.

 

You should try some real DAQmx code where you start an acquisition with continuous samples before the the loop, acquire exactly 1 sample in the loop.  Then close out the DAQmx task once the loop ends.  See if that keeps up.

 

Why do you need to do this?  Note that at any minute Windows might decide to steal a second or two and go off and do something else like a virus check.  If you need such precise timing (how exact do you need this?), then Windows is not the correct system to be running this on.

0 Kudos
Message 7 of 11
(3,650 Views)

Thanks.

 

I don't need too much precision but a comparison on the order of 1 or 2 kHz would be great because the resistances in my system are changing rapidly and have sharp peaks and valleys on the order of milliseconds. The resistances are actually being scaled to temperatures so it is actually temperature that is varying.   So I need the evaluation or comparison to take place fast enough to capture a good portion of the transients. I don't have an exact number for this but comparable order of magnitude should be fine, I guess.

 

 

0 Kudos
Message 8 of 11
(3,646 Views)

But why do you need to detect the differences so instantly?  What are you needing to do in that next millisecond?

 

Why is it not acceptable to determine when that happened within a chunkd of data even it you don't know where that point is until a short time later once you've had a chance to acquire and process?

0 Kudos
Message 9 of 11
(3,629 Views)

Because high temperatures are undesirable for the system. So if a rapid transient takes place and the temperature spikes, I want to be able to take immediate action and cut off power to a certain module. This is essentially a demonstration of a safety mechanism.  So the 'task' being perfomed as I mentioned in my first post, is the shutting off of power.

 

 

The Daqmx code with 1 sample per loop was pretty quick.  The 'Write to measurement file' task that I threw into the loop slowed it down quite a bit but it was still close to 200 Hz. I am guessing it will not stay consistent at this rate because of Windows.

 

Still pretty good for a start and much quicker than the ~ 1 Hz I was sampling at previously. 

 

Cheers!

0 Kudos
Message 10 of 11
(3,622 Views)