« Wooden It Be Nice To Have An Update | Main | Wheels, Windscreens & Wipers »
Tuesday
Dec072010

You Don't Want To Do It Like That...

Apologies for the geological epoch-like delay since the last update, but I’ve been busy for most of the year - my Mum was diagnosed with cancer, and obviously my mind has been elsewhere whilst we’ve been getting her through her treatment. Good news is that the treatment seems to have done the job, and it looks like she’s going to be OK. 

Progress on finishing off Vikki has been slow, but I have done some things. One of them was redevelop the low fuel light

It became apparent after burning through several tanks of petrol that the damn thing wasn’t working. To try and understand why, I got Rob, my electronics guru, to keep an eye on the circuit with a multimeter whilst I filled up, to see what voltages we where getting as the tank filled. 

Needless to say, they where nothing like the carefully calculated values we based the circuit on. So it was completely useless! Another case of good in theory, but piss poor in practice. :-) 

So it was back to the drawing board. Rob observed that one of the reasons that the circuit wouldn’t have worked was due to the voltages swinging back and forth rapidly as fuel shifted in the tank (under cornering, acceleration, braking) - this is the reason why the needle was all over the place on the gauge. Due to this, even if the voltages we where trying to detect had been correct, it’d never have stayed in one place long enough for the circuit to register it. 

So - I got to thinking. What we needed was: 

    - Something to smooth out the gauge / sender output, to stop the needle dancing all over the shop

    - Something that could be easily ‘amended’ if the first attempt wasn’t correct

That’s when I started looking at Arduinos. An arduino is a clever bit of kit - they’re very popular in programming / hacking / robot circles as they’re cheap, programable and can be made to do just about anything if you add the right bits to them.  

So I got one to play around with:

This is a an Arduino nano. It has built in USB, so it can be programmed direct from a laptop. I started of easy, using a pot to simulate a sender, and had it spit the values out to the laptop to see what the arduino was seeing on it’s input line. Once I was happy with how it worked, and how I could program it, I set to work:

This was the first stab. Quite crude, but it proved the theory. The pot simulates the sender, and the Arduino reads the voltage change on one of it’s analog inputs. The program running on the arduino constantly monitors the values on this input, and when it gets to a set level turns on a digital output. This turns on the lamp via a power transistor. Another digital output drives the gauge using PWM (Pulse Width Modulation)

All well and good, but Rob took one look at it and after an intake of breath, uttered the immortal line. ;-)

He pointed out that microprocessors really like to be cosseted, and that the arduino wouldn’t really like the dirty (power wise) environment of a car. So filtering would be needed on the power supply. The outputs could also be affected by nasty spikes as well, so they needed isolating. Oh, and as we’re driving the gauge, we’d need power to the sender (as it would normally have gotten it from the guage).

So this we put our heads together and came up with this:

The arduino is protected, the outputs decoupled using optocouplers and a nice steady supply to the sender. And just to show off, two LEDs instead of an incandescent lamp - red for really low:

Yellow for low:

And both off if we’re over the thresholds:

Once I was happy that was all working, I used the circuit design package I drew the circuit up into develop a PCB. Printing out the traces onto an OHP, I took it to a friend of Rob’s who exposed the ‘negative’ onto a photo sensitive copper clad board, and then etched it in his bubble tank.

I then drilled all the holes on the component pads, shaped the board to fit the enclosure I’d got for it and took and cleaned the copper ready for soldering:

After a quick test fit

All the components where soldered on and the board was mounted securely in the box.

The lid of the box got some weather proof connectors, and these where hooked up to the USB socket on the arduino and the screw terminals on the board

The USB connector on the arduino had to have the insulation stripped off it so it would fit and not foul on the other components on the board. Putting the lid on the box makes the whole thing water tight, and all the inputs and outputs are terminated with a normal multiway plug to allow it to sit in Vikki’s loom with little fiddling around.

I’ve tested it all on the dining room table, and it works as expected - LEDs work, and the gauge is working just like the prototype on the breadboard. Now all I have to do is complete the program. I aim to have it: 

    - Take a reading every 10 seconds

    - Perform a moving average on the data gathered, to smooth the response

    - Update the gauge every 60 seconds, further smoothing the display 

As well as turn the LEDs on and off as required. There’s plenty of memory on the arduino, so I’m also going to try and ‘map’ the fuel tank so that I can display a true linear response on the gauge as it empties. 

I’m sure I won’t get it right first time - but this time I don’t have to junk the entire circuit if it doesn’t work. I can just plug in a USB cable and re-write the code until it works!

All of the circuit diagrams, component lists and PCB layouts can be found in the Electronics section, HERE.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>