Help w/ speaker for 16F690 and SOUND command


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I removed the sound command from my main program just so I could focus on that. The only line of code I have now is:

    sound portc.0, [100,100]

    the LED tied to portc.0 lights up, but all I get is an initial click from the speaker. I've tried 6-10 different capacitors and that doesn't help either.

    Anyone have any other thoughts? I've tried changing the tone from 1 to 127 and no change. When I use one of the "white noise" tones, say 157, then I do see the LED flicker and the speaker crackles with the LED flicker.

    I wish I had a scope, but I don't.

    Any other thoughts?

  2. #2
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    PORTC.0 is also an analog port with comparator and ADC. Is the port configured correctly to be a digital output?
    I know the sound command *says* it automatically makes it an output, but....?

    Have you tried the speaker on a different port? maybe yer PIC is busted.

    Any chance you have the PIC's oscillator set to the wrong frequency and it's outputting your sound at some super high "only dogs can hear it" frequency?

    Have you tried a really low note setting like 10 or 20?

    That's all that comes to mind now.


    steve

  3. #3
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Oh, and what's your power supply?

    A speaker is a pretty low impedance load. Any chance that when the speaker turns on it drags your supply voltage down to unhappy levels?

  4. #4
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I downloaded an application that uses the sound card and provides AC osciliscope capabilities (no DC). With no speaker (load) attached I see a spike when the sound starts and a matching inverted spike when the sound stops and since I don't think it does DC I expect it's shifting to a TTL high during this period. There is no detectable waveform present. When I switched back to the note 157 (white noise) I DO see a square wave form that is random in nature. Still no clue here why it's not producing any noise for the 1-128 notes.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    From the Data sheet: ANSEL and ANSELH must be configured to use port C as I/O.
    Code:
    ;@MyConfig =  
    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON  
    @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF 
    @ __config  MyConfig 
    
    DEFINE OSC 4
    PortA = 0
    PortB = 0
    PortC = 0
    TRISA = 1
    TRISB = 0
    TRISC = 0
    i var byte
    ANSEL = 0
    ANSELH = 0
    CM1CON0 = 0
    CM2CON0 = 0
    main:
    
    portc = 0
    pause 500
    
    for i = 1 to 15; step -1
    
    
    portC = i
    i=i  << 1 
    pause 250
    next i
    sound portB.6, [120,2,124,2,123,2,121,2]
    sound portC.6, [120,2,124,2,123,2,121,2]
    goto main
    end
    Without them sound works on PortB but not PortC, the code snippet above is configured to use the MicroChip low parts count demo board.
    Last edited by Archangel; - 21st March 2009 at 02:08.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    From the Data sheet: ANSEL and ANSELH must be configured to use port C as I/O.
    Uh huh... that would've been my first guess.

  7. #7
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default It works!

    Thanks very much for the help. I didn't have ANSELH and that was the missing link. Very much appreciated!

Similar Threads

  1. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  2. Replies: 4
    Last Post: - 10th November 2006, 07:37
  3. SOUND command not working
    By RUBiksCUbe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th December 2005, 22:41
  4. question about SOUND command
    By bartman in forum General
    Replies: 7
    Last Post: - 1st December 2005, 13:50
  5. Re: quick fix for sound command?
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 9th July 2004, 01:44

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