LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building an array with custom counter

I want to use a counter as index in an array (see attached vi). I've tried to put the counter and the "energy consumption" into a txt file. That really worked well. But I don't want to use a txt file. I want to have my recorded numbers in an array, indexed by the counter so that I can go back in the vi to a specific index of the array.
 
Any ideas?
 
Thanks in advance.
 
The German Guy
The German Guy
0 Kudos
Message 1 of 5
(3,281 Views)
Hello Neighbour in the east Smiley Very Happy

What do you want to do? You want to store the 'energy consumption' in an array at a point indexed by the counter?
In that case you have to determine what your maximum counter and your resolution should be.
With that info you can initialize an array before the the while loop filled with NaN's.
And with a shift register fill this array at the correct point (look out this will overwrite elements!!)
Then afterwards you can save this array to a file, you only have to make sure to save the offset and resolution of the array as well.

Ton
Sorry I can't post an attachment
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 5
(3,263 Views)

TonP,

thanks for your help first. I have replaced the txt-file part with an array part. I would have expected, that I can store the consumption data at the counter-index.

Here's what it does: The consumption is written in index 1, then 2, then 3, etc. , everytime a new index (by the counter) comes up. So the indicator on the front panel shows me a value at the current index (I like that so far). The bad thing is, that only the latest consumption value stays in the array. When I want to go back to i.e. index 1, I only get the latest value when scrolling back.

I've attached the mod. If you have a chance to look at it....

Thanks for your help,

The German Guy

 

The German Guy
0 Kudos
Message 3 of 5
(3,246 Views)
Hello German Guy,

what you have done is at every loop reinitialize the array, you should move the initialization outside the while loop and feed this into a shift register and replace elements of this array (after replacing feed the array to the right hand side of the shift register.

Use executed highlighting to see (and understand) what's going on.

Ton

The link to the LabVIEW Learning Center is here
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 4 of 5
(3,229 Views)
Hello Ton,
 
thanks for your help. It works and now I also know why. I'm pretty new to labview and we didn't cover arrays in depth in our class. So I have to do a little more learning on my own. Appreciate the link to the learning resources.
 
Thanks again for helping out,
 
The German Guy
The German Guy
0 Kudos
Message 5 of 5
(3,214 Views)