# DC to phase relationship with Low pass filtered sine and square wave multiplication and it's pitfalls. IQ Demodulation

From what I have read about signal (de)modulation I understand that multiplying two sine waves, both with the same frequency, gives a two frequency component sine wave. One at DC and one at $2\omega$. Using a low pass filter will let us remove the $2\omega$ component. Now DC amplitude is proportional to the phase difference between the two sine waves.

So: $$A \sin(\omega t) \sin(\omega t + \theta) = \frac{A}{2}\cos(\theta) + \frac{A}{2}\cos(2\omega t + \theta) \rightarrow {\rm LPF} \rightarrow \frac{A}{2}\cos(\theta)$$ where $\omega$ is the frequency, LPF is Low Pass Filter, $A$ is the amplitude and $\theta$ is the phase difference between the sine waves.

I made a Matlab program to plot this, then I tried with a square wave multiplied with a sine wave. I can see that there is still a connection between DC and phase by doing a FFT as well as in the time domain. I would like to see the math for the relationship between DC and phase.

For sine $\times$ sine, I have read that sampling with a frequency four times the modulated signal frequency will make it possible to get the I and Q values by subtracting samples in the following order:

$$I(t) = s(t) - s(t-2)$$ $$Q(t) = s(t-3) - s(t-1)$$ where $$s(t) = A\sin(\omega t + \theta)$$

This I do not quite understand yet and therefore leads me to be unable to determine if this also is valid for a square $\times$ sine. Can anyone try to explain this to me?

I will appreciate any feedback on how to effectively do IQ demodulation on a micro-controller using a square reference waveform.

I wish to use a micro-controller to sample the analog sine and square (reference) signal and do IQ demodulation. I almost only find information about sine $\times$ sine and therefore want to know if there are any pitfalls using a reference square wave that I am not seeing yet.
So if your sampling rate is four times the modulated signal frequency (and sampling synchronously) then $\omega= \pi/2$. So then $$\begin{array} II(t) &=& s(t) - s(t-2)\\ &=& A\sin(\pi/2 t + \theta) - A\sin(\pi/2 (t - 2) + \theta)\\ &=& 2A\sin(\pi/2 t + \theta) \end{array}$$ and $$\begin{array} QQ(t) &=& s(t-3) - s(t-1)\\ &=& A\sin(\pi/2 (t-3) + \theta) - A\sin(\pi/2 (t - 1) + \theta)\\ &=& A\sin(\pi/2 t + \theta - 3\pi/2) - A\sin(\pi/2 t + \theta - \pi/2)\\ &=& 2A \cos((\pi/2 t + \theta - 3\pi/2 + \pi/2 t + \theta - \pi/2)/2) \\ &&\sin((\pi/2 t + \theta - 3\pi/2 - (\pi/2 t + \theta - \pi/2))/2)\\ &=& 2A\cos(\pi/2 t + \theta) \end{array}$$
• I am not sure what you are asking? Does "I = 2" mean $I(t-2)$ ? – Peter K. Apr 9 '13 at 17:03