Using yesterday’s OOK plugs, I wanted to get a feel for what sort of RF pulses are flying around here at Jee Labs. It’s a first step to picking up that data and trying to decode some of it.
Meet the OOK Scope, a sketch which reports every pulse it receives over the serial port, and a matching Tcl/Tk script for JeeMon to display the results graphically, and in real time.
Here’s the “ookScope.pde” sketch:
The analog comparator is used to generate interrupts on each transition of the input signal across the 1.1V bandgap reference voltage (the digital pin-change interrupt would also have worked – I’ve use both in the past).
One byte of data is sent over the serial port for each transition, containing the elapsed time since the previous one.
Note that the serial port can easily become a bottleneck for all these pulses: at 57600 baud, it can “only” report some 5700 pulses per second, so rapid pulse trains under 170 µs or so will hit the serial port bandwidth limit.
Reporting pulse lengths with 2 bytes of data would halve this bandwidth, so a trick is used to be able to report pulse lengths from 20 µs to over 3 ms using a single byte of data. It works by encoding large values more coarsely, sort of like a poor man’s logarithm:
- pulses are measured at 4 µs resolution, using the Arduino micros() function
- pulses of 20 µs or less are ignored, they are simply too short to deal with
- 24..508 µs pulses are reported as byte values 6 .. 127 (4 µs granularity)
- 512..1020 µs pulses are reported as values 128 .. 191 (8 µs granularity)
- 1024..1532 µs pulses are reported as values 191 .. 223 (16 µs granularity)
- 1536..2044 µs pulses are reported as values 224 .. 239 (32 µs granularity)
- 2048..2556 µs pulses are reported as values 240 .. 247 (64 µs granularity)
- 2560..3068 µs pulses are reported as values 248 .. 251 (128 µs granularity)
- 3072..4604 µs pulses are reported as values 252 .. 255 (256 µs granularity)
- all longer pulses are also reported as value 255
In other words: short pulses get reported fairly precisily, longer ones less so.
Due to the way AGC (Automatic Gain Control) works, most receivers will end up constantly generating pulses, because the gain is adjusted continuously until something is detected, whether actual RF signals or noise.
So this sketch tends to generate a huge amount of data over the serial port. In my case, I’m usually seeing over 2000 bytes of data per second coming in.
That’s a lot of bytes. Trying to make sense of it is not trivial – needles and haystacks come to mind …
So let’s just start by plotting the frequency with which pulses of different durations come in. This is an excellent task for JeeMon, with its built in Tk graphical user interface.
Here’s a first plot, based on some 1,000,000 samples:
The shortest pulses are represented by the lines at the top (i.e. starting at 24 µs), the longest ones are lines furher down. The width of the lines is the number of times such pulse lengths were received. The whole graph is scaled to fit horizontally, with some statistics showing in the window title.
Every 10th pulse width is marked in blue. Every 100th is marked in red.
Note that these are condensed values, as listed above. The “widths” are shown as values 5..255 on the vertical axis.
What the graph shows, is essentially noise. There’s a gradual decrease in pulse widths, i.e. short noise pulses are more frequent than longer noise pulses.
There is a very surprising peak of pulse lengths around 880 µs – I haven’t figured out where they are coming from, but that’s clearly not noise.
Let’s change the graph by switching to a logarithmic scale on the horizontal axis from now on (note that the vertical scale is sort of logarithmic as well, due to the above encoding). Here’s the logarithmic version, from roughly 1,000,000 samples:
Interesting: there’s another source of pulses around 1100 µs – again, no idea where those come from.
Here’s a graph where I held down a button on an FS20 remote control:
Sure enough – peaks around 380 µs, 412 µs, and 584 µs. The FS20 protocol works with 400 and 600 µs pulses – the variations are probably due to skew in the receiver, with different skews depending on the length of the preceding pulse.
Here’s the Visonic “fingerprint”, also on 868 MHz:
Let’s try the 433 MHz band now – a nice clean histogram using the ELV 433 MHz OOK receiver:
And here’s one using the Conrad 433 MHz OOK receiver:
Odd, there’s a blind spot in there. Also, the Conrad receiver reports only 1/10th the number of pulses reported by the ELV receiver. Either it’s filtering out noise much better, or it’s simply a lot less sensitive!
The ookScope code (sketch and Tcl/Tk script) can be found here.
It would be interesting to OOK scope the RFM12B ARSSI (with Joop’s amplifier circuit) as well and see how well it performs as OOK receiver.
Indeed! I haven’t gotten around to building that circuit yet :(