LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add Measured Number to Array if not Already in Array, and output that index

Hello all, sorry for my messy VI I am extremely new to LabView. Currently, my VI reads capacitance, rounds it to the nearest tenth in nano farad, formats that number into a string, reads a csv, looks for a match, and if there is a match provides the index of that string. My struggle is that using a csv limits me to guessing what the capacitance will be. I want the VI to read the string, check if there is already an index with that value in an array, if there is to output that index, and if there isn't to add that value to a new index and output the index. It would also be nice if it organizes it from least to greatest. Any guidance or help is heavily appreciated.

 

I am using LabView 2019, and interfacing with a hp 4192A.

0 Kudos
Message 1 of 9
(761 Views)

@StateMachineGuy wrote:

It would also be nice if it organizes it from least to greatest. Any guidance or help is heavily appreciated.


Look into using a Map or a Set, depending on what you are trying to do with the data. A Map is a lookup to get another value out while a Set is a list of non-repeating values.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(759 Views)

Thanks for your reply, I will look into both. As far as the data, I have random capacitors mixed up and want to sort them into bins.

0 Kudos
Message 3 of 9
(756 Views)

Since you want a key (=number) and a value (=index), you should use a map. What are "bins" in this context.

0 Kudos
Message 4 of 9
(747 Views)

Hi thanks for the reply. The "bins" are physical containers that the capacitors will go in after being measured. So, I take a measurement, round it, and then store that measurement in an index (Ex. 3) and that index will correlate to the correct numbered bin (Ex. 3). So, for example, any capacitor with a value of 17.5 nano farad will always be stored in the same bin.

0 Kudos
Message 5 of 9
(744 Views)

Also, everyone sorry I thought I already attached the VI.

0 Kudos
Message 6 of 9
(740 Views)

So is bin=index?

 


@StateMachineGuy wrote:

Also, everyone sorry I thought I already attached the VI.


You need to start with a few basic tutorials, because your VI makes absolutely no sense in terms of dataflow.

 

  • It is a single downhill run with a sequence of greedy loops
  • A while loop inside a while loop makes no sense if the outer loop never repeats.
  • How often does the csv file change? Do you really need to read it over and over again?
  • Using a one button dialog to stop a loop gives the user no choice to cancel.
  • We are missing the subVIs.
  • Why is the front panel such a mess with controls and indicators randomly scattered over a large area?
  • All you probably need is a simple state machine that fits on a postcard.
0 Kudos
Message 7 of 9
(707 Views)

Yes bin=index.

- I understand that I need to learn more on what the best practice is, but unfortunately, I have been given a short time limit for this.

- As for now my best solution would be to replace the outside while loop with a sequence structure until I have more time to learn.

- The csv file is for testing, ideally the VI would save the measurements to compare with others to see what bin it would be placed in/if a bin would need to be created for that measurement.

- Sorry for my misunderstanding but how is cancelling and stopping the program different?

- I attached the subVIs sorry about that.

- The front panel is a mess because it is currently only used for testing purposes. The random indicators are what I was using to debug.

- Do you have a good example of a state machine similar to my situation in labview?

 

Thank you for your reply and feedback

0 Kudos
Message 8 of 9
(704 Views)

@StateMachineGuy wrote:

- Sorry for my misunderstanding but how is cancelling and stopping the program different?


I was talking about stopping the first two greedy* loops with a dialog each. Even if the user decides to not even continue, there is no choice but to go forward.

 

altenbach_0-1768590984486.png

 

Your csv file seems to be a single column, so why do you read it as 2D array?

 

0 Kudos
Message 9 of 9
(655 Views)