Circuit board Schematic Circuit board Schematic Prototype Prototype keypad

PIC Sound Multiplayer

Share:

Motivation and introduction

This project transforms a PIC microcontroller into an audio player. It plays short audio clips, previously stored in an external eeprom. The analog audio output is generated with a one bit DAC, i.e., using PWM modulation!

It is an expansion to the original project Pic Sound Player that doesn't require the sound to be compiled with the player code. The audio clips reside in an external eeprom with a very simple file allocation table. This eeprom can be swapped without the need to change the player code, changing the audio clips being played.

Currently up to 4 audio clips can be stored in the eeprom. This limitation is mostly due to the number of buttons on the PCB but the player software is not limited in any way to the number of audio clips it can play, nor their size (16MB max).

If a future version of this project is released it will be able to read audio files from an sd card, allowing almost unlimited size audio clips to be played, but always as wave files.

Schematic

The schematic, shown below, has 3 distinct areas. The 5V power supply is in the upper left corner of the image. It provides stabilized voltage to the microcontroller and eeprom. The analog audio section is at the top right of the schematic. It consists of a second order 3KHz low-pass filter, implemented around a TL2272 op-amp, followed by a 1Watt TDA7052 power amplifier. The analog section is powered directly from the input voltage and requires at least 7V to work properly.

sch

The bottom part of the schematic is the digital player and it consists of a PIC16F88, buttons and 25AA1024 eeprom.

PCB

The PCB is is a bit large as a result of using only through-hole components so it can be easily made at home.

  eagle 3d board

 

 

List of parts

Amount Part Description
1 C1 220uF/25V capacitor
1 C2 10uF/25V capacitor
3 C3,C6,C11 100nF capacitor
2 C4,C5 10nF capacitor
2 C7,C8 22pF capacitor
1 C9 2.2uF/25V capacitor
1 IC1 PIC 16F88
1   DIP 18 socket for PIC 16F88
1 IC2 EEPROM 25AA1024 (128KB)
1   DIP 8 socket for 25AA1024
1 IC3 TDA7052 or TDA705A audio amplifier
1   DIP 8 socket for TDA7052
1 IC4 78L05 regulator
1 IC5 TLC2272 dual rail-to-rail op-amp
1   DIP 8 socket for TLC2272
1 PWR1 Molex 2 pin connector type 22-23-2021
1 Q1 20MHz low profile crystal
2 R1,R2 5.6K resistor
6 R3,R4,R5,R6,R7,R10

10K resistor

1 R8

4K7 resistor

1 R9 1K vertical adjustable resistor (trimmer)
5 S1,S2,S3,S4,S5 micro switch N/O similar to omron B3F-10XX
1 SPKR1 Molex 2 pin connector type 22-23-2021
1   9V battery plug
1   9V battery
1   1W speaker with 8 Ohm or higher impedance
1   Single side PCB

 

Prototype

prototype   prototype pcb v1

These are the pictures of the prototype PCB made using the toner transfer method. It was ready to begin placing components.

 

The prototype PCB is slightly different from the published PCB on this page because I found and removed a mistake from the analog section after building it. Now the prototype has a few wrapping wires at the bottom side, and some tracks have been cut.

Video

Video Player

 

Software

Firmware

The firmware divides itself in several layers:

Block diagram and Flowchart
 

A picture says more than a thousand words and the flowchart is self explanatory.

PC Software to create the eeprom image

I also developed a tool to create eeprom image files. It reads wave files and copies their audio PCM samples into the final eepromfs.bin file together with a simple index (named file table).

The file table is organized as follows:

Each file entry consists of a start address and the length in bytes. The start address uses 3 bytes and the length also 3 bytes. All 4 file entries are placed at the beginning of the eeprom. The audio PCM samples come after the file table.

The player reads the file table at start and then jumps to the correct start address of the file selected from the buttons. It will read and play as many audio samples as there are in the length of that file.

To create the eepromfs.bin file to save to the eeprom you can use the makeeepromfs utility available below for download.

C:\MinGW\msys\1.0\home\username\waves>..\win32\makeeepromfs
MakeEepromFS version 1.3.1 starting
Either you forgot to write which files I should use or you entered too many files.
Cannot run with 0 files. Minimum is 1 and maximum is 4.

To create the car sounds eepromfs.bin you should execute the program with the waves included in the zip file:

C:\MinGW\msys\1.0\home\username\waves>..\win32\makeeepromfs.exe 1.wav 2.wav 3.wav 4.wav
MakeEepromFS version 1.3.1 starting
Running with 4 files.
There's no total size validation so make sure you don't go beyond the last address of your eeprom.

File "1.wav", full size is 46580, samples size is 46536
File "2.wav", full size is 44239, samples size is 44195
File "3.wav", full size is 4086, samples size is 4042
File "4.wav", full size is 22335, samples size is 22291
  Fat entry 0: 00024..46559 length 46536 bytes
  Fat entry 1: 46560..90754 length 44195 bytes
  Fat entry 2: 90755..94796 length 04042 bytes
  Fat entry 3: 94797..117087 length 22291 bytes
----------------------------------------------
Will take 117088 bytes in the eeprom
----------------------------------------------
Shall I write the "eepromfs.bin" file (y/N) ? y
Creating "eepromfs.bin" file
Writing file table with 4 of 4 entries filled, sized 24 bytes
  Fat entry 0: start 24 (0x18), length 46536 (0xb5c8)
  Fat entry 1: start 46560 (0xb5e0), length 44195 (0xaca3)
  Fat entry 2: start 90755 (0x16283), length 4042 (0xfca)
  Fat entry 3: start 94797 (0x1724d), length 22291 (0x5713)
Writing file "1.wav": 00024..46559 length 46536 bytes
Writing file "2.wav": 46560..90754 length 44195 bytes
Writing file "3.wav": 90755..94796 length 04042 bytes
Writing file "4.wav": 94797..117087 length 22291 bytes

There's also an utility to check the format of the waves. It reads the wave file header and displays what it finds.

C:\MinGW\msys\1.0\home\username\waves>..\win32\readwave 3.wav
Wave file contents...
-------------------------
  Chunk ID  = RIFF
  ChunkSize = 4078
  Format    = WAVE
-------------------------

SubChunk fmt    = "fmt "
  SubChunk size = 16    Should be = 16 for PCM
  AudioFormat   = 1     Should be = 1 for linear quantization PCM
  NumChannels   = 1     (1 == Mono, 2 == Stereo)
  SampleRate    = 8000  Can be anything! 4000, 8000, 44100 Hz
  ByteRate      = 8000  Should be 8000
  BlockAlign    = 1     Should be 1
  BitsPerSample = 8
-------------------------

SubChunk data    = "data"
  SubChunk size  = 4042
  Offset in file = 44
-------------------------
 

Now you need to burn the eepromfs.bin file to the 25AA1024 eeprom using any programmer.

Downloads

 

References

  1. Pic sound player
  2. FreeSound project - source of all samples available above

 

Published on Monday 2013/06/10, last modified on Wednesday 2014/10/29