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
If I would have decided to break this distributor and look inside, I would see something like
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.
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:
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.
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:
(the code is a picture simply because I wanted to keep the coloring)
How to read RPM - diy tachometer
-
- 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
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).
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!
Re: How to read RPM - diy tachometer
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!
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!