Frequency detection (audio)


Results 1 to 23 of 23

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default Frequency detection (audio)

    I keep revisiting this project, then parking it & then resurrecting it...and guess what I've just resurrected it!

    I seek to derive the frequency of a plucked guitar note so I can do lots of funky frequency related stuff to the signal

    I've presently got a PIC (16f1828) a comparator setup & I'm looking at the number of counts timer1 has incremented between each DT comparator interrupt.

    for now I'm usiing a sig gen with a sine wave (yes I realise a guitar note is way more complicated...but I'll cross that bridge blah blah)

    Anyway, by & large it's working OK.....the TMR1 count jitters about a bit, but it's close enough. but what I'm seeing is that with some frequencies the count jitters *way* too much.

    For example, heres a stable-ish(!) timer1 count for 1khz into the PIC comparator.....

    3208
    3203
    3194
    3183
    3161
    3163
    3163
    3156
    3150
    3152
    3148
    3141
    3139

    Ok so it's a little jittery but in percentage terms the jitter is still fairly low, but look what happens when I then feed 800hz into the same same setup....

    4955
    180
    4982
    205
    5012
    176
    4936
    176
    4963
    183
    4988
    207
    5001
    176
    4936
    176
    4957


    ...the Timer1 count between comparator interrupts is all over the shop!

    Can anyone enlighten me why this might be happening?

    here's the interrupt SETUP......

    Code:
    ASM
    INT_LIST  macro ; IntSource,    Label,         Type, ResetFlag?
        INT_Handler  CMP2_INT,  _CMP2_Interrupt,  PBP,  YES 
        endm
        INT_CREATE       ; Creates the interrupt processor
    ENDASM
    
    
    
    CMP2_Interrupt:   ' COMPARATOR2 INTERRUPT.
    @ INT_DISABLE CMP2_INT 
    hserout [dec TMR1,13,10]
    TMR1=0
    @ INT_ENABLE CMP2_INT 
    @ INT_RETURN

    Is my approach wrong here?


    Basically I want this type of sequence...

    1. Guitar string plucked - PIC detects this (envelope detector)
    2. PIC waits about 0.5s (to let the complex harmonics drop out)
    3. PIC then attemps to detect frequency for a period of about 0.3s
    4. Use a look up table for number of counts
    5. Go do stuff with the outcome!


    Now step 4 (go do stuff) I don't need help on - it's step 3 that I'm wondering what the best approach would be?
    Last edited by HankMcSpank; - 7th June 2012 at 14:37.

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