单片机实习报告 .doc

上传人:飞****2 文档编号:56543444 上传时间:2022-11-02 格式:DOC 页数:25 大小:377.50KB
返回 下载 相关 举报
单片机实习报告 .doc_第1页
第1页 / 共25页
单片机实习报告 .doc_第2页
第2页 / 共25页
点击查看更多>>
资源描述

《单片机实习报告 .doc》由会员分享,可在线阅读,更多相关《单片机实习报告 .doc(25页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、长 沙 学 院单片机原理课程设计说明书题目学校作息时间控制系统设计系(部)电子与通信工程专业(班级)电子信息工程2班姓名戴世稳学号指导教师刘辉、王新辉起止日期2012-12-04单片机原理及应用课程设计任务书系(部):电信系 专业:2010级电子信息工程 指导教师:王新辉、刘辉课题名称学校作息时间控制系统的设计设计内容及要求(1)课题内容:以单片机为核心,设计一个智能化作息时间控制器。该控制器要求的功能有:按本校作息时间接通/断开电铃;并用12864液晶屏的第一行显示本人的姓名和学号,第二行显示实时时钟。作息时间控制器用于学校教学楼的时间控制,利用单片机内部定时器实现时间基准定时,显示的内容要

2、求有时、分、秒各两位,并能调节小时和分钟。发挥部分:可以通过键盘任意调整响铃时间。(2)要求:完成该系统的硬件和软件的设计,在Proteus软件上仿真通过后,下载到单片机实验板验证。最后就课程设计本身提交一篇课程设计说明书。设计工作量1、汇编或C51语言程序设计;2、程序调试;3、在Proteus上进行仿真成功后,进行实验板下载调试;4、提交一份完整的课程设计说明书,包括设计原理、程序设计、程序分析、仿真分析、调试过程,参考文献、设计总结等。进度安排起止日期(或时间量)设计内容(或预期目标)备注第一天课题介绍,答疑,收集材料,C51介绍第二天设计方案论证,练习编写C51程序第三天第六天程序设计

3、第六天第八天 程序调试、仿真第九天第十天系统测试并编写设计说明书教研室意见年 月 日系(部)主管领导意见年 月 日长沙学院课程设计鉴定表姓名戴世稳学号专业电子信息工程班级2班设计题目学校作息时间控制系统的设计指导教师刘辉、王新辉指导教师意见:评定等级: 教师签名: 日期: 答辩小组意见:评定等级:答辩小组长签名:日期:教研室意见:教研室主任签名: 日期: 系(部)意见:系主任签名:日期:说明课程设计成绩分“优秀”、“良好”、“及格”、“不及格”四类;目 录1、系统总体方案选择与说明12、系统结构框图与工作原理12.1 设计方块12.2 单片机核心模块2 2.3 LCD液晶显示模块22.4 声音

4、模块22.5 调节模块23、软件设计与说明34、调试结果与必要的调试说明55、使用说明76、课程设计体会77、参考文献88、附录:程序清单8一、系统总体方案选择与说明题设计是一个具有打铃、广播功能的作息时间控制系统。采用SG12864液晶具有良好的菜单式人机界面更使本系统增色不少。由单片机核心控制模块、调节模块、时间模块、LCD液晶显示模块、声音模块5个部分组成。现代机关企业,特别是学校要求对时间加以控制,要按时打铃及播放广播,以保证学习与工作的正常运行。本课题设计实现了这些功能,给学校及其他机关企业带来方便,整体性好,人性化强、可靠性高,实现了对时间控制的智能化。通过对单片机最小系统的研究,

5、进一步深化和巩固所学基础理论、专业知识及实验技能,提高学生的技术应用能力,使学生了解和掌握单片机应用系统的软、硬件设计过程、方法及实现,为以后设计和实现单片机应用系统打下良好基础。二、系统结构框图与工作原理2.1 设计示意图 单片机AT89C51LCD显示模块声音模块调节模块图2-1 系统电路框图以单片机为核心,设计一个智能化作息时间控制器。该控制器要求的功能有:按本校作息时间接通/断开电铃;并用12864液晶屏的第一行显示本人的姓名和学号,第二行显示实时时钟。作息时间控制器用于学校教学楼的时间控制,利用单片机内部定时器实现时间基准定时,显示的内容要求有时、分、秒各两位,并能调节小时和分钟。2

6、.2 单片机核心控制模块采用AT89C51,它具有Flash ROM,内部具有4KB ROM 存储空间,能于3V的超低压工作,而且与MCS-51系列单片机完全兼容。2.3 LCD液晶显示模块LCD12864为128*64点阵型液晶显示模块,可显示各种字符及图形,可与CPU直接接口,具有8位标准数据总线、6条控制线及电源线,采用KS0107控制IC。该模块包括的函数为LCD_inti()/LCD 的初始化、checkbusy()/检查LCD是否忙碌、 writecode()/写命令、 writedata()/写数据、hanzi()/显示汉字、 zifu()/显示数字或字符。2.4 声音模块电路板

7、上的主控模块直接接一个蜂鸣器,构成一个简单的音响电路,该电路利用单片机的一个引脚作为音源,一个引脚接高电平,导通时,蜂鸣器发声,比一个引脚接地时候的声音要大些。脉冲信号的频率决定了其发出声音的音调。该模块比较简单,其函数为void s_fmq()/蜂鸣器叫 、nling()/判断是否闹铃。2.5 调节模块该模块要实现6个模式的调节和转变。调节模式的实现只用了三个按钮,分别是Mode 、Inc和Dec按钮。图2-2 电路原理图三、软件设计与说明开始作息时间控制子程序比较时、分、秒参数送12864初始化程序是闹铃响10s12864初始化到“8:00”?否读、写日期和时间到“8:45”?闹铃响10s

8、是否T0初始化键盘扫描子程序是到“8:55”?闹铃响10s作息时间控制子程序比较否是闹铃响10s返回到“20:40”?保护现场 图3-2 主程序流程图返回图3-1 作息时间控制子程序流程图键盘扫描子程序Mode键有效,修改时间Inc键有效Dec键有效分加1时加Mode键有效,修改闹铃的小时等待按键程序Inc键有效Dec键有效时加1时减1Mode键有效,修改时间等待按键程序Inc键有效Dec键有效月加1日加1Mode键有效,修改闹铃的分等待按键程序Inc键有效Dec键有效分加1分减1Mode键有效,闹铃设置等待按键程序Inc键有效Dec键有效组数减1组数加1Mode有效,返回主程序等待按键程序图

9、3-3 键盘扫描子程序流程图四、程序清单/*/#include#include#define LCD P0sbit P07=P07; /小数点控制I0sbit mode=P10;/key1分sbit inc=P11;/kye2时sbit dec=P12;/key3 闹铃sbit fmq=P17;/蜂鸣器接口sbit RW=P21;sbit RS=P22;sbit CS1=P24;sbit CS2=P23;sbit BUSY=P00;sbit E=P20;unsigned char a,i,j,k;unsigned char count,hour,minute,second; /用于表,45示时

10、间unsigned char mode_value=0 ,xf; /调节模式unsigned char month=12 ,day=3; /用于表示日期unsigned char h1,h2,f1,f2,s1,s2=0; /用于显示时间unsigned char m1,m2;d1,d2; /用于显示日期unsigned char ds202 = 8,0,8,45,8,55,9,40,10,0,10,45,10,55,11,40,14,0,14,45,14,55,15,40,16,0,16,45,16,55,17,40,19,0,19,45,19,55,20,40; /用于定时闹铃unsigne

11、d char code zi3416=0x08,0xEA,0xAA,0xAA,0xEF,0xAA,0xAA,0xEA,0x08,0x08,0xFF,0x08,0x0A,0xCC,0x08,0x00,0x20,0xAB,0x7E,0x2A,0x2B,0x2A,0x7E,0xAB,0xA0,0x40,0x27,0x18,0x26,0x41,0xF0,0x00, /*戴,0*/0x20,0x20,0x20,0xFE,0x20,0x20,0xFF,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x4

12、7,0x44,0x44,0x44,0x47,0x40,0x40,0x40,0x00,0x00, /*世,1*/0x24,0x24,0xA4,0xFE,0xA3,0x22,0x08,0x94,0x92,0x93,0x92,0x9A,0x96,0xF0,0x00,0x00,0x08,0x06,0x01,0xFF,0x00,0x83,0x60,0x04,0x64,0x8C,0xB4,0x84,0xC4,0x17,0x60,0x00, /*稳,2*/0x00,0xFC,0x84,0x84,0x84,0xFE,0x14,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x

13、00,/*时,3*/ 0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x23,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x98,0x86,0x80,0x80,0x83,0x8C,0x90,0x20,0xC0,0x80,0x80,0x00, /*分,4*/ 0x01,0x00,0x80,0x40,0x20,0x1F,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x01,0x00,0x00,0x20,0x24,0x24,0xA4,0xFE,0xA3,0x22,0x80,

14、0x70,0x00,0xFF,0x00,0x10,0x20,0x60,0x00,/*秒,5*/0x10,0x08,0x06,0x01,0xFF,0x00,0x81,0x80,0x40,0x20,0x17,0x08,0x04,0x03,0x00,0x00,0x10,0x10,0xD0,0xFF,0x94,0x14,0xE4,0xBF,0xA4,0xA4,0xA4,0xBF,0xF4,0x26,0x04,0x00,/*模,6*/ 0x04,0x03,0x00,0xFF,0x08,0x89,0x8B,0x4A,0x2A,0x1E,0x2A,0x2A,0x4B,0xC8,0x48,0x00,0x10,

15、0x10,0x91,0xD6,0xB0,0x10,0xFE,0x82,0x82,0x82,0x82,0x82,0xFF,0x02,0x00,0x00, /* 祝,7*/0x02,0x01,0x00,0xFF,0x80,0x41,0x21,0x18,0x07,0x00,0x3F,0x40,0x41,0x40,0x70,0x00,0x40,0x20,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,0x00, /*你,8*/0x00,0x00,0xFF,0x00,0x00,0x08,0x04,0x43,0x80,0x7

16、F,0x00,0x01,0x06,0x0C,0x00,0x00,0x80,0x70,0x00,0xFF,0x10,0x20,0x10,0x10,0xFF,0x10,0x10,0x10,0xF8,0x10,0x00,0x00, /*快,9*/0x00,0x00,0x00,0xFF,0x82,0x42,0x22,0x1A,0x07,0x0A,0x12,0x22,0x43,0xC2,0x42,0x00,0x00,0x80,0xC0,0xBC,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0xC0,0x80,0x00,/*乐,10*/0x00,0x40,0x

17、20,0x10,0x0C,0x40,0x80,0x7F,0x00,0x00,0x04,0x08,0x30,0x60,0x00,0x00,0x40,0x20,0xF8,0x07,0xF0,0xA0,0x90,0x4F,0x54,0x24,0xD4,0x4C,0x84,0x80,0x80,0x00, /*修,11*/0x00,0x00,0xFF,0x00,0x0F,0x80,0x92,0x52,0x49,0x25,0x24,0x12,0x08,0x00,0x00,0x00,0x04,0xC4,0x44,0x44,0x44,0xFE,0x44,0x20,0xDF,0x10,0x10,0x10,0xF

18、0,0x18,0x10,0x00, /*改,12*/0x00,0x7F,0x20,0x20,0x10,0x90,0x80,0x40,0x21,0x16,0x08,0x16,0x61,0xC0,0x40,0x00,0x00,0xFC,0x84,0x84,0x84,0xFE,0x14,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x00,/*时,13*/0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x23,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0xF8,0x01,0x02,0xF6,0

19、x10,0x12,0x12,0x12,0x12,0xFA,0x12,0x02,0xFF,0x02,0x00, /*间,14*/0x00,0xFF,0x00,0x00,0x3F,0x11,0x11,0x11,0x11,0x11,0x3F,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,0x00, /*日,15*/0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x0

20、0,0x00,0x00,0x00,0x04,0xFF,0x24,0x24,0x24,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00, /*期,16*/0x88,0x48,0x2F,0x09,0x09,0x19,0xAF,0x48,0x30,0x0F,0x02,0x42,0x82,0x7F,0x00,0x00,;/汉字码unsigned char code xuehao208=0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*2,0

21、*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*0,1*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*1,1*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*0,4*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x

22、00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*0,4*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*4,5*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*4,5*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0

23、x00,/*2,7*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*2,0*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*2,0*/;/学号码unsigned char code shu208=0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*0,

24、0*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*1,1*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*2,2*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,/*3,3*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0

25、x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*4,4*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,/*5,5*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,/*6,6*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,

26、0x00,/*7,7*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*8,8*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,/*9,9*/;/数字码unsigned char code fuhao68= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,/

27、*-,0*/0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*:,1*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/* ,2*/;/符号码/*LCD显示模块程序*/void delay(unsigned int t) unsigned int i,j; for(i=0;it;i+) for(j=0;j10;j+) ; /*检查12864LCD中是否忙*/ void

28、checkbusy() E=1; RW=1; RS=0; LCD=0Xff; if(BUSY); /*写命令*/void writecode(unsigned char dat) /写命令 checkbusy(); E=0; RW=0; RS=0; LCD=dat; E=1; E=0;/*写数据*/void writedata(unsigned char dat) /写数据 checkbusy(); E=0; RW=0; RS=1; LCD=dat; E=1; E=0;/*汉字显示程序*/void hanzi(unsigned char page,unsigned char lineaddre

29、ss,int n,int a, unsigned char table16) unsigned char temp32; if(lineaddress0X80) CS1=0; CS2=1; /left for(j=2*a;j=0X80) CS1=1; /right CS2=0; lineaddress=lineaddress-0X40; for(k=0;k16;k+) tempk=tablejk; j+=1; for(k=0;k16;k+) temp16+k=tablejk; writecode(page); writecode(lineaddress); for(i=0;i16;i+) wr

30、itedata(tempi); writecode(page+1); writecode(lineaddress); for(i=16;i32;i+) writedata(tempi); lineaddress+=16; /*数字和字符显示程序*/void zifu(unsigned char page,unsigned char lineaddress,int n,int a, unsigned char table8) unsigned char temp16; if(lineaddress0X80) CS1=0; CS2=1; /left for(j=2*a;j=0X80) CS1=1;

31、 /right CS2=0; lineaddress=lineaddress-0X40; for(k=0;k8;k+) tempk=tablejk; j+=1; for(k=0;k8;k+) temp8+k=tablejk;writecode(page);writecode(lineaddress); for(i=0;i8;i+) writedata(tempi); writecode(page+1); writecode(lineaddress); for(i=8;i16;i+) writedata(tempi); lineaddress+=8; /*LCD初始化*/void LCD_int

32、i() writecode(0X3f);/显示开关关 writecode(0XC0);/修改显示起始行 writecode(0Xb8);/修改页地址,x地址 writecode(0X40);/修改列地址,y地址/*显示固定的汉字*/void xingxian() hanzi(0Xb8,0X40,6,0,&zi);/显示姓名 尹思思zifu(0xb8,0x70,20,0,&xuehao);/显示学号hanzi(0xba,0x60,2,3,&zi);/显示时hanzi(0xba,0x80,2,4,&zi);/显示分hanzi(0xba,0xa0,2,5,&zi);/显示秒hanzi(0xbc,0x

33、a0,2,6,&zi);/显示模zifu(0xbc,0x40,2,2,&shu);/显示年份zifu(0xbc,0x48,2,0,&shu);zifu(0xbc,0x50,2,1,&shu);zifu(0xbc,0x58,2,2,&shu);zifu(0xbc,0x60,2,0,&fuhao);zifu(0xbc,0x78,2,0,&fuhao);zifu(0xba,0x40,2,2,&fuhao);zifu(0xba,0x48,2,2,&fuhao);zifu(0xba,0xb0,2,2,&fuhao);zifu(0xba,0xb8,2,2,&fuhao);zifu(0xbc,0x90,2,

34、2,&fuhao);zifu(0xbc,0x98,2,2,&fuhao);zifu(0xbc,0xb0,2,1,&fuhao);zifu(0xbe,0x80,2,0,&fuhao); /显示符号-zifu(0xbe,0x88,2,0,&fuhao);zifu(0xbe,0x90,2,2,&fuhao);zifu(0xbe,0x98,2,2,&fuhao);zifu(0xbe,0xa0,2,2,&fuhao);zifu(0xbe,0xa8,2,2,&fuhao);zifu(0xbe,0xb0,2,2,&fuhao);zifu(0xbe,0xb8,2,2,&fuhao);/*时间模块程序*/*时间

35、值和日期的计算*/void workhour() /时间的计算h1=hour/10;h2=hour%10;/小时f1=minute/10;f2=minute%10;/分钟s1=second/10;s2=second%10; /秒m1=month/10; /日期的计算m2=month%10;d1=day/10 ;d2=day%10 ;/*显示时间和日期*/void shixian()workhour(); / 取时间 和日期zifu(0xba,0x50,2,h1,&shu);/显示小时zifu(0xba,0x58,2,h2,&shu);zifu(0xba,0x70,2,f1,&shu);/显示分

36、zifu(0xba,0x78,2,f2,&shu);zifu(0xba,0x90,2,s1,&shu);/显示秒zifu(0xba,0x98,2,s2,&shu);zifu(0xbc,0x68,2,m1,&shu); /显示月份zifu(0xbc,0x70,2,m2,&shu);zifu(0xbc,0x80,2,d1,&shu); /显示日子zifu(0xbc,0x88,2,d2,&shu);/*T0中断函数*/void timer() interrupt 1 /中断函数TH0=(65536-50000)/256;/给T0赋初值TL0=(65536-50000)%256;count+;if(count=20)/满一秒钟 ,秒加1count=0;second+;if(second=60)/满一分钟 ,分加1second=0; minute+;if(minute=60) /满一小时,时加1 minute=0; hour+; if(hour=24) /满了一日 ,日加1 hour=0;day+ ;if(day=30)/满了一月,月加1day=0;month+; /*声音模块程序*/*延时*/ void delaysj(unsigned char j)/延时程序 unsigned char i

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁