郑家贵 110800533 陈鹤 110800524
一实验目的
1、掌握用CPU控制扫描的方法实现点阵LED显示器的字符、图形的显示。 2、掌握用单片机进行显示系统开发的方法。
3、了解大容量显示器点阵图形显示驱动扩展的一般方法。 二实验仪器
单片机最小系统,电源模块,8*8点阵LED显示器四块,AT89C51单片机,74HC154N两片,HD74LSO4P一片,100排阻等。 三设计思想
用单片机的P1.0-P1.4和P2.0-P2.7共13个输出口来传递数据码,其中P1.0-P1.3分别接4线-16线译码器的四个数据输入端(A、B、C、D),P1.4作为片选输出信号,当P1.4为高电平时,U2工作,U3不工作;当P1.4为低电平输出,U2不工作,U3工作。信号经过74HC154N译码后输出,再接至4片点阵LED的行信号输入端,而列信号由单片机的P2口直接控制。 1、系统框图:图1:16X16点阵硬件电路图
2、单片机最小系统:
上图是51单片机的最小系统。将程序烧写进单片机后,便可以实现对硬件
系统的控制。
3、LED点阵显示屏:
上图即显示屏,是由4块8*8LED点阵级联,成为16*16 LED点阵。由单片机控制,按照程序中的控制命令和字模数据表输出相应汉字,同时按一定速率流动,显示多个汉字。 4、74HC154N工作原理:
74HC154N为4线—16线译码器,可以实现地址的扩展。 引脚说明:
1-11,3-17 :输出端(outputs) 12:Gnd电源地(ground)
18-19:使能输入端、低电平有效 (enable inputs) 20-23地址输入端 (address inputs)
24:VCC电源正 (positive supply voltage) 四 设计的电路样品的照片如图下图所示
五 实验结论及心得:
通过和同伴的一致努力,最终完成了整个电路的设计。虽然实现的功能并不多,但是在焊制整个电路时,总会出现各种问题,在解决这些问题的过程中对各模块进行调试,最终实现设计目标。16X16点阵字符显示利用人眼视觉残留效应,实现LED字符稳定显示。显示驱动原理先送行扫描一位后立即送列数据直到16位数据送完,当时钟足够快时看到的就是完整的字符了。因为采用了16X16而MCU为8位,故在送数据时应送2次。通过这次试验,让我对单片机的使用产生了更大的兴趣,也对自己的动手能力有了更大的信心。 实验程序参考电子版
#include #define uchar unsigned char #define uint unsigned int uchar table1[]={ 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,/*\"_\ 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,/*\"_\ };/*上移显示的字符*/ uchar code table[]= { 0x00,0x00,0xFE,0xFF,0x22,0x04,0x5A,0x08,0x86,0x07,0x08,0x20,0x88,0x11,0x68,0x0D, 0x18,0x41,0x0F,0x81,0xE8,0x7F,0x08,0x01,0x08,0x05,0x08,0x09,0x08,0x30,0x00,0x00,/*\"陈\ 0x00,0x02,0x02,0x02,0x0C,0x7F,0xC0,0x00,0x00,0x10,0x20,0x08,0x20,0x06,0xE0,0x41, 0x00,0x80,0xFF,0x7F,0x70,0x00,0xA0,0x01,0x10,0x06,0x08,0x08,0x00,0x10,0x00,0x00,/*\"冰\ 0x04,0x01,0x84,0x00,0xC4,0xFF,0x34,0x00,0x04,0x00,0x2F,0x1F,0x24,0x11,0x24,0x11, 0x24,0x11,0x2F,0x1F,0x24,0x40,0x24,0x80,0xE4,0x7F,0x24,0x00,0x24,0x00,0x00,0x00,/*\"荷\ 0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*\"1\ 0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*\"1\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*\"8\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*\"5\ 0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*\"2\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ //至此字模插入结束 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; uchar code table2[]={ 0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x10,0x00,0x2A,0xFC,0x13,0x56,0x4A,0x55,0x86, 0xFC,0x7F,0x80,0x00,0x10,0x43,0x10,0x80,0xFF,0x7F,0x10,0x00,0x10,0x00,0x00,0x00,/*\"谢\ 0x00,0x20,0xC2,0x10,0xBA,0x08,0x82,0x46,0x82,0x81,0xFE,0x7F,0xA2,0x00,0x90,0x00, 0xFC,0xFF,0x4B,0x22,0x48,0x22,0xF9,0x3F,0x4A,0x22,0x48,0x22,0x08,0x20,0x00,0x00,/*\"雅\ 0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x47,0x40,0x40,0x40,0x44,0x44,0x44,0x44, 0x44,0x44,0x7F,0x7F,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,0x00,/*\"佳\ 0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*\"1\ 0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*\"1\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*\" 8\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*\"0\ 0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*\"5\ 0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*\"4\ 0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*\"6\ //至此字模插入结束 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; /*逐屏显示字符*/ uchar v,flag,temp; uchar i,j,k,shuz,shub,temp1; uchar a,b,c,d,e,f,numa,numb; uchar ii,jj,kk; uchar iii,jjj,kkk; uchar a3,b3; uchar num3,temp3; uchar temp2; int zw; /*各变量值的初始化*/ void init(); /*主函数的初始化声名*/ void init1(); /*左移显示方式的初始化声名*/ void init2(); /*上移显示方式的初始化声名*/ void init3(); /*逐屏显示方式的初始化声名*/ void disp1(); /*左移显示子程序声名*/ void disp2(); /*上移显示子程序声名*/ void disp3(); /*逐屏显示子程序声名*/ void delay(uint z)/*延时函数声名及定义*/ { uint x,y; for(x=z;x>0;x--) { for(y=110;y>0;y--); } } void main() { init(); flag=0; P0=0xFF; P2=0XFF; P1_3=0; P1=0x00; for(zw=0;zw<2;zw++) { for(;(P1&0x07)<0x07;P1++) delay(350); P1=P1|0x07; delay(350); P1_3=~P1_3; P1=P1&0xF8; } flag=1; //选择当前显示方式为上移显示 init2(); //上移显示初始化 for(ii=0;ii<=15;ii++) //上移缓冲 { for(jj=0;jj<=v;jj++) //向上移动的速度由变量v控制 { for(kk=0;kk<=15;kk++) //显示一幕 disp2(); //若没有中断调用左移显示子程序 delay(1); } } flag=0; //选择当前显示方式为左移显示 init1(); //左移显示初始化 for(i=0;i<=a;i++) //判断左移的字符个数 for(j=0;j<=v;j++) //向左移动的速度由变量v控制 for(k=i*2;k<(i*2+32);) //显示一幕 disp1(); //若没有中断调用左移显示子程序 flag=2; //选择当前显示方式为逐屏显示 init3();//逐屏显示初始化 for(iii=0;iii<=7*32;iii=iii+32)//判断逐屏显示的字符个数 for(jjj=0;jjj<=v*10;jjj++)//逐屏显示字符的速度由变量v控制 { for(kkk=0;kkk<=15;kkk++) //显示一幕 disp3();//若没有中断调用闪烁显示子程序 num3=0; temp3=0; //显示完一幕准备下一幕的显示 } } void init() //主程序初始化 { EA=1; //CPU开放所有中断源的中断请求 EX0=1; //允许外部中断0中断 EX1=1; //允许外部中断1中断 IT0=1; //外部中断0采用边沿触发方式产生中断 IT1=1; //外部中断1采用边沿触发方式产生中断 v=15; //设置移动速度的初值 } void init1() //左移显示方式各变量的初始化 { shuz=5; shub=1; a=shuz*16+shub*8+16; P0=0; P2=0; temp1=0; } void disp1() //左移显示子程序 { P0=table[k]; k++; P2=table[k]; k++; P1=temp1; temp1++; if(temp1==0x10) temp1=0x00; delay(1); } void init2() //上移显示方式各变量的初始化 { P0=0; P2=0; temp2=0; } void disp2() //上移显示子程序 { numa=kk*2; numb=kk*2+1; a=table1[numa]; b=table1[numb]; if(jj==v) { c=a>>1; d=b<<(8-1); e=b>>1; f=a<<(8-1); c=c|d; table1[numa]=c; e=e|f; table1[numb]=e; } P0=a; P2=b; P1=temp2; temp2++; if(temp2==0x10) temp2=0x00; delay(1); } void init3() //逐屏显示方式各变量的初始化 { P0=0; P2=0; num3=0; temp3=0; } void disp3() //逐屏显子程序 { a3=table2[iii+(num3++)]; b3=table2[iii+(num3++)]; P0=a3; P2=b3; P1=temp3++; delay(1); } void timerr1() interrupt 0 //外部中断0的中断程序 { v=15; //初始化移动速度 flag++; //flag值加1,改变显示方式 temp1=0x00; temp2=0x00; temp3=0x00; } void timerr0() interrupt 2 { v=v/3; if(v==0) v=150; } 因篇幅问题不能全部显示,请点此查看更多更全内容