【正文】
唐 山 學 院 畢 業(yè) 設 計 設計題目: 基于 AVR 單片機的開關電源的設計與實現(xiàn) 系 別: 信息工程系 班 級: 姓 名: 2021 年 6 月 10 日 基于 AVR 單片機的開關電源的設計與實現(xiàn) 摘 要 電源是電子設備 中不可缺少 的功能模塊, 是各種電器設備的能量的來源, 其性能的優(yōu)劣直接影響電子設備的技術性能 與其 可靠性。 因此,能否設計出性能良好的電源是電子設備是 否能夠高效、可靠運行的一個基本保障。 本設計是以 Atmega8 單片機 作 為主 要 控 制 器, 制作輸出電壓可以調節(jié)的開關電源。該系統(tǒng)不僅可以預置輸出電壓而且還可以調節(jié)輸出電壓,并具有過流保護、短路保護以及數(shù)碼管顯示等功能。 本論文主要 講述的是由單片機產(chǎn)生 PWM 波來控制功率管的通斷。通過單片機內部集成的 AD 轉換器檢測輸出電壓,并和預置電壓進行比較得到誤差信號,調用調節(jié)函數(shù)實現(xiàn)穩(wěn)壓。單片機可以通過鍵盤來改變輸出電壓的大小,從而修改 PWM波的占空比來調節(jié)輸出電壓的大小。開關電源的輸出電壓以及輸出電流可以通過數(shù)碼管來顯示,當 線路發(fā)生短路或者過載時都會通過數(shù)碼管的示數(shù)顯示出來。 本開關電源的主要性能有穩(wěn)壓效果好、效率高、輸出電壓可調、響應速率快。 關鍵詞 :開關電源 單片機 電壓可調 電壓顯示 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 開關電源方案設計 ........................................................................................................ 4 開關電源工作原理 ............................................................................................... 4 開關電源方案選擇與論證 ................................................................................... 4 總體結構設計 ....................................................................................................... 5 3 系統(tǒng)核心器件選擇 ........................................................................................................ 7 單片機簡介 ........................................................................................................... 7 引腳說明 ..................................................................................................... 7 Atmega8I/O 口概述 ..................................................................................... 9 Atmega8 的 AD 功能 .......................................................................................... 10 ADC 功能簡介 .......................................................................................... 10 ADC 相關寄存器 ...................................................................................... 11 Atemga8 的 PWM 功能 ...................................................................................... 15 PWM 波形發(fā)生器選擇 ............................................................................. 15 時鐘源選擇 ............................................................................................... 17 4 硬件電路設計 ............................................................................................................... 18 電源電路設計 ..................................................................................................... 18 整流濾波電路設計 ................................................................................... 18 開關變換電路設計 ................................................................................... 18 控制電 路設計 ..................................................................................................... 19 時鐘電路設計 ........................................................................................... 19 單片機復位電路設計 ............................................................................... 19 單片機與數(shù)碼管接口電路設計 ............................................................... 20 單片機與鍵盤接口電路設計 ................................................................... 21 反饋電路設計 ........................................................................................... 22 5 系統(tǒng)軟件設計 ............................................................................................................... 24 主程序設計 ......................................................................................................... 24 鍵盤防抖動子程序設計 ..................................................................................... 25 數(shù)碼管掃描子程序設計 ..................................................................................... 25 ADC 轉換子程序設計 ........................................................................................ 26 調節(jié)函數(shù)子程序設計 ........................................................................................ 27 6 系統(tǒng)調試 ....................................................................................................................... 29 軟件調試調試 ..................................................................................................... 29 系統(tǒng)整體調試 .....