# Demodulating I/Q Data

## Messages In The Air

In the last post, we covered the basics of complex signals and how they work in digital signal processing (DSP) systems. The next question is how do we demodulate these signals and find the messages in them? To answer that, we need to update our model of the incoming signal.

Previously, we used Euler's formula as the basis for our model of complex signals. While this is great to keep in mind, it was only correct given a pure sinusoid as the incoming signal. In reality, we can't make many assumptions about the signal, so modeling it as a simple sinusoid isn't always accurate. We need a more abstract way to model more realistic signals.

Recall that $\cos (\theta)$ represented the in-phase, or $I$, portion of our complex signal and $\sin (\theta)$ represented the quadrature, or $Q$, portion. Since we're not sure that our I and Q functions will be simple sinusoids like sine and cosine, we can use abstract functions like $I(t)$ and $Q(t)$. This way, we arrive at a new, more abstract way to model any signal we'll be receiving over the air.

How do we demodulate our signal with this formula? Well, to modulate a signal is to change one of its properties according to the message it encodes. So, to demodulate the signal we must be able to extract these properties from our new signal formula.

Remember the phasor from our last post and how it modeled our wave. We can use it to help calculate how we can get properties like amplitude, phase, and more using our formula. Finding these properties lets us demodulate the signal.

To help us better understand the math and visuals for these concepts, notice that our phasor is always making a triangle.

We can use algebra and trigonometry to find certain values when given others, which will ultimately give us characteristics of our signal.

### Amplitude

The Pythagorean Theorem concludes that $A^2 + B^2 = C^2$. With that in mind, we can get $C$, the hypotenuse of our triangle above, with just $A$, on the horizontal axis, and $B$, on the vertical axis, by rearranging the equation into $C = \sqrt {A^2 + B^2}$. Applying this formula to our signal function with $I(t)$ being on the horizontal axis and $Q(t)$ being on the verical axis yields a formula that gives us the amplitude of the signal at a certain point in time.

### Phase

In our triangle above, we can get $\theta$ from $A$ and $B$ using the inverse tangent function. That is, $\theta = tan^{-1} \left( \frac {B} {A} \right)$. Applying this formula to our signal function yields a formula that gives us the phase of the signal at a certain point in time.

### Frequency

Quite frankly, I'm not going to try and explain this formula. Just know that we can calculate the signal's instantaneous frequency by calculating the instantaneous change in the signal's phase.

### But why this way?

Using this I/Q model in our DSP system gives us a relatively easy way to process signals with low or negative frequencies. In my opinion, it also happens to make modeling signal properties easier and more robust, thus making demodulation easier.

### To wrap up

I hope this made the concept of RF signal demodulation a bit easier to understand. If you have any questions or would like to offer ways that I can improve this post, feel free to contact me.