Thứ Sáu, 14 tháng 12, 2018

Audio Tone Generator using AVR Microcontroller Description

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.
The photograph given below shows the circuit is built on general purpose PCB and bread board.
Audio Tone Generator using AVR Microcontroller
Fig. 1: Prototype of AVR ATMega32 based Audio Tone Generator
Block Diagram
Audio Tone Generator using AVR Microcontroller: Block Diagram
Fig. 2: Block Diagram of AVR ATMega32 based Audio Tone Generator
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
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.
Audio Tone Generator using AVR Microcontroller
Fig. 3: Image showing output waveform from Audio Tone Generator observed by an Oscilloscope
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

Circuit:
Circuit Diagram of AVR ATMega32 based Audio Tone Generator
Code:
#include<avr/io.h>
#include<util/delay.h>

unsigned int sine_value[25] = {128,150,172,192,210,226,255,226,210,192,172,150,128,105,84,64,45,30,0,30,45,64,84,105,128};

void main()
  {
int i;
DDRC = 0xFF;  // declare PORTC as output
PORTC = 0x00;  // clear port
while(1)   // continuously send values to PORTC
   {
  for(i=0;i<25;i++)  // in loop
    {
   PORTC = sine_value[i];  // send values from sine wave table
   _delay_us(15); // adjust delay to get frequency of 1 KHz
    }
   }
  }   

Không có nhận xét nào:

Đăng nhận xét

Bài đăng mới nhất

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01 # candientu ,  # fujihatsu ,  # candientufujihatsu  #candientu,  # candientufujhatsu , #fuji...

Bài đăng phổ biến