LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the maximum value of read data.

Solved!
Go to solution

Hello Everyone,

 

I am writing data to a text file at 1000 samples/sec for approximately 20 minutes. There are five columns in the text file and I want to be able to determine the largest values in columns 2 and 4 when zero indexed. I see two methods to solve this problem.

 

The first method is to compare the currently read data with the read data from the previous loop. If it is greater, save the variable. Otherwise don’t save the variable. I know to create a local variable, but I don’t know how to reference the variable of the previous loop. Maybe use a shift register?

 

The second method is to run the VI and write all my data to the text file. After all the data has been written I can read the text file into LabVIEW. Converting the data from a string to an array I can use the “Array Max & Min” VI to find the largest value. I tried this method, but I didn’t know how to specify columns 2 and 4 in LabVIEW. I personally don’t like this method, because LabVIEW will have to load tens of thousands of data points. This will fill up the buffer and slow down LabVIEW.

 

Any tips/opinions on the best method would be appreciated!

 

Attached is an example text file and my VI.

 

Thanks

Download All
0 Kudos
Message 1 of 4
(3,931 Views)
Solution
Accepted by KurtzC1

Hi Kurtz,

 

The first method is to compare the currently read data with the read data from the previous loop. If it is greater, save the variable. Otherwise don’t save the variable. I know to create a local variable, but I don’t know how to reference the variable of the previous loop. Maybe use a shift register?

Not "maybe" but "for sure"!

Whenever you need to store values for the next iteration of a loop you should use a shift register! (basic LabVIEW stuff…)

There's a MinMax function, no need for a comparison and select nodes…

 

but I didn’t know how to specify columns 2 and 4 in LabVIEW.

You don't know how to use an IndexArray function?

But you already use them in your VI!

 

On your VI:

- do you really need all those local variables? (Think "race conditions"!)

- NEVER delete the label of controls/indicators! (YOu may hide them in the front panel!)

- NEVER call your charts "Graph"! They are charts and not graphs!

- Instead of checking for an empty array after Dequeue you should check for an error (wire the stop condition directly to the error out of Dequeue!)…

- Some other minor quirks, several of them related to StyleGuide…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(3,897 Views)

Hi Kurtz,

 

Surely you only need store the largest value from columns 2 and 4 and not all the data, using the min/max function as Gerd has said.

 

You can then pass this max value to the next dataset (shift register) and if this is exceeded then replace. etc.

 

Ingram

Ingram | CLA
Message 3 of 4
(3,875 Views)

GerdW, 

 

Thank you for the reply. I knew how to index arrays I just didn't know how to only read columns 2 and 4 from the text file. I didn't want to overload LabVIEW with data. Regardless I went with method one. I used the MinMax function with a shift register and it worked great. 

 

Thank you very much. 

Message 4 of 4
(3,865 Views)