Measuring AC Frequency.

Hi Everyone.
I'm new here, Ive done a bit of PIC programming in the past. Just gotten into the Arduino.

I am working on a digital speedometer for a motorcycle. The power supplied by the motorcycle is 12vAC, I will rectify and regulate this down to 5vDC to power the Arduino and LCD display... However, I would like to measure the frequency of the 12vAC, as this will allow me to calculate the RPM of the engine.

One idea is to connect a coil to the 12vAC and use a hall effect sensor pick up the fluctuations in the coil....

Any other ideas?

Thanks.

OK, So I've been reading some more....

How about, connect an IR LED with resistor to the 12vAC this will basically make the IR LED blink on and off relative to the RPM,point the IR LED at a photo diode hooked up to the Arduino and use pulsein()?

Whatcha think?

How about, connect an IR LED

You get this in one package with an Opto Isolator. It is a good idea to use an opto isolator. Use also a series diode to protect the LED in the opto.

I think tapping in to the 12VAC signal before the rectifier is the simplest approach. Here's a plan:

The 4.7V zener should protect against any "surprising" spikes that happen on the 12VAC line (automotive environment...who knows....)

D1 is any general-purpose diode (1N4004 etc.)

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Thanks for the replies everyone.

I like you idea Rugged, but i would feel a bit more comfortable using the opto isolator between the 12vAC and the input....

Please check my logic: darlington optio isolator input connected to 12v AC via a 1N4004 and a 470ohm resistor, this should make nice +-2V pulses for the input of the opto. Then the output of the Opto connected to a digital in ?

I have one of these: http://www.littlebirdelectronics.com/products/Optoisolator-with-Darlington-Driver-%252d-1-Channel.html

Thanks.

The datasheet linked from Sparkfun (LTV-816) is not a Darlington! Maybe they're selling you the PS2532 used in the example.

There isn't a good reason to use a Darlington here (other than that you have one!) because you have plenty of input current and minuscule output current. Darlingtons are slower, though it probably doesn't make much difference here.

If you want to consider another optocoupler, there are AC optos that will simplify things a bit. Something like the PS2505 might be ideal. I use these for sensing low voltage AC from a model railroad. Connect the emitter to ground and the collector to a pullup and the Arduino input (or the input alone if you're using the internal pullup).