LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get the peak and valley of a MZI signal

I am using MZI signal which is similar to sine wave with frequency of 10MHz to calibrate an interference signal. I want to get the peak and valley of the MZI signal and get the corresponding value of interference signal at the same location. The problem is that the MZI signal aquired by DAQ is not smooth, Please see attached filter.PNG, the top left is the MZI, top right is the MZI Zoomed in, you can see that there may be two values that are approximately same to each other. I used a peak detector to detect both the peak and valley and a build array to concatenate them. I am worried that the peak detector may find two peaks or two valleys in a fringe. So I used the filter function in express to bandpass the MZI signal (cutoff frequency is 8MHZ~12MHZ) to smooth the signal, the result zoomed in is  the bottom graph in filter.PNG. But I found that it did not solve the problem but cause phase shift. Is there somebody can give some help?
Download All
0 Kudos
Message 1 of 5
(2,843 Views)

I don't know anything about MZI signals, but I do know sine waves.  If this is a sine wave, it is relatively easy to measure its amplitude as long as you know the frequency.  Since you say it is 10 MHz, you appear to know the frequency.  You can use Fourier analysis to determine the magnitude and phase of your signal, as long is it is a steady signal that doesn't change frequency or amplitude.

 

Generate a sine and cosine wave using the same frequency.  Divide each wave by the sum of its points.  Multiply each one by your incoming signal and sum all the values, one sum for sine and one sum for cosine.  The sums should be the coefficients of the sine and cosine components of your unknown signal.  The ratio tells you the phase of the signal.  If you multiply the sine and cosine waves by their coefficients and add them together, you should be very close to your incoming signal.  The amplitude of your signal is equal to square root of A*A+B*B, where A and B are your coefficients.

 

I may be off by a constant factor here somewhere (probably pi), since I didn't write down the equations and verify them.  These equations are the basis of the Fourier series, though, so they would be fairly easy to find.

 

Another option would be resampling.  If you upsampled the data and increased the data resolution by a factor of 10 or so and filtered the results using an FIR filter, you would have a much cleaner signal with a lot more detail.  You wouldn't have any problem locating and measuring peaks and valleys.  This would probably work better with your data, since it looks like it doesn't have a constant magnitude.  To upsample the data, just add 9 zeroes between each data point.  Create a lowpass FIR filter that is based on 10 times the original sampling frequency and has an amplitude of 10.  The cutoff frequency should be half the original sampling rate.  Filter your new data and you should get the same waveform with 10 times the resolution.

 

Bruce

Message Edited by Bruce Ammons on 10-02-2008 09:10 PM
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 5
(2,829 Views)

I found a function called Resample (constant to constant) in LV 8.6 that does exactly what you need.  You input your original signal and the new spacing that you want (I used dt = 0.1) where dt = 1 is your original spacing.  It does all the difficult work and gives you the resampled signal at the new resolution.  You can try out different resampling rates and see what works best.  It looks like a value of 0.2 or 0.25 would probably work well also.  Larger values are probably a little bit faster.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 3 of 5
(2,823 Views)
Hi! Bruce. Thank you for your help! I don't know why I should resample my MZI signal and then use the FIR signal. The MZI signal is linear in frequency centered in 10MHz. So resample.vi may not work. Since I see phase shift when I use filter function in Express, do you know what function that I can use to filter with no phase shift just like the filtfilt function in Matlab. Thank you!
0 Kudos
Message 4 of 5
(2,815 Views)

If you need to compare two signals, just use Resample to convert both of them.  Any phase shift or magnitude change will be the same for both of them, so they will still match after the conversion.  I think resampling will work very well.

 

You could also use Rational Resample, which uses integer resampling values.  I found using values of 5, 1 to work very well.

 

Don't worry about the FIR filtering and all that stuff.  That is all inside the Resample vi, and it does it all for you.  Just run your signal through the Resample vi and you are done.  Your new signal will have all the detail you need for your analysis.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 5 of 5
(2,813 Views)