Sensing engine rpm via coil.

I was wanting to measure engine rpm by sensing when the coil is triggered. Its a single coil system, with power to the coil at all times (with the key on) and to trigger the coil it is earthed.

So, to measure rpm I could detect when the coil is earthed, but how can I do this? I would need to protect the Arduino from voltage spikes etc, a optoisolator?

Or I could take a signal from the rev counter gauge in the dash, it is driven by a square wave signal, I think this would be possible to use PulseIn() to measure the squarewave, or is there a better way? Im also not sure if it is a 5v or 12v signal, again would I use a optoisolator to protect the arduino and maybe a voltage divider if the signal is 12v?

I dont have a oscilloscope, is there another way I could measure the voltage? I have a digital multimeter.

I think you would be better off tapping into the rev counter's clean square wave signal as opposed to looking at the coil (-) terminal. The signal on the (-) side of the coil is very dirty and worse if you affect it any way it could alter the performance of the ignition system.
You should be able to use an opto isolator on the rev counter's signal with no problem too.

Orac, you could look at the tach input circuitry used in the open-source "Megasquirt" DIY engine controller.

The V2.2 schematic is here:

Look on the second page for the Ignition Coil interface, which uses a 4N25 optoisolator and toggles a microcontroller input pin when the coil is grounded.

Note that parts labeled "Wing", "John", and "Ed" refer to the names of users who suggested adding those components. There's a good discussion of the circuit options on this page:

http://www.bgsoflex.com/v22/msv22.html

There's a more recent version of the board with a lot more options, including a true zero-point crossing detector for use with variable-reluctance, Hall Effect, HEI, and EDIS systems. Circuit diagrams and discussion here:

http://www.megamanual.com/ms2/pcb.htm

Hope this helps. Good luck with the project!

If I was to measure the square wave signal, how would I do that? Using PulseIn() ?

If I was using the tach signal from the coil, I would have to use an interrupt, since there are many ignition events per second would this slow down the program alot?

"Many ignition events per second" is not necessarily all that fast. An Arduino can do many, many things per second. :slight_smile:

If there aren't a lot of other things that the CPU needs to be doing at the same time, you could probably get away with a loop using DigitalRead() to watch the line. ("Polling loop," as people say.) Even for an 8-cylinder engine at 12,000 rpm, you have 20 us between pulses (assuming 4-cycle engine) which is enough time for a couple hundred AVR instructions.

Megasquirt has the coil input triggering an interrupt, since it needs to do a lot of other things at the same time--computing fuel delivery rates and turning injectors on and off, for example.

I think either way would probably work, and neither would be very hard to do. If all you do between coil pulses is process the results of the last pulse, as in a tachometer, then I see less advantage to using an interrupt.

I don't know much about PulseIn(). That might work too.

Another approach is to use a counter - feed the pulse into the counter then read and reset periodically, say every 100ms (10 times a second).

Mike