PIC Audio


Closed Thread
Results 1 to 29 of 29

Thread: PIC Audio

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default All you need is an ASM interrupt.

    Hi,

    If you use an 8 MHz crystal as your oscillator and let your timer0 run free it would interrupt @ 7.8Khz (Thanks to MisterE for the PIC multicalc utility). Enable timer0 interrupt. In the interrupt routine you don't need to reload timer0 as it already rolls over. This assures a solid timebase interrupting at fixed intervals. On the interrupt set the Go/Done bit of your ADC. Use the ADC in 8 bit mode. When the conversion is done. Simply dump the ADRESH value to the PWM duty register. All this happens in the interrupt routine. Let the AD module run continuosly so that sampling (acquisition) actually occurs when you are outside the interrupt. This should be quite simple to achieve. You get enough time outside the ISR to decide whether the ADC is sampling 0 or say 127 (when you are DC offsetting the Audio that gives you a 0 for the most negative peak, and 255 for most positive sort of pseudo signed ADC you loose resolution again, distort more).
    Regards

    Sougata

  2. #2
    Join Date
    Jun 2006
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi,

    If you use an 8 MHz crystal as your oscillator and let your timer0 run free it would interrupt @ 7.8Khz (Thanks to MisterE for the PIC multicalc utility). Enable timer0 interrupt. In the interrupt routine you don't need to reload timer0 as it already rolls over. This assures a solid timebase interrupting at fixed intervals. On the interrupt set the Go/Done bit of your ADC. Use the ADC in 8 bit mode. When the conversion is done. Simply dump the ADRESH value to the PWM duty register. All this happens in the interrupt routine. Let the AD module run continuosly so that sampling (acquisition) actually occurs when you are outside the interrupt. This should be quite simple to achieve. You get enough time outside the ISR to decide whether the ADC is sampling 0 or say 127 (when you are DC offsetting the Audio that gives you a 0 for the most negative peak, and 255 for most positive sort of pseudo signed ADC you loose resolution again, distort more).
    I'll have to look into this..it sounds interesting but it may keep my PIC busy for longer than I'd want it to be at any given time, especially if I have to monitor the start and end of the audio to communicate via SPI to another device. I'll play around with it though... Thanks for the great suggestion!

  3. #3
    Join Date
    Jun 2006
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi,

    If you use an 8 MHz crystal as your oscillator and let your timer0 run free it would interrupt @ 7.8Khz (Thanks to MisterE for the PIC multicalc utility). Enable timer0 interrupt. In the interrupt routine you don't need to reload timer0 as it already rolls over. This assures a solid timebase interrupting at fixed intervals. On the interrupt set the Go/Done bit of your ADC. Use the ADC in 8 bit mode. When the conversion is done. Simply dump the ADRESH value to the PWM duty register. All this happens in the interrupt routine. Let the AD module run continuosly so that sampling (acquisition) actually occurs when you are outside the interrupt. This should be quite simple to achieve. You get enough time outside the ISR to decide whether the ADC is sampling 0 or say 127 (when you are DC offsetting the Audio that gives you a 0 for the most negative peak, and 255 for most positive sort of pseudo signed ADC you loose resolution again, distort more).
    sougata,
    Do you have any example code of this application? It sounds like something I would like to try but ASM interrupts are over my head...I haven't gotten the whole interrupt concept down just yet...I'd appreciate anything you had to share to help me understand this idea.

    Thanks!
    Dave

  4. #4
    Join Date
    Jan 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Try a precision full wave rectifier feeding a comparator with a reference set by a pot. This will give a logic level output you can poll using the PIC. When it's high, enable the amplifier, when it falls low activate your white noise burst. Try generating random numbers (8 bit) and feeding them to a 2R2 DAC, you could even just switch a diode noise source output into the amp input.

    I did somethineg VERY similar for a company as a water leak detector. A microphone listened for a noise in the pipes then activated an alarm if the noise was of a certain type and exceeded a certain duration.

    Hope this helps

Similar Threads

  1. Replies: 33
    Last Post: - 8th September 2010, 11:28
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  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. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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