LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Min/Max never-ending loop

I am trying to stream data off a real time module and then perform some calculations on it. I am reading the data through a front panel on my PC. I want to find a way to measure the max and the min of each data stream. I constructed the attached VI to do that. Since the loop does not end, the data gets stuck in the loop and no more data is read from the real time module. I cannot end the loop because then the max/min calculations will end. I have thought about storing all of the information in an array and then using the array min/max VI to do my calculations, but this would be extremely inefficient because I need my model to run for hours on end. Is there a way to calculate minimums and maximums without a loop or storing everything in an array? Sorry for the newbie question.
0 Kudos
Message 1 of 8
(3,243 Views)
You are close to your solution. You need to wrap you data acquisition code with something similar to this loop. The way it is now the data is only read in once, then as you note it is stuck in the array. Another thing is the initializing values. If you make both of them 0, and use the same type as the input data, they will immediately show the min and maxes. Additionally, you can make your comparisons G.T or L.T rather than G.E. or L.E. Another method, if you can't put the data acquisition in this loop would be to make it a "LabVIEW2 style global", consisting of three states, initialize, write, read. The vi is called, with the initialize method before the DAQ loop, the write is called right after your DAQ, and in another loop the read is called.


Putnam Monroe
Senior Engineer - North Shore Technology, Inc.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 8
(3,242 Views)

@LV_Pro wrote:
Another thing is the initializing values. If you make both of them 0, and use the same type as the input data, they will immediately show the min and maxes.

Actually, you should probably initialize the Max to -inf and the Min to +inf so they get reasonable values no matter what the input is. (Else your Min will falsely remain zero if all values are positive or the Max would remain zero if all values are negative). You could also initialize with NaN but it is a little more tricky. Any comparison with NaN will result in "False" so you must ensure to set the comparison logic is such that false replaces the stored value in all cases.
Message 3 of 8
(3,230 Views)
I'm surprised nobody has used the "Max & Min" function.

Try this effort of mine - call this sub VI within your own aquisition loop, reseting on the first call (or as and when required).

Unlike "altenbach's" methods approach, with my VI you can simultaneously "reset", "input" and "read" in a single call.

I've set the VI as reentrant so it can be used in multiple instances within an application without confusing seperate data streams.

Mark.

P.S. Remember to rate messages (if appropriate).
Message 4 of 8
(3,216 Views)
Oops! I guess I need to start taking a siesta in the afternoon, my analytic skills do seem to slump during that period.
Altenbach points out very valid points (flaws) in my code and Mark H's performs the same function much more elegantly.


P.M
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 8
(3,197 Views)
Works perfectly. Thanks Mark!
0 Kudos
Message 6 of 8
(3,181 Views)

@Mark H wrote:
Unlike "altenbach's" methods approach, with my VI you can simultaneously "reset", "input" and "read" in a single call.

Hmmm... Actually, I did not post any example at all ... 😉
0 Kudos
Message 7 of 8
(3,165 Views)
Oops - sorry, I'd got confused - it was LV_Pro's example I was refering to.
0 Kudos
Message 8 of 8
(3,160 Views)