PIC Audio


Closed Thread
Results 1 to 29 of 29

Thread: PIC Audio

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Ok, done with my armor...now on to the audio... I've been playing with the PIC but most of the noise that I can get to come out of it are too "digital sounding"...when using the SOUND command. Reading on the site for the original board I found that the board has 5 different modes as well... One that adjusts the amount of distortion that your voice changes from "Normal" to "Distorted" 1-5 depending on where you set the level. You can also upload wav files to the thing using his software and a computer... Delays from when you finish talking to when the static burst comes out, turning the static sounds on and off...Geez!!

    My questions:

    1. How do you adjust the real time audio distortion if the PIC isn't sampling the audio or do you think it is?
    2. Do you think it is using the 1 bit audio, I.e. the Roman Black 1 bit wav file audio?
    3. Do you think it is using a pre-recorded wav file for the static or generating it using the PIC?

    I'm kinda lost here...None of the white noises that I get from the PIC sound anywhere near what I hear on his site..and there is a click before the rush of white noise... the simulated button release of the radio.

    I've found examples of MMC uses, ISD voice recorder uses and a couple other instances where PICs are being used with other devices to produce audio but I can't really settle on which would be best.

    -Dave

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


    Did you find this post helpful? Yes | No

    Default It may be possible

    Hi,

    Excuse me if I am quoting something already mentioned by somebody. I have quickly browsed the thread a may have skipped something. Its sunday and I am back after a long tour. So I am worried about the "Wife" bug to be active any moment!!

    If you sample the audio at 8Khz and continuosly throw the sample out through Hardware PWM you would actually be reducing the bandwidth of the input audio. Sort of a low-pass filter. Couple that with dirty (cheap) filtering and the free quantitizing noise. This may be the sound you are actually looking for.

    You can have a routine detecting when the ADC is receiving no/low signals. Treat them as end of audio and thus trigger your sound fx routine- handsfree.

    Needs some ASM stuff to utilize the conversion and/or acquisition time to update the hardware PWM.

    Just a thought.
    Regards

    Sougata

  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,

    Excuse me if I am quoting something already mentioned by somebody. I have quickly browsed the thread a may have skipped something. Its sunday and I am back after a long tour. So I am worried about the "Wife" bug to be active any moment!!

    If you sample the audio at 8Khz and continuosly throw the sample out through Hardware PWM you would actually be reducing the bandwidth of the input audio. Sort of a low-pass filter. Couple that with dirty (cheap) filtering and the free quantitizing noise. This may be the sound you are actually looking for.

    You can have a routine detecting when the ADC is receiving no/low signals. Treat them as end of audio and thus trigger your sound fx routine- handsfree.

    Needs some ASM stuff to utilize the conversion and/or acquisition time to update the hardware PWM.

    Just a thought.
    Great suggestions. I was thinking about using a digital pot to bias the amplifier...maybe go from a normal bias to overbias to get the distortion... Dunno if that will work as planned or if it's even a good idea but I am going to play around with it. I'm not quite up to speed on sampling the audio and using PWM to distort it but it sounds doable. Working on trying to find info on SPI now... Seems the manuals don't cover SPI (or I couldn't find anything in the manual about SPI)... I found some stuff in a few forum on the web. I thought it was a standard command but I can't find any of the includes or Defines listed anywhere in the book... Not even in the Proton Plus manual... Hmmmm

  4. #4
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by toofastdave
    Seems the manuals don't cover SPI (or I couldn't find anything in the manual about SPI)... I found some stuff in a few forum on the web. I thought it was a standard command but I can't find any of the includes or Defines listed anywhere in the book... Not even in the Proton Plus manual... Hmmmm
    See M25P32 PIC Audio **warning, other compiler**
    Includes hardware SPI routines.

    Norm

  5. #5
    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

  6. #6
    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!

  7. #7
    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

  8. #8
    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

  9. #9
    Join Date
    Jun 2006
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Normnet View Post
    See M25P32 PIC Audio **warning, other compiler**
    Includes hardware SPI routines.

    Norm
    Norm,
    Great project. I think I read about it last week when I was searching for PIC Audio Projects. Thanks for the link and the additional info. Where did you originally get the info for the SPI harware routines if they aren't in the PBP or Proton Manual?? Does RealBasic cover it in their manual?

  10. #10
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default

    Learn hardware SPI routines:

    1.Read data sheet timing diagrams.

    2.Test with working SHIFTOUT and SHIFTIN program. (SHIFTOUT pbp & SHOUT proton are almost identical)

    3.Bitbang above program, something like:
    low CS pin
    pause
    low clock pin
    pause
    high dataout pin (bit 7 = 1)
    pause
    high clock pin
    pause
    low clock pin
    pause
    low dataout pin (bit 6 = 0)
    etc.

    Watch on scope or if you don't have a scope make a led driver with pin > N channel FET > pullup & P channel FET > LED.

    4.Now timing known. Read PIC 452 data sheet page 130 for your SPI configuration of
    SSPSTAT = %01000000
    SSPCON1 = %00100010

    See SPI clk speed adjustment post 13.
    Hardware SPI extremely fast compared to SHOUT.
    Sends and receives in 3line instruction.

    Norm

Similar Threads

  1. Replies: 33
    Last Post: - 8th September 2010, 12: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, 22:01
  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. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00: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