Analyse the frequency of a signal

Hello,

I need to analyse the frequency of a signal to see if it is at 100 Hz, my teach say that just measuring the frequency isn't enought. So I need to compare the phase with a reference signal of 100Hz to see if it is correct.

I want to know how can I produce a reference signal of 100 Hz with arduino and then compare its phase to the phase of a signal in entry ?

Thank you!

What kind of a signal? Is it a pure sine wave, square wave, complex waveform?

Do a Fourier transform.

jremington:
What kind of a signal? Is it a pure sine wave, square wave, complex waveform?

It is a complex waveform !

Then you need to compute an autocorrelation function Autocorrelation - Wikipedia to get the frequency and a cross correlation to get the phase shift with respect to the reference.

IMHO, the reason you need a phase, is to get better accuracy in specified period of time. Simple counting doesn't work well, on low freq., for example to get 10^-4 with 100Hz you need to count 100 sec. Look at this library:
http://interface.khm.de/index.php/lab/experiments/frequency-measurement-library/ Input capture, that is what you need

Do a Fourier Transform:

Thank you all for your anwser ! I'll try it !

Do a Fourier Transform:
Discrete Fourier transform - Wikipedia

On an Arduino, given the limited size of the sampling buffer, frequency measurement by FT is highly inaccurate.