I finally got a proper video camera and was looking for something interesting to use it on and it just so happened that I've been itching to make some tutorials. Luckily, the camera came with Adobe Premiere Elements so I took some time off to learn some very basic video editing. I've found that I'm a horrible speaker on-camera and become completely tongue tied, even though it seems that I talk completely fine when I'm by myself.
Anyways, I figure that nothing beats hacking a high frequency radar module for a video tutorial. It's actually pretty cool and you can use it as either a speed detector or a motion detector. You can see a couple of my dirty design practices in here that are okay for doing a quick throwaway prototype, but I wouldn't recommend to include in a final design. I completely skip the decoupling caps and use the microcontroller input voltage thresholds directly rather than using a proper interface...things that would make my university profs turn over in their graves (they're actually all still alive...I think). But before I start, its probably best to introduce the sensor and explain a bit about how a microwave speed sensor works.
The 24 GHz radar sensor is a short range radar that's used in automotive applications for collision detection, obstacle detection, blind-spot monitoring, and also to assist in automatic cruise control. It has an approximate range of 20 meters but this can vary depending on the how you implement the detection circuitry. The module actually operates based on Doppler theory where the frequency of a wave will change based on the speed of the object producing it. Most people will recognize it as the frequency changes of an ambulance siren when an ambulance approaches and then goes off into the distance.
For radar, a signal is bounced off an object and the reflected wave's frequency is compared with the transmitted wave's frequency. In RF terms, the two signals are mixed and you get the sum and difference components. Usually signals in the microwave range are used (24 GHz in this case) and so its quite simple to filter out the sum component (very high frequency) which just leaves the difference component (very low frequency). The final output signal frequency is just the frequency difference between the transmitted and reflected signals. This is usually in the range of 0 to 50 kHz for every day objects. Here is a Wikipedia link that gives a good treatment of the theory behind it. That link also shows the derivation of the formula you use to extract the speed from the frequency. In a nutshell, the formula is:
speed = 0.0225 * output_frequency
and the units will be in km/hr.
This particular module actually has two outputs. You can pull another trick where you separate the reflected signal into two pieces, the in-phase (I component) and quadrature (Q component). Roughly speaking, its like saying you can separate any horizontal motion into its x and y components. You can measure the speed using either of these two signals, but the in-phase signal will either lead or lag the quadrature one based on if the object is moving towards or away from you. It sounds complicated, but it's actually not too bad in software. Anyhoo, this tutorial will just deal with the speed measurement. Just thought I'd give you a heads up on that.
As well as showing how radar can be used by the everyday hardware hacker, I'm a little bit happy that I can show how useful solderless breadboard prototyping is. Many engineers look down on using solderless breadboards and you rarely (or at least I rarely) see it in the industry. However I've found that my breadboard is something that I'm constantly using to try out different circuits or components. I especially like the fact that you can do quick what-if scenarios with different components and connections without having to pull out a soldering iron.
The components that I'm using can all be found in the FreakLabs store (except those cool potentiometers which I'll be carrying soon). The source code is also included and is at the bottom of this page.
Here is a list of the components that are used in this tutorial:
|24 GHz Microwave Doppler Radar Speed Sensor|
|Chibi 2.4 GHz Board|
|LM358 General Purpose Dual Op Amp |
| Solderless Breadboard Jumper Wires |
To make things simpler, here's an equivalent schematic to the circuit that's being used in the video.
I should also mention that in the last part of the video where I actually show the speed of my hand moving across the sensor, the dimensions are incorrect. I had actually just written that code in between shooting the video and later realized that my units were in meters/second rather than km/hr (damn MKS). I've made already made the adjustments in the code below.
Here is the the main file which has all the code for reading and processing the sensor data.
And here is the complete package that you can build and use on the Chibi board: