02-15-2018 09:07 PM
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
Solved! Go to Solution.
02-16-2018 01:10 AM
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…
02-16-2018 11:13 AM
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
02-16-2018 01:13 PM
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.