Race Clock

An automatic stint timer for endurance racing

My crazy friends and I regularly compete in something called The 24 Hours Of LeMons. It’s a somewhat tongue-in-cheek form of low-budget endurance racing involving cheap cars, heroic repairs, wacky themes, and a lot of serious driving. We’re The B-Team, and our current theme is Kill Phil. The theme is a bit of an inside joke, which I’ll spare you the details of. Anyway, LeMons is a great way to do some real endurance racing at a very low cost, in a fun atmosphere. It’s been called “Burning Man with roll cages”, which is pretty apt.

We’ve done about a dozen races over the past couple of years, and one of the things we found ourselves wanting is a stint timer in the car. If you’re not familiar with endurance racing, the format is simple. The cars race around the track continuously for a set amount of time (usually 12 or 24 hours), and the goal is to complete as many laps as possible in that time. Each team has four or so drivers, who take shifts of up to four hours in length (or one tank of fuel, whichever comes first). When a driver’s stint is over, they come in, and we perform a “pit stop”, whereby we refuel, change drivers, and freshen up the car as needed, as quickly as possible. Fast pit stops are critical, because while your car is in the pit, everyone else is out there earning more laps.

Endurance racing is very hard work- imagine running a marathon while doing long division in roman numerals. When you’re in the car, it’s important to relax and pace yourself. To that end, it’s nice to know how far into your stint you are, and how far into the race the team is. With a stint timer in the car, the driver can get this information any time, without having to bother the radio operator (who has plenty to worry about already).

 

So, the goal for this project was to build a timer that showed elapsed time for this session, and overall time of day. It also needs to cost very little, because this is LeMons, and it’s all about doing things on the cheap. You might say we could do this with a stopwatch in the car, but the problem with that is that someone (the pit crew or driver) would need to manually reset it during pit stops. These races are literally won and lost by cumulative seconds spent in the pit, so any extra little task on the pit-stop checklist would be a real burden on the team’s performance.

What’s needed is for the clock to start automatically when the car’s ignition is fired (marking the stint start), and automatically reset when the car shuts off (marking the stint end). The car is always shut off during pit stops, so this is a convenient way to bracket the stint times. The clock also needs to run on its own power supply, since the car’s entire power system is shut off during pit stops for safety. Race cars have something called a “kill switch” which is a big red lever that is thrown during refueling. This lever disables every last bit of electrical source in the entire car. The clock needs to run on batteries to avoid being reset to midnight every time the kill switch is thrown.

 

Commercial solutions to this problem are very expensive- into the hundreds of dollars. However, I found this dual-time/stopwatch clock for $20 online:

 

Cheap! As an aside, about a dozen companies make a clock exactly like this (same features, same button layout, etc), but they vary in price from $20 - $100. Search on Amazon and you'll see what I mean. Clearly they're all buying the same system board from some company in Asia and slapping their own plastic around it. The rest is marketing. Knowing that allows you to buy the cheapest one with confidence, because the internals are identical, whether you pay $20 or $100.

That clock was really close to what I needed- it has time of day on top, and a stopwatch on the bottom, all on one display with huge numbers. It even has large-size buttons, which would be operable when wearing Nomex gloves (such as when driving or fueling).

All that was needed was to automate it. It’s hackin’ time!

I started by dismantling the clock to see what we're working with here. It's very simple, as you might imagine. I was very pleasantly surprised to find the whole thing was held together with screws. No glue or plastic welding anywhere. Yay! As you can see, the hinged lower portion has a small PCB for the buttons. This looks like an easy way in. I can just drive those pads with my own circuit, thus gaining total control over the timer.
I traced the pads to figure out which one was which button, and soldered on a little harness to gain access. I need access to Start/Stop, and Clear in order to give the device the desired behavior. Luckily, there's no encoding scheme for the controls, and the PCB is even labelled. Thanks, mysterious Chinese system supplier, for making a very hackable device. Also note that I left the original buttons intact, so that the clock can be used manually if needed.
I routed my new harness to a convenient spot, and super-glued it down as a strain relief. I notched the case slightly with a knife to allow the wires to exit.
Presto! One dual clock/stopwatch with externally triggerable functions! Shorting the yellow or red wire to the orange one activates Start/Stop and Clear, respectively.

Now that I knew I could control the clock the way I needed, it was time to develop a circuit that would actually do it! I opted to control the buttons via some little DIP relays I happened to have. I bought a bunch of them at a surplus store a while back, and they’re really nice. I like that they will keep the control circuit physically isolated from the clock, as well. Since the two circuits are on their own grounds and their own power levels, this seems like a good idea.

The operational sequence goes like this- assuming the car is out on track, the timer will be running. The driver will come in to the pit at the end of their session. When they do, they will shut off the car. I need to detect that, then stop the timer. When the next driver is in and ready to go, they will start the car. I need to detect that, and respond by resetting the timer and starting it again.

Here’s what I came up with to do that:

It's based around an ATTiny13A, driving a pair of relays (one for each button on the clock). On the left is a regulated power supply to drive the logic. Using a microcontroller just to drive a simple timed sequence of relay states seems like massive overkill. However, the damn things are just so cheap now, why not? For a couple of bucks and a handful of code, I have something that would have required several dollars worth of discrete logic, and many more hours of development. Still, it feels weird to use a chip that's more powerful than the first three computers I owned, just to flip some relays in a timed sequence.

Here’s the Eagle schematic file, if you’re interested. As you can see, the logic runs off the car’s power. The clock is on batteries to be protected from the killswitch, but I wanted this add-on device to be zero-maintenance. One less thing to go wrong is always a plus in endurance racing.

The relays are driven directly from the MCU’s output pins, because they draw very little current. I put diodes in there to protect the MCU from inductive blowback. The car’s 12V ignition power is fed into a voltage divider to get it down to 5V, then into a transistor which pulls an input pin low. This will tell the MCU when the car is running, and when it has stopped.

Once the clock hacking was done, I put together the logic on a breadboard, and used that setup to develop the code for the microcontroller. So far so good!

The code on the MCU is trivial:

[iframe_loader src=”http://pastebin.com/embed_iframe.php?i=KNFhKXq6″ height=”600″ scrolling=”yes” marginheight=”50″]

If you’d like to use this code, here’s the source, and a compiled binary. This is for the ATTiny13A.

One thing to note in the code is the three second delay at the beginning. Starting a car is rather like an electrical hurricane. This delay before the logic sequence begins is to give the car time to start, and time for the electrical system to settle down. You’ll also see some small delays amidst the relay pulses. The clock is a pretty primitive thing, and can’t handle really rapid button presses. The relay sequencing needs to be sluggish to keep from overwhelming the cheap clock’s logic.

Since reliability is critical here, an etched PCB was in order:

Here’s the Eagle PCB file, and an acetate of the traces, if you’d like to etch your own. I etched the board myself using this process, which I’ve had very good luck with in the past.

Here's my etched board. Lookin' good!
Weeeellll.... almost. I got a bit carried away poking at the board with a toothpick while it was etching. I managed to break a couple of traces, which required some not-so-pretty repairs. What can I say- I only had three evenings to get this built, so no time for pleasantries.
Here's the board, all assembled and ready for the microcontroller. I had already programmed the ATTiny13A while getting the circuit finalized on the breadboard, so it was ready to drop in.

The circuit is built, the microcontroller is programmed, so we’re ready to go, right?

I hooked up the clock, applied power, simulated the car ignition with an external 12V source, and.... nada. I put a probe on the microcontroller's outputs, and verified that the code was running correctly. It was running through the pulse sequence, and responded correctly to the input transistor. It was just the relays that weren't firing, despite getting the right signals from the MCU.

 

A little bit of tracing with a meter revealed the problem:

 

In my haste (three evenings!) to get this done, I hooked up the relay coils incorrectly in the schematic in Eagle. These relays have polarized coils. Hooking them up backwards in the schematic would normally be a harmless clerical error. However, when that schematic is then used to generate a PCB, mayhem ensues. Whoops. I cut a couple of traces, applied some jumpers to reverse the polarity on the coils, and I was back in business.
I mounted the control circuit in a little plastic box that came out of the car. Our race car is a converted 1987 BMW 325e. One of the first things you do when building a street car into a race car is to strip out everything that isn't essential to rapid forward motion of the vehicle. This little black box held a control board for power locks or something frilly like that. It was a good fit for my PCB, and had mounting holes that allowed me to screw it to the back of the clock. The three pig tails coming out of the connector (also harvested from the car) run to chassis ground, main power, and ignition power. The latter is used only to detect when the car starts and stops.

Here’s a little video of the device in action. My finger is simulating the car ignition. Note that when the car starts, there’s a few seconds of delay, then the timer is reset and started. When the car stops, the timer is stopped.

Here’s video of the device in the car, with yours truly getting ready to head out on track. This is the start of the race day, not a mid-race pitstop, hence the apparent lack of rush. The clock is mounted to the rollcage, on the right-hand windshield pillar. When I start the car, notice there’s a brief delay, then two beeps. Those beeps are the clock resetting and starting again.

That’s all there is to this gadget. We’ve used it for one race so far, and it worked perfectly. Hopefully it will continue to do so for many racing seasons to come. See anything you’d change in the design? Want to make fun of my ghetto PCB? Let it all out in the comments, below!

Want to see more video? Check out The B-Team YouTube channel and The-B-Team Facebook Page.

One thought on “Race Clock

Comments are closed.