LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting square signal into sinusiod avoiding Fourier Transform

It often helps to visualize the data.  I calculated the FFT of your data and plotted the magnitude and phase.  Your frequency resolution is 17.2 Hz (df = fs/N = 2000000/116280).  You signal has a fundamental frequency of 49.8 kHz with a typical square wave odd harmonic spectrum.  BUT, it also has a modulation spectrum where each harmonic component also has sidebands at +/- 8690 Hz with amplitudes -30 to -40 dB from the odd harmonics.  The Even harmonics (which are much weaker) ,amy also be modulated.  I cannot tell what has caused this.  It may be due to the fact that nearly every cycle of your input signal has one or two samples during the transitions.  There may be amplitude modulation at the -30 to -40 dB level in at least part of the data set.  At index 5000+ in the Ch 2 the values jump from 0.0559375 to 0.05625 and the high pulse values also have similar fluctuations.  Is this quantization noise from your A/D converter?  The fundamental peak width at -20 dB is greater than 7 times df (120 Hz).

 

With all this it is not clear what your frequency is and without knowing the frequency, defining the phase is impossible.

 

Use a simple filter and compensate for the phase shift of the filter, but understand that your system may not be able to do what you want.

 

Lynn

Message 11 of 13
(417 Views)

Given your large data set, a "simple" way to get accurate phase and frequency information is to find the location of every midpoint crossing of your data set (use linear interpolation to get subsample resolution), then plot the location vs. index.  You should get a nice line whose slope and intercept will give you the period and phase (with a bit of calculation) of your waveform to high accuracy.  You may be able to make this faster than an FFT (it was when I did it using a 16-bit PDP-11/23, but processors have certainly changed...).

 

If you really want a phase-locked loop, you can find sample code here.

Message 12 of 13
(393 Views)

Lynn the sidebands, as well as the even harmonics, seem to be greatly affected by the samples during the transitions. If I impose the samples in the transitions to be all "low" or "high" the amplitude of this extra harmonics greatly changes.

 

The frequency of the source should be pretty stable so I guess I could take a large preliminary measurement to have a frequency measured with resolution around 1Hz and take this value  for granted in all the following phase measurements. So if the frequency is well known and the only incognita is the phase, is there some wiser method to apply?

 

DFGray thank you for your suggestion, it seems the better way of doing the measurement "by hand", I'll try to program it to see how it works. 

 

 

0 Kudos
Message 13 of 13
(380 Views)