LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing External Readings

Solved!
Go to solution

Hello,

I'm new to LabView and came across this problem which I hope is very easy to someone more experienced. I am to read a changing value (like from a temperature sensor but in this case a random value from the outside) and save it to an array.

Indexing Problem.png


I tried auto-indexing the values as well but every reading comes out as the same.

 

What can I do to save the unique number to the array per every iteration of the while loop? 

Many thanks in advance.

0 Kudos
Message 1 of 6
(178 Views)
Solution
Accepted by topic author asciirad

You are reinitializing an array every iteration of the while loop. Moreover, you change its size every iteration.

 

To add a value to an array while keeping previous values, use a shift register:

Basjong53_0-1744295054008.png

 

 

Message 2 of 6
(164 Views)

Hi rad,

 


@asciirad wrote:

Indexing Problem.png

I tried auto-indexing the values as well but every reading comes out as the same.


You already got a solution…

 

Now look at your own VI again: it does exactly what you have it programmed to do…

So try to understand your own VI:

  • You initialize an array IN EACH iteration. In the first iteration it will be empty because the loop iterator starts with 0…
  • Then you run a FOR loop as many times as the outer WHILE loop has iterated…
  • Then you replace elements in the freshly initialized array, as many times as the outer loop has iterated…
  • You use the very same value to write them into all replaced array elements…
  • Once the FOR loop has finished you desplay that array (with all elements having the same value) in an indicator.
  • After a little wait you start the same DATAFLOW again…

You should enhance your LabVIEW training (atleast) in two areas: "THINK DATAFLOW" and "array handling"!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 6
(102 Views)

Thank you for your solution, in the end it all comes down to thinking outside the box. 🙂


0 Kudos
Message 4 of 6
(93 Views)

Hi rad,

 


@asciirad wrote:

Thank you for your solution, in the end it all comes down to thinking outside the box.


No, in LabVIEW it still is "THINK DATAFLOW!"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(87 Views)

 

 


@asciirad wrote:

Thank you for your solution, in the end it all comes down to thinking outside the box.


The box is defined by the rules of dataflow and you should think inside that. I also recommend to "just follow the wire!"

 

A useful tool is execution highlighting. Just click on the lightbulb and then run your VI while watching the diagram. You'll see exactly what is happening. 😄

 

altenbach_0-1744379738247.png

 

0 Kudos
Message 6 of 6
(69 Views)