Creating sound effects with PIC microcontroller

I am developing a "smart" alarm clock. I need to determine how to I will generate the alarm sounds. The main requirement is the ability to generate loud sounds and to vary the sound volume. One option is to use a PIC18Fxx processor (already part of the circuit) to generate the alarm tones and then feed them through an audio amplifier IC and small speaker. I could use a digital potentiometer to vary sound volume, however if I could get the same effect by using the PIC's 10-bit PWM peripherals it would be ideal. Does anyone have code examples or strategies for creating such sound effects using a PIC processor? Thanks

Reply to
techman41973
Loading thread data ...

map out the wave form you want and send it to the PWM, connect the PWM to the amplifier, with a bit of work (and if the chip and PWM is fast enough) you can even go polyphonic.

to reduce the volume either shift the values right before outputting them or use a lower waveform map.

I have a code example, but it's for AVR 90S2313 (10MHz)

Bye. Jasen

Reply to
Jasen Betts

If the sound is just tones or assending/descending tones then I would be tempted to use a pieze instead of a speaker. Nice and loud, only a darlington driver required. As far as varying the volume then this is easilly achievable using one of the PWM modules on the 18F part. Connect the output of the PWM pin through a charging resistor to a capacitor. Connect the capacitor to the power pin of your darlington pair. This will give you control over the voltage presented to the piezo. I have done this before and it works very well. If I remember correctly using a 1K series resistor to 10uF capacitor is perfectly adequate for volume control.

If you need PWM code then I should be able to dig some out on Monday. But where would the fun be in that? :-)

Have fun Jim

formatting link

Reply to
Jim

Google suggests PICBASIC supports the BASIC SOUND command.

Reply to
CWatters

Record and playback samples...

formatting link

Reply to
CWatters

formatting link

formatting link
works with 16f87x does it in software good for awful sounding phone ring tones works with Hitech compiler or demo version

Reply to
Alex Gibson

There was an article regarding RC-2 encoding an playback of sound in "Circuit Cellar" a few months ago. Only 2 I/O pins, 2 Resitors and a Capacitor is needed to generate sound. In the original article a 8051 was used, but I have implimented it on an AVR with very good results. Using a PIC plus a reasonably large data flash should be fine. The author of the Circuit Cellar Article, Mariano Barrón, wrote a PC app which can be used to generate the RC-2 data from a 16-bit mono wave file.

Regards Anton Erasmus

Reply to
Anton Erasmus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.