Amplifier Circuit DiagramsAudio Circuit Diagrams

WAV Doorbell Schematic Circuit Diagram

This electronic doorbell is essentially a small WAV file player based around an ATmega328P. When a guest presses the bellpush the device is activated and plays out a short WAV file using its built-in PWM module. This means that you can customize the sound of your doorbell in just the same way as you can the ringtone on your mobile phone. What’s more, you can load any sound you like into the device. The WAV file is stored in the on-chip flash memory in the microcontroller: no external storage is necessary.

WAV Doorbell Schematic Circuit Diagram

 

To keep the number of components to a minimum, we have dispensed with the sort of low-pass filter that would normally be required on the PWM output of the AVR microcontroller. Instead we simply connect to a small loudspeaker via just an electrolytic and a series resistor. Note that it would not be appropriate to connect the PWM signal directly to an amplifier or to powered speakers without a proper low-pass filter, as distortion can result.

When power is applied the unit immediately plays the stored doorbell sound, and the AVR microcontroller then enters a low-power standby mode. Pressing the bell push button causes the microcontroller to leave standby mode and play the WAV file again. The WAV file must have the following characteristics: ‘RIFF WAVE’ format, 8 bits per sample, mono, and a sample rate of 8 kHz. The ATmega328P has a total of 32 Kbytes of flash memory, of which 1 Kbyte is reserved for the firmware. This leaves 31744 bytes for the WAV file, enough for an audio file with a length of nearly four seconds. The firmware occupies the address range from 0x0000 to 0x03FF, and the WAV data start at 0x0400. If the audio file is not available in the PCM WAV format described above, the freeware tool Audacity [1] can be used to convert it. Open the original file in Audacity and set the ‘project rate’ to 8000 Hz in the bottom lefthand corner of the window. It is also possible to select parts of the waveform (such as periods of silence at the start or end) and delete them. To convert from stereo format to mono, click on the small arrow in the box containing the file name and select ‘Split stereo track’. Then the right channel can for example be deleted with a click on the ‘X’ and the left channel can be converted to mono by clicking on the small ‘Mono’ arrow. Under ‘Edit > Preferences’ the export file format must be set to ‘WAV (Microsoft 8-bit PCM)’, which is uncompressed. To save the file, select the desired region and click on ‘Export as WAV’ in the ‘File’ menu. This should result in a suitable file. To confirm this, right-click on the file in Windows Explorer and check the format in the file information under ‘Properties’.

The tool ‘hex2bin’ [2] is used to convert the WAV file into a hex file suitable for programming into the ATmega328P. The tool takes the binary WAV-format file, changes it to Intel hex format, and inserts the result into the hex file that contains the AVR code. The output of the tool is thus a single hex file that contains both the firmware and the WAV file information that need to be programmed into the ATmega328P. The whole conversion process can be set in train using the ‘convert. bat’ batch file. The firmware determines the length of the WAV file from its header information and uses this to play out the contents of the file for the correct duration.

A ready-made hex file, called ‘tuergong.hex’, comprising both the firmware and a WAV file making a ‘ding-dong’ sound is available free in the ZIP archive accompanying this project. This hex file can be programmed directly into the ATmega328P. The hex file ‘code.hex’ in the directory ‘firmware/default’ contains just the firmware, with no built-in WAV file. This is the place to start if you want to incorporate your own WAV file, combining it with this hex file using the batch script mentioned above. The code for the ATmega328P was developed in AVR Studio using the free WinAVR C compiler. The complete project, including the hex file, can be found in the ‘firmware’ directory in the ZIP archive, which in turn can be downloaded at [3]. The fuse bits in the AVR must be programmed as follows: low fuse byte: 0xE2; high fuse byte: 0xD9; extended fuse byte: 0xFF

Internet Links

[1] http://audacity.sourceforge.net/

[2] http://hex2bin.sourceforge.net/

[3] www.elektor.com/110080

Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close
Read previous post:
Simple Low Cost Square Wave Generator & Tester Schematic Circuit Diagram

This square wave generator and tester is based on audio amplifier chip type TBA820M. It is presented as a design...

Close