Home > Advanced Projects > Speed Trap

Modified: 15:22, 27 October 2013

This was designed for a radio controlled car track using cars of 1/10 scale. It works by measuring the time it takes for an object to pass 2 sensors placed exactly 200mm apart. In this way the speed can be calculated in "MPH" and "mps" (metres per second).

In fact 2 versions were made with the second designed exactly the same but the case was designed for indoor use.

Designed and built by Phil Townshend 2008


The principle is simple. Take the time it takes to travel 200mm, multiply this by 5 to get the time for 1 metre then take the reciprocal.

eg: Time taken to pass 200mm = 0.1s. Then 1 metre takes 5 x 0.1 = 0.5s,

so speed = 1 / 0.5 = 2 m/s.

The speed is displayed in metres/second by default, but pressing SW2 will display the speed in MPH but at a scale speed so actually it will read 10x as much.

The Math routines I wrote I am very pleased with. They can multiply 16bit by 8 bit numbers and are based on long division and multiplication. I wrote them myself - honest!!

The sensors used were opto-transistors and the light sources were some 1mW keyring laser pointers (I found a deal on 30 for £10 from Japan - free shipping - bargain!)

The lasers and sensors were positioned such that a beams were directed across the track exactly 200mm apart. The cars would break the beams as they drove past.

Boxes were made up from 6mm MDF to protect the sensors and Laser modules and also to ensure accurate positioning.

The Lasers were mounted in wooden blocks that swivelled and could be adjusted by bolts from the sides.

Speed Trap block diagram

Thanks to the PIC, most of the circuitry is interface control, such as buffers and drivers. The last 8 display digits are multiplexed, where only one digit is on at any one time, but all very quickly.

To maintain brightness the LEDs are driven much harder than usual so protection was put in to detect if the clock ever stopped because of the PIC locking up for some random reason. In this way as soon as the display is frozen, the outputs from the shift registers is switched off. and thus in turn the display.


The display is made up of 294 LEDs. These are divided up as follows:

  • A fixed 5 character display to show the word "Speed"
  • Digits D to H are for the 5 digits displaying numbers and most of the alphabet letters (except for k,m,v,w,x).
  • Digits C to A are for the display of the units, either "mph" or "mps"
The word speed was formed from 94 LED all wired 4 in series and then parallel (2 LEDs added at the rear for the odd 2 on the "S").

Since they are only ever all on at once, they can all be connected to one output on the control board.

The segments for the displays were constructed from 4 x hi-brightness 5mm LEDs wired in series. This makes wiring a lot neater and easier. Also means best use of power with minimum amount of voltage drop resulting across the series resistor to the LEDs.

Digits C,B and A are for the letters "mph" and "mps" - miles per hour and metres per second).

The "a" and "b" segments were used for other segments since none are needed in the normal position.

Digit C
seg a = middle leg of "m"
seg b = decimal point

Digit B
seg a = leg of "p"

Digit C
seg a = middle of "s"
seg c,e = split for small "s"

The heart of the circuit is the PIC which handles all multiplexing of the display, timing, calculations and monitoring sensor input buffers. The display works by pulsing each display on briefly and letting persistance of vision do the rest. When Digit A is lit, the Data input of the shift register is set high and clocked in, thus providing drive to Q24. The next 7 subsequent clocks will be with the data input low, so only the single output is high at any one time.This is repeated about 125 times a second.

Q6 and Q7 are Darlington transistors - TIP122 - to provide drive for the "Speed" LEDs (96/4 x20mA = 0.48A) and a siren respectively.

Q24 to 31 are also Darlingtons for each digit which can require up to 1.5A. The LEDs in each segment are wired in series and would normally require only 20-25mA for continuous operation. However since each display is on for only 1/8th of the time, they need to be driven a lot harder say about 8 times without doing damage so about 200mA-ish. The power supply feeds the LEDs via D3, a PNP transistor and a Darlington. Each of these reduce the voltage a little. See right for the maths!

A 4MHz crystal clock IC was used for the PIC to ensure accurate timing. .

The rest of the circuit can be divided into sections.

LED voltage

= 12-(0.7v + 0.7v) = 10.4v

The Vf of the LEDs at high current is about 2.35v so each segment will have a voltage drop of

4 x 2.35v = 9.4v

With only 1v across the resistor, only 9.6% of the total power is wasted in the resistor - pretty good!!
Input buffers
Anode LED drivers

These are standard buffers using opto-transistors as sensors. This is because of their sensitivity and reaction time. When the light beam is broken, the transistor switches on and sends the output low. There are 2 of these, one to start timing and one to stop.

The anode (+) drivers consists of 2 transistors. The first to shift the high level voltage from 5v to 12v and also to invert the signal. This provides base current to the second PNP transistor configured as a driver (saturate) for the LED anodes. Only about 150mA is required to pulse the 4 LEDs in any segment so a low power type was used.

Clock detector
Shift register

This section detects the lack of clock signal andf switches off the display by resetting the shift registers outputs to "0". Every transistion on the clock, pulses Q5 on, discharging C3, preventing it from going high and resetting the registers. If these pulses are not received frequently enough - in this case approx 5ms, C3 rises to logic "1".

The shift registers provide the column outputs to the Darlington drivers - for the LED cathodes. If all the segments sre on, then just over 1A will be sunk, thus TIP122 were used again having a max Ic of 3A. The 2 4-bit shift registers are connected with Q3 output from the first to the Data input of the next.

The PCB has all connections to the display at the top, cathodes on the left and anodes on the right - note in the prototype, 2N3702 PNP were swapped for some spare TO18 types I had floating about.

The two presets adjust the threshold of the sensors..

As mentioned earlier, 2 versions were made. The first was built on 2 chrome plated poles for use on the outside radio-controlled car race track. The other was an indoor version I put in my workshop just for the hell of it. The case was made from 6mm MDF and covered in 1mm polystyrene vacuum forming plastic. An impact glue was used to fix the styrene in place and the edges sanded smooth.
Drilling the ends for the switches required some secure clamping onto the pillar drill. I suppose it could have been done by hand, but I didn't want to risk scratching the finished covering. Only 2 switches and 2 sockets to wire up in the case. The PCB was mounted on the top of the case since there were more connections to the LEDs and made opening and maintenance easier.
Having the LEDs in series for each segment meant simple wiring and easy to keep neat. Construction of the case was strengthened by using angled pieces of wood to provide strength and to help prevent the case distorting as it is quite long.
Designed and built by Phil Townshend 2008
Tel./Fax: 01202 474720
Tel: +447976 515290

Contact us by email.
www.edutek.ltd.uk - Working Electronics For Students & Teachers