LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

averaging 100 consecutive measurements below a threshold value

Solved!
Go to solution

Hi,

 

I have just started labview programming. I'm having difficulties with programming just this very simple code. I've been breaking my head all night. I will appreciate a speedy response.

 

How can I make a code that would enable averaging 100 consecutive measurements that are below a certain threshold value in labview?

 

Thanks.

0 Kudos
Message 1 of 13
(3,188 Views)

You need to be a little more specific on your requirements.  Are you just given 100 measurements that are already below a threshold to average?  Do you first have to find 100 measurements that are below the threshold?  Where are these measurements coming from?  Do you need a moving average?

 

What have you tried so far?  Share your code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 13
(3,171 Views)

Hi thanks,

 

Thanks. I will be getting say voltages from a device. However, I am setting a threshold for the values I deem acceptable, like a type of filter. I want to be able to average only 100 CONSECUTIVE values that fall below the threshold.

 

I have attached my code. Its not working yet anyway cant seem to complete it.

 

Thanks

 

0 Kudos
Message 3 of 13
(3,165 Views)
Solution
Accepted by topic author concacid

Try the attached.  The key is the shift registers -- the integer (blue) is a counter of below-threshold measurement and it resets to 0 if there is an above-threshold meas.  The result is saved whenever the counter gets above 100 (indicating >=100 consecutive "good" values). This also stops the internal while loop and the external loop causes the shift registers to reinitialize.  I added a "set file position" function so the values will append rather than overwrite the file.  You'll probably need to insert a carriage return into the string that gets written to file so the values will appear on separate lines.  I also changed your data types to DBL -- they were I32 (integer) which does not seem to jive with your indication you were taking analog measurements.

 

 

Message 4 of 13
(3,154 Views)

Thanks Zwired!

 

0 Kudos
Message 5 of 13
(3,147 Views)

Just a clarification.

 

Why did you use a replace array subset instead of a insert into array?

 

Regards


@Zwired1 wrote:

Try the attached.  The key is the shift registers -- the integer (blue) is a counter of below-threshold measurement and it resets to 0 if there is an above-threshold meas.  The result is saved whenever the counter gets above 100 (indicating >=100 consecutive "good" values). This also stops the internal while loop and the external loop causes the shift registers to reinitialize.  I added a "set file position" function so the values will append rather than overwrite the file.  You'll probably need to insert a carriage return into the string that gets written to file so the values will appear on separate lines.  I also changed your data types to DBL -- they were I32 (integer) which does not seem to jive with your indication you were taking analog measurements.

 

 


 

0 Kudos
Message 6 of 13
(3,145 Views)

insert into array increases the array size and causes a reallocation in memory (the allocated memory space needs to be larger).  This causes the contents of memory location "A" to be copied into (slightly larger) memory location "B" and then deleted from location "A", which is inefficient.  This is also why I did not use a build array function inside the loop.  By pre-allocating the 100-element memory space using the initialize array command, I reserved memory and the size of the reserved space doesn't ever change. 

 

To be even more correct, the init array function should be outside the external while loop, with just a non-indexed tunnel and a wire to initialize the shift register on the internal while loop.  That way the init array only fires once and the array can be used many times instead of recreating it on every iteration of the external while.

Message 7 of 13
(3,127 Views)

sir can u write his program for my LabView ver 8.5.. i am not able to open this vi file in my 8.5 version...

reply soon

thank youSmiley Happy

0 Kudos
Message 8 of 13
(2,901 Views)

There is a discussion thread/app available for all of your version conversion needs.....

 

forums.ni.com/t5/Version-Conversion/bd-p/VersionConversion

0 Kudos
Message 9 of 13
(2,890 Views)

I consider it perfectly appropriate to ask for a conversion to an older LabVIEW version in the same thread where the newer version VI exists.  It will help future readers of this thread if they need the older version also.

 

The Version Conversion thread is more for those people who need conversions for their own purposes on VI's that aren't originating on the forums.

 

Here is a LV 8.5 version.

0 Kudos
Message 10 of 13
(2,881 Views)