Digital power amplifier design using Atmega8

Publisher:meilidaowlLatest update time:2012-06-04 Source: 21IC Keywords:Atmega8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

Digital power amplifiers are increasingly widely used in real life due to their high efficiency and easy connection with digital audio sources. It mainly consists of two parts. Figure 1 is the basic block diagram of a digital power amplifier. There are two types of PWM conversion. One is analog PWM, which is to compare the input analog signal or digital signal with the triangle wave after D/A. This conversion must have a triangle wave with a frequency of hundreds of kHz, good linearity, and full amplitude, and a high-speed analog comparator, otherwise it will affect the waveform of the PWM waveform after demodulation, which will increase the cost and design complexity (the use of integrated Class D power amplifiers or Class D control chips is another matter). The second is digital PWM, which is to compare the input digital signal or analog signal with the counter after A/D, that is, to use the counting method instead of the triangle wave, thereby avoiding the distortion caused by the nonlinearity of the triangle wave. Compared with the traditional analog method, the digital method has the advantages of simple design, higher efficiency, and stronger anti-interference. The timer 1 in the Atmega8 microcontroller can work in PWM mode. It can complete PWM modulation by simply moving the value in its AD to the PWM output compare register, which is quite simple to implement.

In order to increase the output power, most Class D amplifiers are driven by BTL. Whether it is analog or digital PWM, there are two options for the selection of BTL two-way output signals, namely in-phase drive and anti-phase drive. In the former, the superposition effect of the two signals is almost zero when the signal is zero, while in the latter, the voltage superimposed on the filter will become larger when the signal is zero. Of course, the voltage drop on the load can be reduced by modifying the filter parameters, but this will increase the system power consumption and is not convenient for overall implementation. Therefore, this paper selects digital PWM and adopts in-phase drive to realize the digital power amplifier function, thereby further reducing static power consumption and improving efficiency.

2 Hardware Design

The hardware circuit of this design is divided into three parts, including preamplification, A/D and PWM conversion, power amplification and filtering, etc. The principle of the hardware circuit is shown in Figure 2. The PWM frequency of this system must be modulated to at least 5 times the highest frequency of the signal (20 kHz) to ensure a good restoration of the audio signal. If the operating frequency is 16 MHz, the maximum count value of the PWM (hereinafter referred to as TOP) will be: fCLK-I/O/fpwm=16MHz/100kHz=160. In addition, the sampling value of the A/D (maximum 255) must also be divided by a certain value to be used as the value of the PWM output comparison register (hereinafter referred to as OCR1A/OCR1B), which will obviously reduce the equivalent accuracy of the AD. To ensure the original accuracy of the AD and the PWM frequency, the crystal oscillator should be increased. After testing: mega8 can still work normally at 32MHz. At this time, the AD sampling value can be directly used as the OCR1A/OCR1B value. At this time, the PWM frequency is 32MHz/255=125.5kHz.

2.1 Preamplification

The preamplifier is mainly composed of AD's low-power, low-noise, single-power, rail-to-rail input and output amplifier AD8605 and a digital potentiometer. The quiescent current of AD8605 is only 0.9mA (5V), the power supply range is 2.7V~5.5V, and the bandwidth is 10MHz. The digital potentiometer X9C102 has 100 steps, the size is 1kΩ, and the minimum can reach 40Ω. It and AD8605 can form a common-mode amplifier. R2 in Figure 2 is selected as 1kΩ, and the amplification factor can be adjusted between 2 and 250.

2.2 A/D and PWM part

The A/D and PWM in this design are all completed by mega8. In the AVR family, Atmega8 is a very special single-chip microcomputer. It integrates a large-capacity memory and rich hardware interface circuits. It has all the performance and characteristics of the AVR high-end single-chip microcomputer MEGA series, but because it uses a small pin package (DIP 28), its price is comparable to that of low-end single-chip microcomputers, so it has a very high cost performance. In addition, it has ISP function and is extremely convenient to download. Atmega8 single-chip microcomputer has complete functions and rich interfaces. It has 6 channels of A/D, including 4 10-bit A/D and 2 8-bit A/D. The 3 PWM channels in the chip can realize any pulse width modulation output less than 16 bits, as well as adjustable phase and frequency. In addition, each I/O pin in Atmega8 adopts push-pull drive, so it can not only provide large current drive, but also absorb 20mA current. Atmega8's PWM has three working modes: fast PWM mode, phase adjustable PWM mode and phase frequency adjustable PWM mode. The latter two use a two-way counter, so their PWM frequency is only half of the fast mode. This article uses the first working mode. This mode is completed using timer/counter 1, and the counter is a one-way upward addition of 1, from 0x00000 to TOP, cleared when the next count pulse arrives, and then counts by 1 from 0x00000. When setting the positive comparison match output, when the count value is the same as the value of OCRR1A/OCRR1B, the output comparison match bit (hereinafter referred to as OCRR1A/OCRR1B) is set. When the counter value returns from TOP to 0x000, OCRR1A/OCRR1B is cleared. When setting the reverse comparison output, its output is exactly the opposite of the same direction comparison. From the perspective of the two-way PWM generation process, the changes in the two ways are simultaneous, thus avoiding the extra loss caused by the different delays of the two ways. [page] 2.3 Power Amplification Part



The power amplifier uses two IRF7389s, each with a pair of VMOS tubes built in. The on-resistance of the N-channel and P-channel are 46 and 98 mΩ respectively. When VGS = 4.5V, the maximum output power is 30W. In addition, the IRF7389 also has a built-in high-speed recovery diode to reduce harmonic distortion. C17 and C16 in Figure 2 are acceleration capacitors that can be used to improve the excitation waveform so that the VMOS tube can quickly switch from cut-off to on-state, or from on-state to cut-off, so as to reduce the dead time and improve the output waveform. R7 and R8 in Figure 2 mainly play a protective role.

3 Software Design and System Experiment

The system software consists of AD interrupt service program, timer interrupt service program, PWM program and key interrupt service program.

After the system is powered on, the AD interrupt program, clock interrupt program, and PWM program are initialized first, and then the AGC control of the volume is performed at the initial stage of program operation. Considering the logarithmic relationship of the human ear to the intensity of the received sound, the gain of the amplifier is designed to increase logarithmically from 2 times to 20 times, without manually adjusting the amplification factor, so that the output can be guaranteed to be within a certain range, so that the amplifier works in the linear region. The specific process is shown in Figure 3. During the playback process, the volume can be adjusted by calling the interrupt subroutine by pressing a key.

When the conversion accuracy of Atmega8 AD conversion is less than 10 bits, the sampling clock of ADC can be higher than 200 kHz, so a higher sampling rate can be obtained. In addition, setting the ADHSM bit in the SFIOR register can increase the clock frequency of ADC. This system uses the internal reference power supply and continuous conversion mode of ADC, and selects ADC4 channels (accuracy is 8 bits). The experimentally measured conversion speed can reach 40 kHz.

The initialization of PWM A and B channels adopts the same working mode. When there is zero input, A and B are output in phase. When a positive signal is input, the pulse width of channel A increases. At this time, since the comparison value of channel B is complementary to that of channel A, the pulse width of channel B decreases. When there is a negative signal input, the pulse width of channel A decreases and the pulse width of channel B increases.

Through testing, the maximum output of this system under 5V power supply and 8Ω load is 8.4V (i.e. 4.2×2) without losing the peak-to-peak value of true sine wave, the output power is 1.1W, the power supply current is 278mA at 16MHz, and the efficiency is 80%. At 32MHz, the equivalent accuracy of AD will be improved, the sound quality will be better, but the static power consumption current of the system will increase. However, since the loss is basically fixed, it is more suitable to use Atmega8 to design digital power amplifier in higher power occasions. In addition, increasing the voltage between the source of IRF7389 can increase the output PWM level, thereby increasing the output power and further improving the efficiency.

4 Conclusion

The design of the power amplifier using the Atmega8 single-chip microcomputer is very simple, flexible, and scalable. It can also meet different needs by adjusting the program. The frequency response of the power amplifier can be changed by modifying the digital filter program. If a memory is added, recording, repeating, setting the playback time and displaying the volume can be realized. These functions cannot be achieved by integrating only the Class D power amplifier.

Keywords:Atmega8 Reference address:Digital power amplifier design using Atmega8

Previous article:Homemade AVR MCU Unlocker
Next article:Capture interrupt and temperature measurement of thermistor based on AVR microcontroller

Recommended ReadingLatest update time:2024-11-16 22:35

Passive infrared alarm experiment based on Atmega8
 The alarm consists of an infrared transmitter, receiver, buzzer and LED indicator. Under normal circumstances, the green LED flashes constantly, indicating that the monitored area is normal. Once someone breaks into the monitored area, the green LED goes out, the red LED flashes quickly, and the buzzer sounds an alar
[Microcontroller]
Passive infrared alarm experiment based on Atmega8
ATmega8 calibrated on-chip RC oscillator
The calibrated on-chip RC oscillator provides a fixed 1.0, 2.0, 4.0, or 8.0 MHz clock. These frequencies are nominal at 5V, 25°C. This clock can also be used as the system clock by programming the CKSEL fuse according to Table 9. No external components are required when this clock is selected (CKOPT cannot be programm
[Microcontroller]
ATmega8 calibrated on-chip RC oscillator
ATMEGA8 microcontroller drives 4-wire stepper C program
#include  avr/io.h   #include  avr/delay.h   #define uchar unsigned char  #define uint unsigned int  uchar np;  //Stepper motor operation data table  const uchar motortb ={0x11,0x99,0x88,0xCC,0x44,0x66,0x22,0x33};  void delay_nms(uint ms)// Each step delay subroutine  {   uint i;  for(i=0;i ms;i++)     _delay_loo
[Microcontroller]
ATmega88 Idle Mode
When SM2..0 is 000, the SLEEP instruction causes the MCU to enter the CPU stop operation, while the SPI, USART, analog comparator, ADC, two-wire serial interface, timer counter, watchdog and interrupt system continue to work. This sleep mode only stops clkCPU and clkFLASH, and other clocks continue to work. Internal
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号