LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add elements of 2D array every iteration, then average over XX minutes?

Hello,

 

I am reading in xbee data from multiple radios. Every time data is received, I store it in a 2D array which auto populates the array for every radio I plug in. Every radio has its own row which updates every time data is received.

 

My problem: I am able to store instantaneous data for each radio, but I can't figure out how to either add each element for each time I get data for a specific radio then average over a 15 minute period,

OR

can I make a moving average for each row, and output that after 15 minutes and reset the array to zeros?

 

Instead what I get is just the same array added to itself essentially just multiplying the initial values by 2, not actually adding previous iterations together.

 

You would need my specific Xbee/arduino setup to utilize my program, so I have just included an example of what I am trying to do.

 

Thank you!

0 Kudos
Message 1 of 9
(2,520 Views)

I forgot that I should probably add some example data. The array that I am working with looks like this.

 

[5][2][24][12.65][12.85][0][18.8]

[10][0][0][13][13.1][0][25]

 

The data are interpreted as

[Radio #][state][height][batteryV][panelV][current][temperature]

 

After 15 minutes maybe I get 25 values from radio # 5, and 18 values from radio 10 due to rain, trees, interference, something...

I want to average all 25 values from radio 5, and all 18 values from radio 10, then display that array as a 15 minute averaged value of all the radio data.

0 Kudos
Message 2 of 9
(2,513 Views)

Is there a particular way to initialize an array as an open 2D array, then fill it in with data as data come in and average them over a 15 minute period?

0 Kudos
Message 3 of 9
(2,475 Views)

Since the number of elements per radio differs, you cannot use a 2d array without addl. bookeeping. (Arrays cannot be ragged). Also don't forget the ptbypt mean.

0 Kudos
Message 4 of 9
(2,472 Views)

Each radio gives out 7 digits that I store. So the radios should all present the same amount of data. I just want a say... 2row x 7 column 2D array to add data to each row every time a radio sends data, then average that array over a 15 min period, rinse, and repeat.

 

thanks

0 Kudos
Message 5 of 9
(2,469 Views)

@stevenette wrote:

Each radio gives out 7 digits that I store. So the radios should all present the same amount of data. I just want a say... 2row x 7 column 2D array to add data to each row every time a radio sends data, then average that array over a 15 min period, rinse, and repeat.

 


This is direct contradiction to your earlier posts where you said that each radio produces a different amount of points in 15 minutes.

(QUOTE: After 15 minutes maybe I get 25 values from radio # 5, and 18 values from radio 10 due to rain, trees, interference, something..)

 

Do you want to average over 15 minutes once or record continuously (forever) displaying the average over the last 15 minutes at all times?

Are all radios sampled at the ~same time (but some don't respond) or do all radios send at random times?

 

If this is a one-shot 15 minute experiment, you could just use "mean ptbypt" for each radio and display the final mean after 15 minutes. No arrays needed!

0 Kudos
Message 6 of 9
(2,461 Views)

I apologize, I misunderstood. Each radio, every time it sends data, sends 7 bytes worth of data. How many times that radio sends data in a 15 minute period is what can change due to interference in the land.

 

I would like to compile all the data from each radio every 15 minutes, average it, then send to a csv for data logging. Then I would like to clear all the arrays and start over. Continue this process ad naseum.

 

thanks

0 Kudos
Message 7 of 9
(2,455 Views)

OK, so use Mean ptbypt (one instance for each radio) and after each 15 minutes log the mean and reset the ptbypt VI. No arrays needed.

(you could even write your own that maintains an array of means, one for each radio. The subVI only needs to keep track of an array of Ns and an array of sums, one element/radio.)

0 Kudos
Message 8 of 9
(2,453 Views)

Hello, unfortunately I do not have that package on my version at my school.

 

Also, say I have an example array of

 

5   | 30 | 45

5   | 25 | 24

10 | 16 | 78

5   | 57 | 34

10 | 76 | 25

5   | 30 | 46

 

5 being the indicator for the first radio, and 10 the second radio. The second value is temperature, and the third value is battery voltage for a 15 minute period. Every 15 minutes I want to take this array, sort it into all the rows of the radio #5, and all the rows of radio #10. Then for every temperature value for radio #5, I want to average, and the same with battery voltage. Do the same with radio 10 so it looks like this after 15 minutes

 

5 | 47 | 37.25

10 | 46 | 51.5

 

This is another method I am trying instead, but still run into 3 additional problems for every problem I solve.

 

Thanks

0 Kudos
Message 9 of 9
(2,448 Views)