Rough 'n Ready Audio Frequency extraction with a PIC


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    originally posted by hankmcspank

    Were the fun in that?!
    ???????????????

    Robert

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    ???????????????

    Robert

    just wait and see ...

    and finally laugh.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    ???????????????

    Robert
    I meant if simply used dedicated ICs to solve each and every one of my needs - I wouldn't learn anything about PIC programming (the fun bit)

    Quote Originally Posted by Acetronics View Post
    just wait and see ...

    and finally laugh.

    Alain
    it was a meant to be a quip.

    If I'm to grasp PIC programming, then I need a small bite sized goal/challenges (& grasp some concepts)...sure there's normally dedicated h/w for just about everything nowadays, but I won't learn much if I simply throw in a dedicated IC for each & every requirement....hence my line of questiong & reluctance to add in extra h/w,
    Last edited by HankMcSpank; - 7th March 2010 at 13:45.

  4. #4
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    If you have a super clean sine wave signal with no distortion, you might be able to do this with a pic that is also performing other tasks. Otherwise, it is a very difficult task involving FFT or DFT programming--certainly not the standard place to start learning PIC programming. (And PBP is a pretty code-heavy compiler, so it may not be able to process the data fast enough, even as slow as 150Hz.)

    The biggest drawbacks I see to the NE567 is high voltage requirement and high current draw. On the other hand, it is the perfect simple solution to a potentially challenging problem.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Well it's not my first PIC project - that was PIC AGC...then I got the relaxtaion ocillator setup to do PIC capaciitve touch - but this is my first exploration into frequency counters (ie my latest goal if you like)

    Re the waveform, I'd be trying to glean the frequency after the complex harmonics have dropped out, here's the waveform (it's been amplified to get it up nearer the 5V that the PIC prefers) ....



    ...pretty clean & pretty sine-waveish too!

    ok, if you think it's do-able, I'll push on & give it a pop.

    So what would be the best way to set up a 100mS sampling 'window' to see how many transitions (cycles) the comparator has toggled in that time?
    Last edited by HankMcSpank; - 7th March 2010 at 16:55.

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


    Did you find this post helpful? Yes | No

    Default

    Well that sure does look clean! For your rough and ready approach, how about a simple count command like this:

    COUNT PORTB.1,100,W1

    That will count pulses during a 100ms period. Other way to do it for more accuracy is interrupts. But as you say, you just are going to do a lookup table.

    Edit:
    For the accuracy you need between D and D# etc, you would need to sample for 1 second using this method. If that's too long, you would have to go with interrupts, and measure time between pulses. Another quick and dirty try might be pulsin? Not sure how well that would work on an analog signal though. Maybe you could average a few...
    Last edited by ScaleRobotics; - 7th March 2010 at 17:37.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Here's another approach.
    You can use timer 1 as a frequency counter. Not sure if will be accurate enough? You did not say which pic you are using? Timer 1 external input is normally on portc. There should be a way to route the comparator output to tmr1? You will have to play with the pause statement to calibrate the output ie "pause 97" to compensate for the delays in pbp.


    CCP1CON = %00000101 ' Capture every rising edge
    T1CON = %00000011 ' No prescale/Osc off/Sync on/External source/TMR1 on

    Freq var word ' 100ms count result

    LOOP:

    TMR1H = 0 ' Clear Timer1 high 8-bits
    TMR1L = 0 ' Clear Timer1 low 8-bits
    T1CON.0 = 1 ' Start 16-bit timer
    Pause 100 ' Capture 100 mS of Input
    T1CON.0 = 0 ' Stop 16-bit Timer
    Freq.BYTE0 = TMR1L ' Read Low 8-bits
    Freq.BYTE1 = TMR1H ' Read High 8-bits

    GoTo LOOP

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