版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
#基于驅(qū)動電路板的設(shè)計基于中文摘要ABSTRACT目錄%#?刖言第一章概述 □□□□□□ □□□□□□□□□□□□□□□□□□□□□□□開關(guān)電源的研究現(xiàn)狀………………開關(guān)電源的組成……………………開關(guān)電源的特點……………………□□□□□□ □□□□□□□□□□□□□□□□□□□□□□□□□根據(jù)開關(guān)口在電路中的連接方式分類 …………根據(jù)開關(guān)口的激勵方式不同分類…………………根據(jù)使用的器件種類不同分類……………………根據(jù)穩(wěn)壓的控制方式不同分類…………………其他開關(guān)穩(wěn)壓電源…………………□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□理想的開關(guān)電路…………………整流及LC濾波器…………………輸入電壓U………………………i反饋控制電路……………………基本工作過程……………………第二章 電路的工作原理 LM2576□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□第三章基于的 測試板的焊接與調(diào)試□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□第四章開關(guān)電源設(shè)計 protel99se□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□PCB□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□制作PCB□□□□□□□□□□□□□□□□□□□□□□□□□□□□結(jié)論參考文獻(xiàn)致謝附錄外文資料翻譯一、正文國內(nèi)研究現(xiàn)狀□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□,□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□; □□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□,□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□; □□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□,□□□□,□□□□□□□□□□□□□□□,□□□□,□□□□□□□□□□,□□□□□□□,□□□□□□□□,□□□□□□,□□□□□□,□□□□□□□,□□□□□□□□□□□□,□□□□□,□□□,□□□□□□□□□□□,□□□,□□□□□□□□□,□□□□□□□□□□□, □□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□:□□□□□□□□, 其輸□□□□□□□□□,□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□?□□□□□□□□□□□□□□□□□□□,□□□□□□□□□,□□□□□□□□□□□□□□□,□□□□□□;□□□□□□□□□,□□□□□□□□□□□□□□□,□□□□□□□選題意義、目的□□□□□□□□□□□□□□□□□□□□□, □□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□, □□□□□□□□, □□□□□□□□□□□,□□□□□□□□□□□□□□□□□,□□□□□□□□,□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□,□□□□□□□□□□□□□□:.□□□□□□□□□□□, 體積更小, □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□;.□□□□□□□□□□□□□□□□□□□□□□ PCB電路;.□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□;.□□□□□□□□□□□□□□□□□□□□□□□致謝參考文獻(xiàn)(至少篇)樣式:[1]龔尚福,[1]龔尚福,朱宇等 .微機(jī)原理及應(yīng)用[M].西安:西安電子科技大學(xué)出版社,2003.[2]龔尚福.網(wǎng)絡(luò)管理新技術(shù)探討 [J].西安:西安科技大學(xué)學(xué)報, 2004.[1]康華光□□□□□□□□□□□□□□□ [M]□□□□□□□[2]謝運祥等譯□□□□□□ [M]□□□□□□□[3]□□□□□protel2004□□□□□□ [M]□□□□□□□[4]李祥臣□□□□□□□□□□ □□□□□□□ [M]□□□□□□□□社[5][Z]頭文件及宏定義區(qū)#include<reg51.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedint*頭文件及宏定義區(qū)數(shù)據(jù)及變量定義區(qū),每年三字節(jié)codeucharyear_code[597]={ ,每年三字節(jié)0x04,0xAe,0x53, //190100x0A,0x57,0x48, //190230x55,0x26,0xBd, //190360x0d,0x26,0x50, //190490x0d,0x95,0x44, //190512TOC\o"1-5"\h\z0x46,0xAA,0xB9, //1906 150x05,0x6A,0x4d, //1907 180x09,0xAd,0x42, //1908 210x24,0xAe,0xB6, //19090x04,0xAe,0x4A, //19100x6A,0x4d,0xBe, //19110x0A,0x4d,0x52, //19120x0d,0x25,0x46, //19130x5d,0x52,0xBA, //19140x0B,0x54,0x4e, //19150x0d,0x6A,0x43, //19160x29,0x6d,0x37, //19170x09,0x5B,0x4B, //19180x74,0x9B,0xC1, //19190x04,0x97,0x54, //19200x0A,0x4B,0x48, //19210x5B,0x25,0xBC, //19220x06,0xA5,0x50, //19230x06,0xd4,0x45, //19240x4A,0xdA,0xB8, //19250x02,0xB6,0x4d, //19260x09,0x57,0x42, //19270x24,0x97,0xB7, //19280x04,0x97,0x4A, //19290x66,0x4B,0x3e, //19300x0d,0x4A,0x51, //19310x0e,0xA5,0x46, //19320x56,0xd4,0xBA, //19330x05,0xAd,0x4e, //19340x02,0xB6,0x44, //19350x39,0x37,0x38, //19360x09,0x2e,0x4B, //19370x7C,0x96,0xBf, //19380x0C,0x95,0x53, //19390x0d,0x4A,0x48, //19400x6d,0xA5,0x3B, //1941
0x0B,0x55,0x4f,〃19420x05,0x6A,0x45,〃19430x4A,0xAd,0xB9,//19440x02,0x5d,0x4d,〃19450x09,0x2d,0x42,//19460x2C,0x95,0xB6,//19470x0A,0x95,0x4A,//19480x7B,0x4A,0xBd,//19490x06,0xCA,0x51,//19500x0B,0x55,0x46,//19510x55,0x5A,0xBB,//19520x04,0xdA,0x4e,//19530x0A,0x5B,0x43,//19540x35,0x2B,0xB8,//19550x05,0x2B,0x4C,//19560x8A,0x95,0x3f,//19570x0e,0x95,0x52,//19580x06,0xAA,0x48,//19590x7A,0xd5,0x3C,//19600x0A,0xB5,0x4f,//19610x04,0xB6,0x45,//19620x4A,0x57,0x39,//19630x0A,0x57,0x4d,//19640x05,0x26,0x42,//19650x3e,0x93,0x35,//19660x0d,0x95,0x49,//19670x75,0xAA,0xBe,//19680x05,0x6A,0x51,//19690x09,0x6d,0x46,//19700x54,0xAe,0xBB,//19710x04,0xAd,0x4f,//19720x0A,0x4d,0x43,//19730x4d,0x26,0xB7,//19740x0d,0x25,0x4B,//19750x8d,0x52,0xBf,//19760x0B,0x54,0x52,//19770x0B,0x6A,0x47,//19780x69,0x6d,0x3C,//19790x09,0x5B,0x50,//19800x04,0x9B,0x45,//19810x4A,0x4B,0xB9,//19820x0A,0x4B,0x4d,//19830xAB,0x25,0xC2,//19840x06,0xA5,0x54,//19850x06,0xd4,0x49,〃19860x6A,0xdA,0x3d,//19870x0A,0xB6,0x51,//19880x09,0x37,0x46,//19890x54,0x97,0xBB,//19900x04,0x97,0x4f,//19910x06,0x4B,0x44,//19920x36,0xA5,0x37,//19930x0e,0xA5,0x4A,//19940x86,0xB2,0xBf,//19950x05,0xAC,0x53,//19960x0A,0xB6,0x47,//19970x59,0x36,0xBC,//19980x09,0x2e,0x50,//19992940x0C,0x96,0x45,//20002970x4d,0x4A,0xB8,//20010x0d,0x4A,0x4C,//20020x0d,0xA5,0x41,//20030x25,0xAA,0xB6,//20040x05,0x6A,0x49,//20050x7A,0xAd,0xBd,//20060x02,0x5d,0x52,//20070x09,0x2d,0x47,//20080x5C,0x95,0xBA,//20090x0A,0x95,0x4e,//20100x0B,0x4A,0x43,//20110x4B,0x55,0x37,//20120x0A,0xd5,0x4A,//20130x95,0x5A,0xBf,//20140x04,0xBA,0x53,//20150x0A,0x5B,0x48,//20160x65,0x2B,0xBC,//20170x05,0x2B,0x50,//20180x0A,0x93,0x45,//20190x47,0x4A,0xB9,//20200x06,0xAA,0x4C,//20210x0A,0xd5,0x41,//20220x24,0xdA,0xB6,//20230x04,0xB6,0x4A,//20240x69,0x57,0x3d,//20250x0A,0x4e,0x51,//20260x0d,0x26,0x46,//20270x5e,0x93,0x3A,//20280x0d,0x53,0x4d,//2029
0x05,0xAA,0x43,//20300x36,0xB5,0x37,//20310x09,0x6d,0x4B,//20320xB4,0xAe,0xBf,//20330x04,0xAd,0x53,//20340x0A,0x4d,0x48,//20350x6d,0x25,0xBC,//20360x0d,0x25,0x4f,//20370x0d,0x52,0x44,//20380x5d,0xAA,0x38,//20390x0B,0x5A,0x4C,//20400x05,0x6d,0x41,//20410x24,0xAd,0xB6,//20420x04,0x9B,0x4A,//20430x7A,0x4B,0xBe,//20440x0A,0x4B,0x51,//20450x0A,0xA5,0x46,//20460x5B,0x52,0xBA,//20470x06,0xd2,0x4e,//20480x0A,0xdA,0x42,//20490x35,0x5B,0x37,//20500x09,0x37,0x4B,//20510x84,0x97,0xC1,//20520x04,0x97,0x53,//20530x06,0x4B,0x48,//20540x66,0xA5,0x3C,//20550x0e,0xA5,0x4f,//20560x06,0xB2,0x44,//20570x4A,0xB6,0x38,//20580x0A,0xAe,0x4C,//20590x09,0x2e,0x42,//20600x3C,0x97,0x35,//20610x0C,0x96,0x49,//20620x7d,0x4A,0xBd,//20630x0d,0x4A,0x51,//20640x0d,0xA5,0x45,//20650x55,0xAA,0xBA,//20660x05,0x6A,0x4e,//20670x0A,0x6d,0x43,//20680x45,0x2e,0xB7,//20690x05,0x2d,0x4B,//20700x8A,0x95,0xBf,//20710x0A,0x95,0x53,//20720x0B,0x4A,0x47,//20730x6B,0x55,0x3B,//20740x0A,0xd5,0x4f,//20750x05,0x5A,0x45,//20760x4A,0x5d,0x38,//20770x0A,0x5B,0x4C,//20780x05,0x2B,0x42,//20790x3A,0x93,0xB6,//20800x06,0x93,0x49,//20810x77,0x29,0xBd,//20820x06,0xAA,0x51,//20830x0A,0xd5,0x46,//20840x54,0xdA,0xBA,//20850x04,0xB6,0x4e,//20860x0A,0x57,0x43,//20870x45,0x27,0x38,//20880x0d,0x26,0x4A,//20890x8e,0x93,0x3e,//20900x0d,0x52,0x52,//20910x0d,0xAA,0x47,//20920x66,0xB5,0x3B,//20930x05,0x6d,0x4f,//20940x04,0xAe,0x45,//20950x4A,0x4e,0xB9,//20960x0A,0x4d,0x4C,//20970x0d,0x15,0x41,//20980x2d,0x92,0xB5,//2099};codeucharday_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3};codeuintday_code2[3]={0x111,0x130,0x14e};//月份數(shù)據(jù)表dataucharyear_moon,month_moon,day_moon,week;unsignedchardatadisdata[5];unsignedinttvalue;//溫度值unsignedchartflag;//溫度正負(fù)標(biāo)志unsignedcharcodedis_week口={"SUN,MON,TUE,WED,THU,FRI,SAT"};unsignedcharcodepara_month[13]={0,0,3,3,6,1,4,6,2,5,0,3,5};//星期月參變數(shù)unsignedchardatadis_buf1[16]; //lcd上排顯示緩沖區(qū)unsignedchardatadis_buf2[16]; //lcd下排顯示緩沖區(qū)unsignedchardatayear,month,date,week;//年、月、日、星期unsignedchardataarmhour,armmin,armsec;//鬧鐘時、分、秒unsignedchardatahour,min,sec,sec100; 〃時、分、秒、百分之一秒unsignedchardataflag,vkey,skey;//設(shè)置狀態(tài)計數(shù)標(biāo)志、按鍵先前值、按鍵當(dāng)前值據(jù)及變量定
1--啟用,0—關(guān)閉bitalarm;〃標(biāo)識是否啟用鬧鐘,1--啟用,0—關(guān)閉bitc_moon;sbitrs=P2A7;//LCDOO川口選擇端 (H/L)sbitrw=P2A6;//LCDD/ODDO (H/L)sbitep=P2A5;//LCD使能控制sbitPRE=P2A4;//DOD (k3)sbitSET=P2A3;//DOD (k4)sbitSPK=P2A2;sbitDQ=P2A1;//DS18B20與單片機(jī)連接口/**************************子函數(shù)定義區(qū)/**************************子函數(shù)定義區(qū)voiddelay(unsignedcharms);intlcd_busy();voidlcd_wcmd(charcmd);voidlcd_wdat(chardat);voidlcd_pos(charpos);voidlcd_init();voidpro_timedate();voidpro_display();voiddelay(unsignedcharms);intlcd_busy();voidlcd_wcmd(charcmd);voidlcd_wdat(chardat);voidlcd_pos(charpos);voidlcd_init();voidpro_timedate();voidpro_display();voidpro_key();voidtime_alarm();unsignedcharscan_key();unsignedcharweek_proc();intleap_year();voidlcd_sef_chr();〃延時程序〃測試 LCD忙碌狀態(tài)程序〃寫入指令到 LCD程序〃寫入數(shù)據(jù)到 LCD程序//LCD數(shù)據(jù)指針位置程序//LCD初始化設(shè)定程序〃時間日期處理程序〃顯示處理程序〃按鍵處理程序〃定時報警功能 (鬧鐘)〃按鍵掃描程序〃星期自動計算與顯示函數(shù)〃判斷是否為閏年//LCD自定義字符程序voidupdate_disbuf(unsignedchart1,unsignedchardisdata口,unsignedchardis_h,unsignedchardis_m,unsignedchardis_s);〃更新顯示緩沖區(qū)函數(shù)voiddelay_18B20(unsignedinti);voidds1820rst();〃延時 1微秒unsignedchards1820rd();//ds1820復(fù)位//DOOvoidds1820wr(unsignedcharwdata);intread_temp();voidds18b20disp();//〃口數(shù)據(jù)〃讀取溫度值并轉(zhuǎn)換〃溫度值顯示子 函 數(shù) 定 義區(qū){uchartemp;switch(month_p){case1:{temp=year_code[table_addr]&0x08;if(temp==0)return(0);elsereturn(1);}case2:{temp=year_code[table_addr]&0x04;if(temp==0)return(0);elsereturn(1);}case3:{temp=year_code[table_addr]&0x02;if(temp==0)return(0);elsereturn(1);}case4:{temp=year_code[table_addr]&0x01;if(temp==0)return(0);elsereturn(1);}case5:{temp=year_code[table_addr+1]&0x80;if(temp==0)return(0);elsereturn(1);}case6:{temp=year_code[table_addr+1]&0x40;if(temp==0)return(0);elsereturn(1);}case7:{temp=year_code[table_addr+1]&0x20;if(temp==0)return(0);elsereturn(1);}case8:{temp=year_code[table_addr+1]&0x10;if(temp==0)return(0);elsereturn(1);}case9:{temp=year_code[table_addr+1]&0x08;if(temp==0)return(0);elsereturn(1);}case10:{temp=year_code[table_addr+1]&0x04;if(temp==0)return(0);elsereturn(1);}case11:{temp=year_code[table_addr+1]&0x02;if(temp==0)return(0);elsereturn(1);}case12:{temp=year_code[table_addr+1]&0x01;if(temp==0)return(0);elsereturn(1);}case13:{temp=year_code[table_addr+2]&0x80;if(temp==0)return(0);elsereturn(1);}}////bitget_moon_day(ucharmonth_p,uinttable_addr)/*子函數(shù) ,////bitget_moon_day(ucharmonth_p,uinttable_addr)/*子函數(shù) ,用于讀取數(shù)據(jù)表中農(nóng)歷月的大月或小月,如果該月為大返回1,為小返回產(chǎn) 生0*//*函數(shù)功能{據(jù):輸入 BCD陽歷數(shù)據(jù) ,輸出 BCD陰歷數(shù)據(jù)//c=0為21世紀(jì),c=1(只允許1901-2099年)*/為19世紀(jì)輸入輸出數(shù)據(jù)均為BCD數(shù)uchartemP0,temp2,temp3,month_p;uinttemp4,table_addr;bitflag2,flag_y;temP0=year/16;//BCD->hex先把數(shù)據(jù)轉(zhuǎn)換為十六進(jìn)制temp2=year%16;year=temP0*10+temp2;temP0=month/16;temp2=month%16;month=temP0*10+temp2;temP0=day/16;temp2=day%16;day=temP0*10+temp2;〃定位數(shù)據(jù)表地址if(c==0){table_addr=(year+0x64-1)*0x3;}else{table_addr=(year-1)*0x3;}〃定位數(shù)據(jù)表地址完成〃取當(dāng)年春節(jié)所在的公歷月份temP0=year_code[table_addr+2]&0x60;temP0=_cror_(temP0,5);〃取當(dāng)年春節(jié)所在的公歷月份完成〃取當(dāng)年春節(jié)所在的公歷日temp2=year_code[table_addr+2]&0x1f;〃取當(dāng)年春節(jié)所在的公歷日完成//計算當(dāng)年春年離當(dāng)年元旦的天數(shù) ,春節(jié)只會在公歷 1月或2月if(temP0==0x1){temp3=temp2-1;}else{temp3=temp2+0x1f-1;}//計算當(dāng)年春年離當(dāng)年元旦的天數(shù)完成〃計算公歷日離當(dāng)年元旦的天數(shù) ,為了減少運算 ,用了兩個表//day_code1[9],day_code2[3]〃如果公歷月在九月或前〃在九月后 ,0000〃如輸入公歷日為〃如輸入公歷日為if(month<10){,天數(shù)會少于0xff,OO0xff,用表 day_code2[3]8月10日,則公歷日離元旦天數(shù)為11月10日,則公歷日離元旦天數(shù)為temp4=day_code1[month-1]+day-1;}else{temp4=day_code2[month-10]+day-1;}if((month>0x2)&&(year%0x4==0)){〃公歷0001day_code1[9],day_code1[8-1]+10-1day_code2[11-10]+10-12月并且該年的20為閏月 ,00加temp4+=1;}〃計算公歷日離當(dāng)年元旦的00完成〃判斷公歷日在春節(jié)前還是春節(jié)后if(temp4>=temp3){〃公歷日在春節(jié)后或就是春節(jié)當(dāng)日使用下面代碼進(jìn)行運算temp4-=temp3;month=0x1;month_p=0x1;//公歷日在春節(jié)前或就是春節(jié)當(dāng)日flag2=get_moon_day(month_p,table_addr);//0000flag_y=0;if(flag2==0)temP0=0x1d;//小月 290elsetemP0=0x1e;//大小 300temp2=year_code[table_addr]&0xf0;temp2=_cror_(temp2,4);〃從數(shù)據(jù)表中取該年的閏00份while(temp4>=temP0){temp4-=temP0;month_p+=1;if(month==temp2){flag_y=~flag_y;if(flag_y==0)month+=1;}elsemonth+=1;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temP0=0x1d;elsetemP0=0x1e;month_p指向首月1,0000 0,如為 0則該年無閏月}day=temp4+1;}else{〃公歷日在春節(jié)前使用下面代碼進(jìn)行運算temp3-=temp4;if(year==0x0){year=0x63;c=1;}elseyear-=1;table_addr-=0x3;month=0xc;temp2=year_code[table_addr]&0xf0;temp2=_cror_(temp2,4);if(temp2==0)month_p=0xc;elsemonth_p=0xd;〃如果當(dāng)年有閏月 ,一年有十三個月 ,月指向 13,無閏口指向 12flag_y=0;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temP0=0x1d;elsetemP0=0x1e;while(temp3>temP0){temp3-=temP0;month_p-=1;if(flag_y==0)month-=1;if(month==temp2)flag_y=~flag_y;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temP0=0x1d;elsetemP0=0x1e;}day=temP0-temp3+1;}c_moon=c; 〃HEX->BCD,運算結(jié)束后 ,把數(shù)據(jù)轉(zhuǎn)換為 BCD數(shù)據(jù)temP0=year/10;temP0=_crol_(temP0,4);temp2=year%10;year_moon=temP0|temp2;temP0=month/10;temP0=_crol_(temP0,4);temp2=month%10;month_moon=temP0|temp2;temP0=day/10;temP0=_crol_(temP0,4);temp2=day%10;day_moon=temP0|temp2;}/********************************農(nóng)歷的產(chǎn)生/******************************液晶驅(qū)動程序voiddelay(unsignedcharms)//延時程序{while(ms--){unsignedchari;for(i=0;i<250;i++){_nop_(); 〃執(zhí)行一條 _nop_()指令為一個機(jī)器周期_nop_();_nop_();_nop_();}}}intlcd_busy()〃測試LCD忙碌狀態(tài){intresult;rs=0;rw=1;ep=1;_nop_();_nop_();_nop_();_nop_();result=(bit)(P0&0x80);//LCD的D0--D7中,D7=1為忙碌,D7=0為空閑ep=0;returnresult;}voidlcd_wcmd(charcmd)〃寫入指令到LCD{while(lcd_busy());//當(dāng)lcd_busy為1時,檢測LCD忙碌狀態(tài),lcd-busy為0時,開始口指令rs=0;rw=0;ep=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();_nop_();ep=1;_nop_();_nop_();_nop_();_nop_();ep=0;}voidlcd_wdat(chardat)〃寫入數(shù)據(jù)到 LCD{while(lcd_busy());//當(dāng)lcd_busy為1時,檢測 LCD忙碌狀態(tài),lcd-busy為0時,開始寫數(shù)據(jù)rs=1;rw=0;ep=0;P0=dat;_nop_();_nop_();_nop_();_nop_();ep=1;_nop_();_nop_();_nop_();_nop_();ep=0;}voidlcd_pos(charpos)//LCD數(shù)據(jù)指針位置程序{lcd_wcmd(pos|0x80);〃數(shù)據(jù)指針 =80+地址碼(00H~27H,40H~67H)}voidlcd_sef_chr()〃設(shè)定二個自定義字符 ,(注意:LCD1602中自定義字符的地址為 0x00—0x07』可定義 8個字符)〃這里我們設(shè)定把一個自定義字符放在 0x00位置(000),另一個放在0x01位子(001){ 〃第一個自定義字符lcd_wcmd(0x40);//"01000000"第1行地址//(D7D6為地址設(shè)定命令形式 D5D4D3為字符存放位置 (0--7),D2D1D0為字符行地口(0--7))lcd_wdat(0x1f); //"XXX11111" 第1行數(shù)據(jù)//D7D6D5為XXX,表示為任意數(shù)(一般用 000),D4D3D2D1D0為字符行數(shù)據(jù)lcd_wcmd(0x41);//"01000001" 第2行地址lcd_wdat(0x11); //"XXX10001" 第 2 行數(shù)據(jù)lcd_wcmd(0x42); //"01000010" 第 3 行地址lcd_wdat(0x15); //"XXX10101" 第 3 行數(shù)據(jù)lcd_wcmd(0x43); //"01000011" 第 4 行地址lcd_wdat(0x11); //"XXX10001" 第 4 行數(shù)據(jù)lcd_wcmd(0x44); //"01000100" 第 5 行地址lcd_wdat(0x1f); //"XXX11111" 第 5 行數(shù)據(jù)lcd_wcmd(0x45); //"01000101" 第 6 行地址lcd_wdat(0x0a); //"XXX01010" 第 6 行數(shù)據(jù)lcd_wcmd(0x46); //"01000110" 第 7 行地址lcd_wdat(0x1f); //"XXX11111" 第 7 行數(shù)據(jù)lcd_wcmd(0x47); //"01000111" 第 8 行地址lcd_wdat(0x00); //"XXX00000" 第 8 行數(shù)據(jù)〃第二個自定義字符lcd_wcmd(0x48);//"01001000"第1行地址lcd_wdat(0x01); //"XXX00001" 第 1 行數(shù)據(jù)lcd_wcmd(0x49); //"01001001" 第 2 行地址lcd_wdat(0x1b); //"XXX11011" 第 2 行數(shù)據(jù)lcd_wcmd(0x4a); //"01001010" 第 3 行地址lcd_wdat(0x1d); //"XXX11101" 第 3 行數(shù)據(jù)lcd_wcmd(0x4b); //"01001011" 第 4 行地址lcd_wdat(0x19); //"XXX11001" 第 4 行數(shù)據(jù)lcd_wcmd(0x4c); //"01001100" 第 5 行地址lcd_wdat(0x1d); //"XXX11101" 第 5 行數(shù)據(jù)lcd_wcmd(0x4d); //"01001101" 第 6 行地址lcd_wdat(0x1b); //"XXX11011" 第 6 行數(shù)據(jù)lcd_wcmd(0x4e); //"01001110" 第 7 行地址lcd_wdat(0x01); //"XXX00001" 第 7 行數(shù)據(jù)lcd_wcmd(0x4f); //"01001111" 第 8 行地址lcd_wdat(0x00); //"XXX00000" 第 8 行數(shù)據(jù)}voidlcd_init()//LCD初始化設(shè)定lcd_wcmd(0x38);〃設(shè)置LCD為16X2顯示,5X7點陣,八位數(shù)據(jù)借口delay(1);lcd_wcmd(0x0c);//LCD開顯示及光標(biāo)設(shè)置(光標(biāo)不閃爍,不顯示 "-")delay(1);lcd_wcmd(0x06);//LCD顯示光標(biāo)移動設(shè)置(光標(biāo)地址指針加1,整屏顯示不移動 )delay(1);lcd_wcmd(0x01);〃清除 LCD的顯示內(nèi)容delay(1);intleap_year()〃閏年的計算{intleap;if((year%4==0&&year%100!=0)llyear%400==0)〃閏年的條件leap=1;elseleap=0;returnleap;}unsignedcharweek_proc()〃星期的自動運算和處理{unsignedcharnum_leap;unsignedcharc;num_leap=year/4-year/100+year/400;//自00年起到y(tǒng)ear所經(jīng)歷的閏年數(shù)if(leap_year()&&month<=2) 〃既是閏年且是 1月和2月c=5;elsec=6;week=(year+para_month[month]+date+num_leap+c)%7;//計算對應(yīng)的星期returnweek;}voidpro_timedate()〃時間和日期處理程序{sec++;if(sec>59){sec=0;min++;if(min>59){min=0;hour++;if(hour>23){hour=0;date++;if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)if(date>31){date=1;month++;}if(month==4llmonth==6llmonth==9llmonth==11)if(date>30){date=1;month++;}if(month==2){if(leap_year()){if(date>29){date=1;month++;}}else{if(date>28){date=1;month++;}}}if(month>12){month=1;year++;}if(year>99)year=0;}}}week_proc();if(sec==armsec&&min==armmin&&hour==armhour){if(alarm)SPK=0;〃鬧鐘啟用時,報警時間到,啟動 Timer1}if(sec==(armsec+15)&&min==armmin&&hour==armhour){if(alarm)SPK=1;〃鬧鐘啟用時,報警時間到 ,啟動Timer1voidtimer0()interrupt1//Timer。中斷處理程序 ,秒的產(chǎn)生{TH0=0xdc;TL0=0x06;sec100++;〃大月 31天〃小月 30天〃閏年的條件〃閏年 2月為 29天〃平年 2月為 28天//Timer。置10ms定時初值 dc00H(2A16=65536D,dc06H=56326D)〃定時時間 =(65536-56326)*(1/12.0)*12=10ms(f0=12.0Mhz)if(sec100>=100)//1秒時間 (100*10ms=1000ms=1s){sec100=0;pro_timedate();〃調(diào)用時間和日期處理程序}update_disbuf(0x00,disdata,hour,min,sec);//0x00表示顯示00位置的自定義字符pro_display(); 〃調(diào)用顯示處理函數(shù)unsignedcharscan_key()〃給變量 vkey置初值〃給變量 vkey置初值〃讀取PRE鍵的狀態(tài)〃將PREDOODOOskey的B1〃讀取SET鍵的狀態(tài) ,并存于 skey的〃返回 skey的鍵值 (即PRE,SETOOD)voidint0()interrupt0〃外部中斷 INT0中斷處理程序{TR0=0;IE=0;lcd_wcmd(0x0e);alarm=1;〃禁止 Timer。〃禁止中斷〃顯示光標(biāo) ”,整個光標(biāo)不閃爍〃按鍵掃描程序{skey=0x00;skeyl=PRE;skey=skey<<1;位skeyl=SET;B0位returnskey;}flag=0;vkey=0x03;while(flagA0x0a){skey=scan_key();if(skeyAvkey){delay(10);skey=scan_key();flag=0;vkey=0x03;while(flagA0x0a){skey=scan_key();if(skeyAvkey){delay(10);skey=scan_key();if(skeyAvkey)〃掃描按鍵狀態(tài)〃若skey與vkey相同跳出 ,相異執(zhí)行〃去按鍵抖動〃轉(zhuǎn)回掃描按鍵狀態(tài)〃若skey與vkey相同跳出 ,相異執(zhí)行vkey=skey;if(skey==0x01)〃將skey的值付給vkey//PRE鍵按下pro_display();lcd_pos(0x47);〃調(diào)用顯示處理程序〃使光標(biāo)位于第一個調(diào)整項下{flag++;//調(diào)整標(biāo)志位加 1switch(flag)〃將光標(biāo)置于相應(yīng)調(diào)整位置{lcd_pos(0x49);break;〃光標(biāo)置小時報警設(shè)置位置lcd_pos(0x4c);break;〃光標(biāo)置分鐘報警設(shè)置位置lcd_pos(0x4f);break;
〃光標(biāo)置秒時報警設(shè)置位置update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x05);break;〃光標(biāo)置年調(diào)整位置lcd_pos(0x08);break;〃光標(biāo)置月調(diào)整位置lcd_pos(0x0b);break;〃光標(biāo)置日調(diào)整位置lcd_pos(0x49);break;〃光標(biāo)置時調(diào)整位置lcd_pos(0x4c);break;〃光標(biāo)置分調(diào)整位置lcd_pos(0x4f);break;〃光標(biāo)置秒調(diào)整位置default:break;}}//SET鍵按下〃轉(zhuǎn)設(shè)置按鍵處理程序//SET鍵按下〃轉(zhuǎn)設(shè)置按鍵處理程序〃設(shè)置 LCD開顯示及光標(biāo)不閃爍〃清除 LCD的顯示內(nèi)容//CPU開中斷,INT0,INT1』中斷//Timer。啟動{pro_key();}}}}lcd_wcmd(0x0c);不顯示"-"lcd_wcmd(0x01);IE=0x8f;TR0=1;}voidpro_key()〃設(shè)置按鍵處理程序{switch(flag){case0:alarm=!alarm;〃啟用或關(guān)閉鬧鐘( alarm=1:啟用,alarm=0:關(guān)閉)update_disbuf(0x50,"alar:",armhour,armmin,armsec);〃更新顯示數(shù)據(jù)pro_display();〃調(diào)用顯示處理lcd_pos(0x47);break;〃光標(biāo)回到原調(diào)整位置case1:armhour++;if(armhour>23)armhour=0;update_disbuf(0x50,"alar:",armhour,armmin,armsec);〃更新顯示數(shù)據(jù)pro_display();〃調(diào)用顯示處理lcd_pos(0x49);break;〃光標(biāo)回到原調(diào)整位置case2:armmin++;if(armmin>59)armmin=0;update_disbuf(0x50,"alar:",armhour,armmin,armsec);pro_display();lcd_pos(0x4c);break;case3:armsec++;if(armsec>59)armsec=0;update_disbuf(0x50,"alar:",armhour,armmin,armsec);pro_display();lcd_pos(0x4f);break;case4:year++;if(year>99)year=0;week_proc(); 〃星期自動運算update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x05);break;case5:month++;if(month>12)month=1;week_proc(); 〃星期自動運算update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x08);break;case6:date++;if(month==1||month==3||month==5||month==7
||month==8||month==10||month==12)if(date>31)date=1; 〃大月 31天if(month==4||month==6||month==9||month==11)if(date>30)date=1; 〃小月30天if(month==2){if(leap_year()) 〃閏年的條件29天{if(date>29)date=1;} 〃閏年2月為29天else{if(date>28)date=1;}} 〃平年 2月為28天week_proc(); 〃星期自動運算update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x0b);break;case7:hour++;if(hour>23)hour=0;update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x49);break;case8:min++;if(min>59)min=0;update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x4c);break;case9:sec++;if(sec>59)sec=0;update_disbuf(0x50,"time:",hour,min,sec);pro_display();lcd_pos(0x4f);break;default:break;}}/********************萬年口及/********************萬年口及溫度溫馨提示的顯示等voidupdate_disbuf(unsignedchart1,unsignedchardisdata口,unsignedchardis_h,unsignedchardis_m,unsignedchardis_s)〃更新顯示緩沖區(qū){inti=0;unsignedcharcodedis1[16]={"Cold!Wearmore!"};〃原來空格也算進(jìn)去了,如此unsignedcharcodedis2[16]={"Agoogweather!!"};unsignedcharcodedis3[16]={"Hot!Iwantice!"};ds18b20disp();dis_buf2[0]=disdata[0];dis_buf2[1]=disdata[1];dis_buf2[2]=disdata[2];dis_buf2[3]=disdata[3];dis_buf2[4]=disdata[4];if(dis_buf2[3]==0x2e){dis_buf2[5]=0xdf;dis_buf2[6]='C';}else{dis_buf2[5]=0x20;dis_buf2[6]=0x20;}if(alarm)dis_buf2[7]=0x01; //alarm=1,顯示鬧鐘啟用標(biāo)致(第二個自定義字符)elsedis_buf2[7]=0x20; //alarm=0,不顯示鬧鐘啟用標(biāo)致dis_buf2[8]=dis_h/10+48;dis_buf2[9]=dis_h%10+48;dis_buf2[10]=0x3a; //':'dis_buf2[11]=dis_m/10+48;dis_buf2[12]=dis_m%10+48;dis_buf2[13]=0x3a; //':'dis_buf2[14]=dis_s/10+48;dis_buf2[15]=dis_s%10+48;if(dis_buf2[15]-48==7|dis_buf2[15]-48==8){if(dis_buf2[1]-48==0|dis_buf2[1]-48==1){for(i=0;i<16;i++)dis_buf1[i]=dis1[i];}elseif(dis_buf2[1]-48==2){for(i=0;i<16;i++)dis_buf1[i]=dis2[i];}
else{for(i=0;i<16;i++)dis_buf1[i]=dis3[i];}}elseif(dis_buf2[15]-48==3|dis_buf2[15]-48==4){Conversion(0,year,month,date);dis_buf1[0]='L';dis_buf1[1]='u';dis_buf1[2]='n';dis_buf1[3]='n';dis_buf1[4]='a';dis_buf1[5]='r';dis_buf1[6]=50;dis_buf1[7]=48;dis_buf1[8]=year_moon/16+48;dis_buf1[9]=year_moon%16+48;dis_buf1[10]=0x2d;dis_buf1[11]=month_moon/16+48;dis_buf1[12]=month_moon%16+48;dis_buf1[13]=0x2d;dis_buf1[14]=day_moon/16+48;dis_buf1[15]=day_moon%16+48;}else{TOC\o"1-5"\h\zdis_buf1[0]=t1; //dis_buf1[1]=0x20; 〃空格dis_buf1[2]=50; //'2'dis_buf1[3]=48; //'0'dis_buf1[4]=year/10+48;dis_buf1[5]=year%10+48;dis_buf1[6]=0x2d;dis_buf1[7]=month/10+48;dis_buf1[8]=month%10+48;dis_buf1[9]=0x2d; //'-'dis_buf1[10]=date/10+48;dis_buf1[11]=date%10+48;dis_buf1[12]=0x20;dis_buf1[13]=dis_week[4*week];dis_buf1[14]=dis_week[4*week+1];dis_buf1[15]=dis_week[4*week+2];}}voidpro_display()〃顯示處理程序{unsignedchari;lcd_pos(0x00);for(i=0;i<=15;i++){lcd_wdat(dis_buf1[i]);}lcd_pos(0x40);for(i=0;i<=15;i++)
{l
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025排污許可證轉(zhuǎn)讓合同
- 2025拆遷房屋買賣合同范文
- 二零二五版教育培訓(xùn)機(jī)構(gòu)董事會一致行動人資源共享協(xié)議3篇
- 2025年度綠色大米采購與銷售合作協(xié)議范本4篇
- 二零二五版高端公寓地暖系統(tǒng)安裝及維護(hù)合同3篇
- 基于多特征信息融合的實體對齊方法研究
- 不同林齡興安落葉松人工林植被碳密度對溫度梯度的響應(yīng)
- 糙米皮胚分離技術(shù)與適碾米食用品質(zhì)的研究
- 二零二五情侶戀愛期間生活禮儀與修養(yǎng)協(xié)議2篇
- 2025年度民宿布草租賃與民宿客棧客戶滿意度提升合同4篇
- 2024公路瀝青路面結(jié)構(gòu)內(nèi)部狀況三維探地雷達(dá)快速檢測規(guī)程
- 2024年高考真題-地理(河北卷) 含答案
- 2024光儲充一體化系統(tǒng)解決方案
- 處理后事授權(quán)委托書
- 食材配送服務(wù)方案投標(biāo)方案(技術(shù)方案)
- 足療店營銷策劃方案
- 封條(標(biāo)準(zhǔn)A4打印封條)
- 2024年北京控股集團(tuán)有限公司招聘筆試參考題庫含答案解析
- 延遲交稿申請英文
- 運動技能學(xué)習(xí)與控制課件第十章動作技能的指導(dǎo)與示范
- 石油天然氣建設(shè)工程交工技術(shù)文件編制規(guī)范(SYT68822023年)交工技術(shù)文件表格儀表自動化安裝工程
評論
0/150
提交評論