Frequency detection (audio)


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Frequency detection (audio)

    Ok, it looks like interrupts are a big no-no here so I've established a way of doing this without an interrupt...

    Code:
    T1GCON.4 = 1
    Loop1:
    pause 500
    T1GCON.3 = 1
    TMR1=0
    while  T1GCON.3 = 1
    wend
    count1=tmr1
    HSEROUT [dec count1,13,10]
    GOTO Loop1
    The above can detect up to 50khz audio input (can probably go higher...but the amount of timer1 counts between comparator edges gets less, so the 'percentage error' increases)

    Basically I'm using a Timer gate single pulse mode (T1GCON.4 = 1), then forcing the other part of the single pulse mechanism to a 1 ( Single-Pulse Acquisition Status bit T1GCON.3 = 1), after the comparator2 output drops then T1GCON.3 is dropped to a zero automatically, I therefore use a wend to loop until T1GCON.3 = 1 is a 0 ....then I ouput the timer1 counts. My only problem is I'm getting a zero reading intermittently, but other than that, the counts are pretty solid.

    here's the TMR counts for 1,000Hz....

    1824
    1824
    1825
    1825
    1826
    0
    1824

    just got to get to the bottom of why those readings of 0 are creeping in .....
    Last edited by HankMcSpank; - 10th June 2012 at 18:06.

  2. #2
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Frequency detection (audio)

    Hi Hank,
    The only thing I can think of is the method you are using to couple the audio signal you wish to measure. Hopefully you are using a capacitor? To chose the best value would be with the formula Xc= .159/F*C "F" is in hertz "C" is in farads and in most audio work .047 mfd is common. Xc give the "resistive" value for a capacitor to AC. Again I am not sure how you would ever obtain great accuracy without conversion to a square wave with a consistant time duration. Again hope this helps. Best, Ed

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