PDA

View Full Version : SOUND command not working



RUBiksCUbe
- 18th December 2005, 02:26
I'm trying to generate a tone whenever a specific event occurs using the code:


SOUND PortA.1, [127, 255]
I have tried this code with both a speaker (with and without 22 uf capacitor) and two different piezo-speakers and neither has produced a tone. When I run the program I hear a "click" coming from the speaker, but then silence. I have changed the code for this program to:


main:
sound PortA.1, [127, 255]
goto main
But I still only hear a click. I have defined OSC as 20 (PIC 18F252) but still nothing is generating a tone. I even tried:


main:
high PortA.1
pauseus 30
low PortA.1
pauseus 30
goto main
But that also made a clicking noise, no tone. Shouldn't this work?

MikeTamu
- 18th December 2005, 04:28
Are you sending the signal to an amplifier before it gets to the speaker? If not, what type of speaker do you have?

milestag
- 18th December 2005, 07:15
1. Make sure PortA is configured as Digital I/O. The sound command will not work if it's configured as AtoD inputs.

2. Try another frequency, 127 is the highest (10KHz). Try something lower.

3. Try another pin on another Port (PortB maybe).

4. Test the speaker(s) by putting another sound trough them (like a radio). Just to make SURE they work.

Jim

RUBiksCUbe
- 18th December 2005, 22:41
I think I figured it out. I was sending inaudible stuff. The frequency was way to high. I changed the pauseus to 500 and got a nice tone.