Rough 'n Ready Audio Frequency extraction with a PIC


Results 1 to 34 of 34

Threaded View

  1. #24
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    HankMcSpank ,I would personally count the time between interrupts instead of the number of interrupts in 1/2 second. That way you can increase the low end resolution you are looking for. Even a 1000 hz clock will give you .1% resolution at 100 hz....

    Dave Purola,
    N8NTA

    Dave you're right on the money there - I'm now getting much better stability with your suggested method, here's what I'm seeing onscreen for Timer1 counts between comparator interrupts (this was for approx 100Hz)...

    Timer1 Count= 5007
    Timer1 Count= 5005
    Timer1 Count= 5007
    Timer1 Count= 5004
    Timer1 Count= 5007
    Timer1 Count= 5004
    Timer1 Count= 5007
    Timer1 Count= 5005
    Timer1 Count= 5007
    Timer1 Count= 5004
    Timer1 Count= 5007
    Timer1 Count= 5005
    Timer1 Count= 5007
    Timer1 Count= 5004
    Timer1 Count= 5007
    Timer1 Count= 5004
    Timer1 Count= 5007
    Timer1 Count= 5004



    ...so my jitter is now something like 0.001% - that couls be down to my sigen not being stable even - it has been known to drift about a bit)

    I've got a bit of a mental block with the last remaining bit though (converting to frequency in hertz! - which for all I don't actually need the result in Hz - as I'll just be comparing on the timer count alone to establish whether of not the frequency is stable - it'd be a nice to have!!)

    So, what I'm seeing with my timer counts...

    A 'Timer1 count' of 5000 equals 100Hz
    A 'Timer1 count' of 500 = 1000Hz
    Therefore the timer clock cycle = 2us (0.000002s)

    What formula do I use to convert my Timer1 count into Hertz? (it's the floating point aspect that messing me up - else I'd just use this simple formula....

    1 / ('timer1 count' * 0.000002)

    If I add to the left side of the equation (to take the right hand side out of 'decimals' territory)...it cranks up into the millions - tilt!!!!

    So how should I approach this Hertz conversion?
    Last edited by HankMcSpank; - 27th August 2010 at 20:17.

Similar Threads

  1. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47
  2. PIC Audio
    By toofastdave in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 27th June 2007, 13:49
  3. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 20:42
  4. Audio Encoding and playback in a PIC
    By Rob in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 24th March 2005, 08:56
  5. Frequency Counter using PIC and PicBasic
    By PICtron in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 28th January 2005, 06:20

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