Frequency meter / counter using ANALOG input

Hi all. First post, so please go easy on me.

I am trying to make a frequency counter of the AC grid. I've taken the filter capacitor and half the diodes out of a 3V linear AC adapter, so I have a saw-like wave that is on average 1.5 ish Volts DC, and with the instantaneous AC power grid frequency. in other words good frequency, but voltage not high enough for the serial input.

So I've seen the libraries out there for serial pin frequency counters, but am not sure how that would be easily adapted for use with a different (analog) pin.

Would anyone be kind enough to help me?

Thanks!

Counting a signal's frequency requires using a digital input pin and counting the number of pulses for a fixed amount of time. Using a analog pin using analogRead() commands would only get you the instantanous amplitude of the signal not it's frequency. Your voltage peaks may not work with digital inputs if it is not high enough a voltage to be read as a valid logic HIGH signal. You need around a 2.5vdc to +3vdc peak signal for a logic HIGH. You could take the pulse if it's too low a peak value and wire it to a series resistor (say 1k ohm) to the base of a simple NPN switching transistor with the emitter wired to ground and the collector wired to a series resistor (say 10k ohms) to the arduino +5vdc pin. Then wire from the collector terminal to a arduno digital input pin. That would convert the signal to a 0-5vdc signal pulse which can be counted by the arduino digital input pin. You also need to have a ground wire from the source of the 1.5v signal to a arduino ground pin.

Lefty

Why not sample analog and look for a threshold of e.g. 1V and count this?

retrolefty:
You could take the pulse if it's too low a peak value and wire it to a series resistor (say 1k ohm) to the base of a simple NPN switching transistor with the emitter wired to ground and the collector wired to a series resistor (say 10k ohms) to the arduino +5vdc pin. Then wire from the collector terminal to a arduno digital input pin. That would convert the signal to a 0-5vdc signal pulse which can be counted by the arduino digital input pin. You also need to have a ground wire from the source of the 1.5v signal to a arduino ground pin.

Lefty

Awesome. why didn't I think of that....

thanks!

Analog input takes time so your samples may be random or more likely the read pattern on the input frequency will have a possibly long frequency of its own.

Once you've converted you rough sawtooth to a square-ish wave, can you use that to trigger an interrupt? That would let you count the pulses without wasting time polling the input.