Reading speed from car ECU

Hello everybody,

I am building a new dash board from my old Mini and need to buy a speedo. One that looks nice and can be calibrated to my wheel size and gear box is eye waveringly expensive. I would like to be able to read in the speed to an arduino and output it to a display.

The original speedo is driven by a single wire from a MEMS2j ECU. The tacho feed is a 12v pulsed signal and I am guessing that the speed output from the ECU is the same. I can't find anything to confirm this but I am fairly confident that's how it operates. I don't have much opportunity for trial and error as I need to spin wheels so I would like some advice on the best way of counting pulses. I have no idea of the frequency.

Would an interrupt be the way to go? Any other suggestions?
All advice is welcome and a pre-emptive thanks to all replies

toby

tobycatlin:
I would like some advice on the best way of counting pulses. I have no idea of the frequency.

I'm a little surprised that the speed drive comes from the ECU - I would have expected that the ultimate source is a transducer on the transmission. Are you sure you're looking at the right thing? Is it possible that it's just being passed through the ECU (since some ECU functions may need to know road speed)?

I don't know what form the speedo signal takes, and I suggest you absolutely need to know that before you go any further. It's possible that it is a completely different signal to what you're assuming.

If it turns out that it is in fact a variable frequency square wave as you suggest, then you need to know what the frequency / speed relationship is. If you get lucky, there is a remote possibility that you could even wire it up to an ordinary analog tacho and just stick a MPH dial on it. Or connect it to any other electronic speedo covering the right speed range and simply replace the dial.

Would I be right in assuming that you are going for minimum cost rather than a pretty/elegant solution? If so, yes you could use an Arduino to measure the frequency of a pulse train and display a number on an LCD display, but it's not likely to be very robust or very pretty.

There is a speed sensor on the gearbox that feeds into the ECU. The car has an kseries engine from a rover 200 and so the ECU and gauges came with it from the donor car. It was always inaccurate as the wheel sizes are different. The original speedo uses a servo/stepper motor to drive the needle rather that a resistance driven analogue coil.

One forum suggests for a similar Rover ECU "the speedometer is a squarewave that increases in frequency as road speed increases". So it seems like a good first guess to assume it is a squarewave signal. My idea is that once I can determine the frequency, I will use a gps tracker to drive at a known speed and determine the relationship between frequency and speed.

How do I measure the frequency of a squarewave?
A quick google turned up this:
http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/

Any other ideas?
thanks
toby

A very useful tool for this sort of investigation would be a DSO (Digital Storage Oscilloscope). Once these used by very expensive items for specialist electronic engineers, a small but very effective unit is now quite cheap: $99.95 US

I am stunned at the capability of this little unit compared to the many thousands of dollars for less function a few years ago!

One readily available (automatic) option is to display frequency of an input waveform.

See: DSO Nano V2 - Pocket-Sized Digital Oscilloscope (Sale) - TOL-10244 - SparkFun Electronics for one supplier - there are others via ebay etc etc

A user manual is available: http://www.sparkfun.com/datasheets/Tools/dsomanual.pdf

PS My sympathy if you are working with the electronics of a Rover - when we travel in remote areas of Australian outback we seem to frequently need to resolve and support Landrover difficulties. They may be fine on English paddocks, but I personally hate them in remote rough terrain.

I have never had much problems with the electrics apart from a small ground leak that drains the battery over a couple of weeks. The bumper fell off while going down the m11 but that is due to the ever rusting nature of the Mini

A friend has suggested using a frequency to voltage converter IC and then sampling the voltage in the arduino.
toby

My sympathy if you are working with the electronics of a Rover - when we travel in remote areas of Australian outback we seem to frequently need to resolve and support Landrover difficulties.

LandRover and Rover have been separated for nearly a quarter of a century.
They've been through the hands of BAE, BMW, Ford and now Tata since 1988.

tobycatlin:
A friend has suggested using a frequency to voltage converter IC and then sampling the voltage in the arduino.

If you're involving the Arduino at all, I would have thought it would be more accurate to have the Arduino count the frequency directly and avoid the inherent inaccuracies of going via analog. You will need to condition the signal to bring it down to a level suitable to be ready by the Arduino. To do that you need to know what the peak voltage is. Depending how the signal is generated, you might find the voltage is speed-sensitive rather than a clean constant-voltage square wave, but since you're getting it via the ECU I think there's every chance it has been converted to a constant voltage square wave for you - in that case all you would need is a voltage divider.

What do you plan to replace the speedo with? If you have any speed or tacho designed to be driven from a variable frequency square wave signal then it would seem straight forward to have the Arduino determine the incoming frequency and generate a suitably-scaled output frequency from it; amplify that up to 12V and Bob's your uncle.

Would you please expand on the part where you say "constant voltage square wave for you - in that case all you would need is a voltage divider", I don't understand how a voltage divider would work in this situation. Do you mean that I would need a voltage divider to bring down the voltage to a 0-5v range so that it can be read by the Arduino?

Would you use the pulseIn function http://arduino.cc/en/Reference/pulseIn to count the frequency directly? or something like the Frequency Counter Library http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/
If I can get away with not making a preamp that would be cool. As i understand the interrupt driven method is much more accurate but could be overkill for what i want. I doubt the frequency is going to very high.

I think the peak voltage will be 12v and it makes sense that the ECU cleans up the signal before passing it off the to speedo dial. That would mean you could use a range of dials which is the kinda thing car companies do to save money. MEMS stands for modular engine management system. I have some datasheets on the ECU but none of them mention anything about the signal it kicks out, just the pins it uses.

In regard to the display itself, I have bought a automotive micro stepper motor that is designed for driving dials and have had some success in using the servo library to drive it. However I am having issues in calibrating zero position of the needle and the movement isn't very smooth at all. I think that this is just the start of a series of problems I don't have the skills to fix. There is obviously a reason why the programmable speedo i really want is £250.

I am thinking to simplify the problem I will laser etch a piece of acrylic that will make up the whole dash display. I will then use leds driven by the arduino to backlight each number that makes up the speedo as speed increases. I am happy with 5mph increments or use 10mph increments and use PWM to change the brightness as i get closer to the next light. Using this method I can create all of my dials for fuel level, indicators, temperature on one panel and have total control over the design. The laser cutter is very accurate and I can refine the design at a later date.

tobycatlin:
Do you mean that I would need a voltage divider to bring down the voltage to a 0-5v range so that it can be read by the Arduino?

Yes, that's it exactly. You need to ensure that the input never exceeds 5V. You have the option of connecting the signal to a digital pin and polling the pin, or attaching it to a digital pin that supports interrupts and counting the interrupts, or connecting it to an analog pin and reading the analog voltage (that does not seem a sensible way to detect a square way, but it's an option). In order for either of the approaches using a digital pin to work, you need to ensure that the signal transitions cleanly past the threshold voltage (from memory, 60% of the supply voltage i.e. 3V on a 5V Arduino). To decide whether interrupts are necessary/sensible you're need to know the maximum frequency you need to handle, but if this is just a cleaned up signal from a transmission sensor I'd be pretty confident that the frequency is low enough to be handled easily whichever approach you choose to use.

In general, when connecting an Arduino to a noisy 12V system you would need to buffer the signal to eliminate noise and protect the Arduino from spikes. But in this case since the signal comes from the ECU I think it would be reasonable to assume it is a well behaved source. But if you find you're blowing Arduinos up or getting erratic behaviour, it would be worth revisiting that assumption.

Thank you very much for your response, your information is very useful. I think I have enough of a plan to try something out this weekend. At the very least I should succeed in frying an arduino.

Quick tangent, is the next level on the Arduino forum from Edison level, Tesla level?

thnx

See: DSO Nano V2 - Pocket-Sized Digital Oscilloscope (Sale) - TOL-10244 - SparkFun Electronics for one supplier - there are others via ebay etc etc

Single channel, right? - Scotty

You can connect the ecu speed output to an Arduino digital input via a 100k series resistor and let the pin protection diode clip the signal to 5v. Position the resistor at the Arduino end of the cable (not the ecu end) to avoid noise pickup. To measure the frequency, use one of the Arduino inputs that supports an interrupt, record the value returned by micros() at each interrupt, and hence calculate the interval between interrupts. Then divide that interval into whatever number gives you the required output in mph, kph, feet per nanosecond or whatever else is required. You also need to detect when there have been no interrupts for half a second or so and set the display to zero when that happens.

Why dont you use an arduino and a gps module that way you will avoid the fuss of reverse engineering the protocols and the diferences in wheel base.Problem Solved

manosv:
Why dont you use an arduino and a gps module that way you will avoid the fuss of reverse engineering the protocols and the diferences in wheel base.Problem Solved

GPS signals are not always received reliably, especially in high rise cities and mountainous areas. But you could use a combination of GPS and ECU output, calibrating the ECU output frequency/speed relationship when the GPS is working and using the ECU output when it isn't.