您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 传送带产品计数器的设计(LCD显示)
目录摘要........................................................................................................................................11题目....................................................................................................................................22电路原理图的设计.............................................................................................................22.1传送带产品计数器(LED显示)电路原理图...............................................................22.2LED显示模块................................................................................................................22.3置数模块......................................................................................................................33软件系统设计....................................................................................................................43.1软件系统的流程结构...................................................................................................43.2C51程序....................................................................................................................43.3计数程序模块................................................................................................................74仿真及调试......................................................................................................................105总论..................................................................................................................................11参考文献.........................................................................................................................12致谢................................................................................................................................131摘要MCS-51系列单片机LCD显示LCM160221题目传送带产品计数器的设计(LCD显示)功能要求:用MCS-51系列单片机作为控制器;采用LCM1602进行计数显示;采用光电传感器计数;用按键控制传送带电机的起停;用拨码盘预置计数值,计数到预定值时,传送带停止,按键后传送带继续运行。2电路原理图的设计2.1传送带产品计数器(LED显示)电路原理图硬件原理图如下图所示,包括显示模块,按键模块,电机控制模块,置数模块。2.2LED显示模块使用4位LED数码管来显示数字,通过NPN管来驱动数码管。XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C51OFFON12345678161514131211109DSW1DIPSW_8234567891RP110*865412U2OPTOCOUPLER-NPNR1100R22kR310kU1(P3.4/T0)R55kR410kRL112VQ5NPND11N4001VCC+12V+12vVCCVCC急停计数重启动电机计数值设定D714D613D512D411D310D29D18D07E6RW5RS4VSS1VDD2VEE3LCD1LM016LRV11kVCC32.3置数模块使用8位薄码盘和5位薄码盘组合来组成最高13位的二进制数,即8191的最大置数值,很好的利用了4位数码管。D714D613D512D411D310D29D18D07E6RW5RS4VSS1VDD2VEE3LCD1LM016LOFFON12345678161514131211109DSW1DIPSW_8计数值设定65412U2OPTOCOUPLER-NPNVCCVCC43软件系统设计3.1软件系统的流程结构3.2C51程序/*-----------------------------------------------------------文件名:lcd1602.h头文件功能:LCD1602驱动函数的声明-----------------------------------------------------------*/#ifndef_LCD1602_H_#define_LCD1602_H_#includereg52.h#defineuintunsignedint#defineucharunsignedchar5//接口定义sbitLcdRs=P2^0;sbitLcdRw=P2^1;sbitLcdEn=P2^2;sfrDBPort=0x80;//P0口为LCD数据总线/*-----------------------------------------------------------功能:LCD初始化函数-----------------------------------------------------------*/voidLCD_Initial();/*-----------------------------------------------------------功能:LCD显示字符(ASIIC码)函数参数:x-列0~15;y-行0~1;str-要显示的字符串指针-----------------------------------------------------------*/voidLCD_Prints(ucharx,uchary,uchar*str);#endif/*-----------------------------------------------------------文件名:lcd1602.c函数功能:LCD1602的驱动函数原理:采用普通IO口方式模拟LCD1602时序,未采用总线方式-----------------------------------------------------------*/#includeREG52.H#includeintrins.h//次头文件中定义有_nop_()函数#includelcd1602.h/*-----------------------------------------------------------功能:内部等待函数返回参数:P0数据-----------------------------------------------------------*/ucharLCD_Wait(void){LcdRs=0;LcdRw=1;_nop_();LcdEn=1;_nop_();//while(DBPort&0x80);/*在用Proteus仿真时,屏蔽此语句,否则会进入死循环,实际硬件操作时打开此语句.*/LcdEn=0;6returnDBPort;}/*-----------------------------------------------------------功能:写LCD命令/数据函数参数:style为写命令/数据,0-命令,1-数据;input为写入的8位命令/数据-----------------------------------------------------------*/#defineLCD_COMMAND0//命令#defineLCD_DATA1//数据#defineLCD_CLEAR_SCREEN0x01//清屏#defineLCD_HOMING0x02//光标返回原点voidLCD_Write(bitstyle,ucharinput){LcdEn=0;LcdRs=style;LcdRw=0;_nop_();DBPort=input;_nop_();LcdEn=1;_nop_();LcdEn=0;_nop_();LCD_Wait();}/*-----------------------------------------------------------功能:设置LCD显示模式参数:DisplayMode见下面的定义-----------------------------------------------------------*///显示模式定义#defineLCD_SHOW0x04//显示开#defineLCD_HIDE0x00//显示关#defineLCD_CURSOR0x02//显示光标#defineLCD_NO_CURSOR0x00//无光标#defineLCD_FLASH0x01//光标闪动#defineLCD_NO_FLASH0x00//光标不闪动voidLCD_SetDisplay(ucharDisplayMode){LCD_Write(LCD_COMMAND,0x08|DisplayMode);}/*-----------------------------------------------------------功能:设置LCD输入模式参数:InputMode见下面的定义-----------------------------------------------------------*/7#defineLCD_AC_UP0x02//地址计数器增加
本文标题:传送带产品计数器的设计(LCD显示)
链接地址:https://www.777doc.com/doc-5801569 .html