Reading signal frequency

It sounds like your signal generator's output is not connected to the Arduino. Here's why:

  • You consistently get a frequency reading close to 50 Hz. That's the power frequency at your location. That result is consistent with the notion that you have no signal connected to pin 8, and that the voltage on pin 8 is being affected by the electromagnetic fields generated by parts of the power system close to the Arduino.
  • When you connect to a PWM output, you get the expected results. That certainly suggests that pin 8 hasn't been damaged in your experiments.

Here's a warning:

  • Be careful in fiddling with the output of the frequency generator. While 30mV is indeed too low to be sensed reliably by a digital input, it's likely that the output is an AC signal that goes both negative and positive with respect to ground. At a reasonable output level, the positive half-cycle won't hurt anything, but the negative half-cycle will try to drive the voltage at pin 8 below ground. There's a bit of protection on that pin inside the microcontroller, but it's not sophisticated, and it's not particularly robust. You will need to be certain that the output of the signal generator doesn't go below ground. If you can't persuade it to give you an appropriate DC offset, you'll have to add some level-shifting circuitry, an optocoupler, or something like that.

You'll get better results if your signal generator produces a square-wave.

More questions:

  • What's the model number of your signal generator? I ask because I suspect that there may be a switch on the front panel that disconnects the output, and it may be in the disconnected position.
  • Do you have confidence in the leads connected between the signal generator and the Arduino? If you have an ohmmeter, please verify that your leads are continuous.
  • What's the output frequency setting of the signal generator?

Try this:

  • Connect a 10K resistor between pin 8 and ground. It's possible, but not likely, that the 50 HZ noise is so intense that it can overwhelm a 100K resistor. A 10K should certainly overwhelm any reasonable noise. If you still read 50 Hz with a 10K resistor connected, and the signal generator disconnected, there's something fishy going on.