From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate the Envelope of a Signal?

I have a signal and I want to generate its upper and lower envelope. I have tried using the envelope function in the sound and vibration tools but still was unable to get the envelope which I wanted. How do I go about this. I have attached my signal, showing how my envelope should more or less look like.

 

 

0 Kudos
Message 1 of 10
(7,065 Views)

What is your purpose to do that?

but you can look at this:

https://forums.ni.com/t5/Multifunction-DAQ/How-can-I-get-envelope-wave-of-any-signal/td-p/2605951

Benoit

0 Kudos
Message 2 of 10
(7,048 Views)

I use the envelope to calculate the decay time of the envelope by interpolation techniques.

0 Kudos
Message 3 of 10
(7,019 Views)

You could maybe try to run the "Peak detection" function on your data twice, once for peaks and once for valleys, and plot that.  

 

<vi.lib>\measure\mamon.llb\Waveform Peak Detection for 1 Chan.vi

 

If that makes a graph that's too rough you could try fitting the points to a spline (Mathematics --> Fitting palette).

0 Kudos
Message 4 of 10
(7,010 Views)

It should be possible to use Hilbert transform for this, but it never worked for me, you can try google. Or you can try do it by using of aggregation window (this is what Kyle suggested). First you have to realize that you need generate two waveform from input, one for max and second for min. First thing is split positive and negative part of signal, then aggregate each part.

 

The example shows two possible way how achieve this. One search for min max in window, second splits signal and after average. You can control smoothness of output by changing window size (number of samples).

 

I dont know if this will work for you signal, but you can play with this and try changing windows size and/or try different aggregation function, eg. filter.

 

You can use peak search as Kyle mentioned but be aware the peak search can be quite cpu consuming in some cases (lots of peaks).

 

Note this example is poor in programing, just trying to send the idea.

0 Kudos
Message 5 of 10
(7,002 Views)

When the signal is symmetric with a mean of 0, the answer is simple (every electrophysiologist knows about integrating EMG signals by doing a full-wave rectification followed by a low-pass filter).  For two-sided signals, particularly with significant information in the low frequencies (unlike EMGs), the problem is trickier, but I'd suppose someone who knows Signal Theory would know how to do this.  Know any smart Electrical Engineers?  Tried Google?

 

Bob Schor

0 Kudos
Message 6 of 10
(6,990 Views)

How silly I was -- the "trivial example" I should have used was AM Radio (I also wasn't a Ham, but my brother was).  We actually build a crystal detector radio, which used a crystal (rectifier) and very little else to let you hear AM radio stations (who listens to AM anymore?).

 

Bob Schor

0 Kudos
Message 7 of 10
(6,989 Views)

The problem with generating an envelope of a signal is to decide "what is signal" and "what is noise".  In the case of AM radio, the high-frequency carrier is not noise, but the basis on which the "signal" rides by modulating its amplitude.  The classic way to demodulate it is to do a very non-linear operation, namely to rectify it, and then to low-pass filter it, effectively removing the carrier.

 

If you have a situation with high frequency "noise" and a low frequency signal, simply low-pass filter it and you are done.

 

But what if you have high frequency "noise", intermediate frequency (say, 60 Hz) "unwanted stuff", and a low frequency signal, a real mess?  You could try Peak/Valley detection, and "connect the peaks" and "connect the valleys" -- this would work reasonably well in places where you have Intermediate Frequency modulating a low frequency signal.  Where you have only High and Low frequencies (i.e. Signal + Noise), a simple Low Pass Filter would work.  How to marry the two?  I don't know -- you may have to experiment.

 

Bob Schor

 

 

0 Kudos
Message 8 of 10
(6,987 Views)

@Bob_Schor wrote:

...(who listens to AM anymore?).

 

Bob Schor


Me.

 

When you only have half an ear, stereo is worthless and besides, AM carries talk radio. (smiley-wink).

 

Agreed that the rectify and low pass filter is how it would be done with radio where the amplitude is being modulated.

 

For that weird signal shown in this it could be done by separating the positive from the negative and finding peaks and possibly using a spline fit to create two channels, one for positive and one for negative.

 

Ben  

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 10
(6,987 Views)

@Ben wrote:

@Bob_SchorFor that weird signal shown in this it could be done by separating the positive from the negative and finding peaks and possibly using a spline fit to create two channels, one for positive and one for negative.

 


Yeah, the trick is "separating the positive from the negative" (and then "flattening" it along the dividing line).  I thought about a big LP Filter, but would want to play "Explorer" with the signal first ...

 

Bob Schor

0 Kudos
Message 10 of 10
(6,978 Views)