【正文】
} /********************************************************/ /* /*步進(jìn)電機(jī)反轉(zhuǎn) /* /********************************************************/ void motor_rev2() { uchar i。 //發(fā)送數(shù)據(jù) RST_L。 if(SDA_IN) temp|=0x80。i7。 } 30 致 謝 感謝他們一直以來對我的關(guān)心和支持。 l_tmpdate[1]=Read_Ds1302(0X83)。i8。 RST_H。 j++) //轉(zhuǎn) 1*n 圈 { for (i=0。 j++) //轉(zhuǎn) 1*n 圈 { for (i=0。=~(BIT(PA0)|BIT(PA1)|BIT(PA2)|BIT(PA3)|BIT(PA4))。最后,我發(fā)現(xiàn)原來我沒對端口進(jìn)行初始化,當(dāng)加上端口初始化語句之后,正確的結(jié)果就出來了。再對 DS1302 的實時時鐘程序進(jìn)行編寫,根據(jù)芯片的資料和時序要求,編寫程序,在開發(fā)板的數(shù)碼管上顯示當(dāng)前時鐘。 首先,對相關(guān)引腳進(jìn)行初始化,把單片機(jī)的 PD PD5 和 PD6 引腳設(shè)置為輸出。如果絕對值大于設(shè)定值,接著判斷 U1是否大于 U2,若是,則讓步進(jìn)電機(jī) 1 正轉(zhuǎn)一個角度;若否,則讓步進(jìn)電機(jī) 1 反轉(zhuǎn)一個角度。 LM7805 特點如下: ( 1) 最大輸出電流為 ; ( 2) 輸出電壓為 5V; ( 3) 熱過載保護(hù); ( 4) 短路保護(hù); ( 5) 輸出晶體管安全工作區(qū)保護(hù)。內(nèi)部固定的恒壓充電電壓為,也可以通過一個外部的電阻調(diào)節(jié)。當(dāng)通電狀態(tài)的改 變完成一個循環(huán)時,轉(zhuǎn)子轉(zhuǎn)過一個齒距。采用雙電源供電(主電源和備用電源),可設(shè)置備用電源充電方式,提供了對后背電源進(jìn)行涓細(xì)電 10 流充電的能力。 ADC 與一個 8通道的模擬多路復(fù)用器連接,能對來自端口 A 的 8 路單端輸入電壓進(jìn)行采樣。為了獲得高的靈敏度,光敏電阻的電極一般采用硫狀圖案。實際應(yīng)用時,如果想簡化線路,可以將 AVCC 直接接到 VCC, AREF懸空,即這部分不需要任何的外圍零件。其中第一功能是作 為數(shù)字通用 I/O 接口使用,而復(fù)用的功能可分別與片內(nèi)的各種不同功能的外圍接口電路組合成一些可以完成特殊功能的 I/O 口,如定時器、計數(shù)器、串行接口、模擬比較器、捕捉器、 USART、 SPI 等。設(shè)計中為了使太陽能電池板能夠始終正對著太陽則需要四個光敏電阻對陽光強(qiáng)弱進(jìn)行檢測,這四個光敏電阻為光敏電阻 光敏電阻 光敏電阻 3和光敏電阻 4,光敏電阻間由垂直的遮光板隔開。它能夠?qū)μ柕母叨冉呛头轿唤沁M(jìn)行全面跟蹤,實現(xiàn)更高的采集效率。 2 太陽能跟蹤系統(tǒng)的國內(nèi)外研究現(xiàn)狀 隨著科學(xué)技術(shù)的迅猛發(fā)展,人們對已經(jīng)把太陽能應(yīng)用到許多領(lǐng)域,太陽能的使用逐漸進(jìn)入人類的生活。 關(guān)鍵詞 :單片機(jī) 雙軸跟蹤 太陽能 充電 Design of Twoaxe Solar Tracking and Charging System Based on MCU Tan Xueqing (College of Engineering, South China Agricultural University, Guangzhou 510642, China) Abstract: With the rapid growth of social economy, the traditional fuel sources is decreasing quickly, and the harm of environment is more and more serious at the same time. Solar energy is one of the renewable energy, and has the unique advantages such as clean, abundant, has a broad development prospects. But the current solar utilization is low, restricting its development. Currently, most solar tracking system is fixed, unable to shift as the sun run, so the energy conversion efficiency is low. Microcontroller is the core of the whole system. The system can track the sun in the two degrees of freedom, which can effectively improve the utilization of solar energy. This system adopts microcontroller as nucleus and photoelectric sensor transmit the collected light information to the microcontroller. After analyzing and processing, microcontroller drive two stepper motors running, so it can adjust the angle of solar panels on the two degrees of freedom. This system achieves the goal of twoaxis tracking solar, and to control charging at the same time. By microcontroller to realize twoaxis tracking solar systems can effectively improve the conversion efficiency of solar energy, and has a broad application prospect with the advantages of good realtime and low cost. Key words: Microcontroller Twoaxes tracking Solar Charging 目 錄 1 前言 ................................................................... 1 課題的研究背景和意義 ................................................. 1 太陽能跟蹤系統(tǒng)的國內(nèi)外研究現(xiàn)狀 ....................................... 2 本設(shè)計的主要研究內(nèi)容 ................................................. 2 2 總體方案確定 ........................................................... 3 方案簡述 ............................................................. 3 光電檢測跟蹤太陽原理 ................................................. 3 3 系統(tǒng)的硬件設(shè)計 ......................................................... 4 ATmega16 單片機(jī)最小系統(tǒng)電路 ........................................... 4 ATmega16 單片機(jī)的簡介及引腳功能說明 ................................ 4 ATmega16 單片機(jī)最小系統(tǒng)電路設(shè)計 ..................................... 5 ISP 下載線路 ........................................................ 7 光強(qiáng)度檢測電路 ....................................................... 7 光敏電阻介紹和工作原理 ............................................. 7 光強(qiáng)檢測電路 ....................................................... 8 A/D 轉(zhuǎn)換電路 .......................................................... 9 時鐘電路 ............................................................. 9 DS1302 時鐘芯片介紹 ................................................. 9 時鐘電路 .......................................................... 10 電機(jī)驅(qū)動電路 ........................................................ 10 步進(jìn)電機(jī)的介紹 .................................................... 10 ULN2020 芯片介紹 ................................................... 11 電機(jī)驅(qū)動電路設(shè)計 .................................................. 12 鋰電池充電電路 ...................................................... 13 太陽能充電管理專用充電芯片 CN3063 簡介 ............................. 13 鋰電池充電電路設(shè)計 ................................................ 13 電源電路 ............................................................ 14 LM7805 芯片簡介 .................................................... 14 電源電路設(shè)計 ...................................................... 15 4 系統(tǒng)軟件設(shè)計 .......................................................... 15 系統(tǒng)主程序設(shè)計及工作原理 ............................................ 15 太陽跟蹤算法程序設(shè)計 ................................................ 16 A/D 轉(zhuǎn)換程序設(shè)計 ..................................................... 17 DS1302 時鐘程序設(shè)計 .................................................. 18 5 軟硬件調(diào)試 ...