Motorcycle Digital Speedo With Arduino

The first part of a (very) occasional series which follows my creation of a digital speedo for my motorcycle.

This is a project I’ve been thinking about, and working towards, on and off, for positively ages now. Work is really busy, and with a (still relatively) new daughter to fill in the gaps, my free time for the last eighteen months has been somewhat limited.

Apart from electronics projects, another work in progress is my motorcycle. It’s thirty-two years old, and, being a Honda, still runs really well. I do plan to strip it right down and re-paint the frame eventually. It also needs the occasional fix, for example the speedometer gave up the ghost last year, simply making a racket as the drive cable rotated around, presumably, a jammed shaft. I didn’t bother trying to fix it – I’d been thinking for a while how cool it would be to build an arduino-based circuit that counted wheel revolutions via a hall sensor and magnet to display speed.

My plans became more grandiose – I could also monitor engine revs, extrapolate the gear I’m in from the speed/revs, and have an electronic ignition lock. I actually built the first circuit. It worked really well on my desk, not so well on the bike. For one thing the ignition lock was based around a relay which would disconnect occasionally, stalling the bike. Also the 4×20 LCD display was too small and impossible to read in sunlight, and the rectangular project box that everything went in looked horrible on the bike.

I decided to pare back to essentials. Essentially I need a speedo, and I wanted it to look more in keeping. I decided I was going to use the original speedo housing, and add bright LEDs around the outside to show the speed, and have more in the middle to act as indicator, neutral and high-beam warning lights.

I started, with Eagle, to lay out the LEDs. I’d need twenty-seven to go around the outside to show speed in 5kph increments, another three for the warning lights, and then I thought maybe I’d add a ten-LED array (from Farnell) below them in case down the line I wanted to use it as a rudimentary tacho. Getting the LEDs arranged in a circle required a bit of a spreadsheet with sine and cosine calcs on it.

To drive 40 LEDs from one Arduino requires either a bit of jiggery pokery (Google “charlieplexing” if you’re interested) or, to cut the Gordian knot, simply buying a bit of extra hardware to do it. I opted for the latter given my lack of time. I went for the Maxim 7221 (from Farnell, the link to the item is: http://uk.farnell.com/maxim-integrated-products/max7221cng/ic-led-display-driver-8dig-24dip/dp/1593381). Information on linking this IC to an Arduino can be found here. It basically allows you to drive 64 LEDs from the one chip, and you can daisy-chain them together. The Arduino communicates with it via SPI, so it only ties up three pins no matter how many MAX7221s you have chained together.

I’ve been experimenting with etching my own circuit boards using the printer toner and HCl/H2O2 method with great success, so that’s what I used here.

The LEDs effectively sit in an array – obviously physically they can be laid out any way – and I was using single-sided copper-clad board as it’s DIY. Usually when laying out a circuit in Eagle when you’ve only got one side (or layer) of copper means a bit of tweaking here and there to allow “nets” or tracks to connect where there’s no route for them to do so – normally I’ll add a few zero-ohm resistors in the board layout to connect them (and use plain wire, of course, when building). I found laying this array out impossible like this though, so the easiest solution was to tell Eagle I was using double-sided board, and tell it to favour the bottom side, and I figured I’d just add wire on the top where the tracks were meant to be. That ended up a bit of a rat’s nest when I came to build it!

  

I’m not proud of how this looks – but it works, which I was pleased with. I think if I had to lay out something like this with so many top-side connections again I’d experiment with using two single-sided boards and sandwiching them together, linked with through pins (“vias“) where needed.

To control the 7221, I used the LedContol library – which makes addressing each individual LED on the matrix as easy as just specifying a row and column. You can also control the intensity of the LEDs as well, which is nice. Here’s the thing running. The photo doesn’t do the display justice – it should be much easier to see the LEDs even in bright sunlight. The green LED in the middle will be the neutral indicator.

Next time (when I get a chance!!) I’ll document building the “veroboarduino” driver and handling the inputs from the hall sensor to count wheel rotations and pick up the neutral, high-beam and indicator warning signals.

 

Comments 12