基于单片机函数发生器系统设计论文_第1页
基于单片机函数发生器系统设计论文_第2页
基于单片机函数发生器系统设计论文_第3页
基于单片机函数发生器系统设计论文_第4页
基于单片机函数发生器系统设计论文_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

沈阳航空航天大学北方科技学院毕业设计(论文)结束语在本次设计的过程中,我学会了怎样把所学的书本知识应用于实践中去,并学会了如何去思考整个控制系统的软硬件设计。实践过程中我遇到了一些困难,但在解决问题的过程中,我学会了怎样发现问题、分析问题,进而解决问题。此次毕业设计,使我不仅对单片机这门课程有了更深刻的认识,懂得了如何运用课本知识结合实际来完成定时器的显示和编程方法以及显示电路的驱动方法,使我能够很快的适应现代控制技术发展的需求,同时也提高了我的思维能力和实际操作能力,为以后更好的走上工作岗位奠定了坚实的基础。致谢本设计在指导老师的悉心指导和严格要求下已完成本次设计,从课题选择、方案论证到具体设计和调试,无不凝聚着老师的心血和汗水,老师在我做毕业设计的每个阶段,都给予我耐心的指导和帮助。可以说,没有老师的耐心指导和帮助,我是不可能顺利完成我的毕业设计的。另外,老师严谨的治学态度以及对待学生极端负责的精神,给我留下很深的印象,并将积极影响我今后的学习和工作。在四年的本科学习和生活期间,也始终感受着导师的精心指导和无私的关怀,我受益匪浅。在此向老师表示深深的感谢和崇高的敬意。四年寒窗,所收获的不仅仅是愈加丰厚的知识,更重要的是在阅读、实践中所培养的思维方式、表达能力和广阔视野。很庆幸这四年来我遇到了如此多的良师益友,无论在学习上、生活上,还是工作上,都给予了我无私的帮助和热心的照顾,让我在一个充满温馨的环境中度过四年的大学生活。感恩之情难以用言语量度,谨以最朴实的话语致以最崇高的敬意。参考文献[1]贾金玲等.单片机原理及应用.成都:电子科技大学出版社,2004[2]胡汉才.单片机原理及其接口技术.北京:清华大学出版社,2004[3]张毅刚.MCS-51单片机原理及应用.哈尔滨:哈尔滨工业大学出版社,1990[4]潘新民.单片机实用系统.北京:人民邮政出版社,2001[5]胡汉才.主编单片机原理及其接口技术清华大学出版社,1996.[6]靳桅等.基于51系列单片机的LED显示屏开发技术[M].北京:北京航空航天大学出版社,2009[7]蒋辉平.基于Proteus的单片机系统设计与仿真实例[M].北京:机械工业出版社,2009[8]周润景.PROTEUS入门实用教程[M].北京:机械工业出版社,2007.[9]胡汉才.单片机原理及其接口技术[M].2版.北京:清华大学出版社,2004.[10]徐爱钧.8051单片机实践教程[M].北京:电子工业出版社,2005.[11]张义和.例说51单片机:C语言版[M].北京:人民邮电出版社,2008[12]赵建领.51系列单片机开发宝典[M].北京:电子工业出版社,2007[13]赵建领.Protel电路设计与制版宝典[M].北京:电子工业出版社,2007[14]赵建领.Protel99SE设计宝典[M].北京:电子工业出版社,2007[15]江志红.51单片机技术与应用系统开发案例精选[M].北京:电子工业出版社,2007附录Ⅰ电路图附录Ⅱ实物图附录Ⅲ系统元件清单元器件名称型号个数51单片机AT89C521数模转换芯片DAC08321运放LM3241晶振11.0592MHz1电阻4701电阻1k4电阻10k8排阻10k1独石电容30p2铝电解电容470u2铝电解电容220u1铝电解电容10u1附录Ⅳ主控单片机程序清单 #include<reg52.h>#defineLCDLCDDisp_Off0x3e#defineLCDLCDDisp_On0x3f#definePage_Add0xb8//页地址#defineLCDCol_Add0x40//列地址#defineStart_Line0xC0//行地址/*****液晶显示器的端口定义*****/#definedata_oraP0/*液晶数据总线*/sbitLCDMcs=P2^1;/*片选1*/sbitLCDScs=P2^2;/*片选2*/sbitRESET=P2^3;/*复位信号*/sbitLCDDi=P2^4;/*数据/指令选择*/sbitLCDRW=P2^5;/*读/写选择*/sbitLCDEnable=P2^6;/*读/写使能*/#defineucharunsignedchar#defineuintunsignedintuchari,sqar_num=128;ucharcho=0;//0:正弦波。1:方波。2:三角波。3:锯齿波。ucharnum=0;ucharTIME0_H=255,TIME0_L=176;//定时器0的初值设置;全局变量.对应正弦波,锯齿波50HZsbitkey=P3^4;ucharx1=0,x2=0;sbitcs=P3^7; //DAC0832控制ucharFREQ=30;//初始化频率,30HZucharflag1;ucharg=3,d=0;/*源文件/文字:F:\LD测试仪\液晶\字模提取+排版软件\液晶字模提取\图例\wo.bmp宽×高(像素):16×字模格式/大小:单色点阵液晶字模,纵向取模,字节倒序/32字节数据转换日期:2010-7-2817:10:17*/ucharcodeBozi[]={0x10,0x04,0x60,0x04,0x02,0x7C,0x0C,0x03,0xC0,0x80,0x00,0x60,0xF8,0x1F,0x88,0x80,0x88,0x43,0x88,0x2C,0xFF,0x10,0x88,0x28,0x88,0x46,0xA8,0x81,0x18,0x80,0x00,0x00//波};ucharcodeFangzi[]={0x08,0x00,0x08,0x80,0x08,0x40,0x08,0x20,0x08,0x18,0xF8,0x07,0x89,0x00,0x8E,0x00,0x88,0x40,0x88,0x80,0x88,0x40,0x88,0x3F,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00//方};ucharcodeJiaozi[]={0x20,0x80,0x10,0x60,0xE8,0x1F,0x24,0x09,0x27,0x09,0x24,0x09,0x24,0x09,0xE4,0x7F,0x24,0x09,0x34,0x09,0x2C,0x49,0x20,0x89,0xE0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00//角};ucharcodeSanzi[]={0x00,0x20,0x04,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x04,0x20,0x00,0x20,0x00,0x00//三};ucharcodeZhengzi[]={0x00,0x40,0x02,0x40,0x02,0x40,0xC2,0x7F,0x02,0x40,0x02,0x40,0x02,0x40,0xFE,0x7F,0x82,0x40,0x82,0x40,0x82,0x40,0x82,0x40,0x82,0x40,0x02,0x40,0x00,0x40,0x00,0x00//正};ucharcodeXianzi[]={0x02,0x00,0xE2,0x43,0x22,0x82,0x22,0x42,0x3E,0x3E,0x00,0x00,0x08,0x21,0x88,0x71,0x48,0x29,0x39,0x25,0x0E,0x23,0x08,0x21,0xC8,0x28,0x08,0x70,0x08,0x00,0x00,0x00//弦};ucharcodeChizi[]={0x40,0x00,0x40,0x00,0x40,0x7F,0x7C,0x40,0x40,0x50,0x40,0x48,0x40,0x44,0x7F,0x43,0x44,0x44,0x44,0x48,0x44,0x50,0x44,0x40,0x44,0xFF,0x40,0x00,0x40,0x00,0x00,0x00//齿};ucharcodeJvzi[]={0x40,0x01,0x30,0x01,0xEF,0x7F,0x24,0x21,0x24,0x91,0x00,0x60,0xFE,0x1F,0x92,0x00,0x92,0xFC,0x92,0x44,0xF2,0x47,0x92,0x44,0x92,0x44,0x9E,0xFC,0x80,0x00,0x00,0x00//锯};ucharcodeLing[]={0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00//0};ucharcodeYi[]={0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00//1};ucharcodeEr[]={0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00//2};ucharcodeSa[]={0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00//3};ucharcodeSi[]={0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00//4};ucharcodeWu[]={0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00//5};ucharcodeLiu[]={0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00//6};ucharcodeQ[]={0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00//7};ucharcodeBa[]={0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00//8};ucharcodeJiu[]={0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00//9};ucharcodeH[]={0x08,0x20,0xF8,0x3F,0x08,0x21,0x00,0x01,0x00,0x01,0x08,0x21,0xF8,0x3F,0x08,0x20//H};ucharcodeZ[]={0x10,0x20,0x08,0x38,0x08,0x26,0x08,0x21,0xC8,0x20,0x38,0x20,0x08,0x18,0x00,0x00//Z};/****************************************************************************函数功能:LCD延时程序入口参数:t出口参数:****************************************************************************/voidLCDdelay(unsignedintt){ unsignedinti,j; for(i=0;i<t;i++); for(j=0;j<10;j++);}/****************************************************************************状态检查,LCD是否忙*****************************************************************************/voidCheckState() {unsignedchardat,DATA;//状态信息(判断是否忙)LCDDi=0;//数据\指令选择,D/I(RS)="L",表示DB7∽DB0为显示指令数据LCDRW=1;//R/W="H",E="H"数据被读到DB7∽DB0do{DATA=0x00;LCDEnable=1; //EN下降源 LCDdelay(2);//延时 dat=DATA;LCDEnable=0;dat=0x80&dat;//仅当第7位为0时才可操作(判别busy信号)}while(!(dat==0x00));} /*****************************************************************************函数功能:写命令到LCD程序,RS(DI)=L,RW=L,EN=H,即来一个脉冲写一次入口参数:cmdcode出口参数:*****************************************************************************/voidwrite_com(unsignedcharcmdcode){CheckState();//检测LCD是否忙 LCDDi=0; LCDRW=0; P0=cmdcode; LCDdelay(2); LCDEnable=1; LCDdelay(2); LCDEnable=0;} /*****************************************************************************函数功能:LCD初始化程序入口参数:出口参数:*****************************************************************************/voidinit_lcd(){ LCDdelay(100); LCDMcs=1;//刚开始关闭两屏 LCDScs=1; LCDdelay(100); write_com(LCDLCDDisp_Off); //写初始化命令 write_com(Page_Add+0); write_com(Start_Line+0); write_com(LCDCol_Add+0); write_com(LCDLCDDisp_On);} /*****************************************************************************函数功能:写数据到LCD程序,RS(DI)=H,RW=L,EN=H,即来一个脉冲写一次入口参数:LCDDispdata出口参数:*****************************************************************************/voidwrite_data(unsignedcharLCDDispdata){CheckState();//检测LCD是否忙 LCDDi=1; LCDRW=0; P0=LCDDispdata; LCDdelay(2); LCDEnable=1; LCDdelay(2); LCDEnable=0;} /*****************************************************************************函数功能:清除LCD内存程序入口参数:pag,col,hzk出口参数:*****************************************************************************/voidClr_Scr(){ unsignedcharj,k; LCDMcs=0;//左、右屏均开显示 LCDScs=0; write_com(Page_Add+0); write_com(LCDCol_Add+0); for(k=0;k<8;k++)//控制页数0-7,共8页 { write_com(Page_Add+k);//每页每页进行写 for(j=0;j<64;j++)//每页最多可写32个中文文字或64个ASCII字符 { write_com(LCDCol_Add+j); write_data(0x00);//控制列数0-63,共64列,写点内容,列地址自动加1 } }} /*****************************************************************************函数功能:指定位置显示汉字16*16程序入口参数:page,column,hzk出口参数:*****************************************************************************/voidhz_LCDDisp16(unsignedcharpage,unsignedcharcolumn,unsignedcharcount,unsignedcharcode*hzk){ unsignedcharj=0,i=0; write_com(Page_Add+page); write_com(LCDCol_Add+column); for(i=0;i<count;i++)write_data(hzk[i*2]); write_com(Page_Add+page+1); write_com(LCDCol_Add+column); for(i=0;i<count;i++) write_data(hzk[1+i*2]); }/* voiddelay(unsignedintms){ uinti,j; for(j=0;j<ms;j++) for(i=0;i<120;i++);}*/ucharcodesin_num[]={0x80,0x82,0x85,0x88,0x8b,0x8e,0x91,0x94,0x97,0x9a,0x9d,0xa0,0xa3,0xa6, 0xa9,0xac,0xaf,0xb2,0xb6,0xb9,0xbc,0xbf,0xc2,0xc5,0xc7,0xca,0xcc,0xcf, 0xd1,0xd4,0xd6,0xd8,0xda,0xdd,0xdf,0xe1,0xe3,0xe5,0xe7,0xe9,0xea,0xec, 0xee,0xef,0xf1,0xf2,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd, 0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xfe,0xfd,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf4,0xf2,0xf1, 0xef,0xee,0xec,0xea,0xe9,0xe7,0xe5,0xe3,0xe1,0xde,0xdd,0xda,0xd8,0xd6, 0xd4,0xd1,0xcf,0xcc,0xca,0xc7,0xc5,0xc2,0xbf,0xbc,0xba,0xb7,0xb4,0xb1, 0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x99,0x96,0x93,0x90,0x8d,0x89,0x86, 0x83,0x80, 0x80,0x7c,0x79,0x76,0x72,0x6f,0x6c,0x69,0x66,0x63,0x60,0x5d, 0x5a,0x57,0x55,0x51,0x4e,0x4c,0x48,0x45,0x43,0x40,0x3d,0x3a,0x38,0x35, 0x33,0x30,0x2e,0x2b,0x29,0x27,0x25,0x22,0x20,0x1e,0x1c,0x1a,0x18,0x16, 0x15,0x13,0x11,0x10,0x0e,0x0d,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04, 0x03,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x02,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b, 0x0d,0x0e,0x10,0x11,0x13,0x15,0x16,0x18,0x1a,0x1c,0x1e,0x20,0x22,0x25, 0x27,0x29,0x2b,0x2e,0x30,0x33,0x35,0x38,0x3a,0x3d,0x40,0x43,0x45,0x48, 0x4c,0x4e,0x51,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66,0x69,0x6c,0x6f,0x72, 0x76,0x79,0x7c,0x80 /* 135,145,158,167,176,188,199,209,218,226,234,240,245,249,252,254,254,253,251,247,243,237,230,222,213,204,193,182,170,158,146,133,121,108,96,84,72,61,50,41,32,24,17,11,7,3,1,0,0,2,5,9,14,20,28,36,45,55,66,78,90,102,114,128*/};ucharcodesanjiao_num[]={ 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52, 54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102, 104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140, 142,144,146,148,150,152,154,158,160,162,164,166,168,170,172,174,176,178,180, 182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218, 220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,255, 254,252,250,248,246,244,242,240,238,236,234,232,230,228,226,224,222,220,218, 216,214,212,210,208,206,204,202,200,198,196,194,192,190,188,186,184,182,180, 178,176,174,172,170,168,166,164,162,160,158,154,152,150,148,146,144,142,140, 138,136,134,132,130,128,126,124,122,120,118,116,114,112,110,108,106,104,102, 100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52, 50,48,46,44,42,40,38,36,34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2,0,};//波形发生函数voidsint(void){cs=0;P1=sin_num[num++];cs=1;}voidsquare(void){if(i++<sqar_num){cs=0;P1=0XFF;cs=1;} else{cs=0;P1=0X00;cs=1;}}voidtriangle(void){cs=0;P1=num++;cs=1;}voidstw(void){ cs=0;P1=sanjiao_num[num++];cs=1;}voidmain(){ init_lcd(); Clr_Scr();TMOD=0X01;TH0=0xff;TL0=0xd9;IT0=1;//设置中断触发方式,下降沿EA=1;EX0=1;ET0=1;IP=0X05;//键盘中断级别高 IT1=1;//设置中断触发方式,下降沿EX1=1; PX1=1;//键盘中断级别?TR0=1;while(1){LCDMcs=0;//左屏开显 LCDScs=1; if(cho==0) { hz_LCDDisp16(3,16,16,Zhengzi); hz_LCDDisp16(3,32,16,Xianzi); } if(cho==1) { hz_LCDDisp16(3,16,16,Fangzi); hz_LCDDisp16(3,32,16,Bozi); }if(cho==2) { hz_LCDDisp16(3,16,16,Sanzi); hz_LCDDisp16(3,32,16,Jiaozi); } if(cho==3) { hz_LCDDisp16(3,16,16,Jvzi); hz_LCDDisp16(3,32,16,Chizi); }LCDMcs=1;//右屏开显 LCDScs=0; hz_LCDDisp16(3,24,8,H);hz_LCDDisp16(3,32,8,Z);switch(g){ case0:{break;} case1:{hz_LCDDisp16(3,8,8,Yi);break;} case2:{hz_LCDDisp16(3,8,8,Er);break;}case3:{hz_LCDDisp16(3,8,8,Sa);break;} case4:{hz_LCDDisp16(3,8,8,Si);break;} case5:{hz_LCDDisp16(3,8,8,Wu);break;} case6:{hz_LCDDisp16(3,8,8,Liu);break;} case7:{hz_LCDDisp16(3,8,8,Q);break;} case8:{hz_LCDDisp16(3,8,8,Ba);break;} case9:{hz_LCD

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论