Audio Tone Generator using AVR Microcontroller Using Atmega

Audio Tone Generator

The circuit presented here demonstrates how to generate Audible Frequency from an AVR Microcontroller. The output of Microcontroller is always digital so to generate audible sound at the outset first it needs to be converted into Analog. A DAC (Digital to Analog Converter) is used for this purpose. Microcontroller generates sine wave of Audible Frequency using DAC. This sine wave is further given to Audio Amplifier that drives speaker. Microcontroller generates sine wave of fix frequency continuously. So we can hear an audible tone of fix frequency.

Audio Tone Generator

The photograph given below shows the circuit is built on general purpose PCB and bread board.
As shown in figure the major building blocks are AVR Microcontroller ATMega32, 8-bit DAC DAC0808, OP-AMP LM741 and Audio Amplifier TDA7056
AVR Microcontroller
AVR Microcontroller gives Digital values to DAC to generate sine wave output through it.
DAC0808
It converts digital values given by ATMega32 into Analog and generates continuous type sine wave

Audio Tone Generator schematic

OP-AMP LM741
DAC0808 gives output in form of current. OP-AMP works as I to V converter and converts it in to voltage
Audio Amplifier
Audio Amplifier amplifies the signal given by OP-AMP so that it can drive speaker and generates sound output of around 1W to 3W

Circuit & Programming Description

Circuit Description

As shown in Circuit Diagram, PORTC pins PC0 – PC7 of ATMega32 are connected to digital inputs D0-D7 of DAC0808 respectively.

8Vref+ pin (14) of DAC0808 is connected to 5V through 5 K resistor that will generate Iref of 1 mA.

Vref- pin (13) is connected to ground through another 5K resistor.

The current output pin (4) of DAC is connected to non inverting input pin (3) of op-amp LM741. Inverting terminal of op-amp is grounded. A 5 K resistor is connected between Input and Output of op-amp as shown. Output of op-amp is given to input of Audio Amplifier through 5 K pot. Pot works as volume control. Audio Amplifier TDA7056 does not require any external components.

An 8 Ohm speaker is connected to output terminals 6 – 7 of TDA7056. All the chips works on 5 V so complete circuit is given power through 5 V supply.

DAC0808 needs -12 v supply for its –Vee pin (2).

A 16 MHz crystal along with 2 capacitors of 22 pF is connected to crystal input pins of ATMega32.

Circuit Operation

Microcontroller generates sequence of Digital Data in such a manner that a sine wave of Audio Frequency is generated through DAC0808 and op-amp. The output of op-amp is not pure sine wave but its staircase type sine wave as shown in photograph below.

Circuit Operation

This sine wave is further amplified by Audio Amplifier chip. This chip drives 8? speaker and generates sound output of around 1 W.

Software Program

A software program written in C language is embedded into ATMega32 Microcontroller that will give sequence of data on PORTC to generate sine wave through DAC and op-amp. The program is edited, compiled and simulated in AVR studio software tool. Please refer the code for complete program with comments

 

Read more: Audio Tone Generator using AVR Microcontroller

Leave a Comment

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