I am doing a project that reads frequency of audio signals generated from Android device through the headset jack. The audio jack is connected to Atmega microcontroller as shown in the figure.!
I am using the analog comparator to compare between a reference voltage 2.61v and the audio signal (DC biased; AC + 2.5v). The audio signal range is 200mv p-p so after DC biasing it will be from 2.3 to 2.7. When the comparator input 1 passes 2.61 (reference volt), a timer starts to measure the frequency. But the problem is I am not getting a stable reading of frequency. For example, if the signal is 1000Hz, I read it between 4000 and 5000 Hz. The values always change. Sometimes the comparator outputs one for few microseconds even there is no audio signal (the output should be zero).!!
I think the problem is one of these:
1) The power supply has a high ripple so I cannot read low-level signals properly.
2) I should use a higher blocking capacitor C2 like 10uF instead of 100nF.
3) The 200 mv is in the range of noise signals, I should amplify it before read.
4) The voltage divider should use high values of resistors like 3MOhm as in the Hijack project.
What do you think.
I am using the analog comparator to compare between a reference voltage 2.61v and the audio signal (DC biased; AC + 2.5v). The audio signal range is 200mv p-p so after DC biasing it will be from 2.3 to 2.7. When the comparator input 1 passes 2.61 (reference volt), a timer starts to measure the frequency. But the problem is I am not getting a stable reading of frequency. For example, if the signal is 1000Hz, I read it between 4000 and 5000 Hz. The values always change. Sometimes the comparator outputs one for few microseconds even there is no audio signal (the output should be zero).!!
I think the problem is one of these:
1) The power supply has a high ripple so I cannot read low-level signals properly.
2) I should use a higher blocking capacitor C2 like 10uF instead of 100nF.
3) The 200 mv is in the range of noise signals, I should amplify it before read.
4) The voltage divider should use high values of resistors like 3MOhm as in the Hijack project.
What do you think.