Your use of the terms "Waveforms" and "amplitude" implies a
measurement of many samples into one number (for each channel).
For example, if your signal was pure 100 Hz, 1.000 Volts peak, and you
captured a 0.1 second block of that signal, then you would have 10
cycles in the capture buffer, varying from +1V to -1V.  You can use
the RMS function to turn that block of samples into a number of 0.707,
meaning the RMS value is 0.707V (= 1.0 V peak).

The basic philosophy would be:
1... Start a continuous acquisition.  By specifying NUMBER oF SAMPLES
= 0 in the AI-START vi, you will acquire data forever (until the
buffer overflows, or until stopped).
2... Periodically (based on a timer), you ask the AI READ function to
read zero samples. This does not remove data, but it does tell you how
many samples are in the buffer.
3... You immediately read that many samples out of the buffer, and
convert from volts to engineering units (if appropriate).
4... If you are measuring their frequency, you need to perform an FFT
now.  The highest peak in the magnitude of the FFT output is the
dominant frequency in the signal. (Freq. of peak = Index of peak *
Sample Rate / NPoints in block.
5... If you are doing FFTs, you get a big speed advantage if your
block size is a power of two (128, 256, 512, 1024, etc.). If so, then
replace step 3 with *-IF-* backlog >= N (power of 2) then read N
points from buffer.
6... Apply your criteria - *-IF-* the button has been pressed, *-OR-*
if the frequency of channel 2 is different, then compute the RMS or
peak values and append to your final results array. Otherwise do
nothing.

If you want to detect 2-Hz changes, you need to know the rules of how
FFTs work - the frequency resolution is the BIN WIDTH, which equals
the sample rate divided by the number of points in the block.  If you
have a 1000 Hz sample rate and a 1024 point block, your resolution is
1000 / 1024 or just less than 1 Hz.  But if you have a 1000 Hz sample
rate and a 32 point block, your resolution is 1000 / 32 or about 30
Hz.

Reply via email to