08-17-2017 02:49 PM
Hi,
I am working on a project where I have to record data and find max and min values. Here are the details:
I need to record continuous data from DAQ card and write to a text file with the sampling frequency of 100 Hz. This should be fine for me. I can use while loop and record data. The problem is finding the max and min from continuous data. The signal is sine wave with varying amplitudes. I cannot use the max and min function in each while loop iteration for maximum and minimum as the signal might be high or low for extended period of time. Basically, I need to find max and mins on continuous data and record them.
Hopefully, someone can help with this.
Thanks
08-17-2017 03:01 PM
Do you mean you want a single max and min during the whole data collection? Just store your max and min in a shift register. If the new max is greater than the old max, or the new min is less than the old min, store the new value.
08-17-2017 03:13 PM
While I went off to create this snippet, gregoryj already gave you the same answer. Here it is again, visually:
-Kevin P
08-17-2017 03:36 PM
There is a ptbypt version (min&max ptbypt or similar) that will do exactly what you want. No need for shift register and fancy code.
08-17-2017 03:50 PM
@altenbach wrote:
There is a ptbypt version (min&max ptbypt or similar) that will do exactly what you want. No need for shift register and fancy code.
Technically, there is a need for shift registers and fancy code but they are already found in the aforementioned prepackaged VI.
08-17-2017 03:57 PM
... and it contains more features, such as finite and infinite history length, reset, etc. 🙂
08-17-2017 04:03 PM
Actually, I want to record every peak and trough of the signal, not just the highest and lowest value. So basically, there will be peak followed by trough and followed by peak and it continues. I want to record all of them.
the problem with using max and min function is that there might be multiple peaks and troughs in single while loop iteration. But the max and min will only take one from that iteration.
Also, I thought of using peak detector as well. But as the data might be little noisy, it will records all smaller peaks. I just want highest and lowest point continuously.
Hopefully this makes things clearer. Sorry for the confusion earlier.
Thanks
08-17-2017 04:27 PM
@manny09 wrote:
Actually, I want to record every peak and trough of the signal, not just the highest and lowest value. So basically, there will be peak followed by trough and followed by peak and it continues. I want to record all of them.
the problem with using max and min function is that there might be multiple peaks and troughs in single while loop iteration. But the max and min will only take one from that iteration.
Also, I thought of using peak detector as well. But as the data might be little noisy, it will records all smaller peaks. I just want highest and lowest point continuously.
Hopefully this makes things clearer. Sorry for the confusion earlier.
Thanks
Oh, In that case use Peak Detector PtByPt VI
08-22-2017 05:02 PM
Thanks all for the help.
I never got a chance to check it. The project scope changed.
Thanks
08-22-2017 06:56 PM
Oh Manny, don't go bringing the real world into this!