LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array index

Solved!
Go to solution

Hello, I'm pretty green to Labview.  I have read 2 books on the topic, spent hours in the help section, done several related tutorials and cruised the boards for a solution to my problem already.  I'm using Labview 8.2 so I can't handle many of the examples that have previously been posted.  If you encode something please save it as an 8.2 or lower file.

 

I have a digital multimeter attached via GPIB and I have used the corresponding labview program to go with the specific multimeter.  This part works fine.  What I need to do is to take an average (an average over 100 or 1000 measurements, if not more) that exceeds the averaging capability of the multimeter.  My thought was to use the data to write a mini labview program.  Take the data, put it into an array and then average the array after it gets to a specified size.  So far, I can get the data to go into the 1st element of the array, but all my methods for incrementing the data to higher elements isn't working.

 

I tried a "Signal Compression" function, to no avail.  a double isn't a signal, so it refuses to give a mean output.

I tried a time delayed for/while loop, but when the vi runs, the loop iterates until finished before allowing the multimeter to reaquire more data.  So I get 100 data points all written to the first element of the array.

I tried the "build array" function incorrectly.

 

I have attached my vi.  When running with no averaging from the multimeter, data is updated approximately every 10ms.  I need to be able to take a larger average as well as perhaps have a scalable average.

 

Thank you for your patience,

Benjamin

Message Edited by dark7flame on 06-02-2009 01:04 PM
0 Kudos
Message 1 of 11
(4,541 Views)

I dont seem to be completely understanding your question.

Do you want an average of the first N points?
Or are you trying to create a moving average?

 

Here is an example of how to do the former:

 avg.PNG

 

You will have your multimeter value wired in place of the 'Data' control I placed. 

This will take an average of your first 100 points, and display them in an indicator named 'average' 

 

 

If you are interested in the latter, let me know and I will show you a quick example.

Message Edited by Cory K on 06-02-2009 02:01 PM
Cory K
Message 2 of 11
(4,528 Views)

A few problems.

 

1.  Your VI only runs once.  Thus it is going to only give you one value in your array.

2.  You are intializing an empty array an inserting the single value into the beginning of it.  Assuming you had a loop happening, you would always be inserting into the beginning which is just not very efficient.  Insert Into Array is rarely the VI you want to use.  You are better off Auto indexing the tunnel coming out of the loop like shown.  Or using Build array and mainting the array in a shift register.

3.  No need for that stacked sequence structure that hides too much code.  You don't need a sequence structure at all because the data flow in the wires will determine execution order.  If you do need an sequence structure, a flat sequence is preferred.

Message Edited by Ravens Fan on 06-02-2009 03:02 PM
Message 3 of 11
(4,526 Views)

Here is the appended vi.  I am having difficulty ensuring that my "control" array is of the double type (I put in 0.0 into the numeric constant and it still registers as an integer).  I also am having difficulty with the "Build Array" command that you used.  It's the first array manipulation that is used inside the while loop.  Several manuals have the same symbol, but don't inform where to get it.  The "Build Array" command that is in my labview has an (or multiple) array inputs or element inputs, not both to the same vi.

 

Thank you for your patience and your clarity,

Benjamin

0 Kudos
Message 4 of 11
(4,502 Views)

Your VI still has problems.

 

The upper part of your code only runs once returning a single value.  You are using that same value continuously in your lower while loop.  You did not set up your shift register the same was as Cory shows it as you created an autoindexing tunnel you are using rather than the shift register.  Start with my code, then drop in Cory's code for doing the averaging after that.

0 Kudos
Message 5 of 11
(4,498 Views)

Ravens Fan wrote:

Your VI still has problems.

 

.... Start with my code, then drop in Cory's code for doing the averaging after that.


 

Go Teamwork! Smiley Very Happy
Cory K
0 Kudos
Message 6 of 11
(4,477 Views)

Ah, fixed the shift register.  Implemented Ravens Fan's code.  Ravens code slows the data aquisition process, but not to an unreasonable extent.  Now the issue is that the data never leaves the upper while loop.  Attached is the current revision of the vi.

 

we're getting close,

Benjamin.

Message Edited by dark7flame on 06-03-2009 08:48 AM
0 Kudos
Message 7 of 11
(4,458 Views)
Solution
Accepted by topic author dark7flame
Message 8 of 11
(4,442 Views)

Thank you! that's the solution!  Now to fix a few other things and i'm golden.  Thank you all for your time and patience.

Any way I can tag 2 people for the solution?

 

Benjamin

Message Edited by dark7flame on 06-03-2009 10:44 AM
0 Kudos
Message 9 of 11
(4,431 Views)
Any reason to use summation and array size instead of just using the Mean.vi?
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 10 of 11
(4,423 Views)