Low frequency audio level detector using PIC ADC?


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Quote Originally Posted by HankMcSpank View Post
    Thanks Bert - Actually, I think we're done here would you believe! (Bert sighs in relief!)
    No sigh at all Hank, I really enjoy these kinds of threads. Lots of new things learned by all. I don't seem to have the imagination or desire to make such projects, but I LOVE thinking about them.

    So Thank YOU and I look forward to your next one.

    BTW, I agree you should consider making a WIKI of this. Your coding is fine, as Dave said you underestimate yourself. I do get the time aspect of it.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Thumbs up from me too.

    Good idea with just a few components and clever programming. To the Wiki absolutely!

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Back at post #42 there is a picture of a square wave, (not so square wave) and a comment about how bad it looks. The wave looks like this because it has just passed through a capacitor. (A high pass filter) (DC blocking capacitor)

    What are you trying to do? Measure the output of your electric guitar in peak response mode?

    For long before I was born, audio has been measured in two modes.

    Average mode: Full wave rectify. Then use a 2hz low pass filter. The response time is set to about the spoken syllable rate. (half wave produces little error)

    Peak mode: Full wave rectify. Use a filter with an attack time of 1.7mS and a decay time of 660mS. You need the 1.7mS attack time or any very small peak will peg you meter but you ear can not hear that small peak.

    Do you want RMS response?

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Hi Ron,

    Post #52 above explains what I was trying to achieve.....thankfully, it's al sorted now & seems to work ok.

  5. #5
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    If you search for VU meter you will find examples of what you are working on.
    With out a PIC the two attached pictures show an analog way of getting average and peak readings.
    The rectifier is:
    if MSB is 1 then shift left to remove that bit.
    if MSB is 0 then compliment number +1 then shift left.
    The peak detector (analog version):
    The meter moves up at a rate set by R18 & C5. (fast)
    The meter moves down at a rate set by R17+R18 & C5. (slow)
    In software:
    If the output of the rectifier > than the meter reading then (meter-rectifier)/x add to meter.
    If rectifier is < meter then meter=meter-y.
    Where y is a small number that will move the meter from full scale to 0 in about 600mS.
    Where x sets the response time. (moving up)

    There are several companies (THAT CORP and National see LM3915/16.) that have applications notes on the response of of VU meters. A typical test is to inject a 5khz tone for 10mS then stop. The meter should reach near full scale in 1.7mS and decay in 660mS.

    My first try at a VU meter is attached. R2,3 set the input at 1/2 supply.
    C1 blocks DC. 1/(2*2.14*50k*C1)=20hz set lowest frequency of intrest.
    R1 & C2 makes a low pass filter to block information above 20khz.
    R1 is to limit the current going into the PIC if the signal gets above 5 volts or below 0 volts. Could be 1k.

    There is several better ways of setting the DC input of the ADC to 2.5 volts. More later.
    Attached Images Attached Images    

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Quote Originally Posted by ronsimpson View Post
    In software:
    If the output of the rectifier > than the meter reading then (meter-rectifier)/x add to meter.
    If rectifier is < meter then meter=meter-y.
    Hi Ron

    If you glance at the final code I knocked together - that's essentially what I'm doing ...... 'x' being the AC signal coming in on a PIC pin, 'y' being my pseudo (sw) cap discharge rate (albeit I'm not driving VU meters & I require different attack/release times).

  7. #7
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Low frequency audio level detector using PIC ADC?

    Audio has a large dynamic range. I wanted to get as much range as possible. I needed to “zero” at 512 (10 bit). Resistors at 1% and even 0.1% did not always get me to zero. I also tried resistors to get within 1% of zero and then used the PWM output to move the ˝ voltage point +/- a little. I know in software I could have move the zero point to correct for this error. I wanted to do all the math slightly faster than the ADC could work and there was no time.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts