LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building a 1d array of sequential data for analysis

Solved!
Go to solution

I'm have an executable that needs to cycle a minimum of 10 times, and then check to see if the most recent three average load values are within 5%. If so, I can terminate the executable but if not I need to continue cycling until this is true. As it stands now my executable is not fully set up for the latter requirement as I am stumbling on how to build my array of data. I've tried a few different methods but all keep replacing one value with another and I'm not quite sure how to implement some of the for loop solutions I've seen on here in similar cases. I've now got it so I can build an array once my iterative loop is finished but I would like it to be on the fly and then re-enter the cyling process if needed.

 

I'd greatly appreciate any help someone that's actually competent could provide. I've attached the code (version 8.5).

Message 1 of 13
(4,911 Views)

I haven't looked at your code, so forgive if this isn't relavant.

 

I think you can use the build array, followed by an index array using i, i-1 and i-2 as the indexes to pull values...then average them by sum and division by 3...compare the result to the desired and when it meets the criteria, use a boolian to stop the while ...

 

Example attached.

 

See how many numbers you have to pick randomly to get a small difference....I got hooked playing with it.

 

 

0 Kudos
Message 2 of 13
(4,899 Views)

I think the trick you are looking for is the append to array mode for the build array...It escapes me too. 

 

I used a build array with two elements.  I put the random unmber into the first...and then the output back into the second...(this is an error...as it is making copies of lots of copies.)

 

I couldn't get the append mode to appear on the build array function...that's what you need...

 

Help with that please.

0 Kudos
Message 3 of 13
(4,895 Views)

Your code makes no sense. You need to accumulate your data somewhere. (try the collector express VI, for example or built your own usign feedback nodes or shift registers.)

 

Let's look at your code here. It does NOT contain any history mechanism

 

  1. You get a single data point
  2. You make it into an array with one element
  3. You try to get a subset of three elements probably not starting with the only element in existence. 😄
  4. You take array min+max of an empty array or an array with one element..
  5. ...

You might want to familiarize yourself a bit more with LabVIEW basics and dataflow.

Message Edited by altenbach on 11-19-2008 12:04 PM
0 Kudos
Message 4 of 13
(4,886 Views)
Solution
Accepted by topic author JohnnyF

Let's try this one.

 

In the build array (with concantinate mode on...) the new data is added to the first of the array, not the last.

 

The array builds and as it builds, the first (last added) three items are averaged and then checked against a difference constraint you set on the top screen.

 

Sorry about the first code...I haven't figured out all this array stuff yet.

 

This one works as expected.

 

 

Message 5 of 13
(4,878 Views)

Thanks for the help, guys. I'm working with variations of the VI Hummer provided.

 

Altenbach, I'm well aware of the flaw(s) in my code-I've tried various combinations of shift registers and different ways of buidling the arrays but it always ends up with the same issue (the lack of a proper data array). Unfortunately, my fundamental knowledge of LabView is lacking in certain areas, and this is one of those areas, so I was hoping someone could provide some guidance. I'm certainly not expecting anyone to write my code for me, just hoping to get going in the right direction as I'm rather under the gun on this project and I like my job.

 

Thanks again, guys. Off to play with the collector function as I hadn't thought to try that one.

 

EDIT: Hummer, thanks for that second VI-I'll have a crack at that one.

Message Edited by JohnnyF on 11-19-2008 02:10 PM
Message Edited by JohnnyF on 11-19-2008 02:16 PM
0 Kudos
Message 6 of 13
(4,869 Views)
Well, if you haven't figured it out I'm really up a creek without a paddle. I tweaked your code a bit and inserted into my executable and all is well. Thanks so much!
0 Kudos
Message 7 of 13
(4,850 Views)

The array method is overkill and the collector is way overkill.

 

Message Edited by Dennis Knutson on 11-19-2008 04:04 PM
Message 8 of 13
(4,837 Views)

Thanks Dennis, that really streamlined the application. It seems such an obvious solution now but sadly, was not (at least to me).

 

Thanks to all for help with what is, I'm sure, a rudimentary operation for most users on this forum.

0 Kudos
Message 9 of 13
(4,829 Views)

Great suggestion.

 

That array thing would really grow... and you don't need it .... (If you needed an array for some reason, you could check its size and delete it and start over if it got too big.)

 

...

 

Great solution.  ( I had never seen the add element on the shift register before...that's neat...)

0 Kudos
Message 10 of 13
(4,798 Views)