Firstly I needed to work out which type of system to make, Infra-Red or magnetic pick up. Most karting tracks have a magnetic loop fitted in the track so in theory that meant using a hall effect sensor to pick it up. The problem is some track don’t have a loop and some have 2 or 3 loops (for intermediate timing) so this wouldn’t fulfil my requirements. I decided on the Infra-Red option as it was already used in professional systems and I could take it to any track, the down side is that I now have to build an Infra-Red transmitter as well.
Having then researched the IR option further I came across a very useful blog where Jim Ele had already built a similar timer which utilised an existing IR transmitter but used an Arduino as the processor. This would form the base of my build.
The first part was to build the IR transmitter which would sit on the pit wall repeatedly sending out a set code. I simply built a home brew circuit board with the bare minimum to run the Arduino’s Atmeg328p processor as per the diagram below and attached 4 AA batteries for the power. I used 2 IR LED’s purchase from Maplin’s to send the signal out.
|The power circuits have been simplified for the diagram|
The next problem to overcome was how to avoid false triggers from other IR sources, I.e. other IR transmiters that could be at the circuit and also things like the Sun / strip lights etc. The answer was to use a 38Khz carrier frequency with a matched receiver and send out a specific code that the receiver would recognise (The same way your tv knows that you’ve pressed a certain button on the remote). Because the receiver isn’t in the beam for very long I needed a short code which could be received very quickly. After again looking at what Jim Ele had found out I decided to give 3 ‘On’ pulses each 416µs with a 1200µs ‘Off’ gap between each. After the 3 pulse there is a 6ms gap an then the code repeats itself. I’ve tried to show this visually below.
I housed all this inside a suitably side housing purchased from Maplin and attached an old mini tripod as a stand. Waterproofing is done by covering the whole box is a clear plastic bag with the 2 LED tubes sticking out. The total cost was less than £20 and has a range of about 20 meters. The AA batteries easily last for more than the 24hours I needed (more than 50 hours actually).
|Finished Transmitter, The two small plastic tubes sit over the LEDs and are mainly for Aesthetics.|
As the beam was using a 38Khz carrier frequency I needed an IR receiver that was set to that frequency so I opted for the TSOP38238 as it was easily available for a low price and had good performance and will run at 3.3v. The TSOP38238 receives the signal from the transmitter and inverts the signal as shown below.
I housed this about half way inside a separate small box with a small window so that it could be attached to the front panel of the kart for best view of the transmitter. This also meant it wasn’t in direct sunlight. It was sealed closed to make it waterproof. A 3 core lead then connected it directly to the main unit on the steering wheel.
The Main Unit
Again I started with a basic circuit to support the Atmega328p processor. I then added a 16x2 LCD display module with LED backlighting (be careful here as the backlighting is the main current draw and can easily exceed 100mA with some models. I choose a module that had a single LED for backlighting to reduce the current consumption for optimum battery life). To record the lap times I added a microSD module. The microSD card also contains a text file which can be altered to tell the unit how long to ignore the receiver for (I’ll come back to this later)
|The power circuits have been simplified in this diagram|
Note: The system runs at 3.3v not 5 as per the diagram. Because of the change to 3.3v I also changed the IR receiver to a TSOP38238.
This was then housed into suitably sized box from Maplin with foam padding around the circuit board to protect it from vibration.
I then used a second identical box to house the batteries which was then mounted onto the back of the first box around the steering wheel. This meant it could be swapped from one kart to another very quickly and even attached to hire karts.
Originally I wanted to use 9v pp3 batteries for the power but an initial test showed these couldn’t stand the vibration and they destroyed themselves within an hour. I swapped these out for an RC car Ni-mh receiver pack battery – 6v 2500mAh and again wrapped it in foam. This works great and lasts over 30 hours per charge.
How the system works
As the receiver picks up the beam from the transmitter, the sketch checks the length of each pulse and counts them if they are the correct length. Once its counted to 3 it knows a ‘good’ code was received. If a pulse doesn’t fit the right time frame or no further pulses are received then the count is reset. After receiving a good code the sketch then works out the lap time (the time between the last ‘good’ code and this one) to the nearest 1000th of a second, increments the lap counter, works out the delta time to the fastest lap and adds it to the total time expired since the start of the race in hours and minutes. This is then displayed on the screen and also stored onto the micrSD card as a .csv file type and can be opened in excel. The system then ignores any signals from the IR receiver for a period of time, this period of time was set by the text file on the SD card as mentioned earlier. This time should be set to the best possible lap time minus 3 to 4 seconds. This way the IR cannot receive any false signals from other transmitters. About 4 seconds before you pass through the beam again the system starts looking for a beam again.
A Note on using microSD cards: When reading and writing SD card can use quite a high current (200mA or more) so make sure your voltage regulator can handle it! Also they run at 3.3v not 5v so I run the whole system at 3.3v which means you need an LCD module capable of running at that voltage. I also used the SDFat library for this project not the standard Arduino one as the SDFat library (available from GitHub) puts the microSD card to sleep between read/write events which saves a lot of current and prolongs the battery life. The standard SD library keeps the card awake by default and it makes quite a difference.
Finally to make the unit rainproof I printed the front panel onto OHP transparency in reverse. The text was left blank and spray painted in silver afterwards. Turning the transparency over then reveals a nice shiny front cover with silver text and a clear window for the screen. This was double sided taped to the front and worked great.
The total cost for the unit was around £40
Further improvements coming.
I also tested a OLED 16x2 screen and this worked better than the standard LCD as no backlighting is required and its clearer in bright and dark conditions. I used blue text on a black background.
I’ve also started work on a unit with a 2.9inch graphical touch screen but its yet to make it onto a Kart. More on this one to come.