LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

element to array

Dear Memebrs,

  I need to do numerical integration of a data value continously for for every 1 min duration. My raw data is in 2-D array form ('avg.data' in attcahed VI). I am indexing my required data value and executing on 'for loop' for 6 times (because my each sampling interval is 10 secs). But the problem is while executing the for loop I am getting the same value of the variable instead to get an updated values for every 10 secs. But the raw data is regulary updating for 10 secs but not get in to effect on my indexed values.

Could any one suggest me a solution. Thanks

 

Note:This is VI operates as a 'sub-vi' on a while loop.

 

Thanks

Senthil

0 Kudos
Message 1 of 20
(4,097 Views)
You always index the same value from the array.  Row 15, column 2.  This means that you are building an array with 6 copies of that element.  If you want to use 6 different data points, you need to put the index array in the loop and change the element you are indexing or use the 'Get array subset' form the array palette.
0 Kudos
Message 2 of 20
(4,073 Views)

What are you trying to do?

 


jack47 wrote:
You always index the same value from the array.  Row 15, column 2.  This means that you are building an array with 6 copies of that element.  If you want to use 6 different data points, you need to put the index array in the loop and change the element you are indexing or use the 'Get array subset' form the array palette.

Jack is correct.

 

Actually, you can auto index within a loop.  I cannot give advice because I don't understand each step of the way.

 

Can you describe what you intended to do within the block diagram?  Repost the image with comments inside it.  That would give you a good exercise at how to comment code so that when someone looks at it in the future (including yourself) you will know why you did something in such a way.  LabVIEW is no different than comments in any language.

 

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

 

Message 3 of 20
(4,059 Views)

Hi Jack,

  Thnaks for your information. I tried using both 'index array' and 'array subset' inside 'for loop'. Still

I could not get values at different instants of my required variable. It still makes 6 copies of same value.

 

Thanks

 

Senthil

0 Kudos
Message 4 of 20
(4,057 Views)

If your index is constant you'll aways get the same element.

 

Can you show us your new code?

0 Kudos
Message 5 of 20
(4,049 Views)

Hi Ray,

  Thanks for your response. Attached herewith my vi and snapshot of my try with 'arraysubet' inside the loop. In my VI, the input 2-D array (avg.data) is a real time data values of different parameters generated by another sub VI. I am acquiring the values for every 10 sec interval. So all parameter values will vary regularly for each 10 sec. I am interested to integrate the values of parameters corresponding to row index'15' and column index '2' for every 1 min. So i need to iterate the 'for loop' to 6 times. But for each iteration I need to get real time values of concerned parmaeter say A1 at 10 sec, A2 at 20 sec...A6 at 60 sec. Instead I am getting integrated with copies of same values for 6 times. i.e. A1+A1+A1+A1+A1+A1,  A2+.A2+...A2,   A3+....A3 

I tried using index array both inside as well as outside for loop.  Even when I enable autoindexing, it is sending all parameter values indiviually rather than iterating my input array (avg data) 6 times. Hope I did not confuse you

 

Thanks

Senthil

Download All
0 Kudos
Message 6 of 20
(4,034 Views)

So If I understand this right, you are storing data from pervious subvi calls in the shift register and adding 6 values to that?  The way you have the shift register configured, it gets re-initalized with each call.  You could try something like this for the beginning of the subvi:

 

Q-X.png

 

It builds the array with six of the values and adds it to the shift register.

0 Kudos
Message 7 of 20
(4,017 Views)

Just curious whats going on with the for loop and shift registers in the case structure? You only have it iterating one time...why bother having the loop?

 

Edit: being used as a subVI in a while loop. I should read more 🙂

Message Edited by for(imstuck) on 10-30-2009 03:45 PM
0 Kudos
Message 8 of 20
(3,999 Views)

Hi Jack,

  Sorry probably my post description might confused you. I dont want to add 6 values to the existing array i.e repalcing the data. Let me explain step by step the VI function below

 

1. The 'avg.data array' is set of of different parameters with their corresponding values.  It is an output of my previous sub -VI and it serves as an input for the current VI.

2. All sub VIs were executed in a while loop for every 10 sec wait time. Hence I will get fresh data values for 'avg.data array' for every 10 secs.

3. My intention is to accumulate the values of a particular parameter for defined time period (1 min) and integrate them all together using interval size as 10 sec i.e. dt=10 sec. This integration need to be carried out for every 1 min.

 

E.g. Let avg.data array has following parameters and their values

 

                                                         

avg.data t@ 2min

                  Column Index

Row Index    0               1      

                  

  

0               A                0.1   

 

1              B                  0.5

 

 

2             C                   0.7 

 

 

 

 avg.data t@ 2.10 min

 

                  Column Index

Row Index    0               1      

                  

  

0               A                0.3   

 

1              B                  0.9

 

2             C                  1.2 

 

Here, A, B & C are parameters and column 1 has their values. Let say this is array at t @2 min. So, my next avg.data array @ 2.10 min will have diff values.

I wish to extract all the values for a parameter say 'C' in above e.g. regulary for a fixed time interval and need to intgerate those values.

 

The problem is already I have a while loop in my main VI and could not use another while loop inside. As I mentioned in my posts, index array and array subset is copying the same value for 'i' times. Say for 'C' the intgeral is '0.7*10+0.7*10....' instead of making '0.7*10+1.2*10+....'  How could i get the values at different timings not using a while loop?

 

In overall simply telling how could I execute 'avg data' for every loop iteration inorder to extract different values for my required parameter?

 

Thanks

 

Senthil

 

P.S Sorry for this longgg.. post Smiley Happy

0 Kudos
Message 9 of 20
(3,986 Views)

So the subvi that creates the AvgValue array executes once every 10 secondsThen this subvi executesAre you just extracting the one datapoint for that 10seconds?

 

I would put a shift register on the while loop of your main VI, extract the value you want from the Avg Value array and add it to that shift registerThen send the shift register to this subvi and do the integrationIf you want more than one value, you can make the shift register 2D, or an array of clusters, or just add more shift registers

 

Q-X_main VI.png

 

Q-X_2.png

0 Kudos
Message 10 of 20
(3,980 Views)