LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak Detection for Wide Range of Frequencies

For a senior design project, my group must develop software that detects the number of peak values of leakage current on a transformer. To simulate this, we are using a function generator to simulate an input signal and are analyzing the signal in LabVIEW.  Since most transmission lines operate at a frequency of 60 Hz, leakage current measurement needs to be accurate for a range of 60 Hz to about 2 kHz (in order to capture flashover peaks of a short duration). Because the peak detector VI must use a set width and we have a wide range of frequency inputs, we elected to use an array within a for loop to compare incoming Y values to previous Y values and mathematically determine whether a peak has been detected. This method works well for input signals from around the 300/400 Hz - 2 kHz, but causes false peak detections for 60 Hz - 200 Hz (60 Hz signal giving 6x the correct number of peaks) most likely due to high frequency noise. We tried to implement a low pass filter to eliminate this noise, but can't get it set properly (filter not included in uploaded project for this reason). Any advice on peak detection, sampling frequency, LPF settings, or anything at all would be greatly appreciated. But I must reiterate, it is vital to get accurate readings from 60 Hz to 2 kHz. Also, if you think we should purchase anything beyond the standard libraries please let me know. Sorry for the wall of text, I figured the more details, the better.

Additional Info.:

Function Generator - RIGOL DG1022

DAQ Device - NI USB-6008 

DAQ Assistant Settings - Continuous Samples, 36 Samples to Read, Rate 10 kHz

 

Download All
0 Kudos
Message 1 of 6
(3,864 Views)

Before you start to write code or obtain hardware for any design project, it is a good idea to actually do some design.

 

What are the distinguishing characteristics of the peaks? Minimum and maximum duration? Minimum and maximum amplitude? Waveform? How much variation is there between peaks? What is the minimum time between successive peaks? How much other interference will there be in the signal? Here I am referring to anything which is not a 60 Hz sinusoid and not a peak as interference, such as broadband noise.

 

Ask yourself: "How would I detect the peaks without a computer? What instruments would I use? How would I make the decisions about the presence or absence of peaks?"

 

Without answers to questions like those you cannot develop a reasonable design and cannot make specific decisions about the questions you asked.

 

General comments:

1. Note that your 2 kHz signal has only 5 data points per cycle. While this meets the Nyquist criterion, it provides very little information about the waveform.

2. Your strategy of comparing current to previous data values on a sample by sample basis is meaningless because every sample is expected to be different from the previous sample unless your signal is DC.

3. Filters work best with dat sets much longer than the reciprocals of the cutoff frequencies. So, filters may not be the best approach to finding transient behavior.

4. When you post a VI that relies on data collection from external hardware, please include some typical data, saved as default on an indicator. We do not have your DAQ devices or any way to generate your signals.

 

Lynn

Message 2 of 6
(3,836 Views)

1.) Increasing the number of samples causes the percent error for lower frequencies to go up (likely due to some kind of noise).

2.) Yes, every sample will be different than the previous. But the logic behind this is to figure out whether the sinusoid is rising or falling. If the previous value is less than the incoming value, then the sinusoid is still rising. For the first instance of the previous value being greater than the incoming value, the sinusoid has just begun to fall, thus a peak has been detected. Negatives are taken care of using an absolute value operator. This works well for the frequencies I mentioned in my first post, but because of the design itself, high frequency noise will cause false peaks when analyzing lower frequencies. 

3.) The data set is meant to variable. Our design parameters look for anything from a 1s signal duration to a signal duration over multiple days.

4.) I realize this is a huge issue. I will try to adapt my code so that it can be recreated or convert some typical signals to array form and post the data set along with the actual code. But the input data is nothing more than a sinusoid (amplitude is irrelevant) ranging from 60 Hz to 2 kHz. 

 

**Edit: I attached a version of the peak detector without the while loop and user input for time to analyze signal. This version gives accurate peak detections. This tells me that either the DAQ Assistant sampling frequency/number of samples needs to be some very specific number. Or that somehow high frequency noise needs to be eliminated from the signal

0 Kudos
Message 3 of 6
(3,815 Views)

1. Seems unlikely with simulated data. There should be very little noise other than roundoff error.

2. OK. I am thoroughly confused about what you are trying to do. I see that you are finding the peaks of each cycle of the sine wave but that has nothing to do with the stated objective in the first post.

 

Cleaning up your diagrams will make it much easier to see what is going on in the code.

 

You can convert from the (evil) Dynamic Data Type generated by the Express VIs directly to an array without going through a waveform data type.

 

The Peak Detector VI from the Signal Processing palette seems to work just fine on your simulated data. Read the help and look at the block diagram to see how they find peaks.

 

Lynn

0 Kudos
Message 4 of 6
(3,779 Views)

Sorry, I'm sure that I've probably made this sound more confusing than it actually is. 

 

Essentially, all the project seeks to do is count the number of peaks above and below a certain threshold. With a simulated signal this is simple. But we'll be attaching the NI hardware to a transformer to detect leakage current. Leakage current will have the rough appearance of a Sine wave, but the frequency and amplitude will be random. Also, the input data can look like a 60 Hz signal for one period and a 2 kHz signal for the next. So, LabVIEW has to take in this random signal and then analyze it for peaks. For testing, we're using an actual, physical function generator, and varying the frequency. I've tried implementing this with the DAQ Assistant and the Peak Detector VI within a while loop, but because of the width constraint, I haven't been able to get it to read peaks accurately for the range of input frequencies (60 Hz to 2kHz). Because of this constraint, I wrote the pseudo-peak detector code within the for loop. But that code is very susceptible to signal noise.

 

 

I'm going to try again, using the Peak Detector VI with a width of 3, tomorrow.

But if there is still noise at lower frequencies, is there a good way to use Butterworth filters, Fast Fourier Transforms, or some other form of signal smoothing that will clean up the high frequency noise in the low input frequency signals without distorting or eliminating peaks in the high input frequency input signals?

 

 

0 Kudos
Message 5 of 6
(3,772 Views)

If you have real measurements: Sample it with >20kHz (50kHz?) and post the data,  additionally create a png and mark the peaks you want to detect.

To post the data post the vi after you captured the data and 'Make current values default' ..

 

constant leakage is at line frequency ...   flashover will create high frequency content ... SMPSs will create every noise and spikes you (n)ever want 😄

 

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 6 of 6
(3,752 Views)