11-30-2008 04:32 AM
Hi!
In the attacched file I write an array using loop1. In the loop2 2 I build an array of arrays, but im not able to link the two loops in order to add a new array in loop 2 everytime array in loop 1 change.
Any suggestion?
Thank You
Antonio
Solved! Go to Solution.
11-30-2008 05:00 AM
11-30-2008 05:38 AM
Thank You, Pnt.
But I think my request was not cleat at all.
Using the vi You sent me i can write an array of arrays done by N arrays all the same
What i need is something different
1) write the 1st array
2)put it in 2nd 2D array
3) write the 2nd array
4)put it in the 2nd array
.
.
.By this way in the 2D array every element will be different from the other
In order to explain im collecting plant data usind DDE. I write those data in the first array, every time i make a request to DDE server.
I would like to write an array done by N of previous column values in order to average those. During and after my average process the first loop (DDE request must run and it must not stop when average has been performed). For that reason I would like to separato two loops: one only for DDE request, the other, when i like, can perform average on N samples.
Thank you
11-30-2008 11:40 AM
"DDE request must run and it must not stop when average has been performed"
I don't think that you will have any problems, as it cost too little performance but here is an alternative.
11-30-2008 01:06 PM - edited 11-30-2008 01:07 PM
antonio ferrante wrote:In the attacched file I write an array using loop1. In the loop2 2 I build an array of arrays, but im not able to link the two loops in order to add a new array in loop 2 everytime array in loop 1 change.
Right now, but loops are running independently, and there is no guarantee that loop 2 will wait until new data has been produced in loop 1. Your second loop makes no sense. It simpliy duplicates the current data 100 times.
The correct way to do this is by using a queue. Here's is a very quick draft on how to process the 1D array in the second loop whenever new data has been generated.
You still need to add error handling and the averaging code. Most likely you want to initialize the shift register with a fixed size 2D array according to the desired number of averages and then replace the oldest row with each call before averaging. See how far you get and ask again if you get stuck. 🙂
11-30-2008 01:34 PM
antonio ferrante wrote:I would like to write an array done by N of previous column values in order to average those.
Here is a quick example how you would average the last 10 values for each column using a fixed size buffer. Modify as needed.