Summary of PIC sound player (PCM to PWM converter) using PIC18F1320
This project demonstrates how a PIC 18F1320 microcontroller generates audio by converting Pulse-Code Modulation (PCM) data into Pulse-Width Modulation (PWM) signals for a speaker. The system utilizes an internal 8 MHz oscillator, eliminating the need for external crystals, and relies on a 78L05 voltage regulator to power the circuit. Audio files must be converted to 8-bit, 8000Hz mono WAV format under one second in length to fit within the microcontroller's flash memory.
Parts used in the PIC Sound Player:
- PIC 18F1320 microcontroller
- Speaker
- 78L05 voltage regulator
- 100nF decoupling capacitor
- Low-pass filter with 3.3KHz cutoff frequency
Description
This project makes a PIC microcontroller play audio PCM sounds using PWM modulation! Pulse-code modulation (PCM) is a digital representation of an analog signal where the magnitude of the signal is sampled regularly at uniform intervals, then quantized to a series of symbols in a digital (usually binary) code [1]. Pulse-width modulation (PWM) of a signal or power source involves the modulation of its duty cycle, to either convey information over a communications channel or control the amount of power sent to a load [2].
The load of the PIC is the speaker.
Design and Implementation
The selected microcontroller is a PIC 18F1320 [3] with 8KBytes of flash memory and a ECCP unit. A smaller flash unit also exists (18F1220). The 8 KBytes of flash allow almost a second of PCMaudio sampled at 8000Hz to be loaded into the PIC. One second of audio is nothing compared with modern digital audio recorders but is enough to demonstrate the application.
Audio samples can be found free of charge on the internet. As long as they can be converted to WAV format in 8bits per sample, at 8000Hz sampling, mono channel and have less than one second of audio, they can be used in this circuit.
Schematic
The basic circuit includes a 78L05 voltage regulator, 100nF decoupling capacitor, the PIC, the speaker and a low-pass filter. The low-pass filter has its cutoff frequency at 3.3KHz.
The PIC microcontroller is programed to use the internal oscilator running at 8 MHz. That way we save a crystal and two capacitors.
The 78L05 is capable of supply 100mA of current which is enough to power the PIC with the speaker. Even a small amplifier may be included to provide more sound.
For more detail: PIC sound player (PCM to PWM converter) using PIC18F1320
- How does the PIC microcontroller produce audio?
The microcontroller plays audio by using PWM modulation to convert PCM sounds. - What are the required specifications for the audio samples?
Audio samples must be in 8 bits per sample, 8000 Hz sampling rate, mono channel, and under one second long. - Can I use a different microcontroller like the 18F1220?
A smaller flash unit exists such as the 18F1220, but the 18F1320 is selected for its 8 KBytes of flash memory. - Does this circuit require an external crystal oscillator?
No, the PIC is programmed to use the internal oscillator running at 8 MHz to save components. - What is the function of the low-pass filter in this design?
The low-pass filter has a cutoff frequency at 3.3KHz to process the signal for the speaker. - Is it possible to add more volume to the sound output?
Yes, a small amplifier may be included to provide more sound than the direct speaker connection. - What type of digital representation is used for the analog signal?
The project uses Pulse-code modulation which is a digital representation where signal magnitude is sampled at uniform intervals.

