Reading audio frequency with microcontroller

Thread Starter

Razor Concepts

Joined Oct 7, 2008
214
My goal is to measure the frequency of an audio signal using a microcontroller. The source of the audio is unamplified (not enough for headphones), with a 100mv amplitude. This isn't enough for my PIC to distinguish between high or low, so I used a MCP6541 comparator to bring it to logic levels.

It works (great!), but I was wondering if my solution is "correct", as in if there is anything I could do to make it more robust, or if there is any glaring problem in my circuit.


MCP6541 datasheet

I just feel like this is too simple and that I am missing something :D
 

SPQR

Joined Nov 4, 2011
379
Hmmm...do you have a "square wave" audio signal?

If it's an audio signal, would you want the output to be...audio?

I wonder if it might be better to use an op amp for the amplification of a smooth signal, and not a comparator to always give a square wave output.

Let's see what the experts say...
 

Thread Starter

Razor Concepts

Joined Oct 7, 2008
214
Oh yeah, everything is a square wave, and the output is preferably a square wave (it's just going to the input of a microcontroller so square wave made the most sense to me)
 

GopherT

Joined Nov 23, 2012
8,009
You could also use the on board adc (if your chip has one) with internal or external full scale reference voltage. Some chips (most PICs) also have on board comparitors with internal or external voltage references that you could use. It will take a bit more digging and learning how to configure and implement these features in software instead of using the simple-to-use digital I/O ports with your external circuitry but you do start to unlock the power of microcontrollers and reduce the amount of other hardware on your board. You paid for all the features on the chip, you may as well use them instead of adding more solder joints, more chips and more board area.
 

Audioguru

Joined Dec 20, 2007
11,248
What is the load resistance it will be driving?
Why do you have the transistor emitter-follower that reduces the output high voltage to about +2.6V?
 
Top