Rough 'n Ready Audio Frequency extraction with a PIC


Results 1 to 34 of 34

Threaded View

  1. #25
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post


    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?
    Hank, it looks like you are getting great results. Despite what it may look like, you really are not talking to yourself! A lot of people are interested in what you are doing, myself very much included.

    I often have to take a step back to figure out math .. or try to. For your equation,

    1/(counts * .000002) = hertz
    you can change it by multiplying both top and bottom by 500000.

    That gives you

    500,000/counts = hertz
    Then using one of your data points for counts:

    500,000/5007 = 99.86 hertz
    But since that doesn't fit in a pic well, and since I am sure you want the tenth and hundreds, we multiply the top by 100. Giving us:

    50,000,000/5007 = 9986 hundredths hertz. (really 99.86 hertz)
    To make it work inside a pic, check out the DIV32 function. It allows a number as big as 2,147,483,647 to be divided by a number as large as 32,767. Looks like you are good on both "counts"
    Last edited by ScaleRobotics; - 28th August 2010 at 03:18. Reason: Took out "code" tags, which seem to make people sick to their stomachs.
    http://www.scalerobotics.com

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