How to read RPM - diy tachometer

Place your article links, ideas and suggestions here. A moderator will move topics and posts to the approved area when they meet the standards required. Note, this could take years, and there is a lot of great stuff in this section.
Post Reply
User avatar
russian
LQFP112 - Up with the play
Posts: 154
Joined: Fri Feb 01, 2013 4:18 pm
Location: Jersey City, USA

How to read RPM - diy tachometer

Post by russian »

In this article I will explain how I hacked into my car harness in order to read current RPM. This approach is not universal and there are no guarantees - this article only applies to my car and you should not attempt doing anything like that to yours.

A bit of technical background first: the car I have hacked was sold in US as Ford Aspire, it was made in South Korea and it's Mazda design with some Mitsubishi components. Not your average F150 exactly :) This car uses Hall effect crankshaft position sensors (no idea how that works). So I could have used the same approach for something like Mazda Protege or even a Miata from the 90's - the younger cars would have sensors based on Variable reluctance and that would be a different story.

When I open the hood, I see a distributor like the one on the picture

Image

If I would have decided to break this distributor and look inside, I would see something like

Image

That tin wheel spins with the crankshaft and that's what make the CKP signal. If I would keep taking it apart, I would see the actual sensors and the other wheel - the smaller wheel is in charge of CID signal.

Image

Does not really matter what CKP and CID signals are. We only care that even while the car has a 12 volts battery, most of the sensors and the stock ECU run on 5 volts. Somewhere in my harness where are two 5 volts wave signals which look like this:

Image

That's it. We can wire this signal right into the any 5v tolerant microcontroller. Just to be a bit safer, we will put a 1n4001 diode between the harness and the microcontroller.

So, let's get something done. Let's take a STM32F4DISCOVERY dev board - that's a $15 board based on some stm32f4 microcontroller running at 168MHz.

Image

That's actually a lot of cheap computation power.

As is, microcontrollers are not exactly super friendly - ChibiOS/RT would help us, we will let it take care of the the lower level. We will use serial-over-usb to output data - so, mini-usb cable would be used to flash & power the board and the micro-usb cable would be used for serial. If you made it to here you probably know what serial is.

It's not much code, it's quite self-explanatory:
Image

(the code is a picture simply because I wanted to keep the coloring)
ivan141
LQFP112 - Up with the play
Posts: 148
Joined: Sat Sep 29, 2012 9:16 pm
Location: Rotterdam, the Netherlands

Re: How to read RPM - diy tachometer

Post by ivan141 »

I've tried a lot of different ways of measuring RPM, and every one has it's problems (in it's simplest form that is).
Measuring intervals as you do is probably the most precise, but also more processor intensive than pulse counting scheme's.
I wonder how this pans out on a MCU that has a lot of other tasks running (such as freeEMS).
What I always end up adding is some way to force RPM measurement to zero at some point, because almost all ways of measurement
have a hard time going to zero (except interval based pulse counts, which are a lot more inaccurate).
FABRICA MI DIEM, PVNC!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: How to read RPM - diy tachometer

Post by Fred »

I've put a LOT of thought into a generic and high quality RPM measuring scheme. I've implemented most of it, but not shared it yet, because I need to work with Mike to get a wizard made up for it. The down side of my approach is complexity in configuration. The upside is optimally accurate numbers with smooth speed-variation-free values over time. FWIW, my current "force zero" (IE, time out on readings) will be retained with the new calculation mechanism. The current code is accurate at low RPM, but the granularity gets bad at higher RPMs. This is by definition true, but the effects are worse than necessary at present.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply