Rough 'n Ready Audio Frequency extraction with a PIC


Results 1 to 34 of 34

Threaded View

  1. #19
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Well, I got a simple form of frequency detection going on with my 16f690 last night.

    I fed a sine wave into one of the 16f690s comparator input pins & used DT's comparator interrupt routine - the associated handler incremented a count with every comparator flip (interrupt),

    I then simply used timer1 set to overflow at 0.5s - at overflow the comparator count is multiplied by two (to get the equivalent count for 1 second - so the end result was in Hertz).

    I was getting reasonable accurate frequency detection - the 'count' number danced about +/- 2 or 3 (therefore ultimately 2 or 3Hz) ...which I'm pretty sure could probably be averaged out to bring this error down a little).

    I wasn't able to get the 16f690' internal VREF to work (I was using the external VREF pin set at 1/2 VCC)

    This VREF issue aside (which I'll revist soon), what I now need is a 'rolling window' in code, which goes something like thus...

    "If the comparator count hasn't changed - give or take - for the past 1.5 seconds (ie rolling window), then that must mean a note is presently being held, if so ...go & do stuff!"

    Now there are only two timers on the 16f690....and I was really hoping to keep one of them in reserve for flashing LEDS (the LED 'flash rate' depending on the mode), so I'm looking for creative ideas that would allow me to apply the above 'condition' without wasting anther timer!

    Grateful for any input here!
    Last edited by HankMcSpank; - 26th August 2010 at 12:25.

Similar Threads

  1. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 02:47
  2. PIC Audio
    By toofastdave in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 27th June 2007, 14:49
  3. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 21:42
  4. Audio Encoding and playback in a PIC
    By Rob in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 24th March 2005, 09:56
  5. Frequency Counter using PIC and PicBasic
    By PICtron in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 28th January 2005, 07: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