Skip to content

OOK Signal Demodulation

ElectronicBattle edited this page Nov 19, 2023 · 4 revisions

The method use to demodulate the OOK signals in rtl_433 is quite simple. First we define how the OOK signal model appears and how it is transmitted.

s(t) = A*sin(2*pi*f*t)

f = frequency (typically 433.92MHz)
t = time
pi = 3.14
A = amplitude

Here A is the signal amplitude and the carrier of the bits that are transmitted. When the signal is on, a 1 bit could be transmitted and when it is off a 0 could be transmitted (there are other ways to represent the bits also). So the bit stream that we want to send is mapped the following what 1->1A and 0->0A. Very easy signal to transmit.

In the rtl_sdr device we are not only getting the Asin(2pift) version of the signal. We are getting the IQ version of the signal (http://www.ni.com/tutorial/4805/en/). Which means we also get a phase shifted version of the signal (-90 deg).

I(t) = A*sin(2*pi*f*t) Q(t) = A*sin(2*pi*f*t-90 deg)

if we here use the trig identity sin(x-90) = -cos(x) we get the following:

Q(t) = -A*cos(2*pi*f*t)

We then do the following substitution:

x=2*pi*f*t

And then the following calculation step:

R(t) = I(t)^2 + Q(t)^2 = A*sin(x)*A*sin(x) + -A*cos(x)*-A*cos(x) = A^2*sin^2(x) + A^2*cos^2(x) = A^2(sin^2(x) + cos^2(x))

Here we now use the Pythagorean identity sin^2(x) + cos^2(x) = 1.

R(t) = A^2( sin^2(x) + cos^2(x) ) = A^2(1) = A^2

So at the reception end we get a signal R(t)=A^2 that doesn't depend on the time or the frequency which is nice. In an ideal world we would now get R(t) = 0 when sending a 0 and R(t) = A^2 when sending a 1. In the real world we have noise in all the different stages. In the transmitter, in the radio spectrum and in the receiver. And when we multiply the I and Q data we multiply noise which will result in high frequency data. Because of all this and that we only want/need the DC part of the signal we add a low pass filter to R(t).

Here is a picture of how a good quality signal look like before the low pass filter.

https://lh3.googleusercontent.com/5tDjtyZpo-VmLXYaSmBy7gGeeG9R29lKiJxwcVntDkBrB_V7jPOq5qebi4J3iUnvsXStwQ=w1218-h751

You can see the high frequency noise at the top of the pulse.

After the filter the signal looks something like this:

https://lh3.googleusercontent.com/3PE2ceyz_1TwPbbFjiE1XaiDJNFIoY0ToZnZHhnU0caXlluizxGi7rIaH_dbxj6ZOJXC9w=w1218-h751

When we have the signal looking like this it is time to let the synchronizer do it's work for the bit stream recovery.

(Originally posted to the Google Group by Benjamin Larsen)