Amplifier Circuit DiagramsAudio Circuit Diagrams

WAV Doorbell Schematic Circuit Diagram

Electronic Doorbell Overview

This electronic doorbell functions as a compact WAV file player centered on an ATmega328P microcontroller. Upon the guest’s pressing of the bellpush, the device activates and plays a brief WAV file utilizing its integrated PWM module. This unique feature allows you to personalize your doorbell sound, akin to customizing your mobile phone’s ringtone. Additionally, the device permits loading of any preferred sound without requiring external storage; the WAV file is stored directly in the microcontroller’s on-chip flash memory.

WAV Doorbell Schematic Circuit Diagram

Simplified Audio Output

To maintain component count at a minimum, the standard low-pass filter, typically used with the PWM output of the AVR microcontroller, is omitted. Instead, the output connects directly to a small loudspeaker through an electrolytic capacitor and a series resistor. It’s essential to note that connecting the PWM signal directly to an amplifier or powered speakers without an appropriate low-pass filter can lead to distortion.

Device Operation and WAV File Requirements

Upon applying power, the device promptly plays the pre-stored doorbell sound, after which the AVR microcontroller enters a low-power standby mode. Pressing the doorbell button activates the microcontroller, causing it to exit standby mode and replay the WAV file. The WAV file must adhere to specific parameters, namely the ‘RIFF WAVE’ format, 8 bits per sample, mono, and a sample rate of 8 kHz. Of the ATmega328P’s 32 Kbytes of flash memory, 1 Kbyte is reserved for firmware, leaving 31,744 bytes for the WAV file, sufficient for approximately four seconds of audio.

The firmware occupies addresses 0x0000 to 0x03FF, with the WAV data starting at 0x0400. If the audio file is not in the PCM WAV format mentioned, the freeware tool Audacity can be employed for conversion. Open the file in Audacity, set the ‘project rate’ to 8000 Hz, delete unwanted portions (e.g., silence at the start or end), convert from stereo to mono, and ensure the export format is ‘WAV (Microsoft 8-bit PCM)’ under ‘Edit > Preferences.’ This process should yield a suitable file.

Converting WAV to Hex for Programming

To prepare the WAV file for programming into the ATmega328P, the ‘hex2bin’ tool is used. It converts the binary WAV file into an Intel hex format, then integrates the result into the hex file containing the AVR code. This generates a single hex file housing both the firmware and WAV file data needed for ATmega328P programming. The ‘convert.bat’ batch file facilitates this entire conversion process. The firmware ascertains the WAV file’s duration based on header information and plays its contents for the correct length.

Ready-Made Hex File and Fuse Bits Configuration

A pre-made hex file, named ‘tuergong.hex,’ encompassing both firmware and a ‘ding-dong’ WAV sound is available for free in the accompanying ZIP archive. This hex file can be directly programmed into the ATmega328P. The ‘code.hex’ file in the ‘firmware/default’ directory contains only the firmware, devoid of a built-in WAV file, making it a starting point for those who wish to add their own WAV file. Merging it with the custom WAV file is achieved through the mentioned batch script. The ATmega328P code was developed using AVR Studio with the WinAVR C compiler. The entire project, including the hex file, is located in the ‘firmware’ directory within the provided ZIP archive, downloadable at [3]. The AVR’s fuse bits should be programmed as follows: low fuse byte: 0xE2; high fuse byte: 0xD9; extended fuse byte: 0xFF.

Internet Links





Related Articles

Leave a Reply

Your email address will not be published.

Back to top button