【正文】
唐 山 學(xué) 院 畢 業(yè) 設(shè) 計(jì) 設(shè)計(jì)題目: 基于 AVR 單片機(jī)的開(kāi)關(guān)電源的設(shè)計(jì)與實(shí)現(xiàn) 系 別: 信息工程系 班 級(jí): 姓 名: 2021 年 6 月 10 日 基于 AVR 單片機(jī)的開(kāi)關(guān)電源的設(shè)計(jì)與實(shí)現(xiàn) 摘 要 電源是電子設(shè)備 中不可缺少 的功能模塊, 是各種電器設(shè)備的能量的來(lái)源, 其性能的優(yōu)劣直接影響電子設(shè)備的技術(shù)性能 與其 可靠性。 因此,能否設(shè)計(jì)出性能良好的電源是電子設(shè)備是 否能夠高效、可靠運(yùn)行的一個(gè)基本保障。 本設(shè)計(jì)是以 Atmega8 單片機(jī) 作 為主 要 控 制 器, 制作輸出電壓可以調(diào)節(jié)的開(kāi)關(guān)電源。該系統(tǒng)不僅可以預(yù)置輸出電壓而且還可以調(diào)節(jié)輸出電壓,并具有過(guò)流保護(hù)、短路保護(hù)以及數(shù)碼管顯示等功能。 本論文主要 講述的是由單片機(jī)產(chǎn)生 PWM 波來(lái)控制功率管的通斷。通過(guò)單片機(jī)內(nèi)部集成的 AD 轉(zhuǎn)換器檢測(cè)輸出電壓,并和預(yù)置電壓進(jìn)行比較得到誤差信號(hào),調(diào)用調(diào)節(jié)函數(shù)實(shí)現(xiàn)穩(wěn)壓。單片機(jī)可以通過(guò)鍵盤(pán)來(lái)改變輸出電壓的大小,從而修改 PWM波的占空比來(lái)調(diào)節(jié)輸出電壓的大小。開(kāi)關(guān)電源的輸出電壓以及輸出電流可以通過(guò)數(shù)碼管來(lái)顯示,當(dāng) 線路發(fā)生短路或者過(guò)載時(shí)都會(huì)通過(guò)數(shù)碼管的示數(shù)顯示出來(lái)。 本開(kāi)關(guān)電源的主要性能有穩(wěn)壓效果好、效率高、輸出電壓可調(diào)、響應(yīng)速率快。 關(guān)鍵詞 :開(kāi)關(guān)電源 單片機(jī) 電壓可調(diào) 電壓顯示 The Design and Implementation of Switching Power Supply Based on MCU Abstract To electronic equipments, power is a indispensable function module. It is the energy source of all sort of electric equipment . And the performance of the power influences the technical characteristics and reliability of the electronic equipment. Therefore, it is the basic of the electronic equipments’ efficient and reliable operation that if we can design the good power or not. This design makes a power whose output voltage can be adjusted based on Atmega8 MCU as a main controller,. The system can not only preset the output voltage but also adjust the output voltage, and it has functions such as the flow protection, short circuit protection and digital pipe display. This thesis is about that PWM waves generated by MCU can control the hige power tube. It can test the output voltage through MCU integrated AD converter, and get error signals by parison of preset voltage, and stabilize voltage by calling adjustment function. MCU can change the size of the output voltage through the keyboard modifying the PWM waves’ buty cycle. Switch power’s output voltage and output current can be show through the digital tube, and it can be show by the digital when the line shortcircuited or overload happened. The switch power has a good effect to stabilize the voltage, high efficiency, and its output voltage can be adjusted, and its response speed is high. Key words: Switching power 。PWM 。Voltage adjustable 。Voltage display 目 錄 1 引言 ................................................................................................................................ 1 2 開(kāi)關(guān)電源方案設(shè)計(jì) ........................................................................................................ 4 開(kāi)關(guān)電源工作原理 ............................................................................................... 4 開(kāi)關(guān)電源方案選擇與論證 ................................................................................... 4 總體結(jié)構(gòu)設(shè)計(jì) ....................................................................................................... 5 3 系統(tǒng)核心器件選擇 ........................................................................................................ 7 單片機(jī)簡(jiǎn)介 ........................................................................................................... 7 引腳說(shuō)明 ..................................................................................................... 7 Atmega8I/O 口概述 ..................................................................................... 9 Atmega8 的 AD 功能 .......................................................................................... 10 ADC 功能簡(jiǎn)介 .......................................................................................... 10 ADC 相關(guān)寄存器 ...................................................................................... 11 Atemga8 的 PWM 功能 ...................................................................................... 15 PWM 波形發(fā)生器選擇 ............................................................................. 15 時(shí)鐘源選擇 ............................................................................................... 17 4 硬件電路設(shè)計(jì) ............................................................................................................... 18 電源電路設(shè)計(jì) ..................................................................................................... 18 整流濾波電路設(shè)計(jì) ................................................................................... 18 開(kāi)關(guān)變換電路設(shè)計(jì) ................................................................................... 18 控制電 路設(shè)計(jì) ..................................................................................................... 19 時(shí)鐘電路設(shè)計(jì) ........................................................................................... 19 單片機(jī)復(fù)位電路設(shè)計(jì) ............................................................................... 19 單片機(jī)與數(shù)碼管接口電路設(shè)計(jì) ............................................................... 20 單片機(jī)與鍵盤(pán)接口電路設(shè)計(jì) ................................................................... 21 反饋電路設(shè)計(jì) ........................................................................................... 22 5 系統(tǒng)軟件設(shè)計(jì) ............................................................................................................... 24 主程序設(shè)計(jì) ......................................................................................................... 24 鍵盤(pán)防抖動(dòng)子程序設(shè)計(jì) ..................................................................................... 25 數(shù)碼管掃描子程序設(shè)計(jì) ..................................................................................... 25 ADC 轉(zhuǎn)換子程序設(shè)計(jì) ........................................................................................ 26 調(diào)節(jié)函數(shù)子程序設(shè)計(jì) ........................................................................................ 27 6 系統(tǒng)調(diào)試 ....................................................................................................................... 29 軟件調(diào)試調(diào)試 ..................................................................................................... 29 系統(tǒng)整體調(diào)試 .....