Reading audio frequency with microcontroller

Discussion in 'General Electronics Chat' started by Razor Concepts, Jan 22, 2013.

  1. Razor Concepts

    Thread Starter Active Member

    Oct 7, 2008
    212
    1
    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.

    [​IMG]
    MCP6541 datasheet

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

    Member

    Nov 4, 2011
    379
    48
    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...
     
  3. Razor Concepts

    Thread Starter Active Member

    Oct 7, 2008
    212
    1
    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)
     
  4. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,014
    3,788
    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.
     
  5. SPQR

    Member

    Nov 4, 2011
    379
    48
    Ok, so you're not trying to amplify Beethoven's 5th..:D
     
  6. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    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?
     
Loading...