1、 1632点阵数字钟及汉字显示 作者: HEY | 浏览数 (6070) | 评论数(0) | 2007-08-09一电路原理框架设计制作作品:1632 点阵显示数字钟及汉字显示实现功能:点阵显示的实时时钟以及汉字等字符的左移显示实用特征:采用双电源供电,断电后时钟由电池供电还能继续运行,而且精确性较高实现原理:1 时钟显示是由 DS1302精确的时钟芯片产生时钟信号并将其送至单片机,经过单片机处理后再输送到点阵显示模块。2 汉字显示并左移原理是先写入与本点阵驱动相应的代码进单片机,通过单片机控制程序取表进行处理后送点阵模块显示电路主要模块及原理图:1 单片机最小系统及控制按键电路2 DS13
2、02与单片机接口电路DS1302除了系统上电时由系统供电外,如果主电源断电还有一电池给 DS1302供电,防止断电后 DS1302数据消失。4点阵行驱动模块电路行驱动采用74LS154(416线译码器)及 PNP 三极管,由于是1632点阵显示功率较大故采用8550NP 三极管。5点阵列驱动电路列驱动采用74HC595移位寄存器将控制位级连接入单片机,每个 74HC595数据输入端单独接单片机。1632点阵模块由8块小的88点阵模块通过级连而拼成,共16行,32列。二:主要元器件选择:单片机:AT89S51 采用市场上比较常用的 AT89S51三极管:点阵的行驱动电路用,这里采用 PNP 管,
3、具体型号用8550点阵块:为了电路简单,采用双色8 8点阵晶振:采用的是12MHZ 的晶振电源部分:采用5V 电压供电,采用的是 L7805稳压芯片供电电阻:大部分是限流电阻,阻值为4.7K 或10K,1K译码器:416线采用市场上较为常用的74LS154,用来作行驱动移位寄存器:采用74HC595移位寄存器作列驱动,驱动列端口分配及连接:P1.0P1.2:DS1302与单片机接口P1.3P1.4:K0,K1按键,用来调整时间,按下为0P0:P0口接点阵行驱动电路接译码器P2:P2口点阵列驱动电路接74HC595最后是做好之后的图附:点阵时间显示源程序/=/*标题:16*32点阵数字钟显示程序
4、/*说明:时钟信号产生采用 DS1302,列采用74HC595驱动(共4个),行驱动采用4-16线译码器74LS154/*功能:通过动态扫描显示时钟,可显示时,分,秒,日期中的月和日/*作者:HEY/*日期:2006-05-29/*邮箱: 程序和电路设计上难免有不足之处 请谅解/=/#include #include #define uchar unsigned char/=/用到的引脚及端口定义/=/sbit SERIALIN_0=P20; /定义 P2.0为列向第1个74HC595的 DATA 输入 sbit SERIALIN_1=P21; /定义 P2.1为列向第2个74HC595的 D
5、ATA 输入sbit SERIALIN_2=P22; /定义 P2.2为列向第2个74HC595的 DATA 输入sbit SERIALIN_3=P23; /定义 P2.3为列向第2个74HC595的 DATA 输入sbit CLOCK_DATA=P10; /定义 P1.0为 DS1302的DATA 端口 sbit CLOCK_RST=P11; /定义 P1.1为 DS1302的复位输出端口sbit CLOCK_SCLK=P12; /定义 P1.2为 DS1302的时钟信号状态控制sbit K0=P13; /K0为按键1,用来选择要调整时间的选项(时和分)sbit K1=P14; /K1为按键
6、2,执行加1sbit CLOCK=P24; /74HC595的移位时钟控制sbit LATCH=P25; /74HC595的锁存输出时钟控制void control(); /调整时间控制函数void time();uchar CLOCK_TIME3=0,0,0; /定义时钟时间数据存储区,分别为(时,分,秒)uchar BUFFER8=0,0,0,0,0,0,0,0; /显示缓冲区uchar YEAR3=0,0,0; /定义时钟年月日数据存储区uchar temp4=0,0,0,0; /定义74HC595的移位缓冲区uchar FLASH_STOP; /显示小时和分钟之间的两点控制位 ucha
7、r sec_flash; /用单片机定时器模拟的一秒(用来控制小时和分中之间的两点)/=/定义0-9的点阵显示代码段 8*8/=/uchar code bmp108=0xe3,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xe3, /00xf7,0xc7,0xf7,0xf7,0xf7,0xf7,0xf7,0xc1, /10xe3,0xdd,0xdd,0xfd,0xfb,0xf7,0xef,0xc1, /20xe3,0xdd,0xfd,0xe3,0xfd,0xfd,0xdd,0xe3, /30xfb,0xf3,0xeb,0xdb,0xdb,0xc1,0xfb,0xf1, /40x
8、c1,0xdf,0xdf,0xc3,0xfd,0xfd,0xdd,0xe3, /50xe3,0xdd,0xdf,0xc3,0xdd,0xdd,0xdd,0xe3, /60xc1,0xdd,0xfd,0xfb,0xf7,0xf7,0xf7,0xf7, /70xe3,0xdd,0xdd,0xe3,0xdd,0xdd,0xdd,0xe3, /80xe3,0xdd,0xdd,0xdd,0xe1,0xfd,0xdd,0xe3, /9;/=/定义0-9的点阵显示代码段 8*8 与上面不同的是多了小时和分钟之间的两点/=/uchar code bmp_1108=0xe3,0xdd,0x5d,0xdd,0xd
9、d,0x5d,0xdd,0xe3, /:00xf7,0xc7,0x77,0xf7,0xf7,0x77,0xf7,0xc1, /:10xe3,0xdd,0x5d,0xfd,0xfb,0x77,0xef,0xc1, /:20xe3,0xdd,0x7d,0xe3,0xfd,0x7d,0xdd,0xe3, /:30xfb,0xf3,0x6b,0xdb,0xdb,0x41,0xfb,0xf1, /:40xc1,0xdf,0x5f,0xc3,0xfd,0x7d,0xdd,0xe3, /:40xe3,0xdd,0x5f,0xc3,0xdd,0x5d,0xdd,0xe3, /:50xc1,0xdd,0x7d,
10、0xfb,0xf7,0x77,0xf7,0xf7, /:60xe3,0xdd,0x5d,0xe3,0xdd,0x5d,0xdd,0xe3, /:70xe3,0xdd,0x5d,0xdd,0xe1,0x7d,0xdd,0xe3, /:8;/=/定义0-9的点阵显示代码段 数码似的字模 8*8 显示数据前有一横杠将月和日格开/=/uchar code bmp_2108=0xff,0xff,0xf8,0xfa,0x8a,0xfa,0xf8,0xff, /-00xff,0xff,0xfe,0xfe,0x8e,0xfe,0xfe,0xff, /-10xff,0xff,0xf8,0xfe,0x88,0xf
11、b,0xf8,0xff, /-20xff,0xff,0xf8,0xfe,0x88,0xfe,0xf8,0xff, /-30xff,0xff,0xfa,0xfa,0x88,0xfe,0xfe,0xff, /-40xff,0xff,0xf8,0xfb,0x88,0xfe,0xf8,0xff, /-50xff,0xff,0xf8,0xfb,0x88,0xfa,0xf8,0xff, /-60xff,0xff,0xf8,0xfe,0x8e,0xfe,0xfe,0xff, /-70xff,0xff,0xf8,0xfa,0x88,0xfa,0xf8,0xff, /-80xff,0xff,0xf8,0xfa,
12、0x88,0xfe,0xf8,0xff, /-9;/=/定义0-9的点阵显示代码段 模拟数码似的字模 8*8 /=/uchar code bmp_3108=0xff,0xff,0x8f,0xaf,0xaf,0xaf,0x8f,0xff, /00xff,0xff,0xef,0xef,0xef,0xef,0xef,0xff, /10xff,0xff,0x8f,0xef,0x8f,0xbf,0x8f,0xff, /20xff,0xff,0x8f,0xef,0x8f,0xef,0x8f,0xff, /30xff,0xff,0xaf,0xaf,0x8f,0xef,0xef,0xff, /40xff,0x
13、ff,0x8f,0xbf,0x8f,0xef,0x8f,0xff, /50xff,0xff,0x8f,0xbf,0x8f,0xaf,0x8f,0xff, /60xff,0xff,0x8f,0xef,0xef,0xef,0xef,0xff, /70xff,0xff,0x8f,0xaf,0x8f,0xaf,0x8f,0xff, /80xff,0xff,0x8f,0xaf,0x8f,0xef,0x8f,0xff, /9;/=/定义0-59模拟七段数码管显示 8*8/=/uchar code bmp_4608=0xff,0xff,0x88,0xaa,0xaa,0xaa,0x88,0xff, /000x
14、ff,0xff,0x8e,0xae,0xae,0xae,0x8e,0xff, /010xff,0xff,0x88,0xae,0xa8,0xab,0x88,0xff, /020xff,0xff,0x88,0xae,0xa8,0xae,0x88,0xff, /030xff,0xff,0x8a,0xaa,0xa8,0xae,0x8e,0xff, /040xff,0xff,0x88,0xab,0xa8,0xae,0x88,0xff, /050xff,0xff,0x88,0xab,0xa8,0xaa,0x88,0xff, /060xff,0xff,0x88,0xae,0xae,0xae,0x8e,0xf
15、f, /070xff,0xff,0x88,0xaa,0xa8,0xaa,0x88,0xff, /080xff,0xff,0x88,0xaa,0xa8,0xae,0x88,0xff, /090xff,0xff,0xe8,0xea,0xea,0xea,0xe8,0xff, /100xff,0xff,0xee,0xee,0xee,0xee,0xee,0xff, /110xff,0xff,0xe8,0xee,0xe8,0xeb,0xe8,0xff, /120xff,0xff,0xe8,0xee,0xe8,0xee,0xe8,0xff, /130xff,0xff,0xea,0xea,0xe8,0xee,
16、0xee,0xff, /140xff,0xff,0xe8,0xeb,0xe8,0xee,0xe8,0xff, /150xff,0xff,0xe8,0xeb,0xe8,0xea,0xe8,0xff, /160xff,0xff,0xe8,0xee,0xee,0xee,0xee,0xff, /170xff,0xff,0xe8,0xea,0xe8,0xea,0xe8,0xff, /180xff,0xff,0xe8,0xea,0xe8,0xee,0xe8,0xff, /190xff,0xff,0x88,0xea,0x8a,0xba,0x88,0xff, /200xff,0xff,0x8e,0xee,0x
17、8e,0xbe,0x8e,0xff, /210xff,0xff,0x88,0xee,0x88,0xbb,0x88,0xff, /220xff,0xff,0x88,0xee,0x88,0xbe,0x88,0xff, /230xff,0xff,0x8a,0xea,0x88,0xbe,0x8e,0xff, /240xff,0xff,0x88,0xeb,0x88,0xbe,0x88,0xff, /250xff,0xff,0x88,0xeb,0x88,0xba,0x88,0xff, /260xff,0xff,0x88,0xee,0x8e,0xbe,0x8e,0xff, /270xff,0xff,0x88
18、,0xea,0x88,0xba,0x88,0xff, /280xff,0xff,0x88,0xea,0x88,0xbe,0x88,0xff, /290xff,0xff,0x88,0xea,0x8a,0xea,0x88,0xff, /300xff,0xff,0x8e,0xee,0x8e,0xee,0x8e,0xff, /310xff,0xff,0x88,0xee,0x88,0xeb,0x88,0xff, /320xff,0xff,0x88,0xee,0x88,0xee,0x88,0xff, /330xff,0xff,0x8a,0xea,0x88,0xee,0x8e,0xff, /340xff,0
19、xff,0x88,0xeb,0x88,0xee,0x88,0xff, /350xff,0xff,0x88,0xeb,0x88,0xea,0x88,0xff, /360xff,0xff,0x88,0xee,0x8e,0xee,0x8e,0xff, /370xff,0xff,0x88,0xea,0x88,0xea,0x88,0xff, /380xff,0xff,0x88,0xea,0x88,0xee,0x88,0xff, /390xff,0xff,0xa8,0xaa,0x8a,0xea,0xe8,0xff, /400xff,0xff,0xae,0xae,0x8e,0xee,0xee,0xff, /
20、410xff,0xff,0xa8,0xae,0x88,0xeb,0xe8,0xff, /420xff,0xff,0xa8,0xae,0x88,0xee,0xe8,0xff, /430xff,0xff,0xaa,0xaa,0x88,0xee,0xee,0xff, /440xff,0xff,0xa8,0xab,0x88,0xee,0xe8,0xff, /450xff,0xff,0xa8,0xab,0x88,0xea,0xe8,0xff, /460xff,0xff,0xa8,0xae,0x8e,0xee,0xee,0xff, /470xff,0xff,0xa8,0xaa,0x88,0xea,0xe8
21、,0xff, /480xff,0xff,0xa8,0xaa,0x88,0xee,0xe8,0xff, /490xff,0xff,0x88,0xba,0x8a,0xea,0x88,0xff, /500xff,0xff,0x8e,0xbe,0x8e,0xee,0x8e,0xff, /510xff,0xff,0x88,0xbe,0x88,0xeb,0x88,0xff, /520xff,0xff,0x88,0xbe,0x88,0xee,0x88,0xff, /530xff,0xff,0x8a,0xba,0x88,0xee,0x8e,0xff, /540xff,0xff,0x88,0xbb,0x88,0
22、xee,0x88,0xff, /550xff,0xff,0x88,0xbb,0x88,0xea,0x88,0xff, /560xff,0xff,0x88,0xbe,0x8e,0xee,0x8e,0xff, /570xff,0xff,0x88,0xba,0x88,0xea,0x88,0xff, /580xff,0xff,0x88,0xba,0x88,0xee,0x88,0xff, /59;/=/名称:delay/说明:延时函数/功能:根据需要取不同的值,实现不同的延时效果/=/void delay()uchar n;for(n=0;n1; /右移一位 CLOCK_DATA=CY; /输出移位标志
23、位CLOCK_SCLK=1; CLOCK_SCLK=0; for(loop=0;loop1; /右移一位CLOCK_DATA=CY; /输出移位标志CLOCK_SCLK=1;CLOCK_SCLK=0; CLOCK_SCLK=1;CLOCK_RST=0;CLOCK_DATA=1; /设置为输出;/=/单字节读子程序 RC0(SCLK),RC1(I/O),RC2(RST)/名称:outputdata/说明:读数据/功能: 从 DS1302读取1Byte 数据/=/unsigned char outputdata(unsigned char tmaddr) uchar loop;uchar tmda
24、ta=0;inputdata(0x8F,0x00);CLOCK_DATA=0; /设置为输 CLOCK_RST=0;CLOCK_SCLK=0;CLOCK_RST=1; for(loop=8;loop0;loop-) /送地址 tmaddr=tmaddr1; CLOCK_DATA=CY;CLOCK_SCLK=1; CLOCK_SCLK=0; CLOCK_DATA=1; /设置为输入; CLOCK_DATA=1;CLOCK_SCLK=1;CLOCK_SCLK=0; for(loop=8;loop0;loop-) / 读数据tmdata=tmdata1; if(CLOCK_DATA=1)tmdata
25、=tmdata|0x80;CLOCK_SCLK=1;CLOCK_SCLK=0;tmdata=tmdata#include #define uchar unsigned char/=/用到的引脚及端口定义及全局变量/=/sbit SERIALIN_0=P20; /定义 P2.0为列向第1个74HC595的 DATA 输入sbit SERIALIN_1=P21; /定义 P2.1为列向第1个74HC595的 DATA 输入sbit SERIALIN_2=P22; /定义 P2.2为列向第1个74HC595的 DATA 输入sbit SERIALIN_3=P23; /定义 P2.3为列向第1个74H
26、C595的 DATA 输入sbit CLOCK=P24; /74HC595的移位时钟控制sbit LATCH=P25; /74HC595的锁存输出时钟控制uchar temp4=0,0,0,0; /用到的74HC595 显示缓冲区变量uchar disp416; /用到的显示缓冲区/=/定义要显示的汉字代码段 16*16,分别是左上左下右上右下/=/uchar code word5216=/*点 */0xfe,0xfe,0xfe,0xfe,0xfe,0xe0,0xef,0xef,0xef,0xe0,0xef,0xfe,0xd7,0xdb,0xbb,0xff,0xff,0xff,0x07,0xf
27、f,0xef,0x07,0xef,0xef,0xef,0x0f,0xef,0xef,0x77,0xbb,0xbb,0xff,/*阵 */0xff,0x07,0x77,0x68,0x5e,0x6e,0x75,0x70,0x77,0x57,0x68,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x03,0xff,0xbf,0xbf,0x03,0xbf,0xbf,0x01,0xbf,0xbf,0xbf,0xbf,0xbf,/*显 */0xff,0xe0,0xef,0xe0,0xef,0xe0,0xfb,0xfb,0xbb,0xdb,0xeb,0xeb,0xfb,0
28、x00,0xff,0xff,0xff,0x0f,0xef,0x0f,0xef,0x0f,0xbf,0xbf,0xb7,0xb7,0xaf,0x9f,0xbf,0x01,0xff,0xff,/*示 */0xff,0xe0,0xff,0xff,0xff,0x80,0xfe,0xfe,0xee,0xee,0xde,0xbe,0x7e,0xfe,0xfa,0xfd,0xff,0x07,0xff,0xff,0xff,0x01,0xff,0xff,0xdf,0xef,0xf7,0xf3,0xfb,0xff,0xff,0xff,/*由 */0xfe,0xfe,0xfe,0xfe,0xc0,0xde,0xde
29、,0xde,0xc0,0xde,0xde,0xde,0xde,0xc0,0xdf,0xff,0xff,0xff,0xff,0xff,0x07,0xf7,0xf7,0xf7,0x07,0xf7,0xf7,0xf7,0xf7,0x07,0xf7,0xff,/*信 */0xf7,0xf3,0xe7,0xe8,0xcf,0xcc,0xaf,0x6c,0xef,0xec,0xed,0xed,0xed,0xec,0xed,0xff, 0x7f,0x9f,0xbf,0x01,0xff,0x07,0xff,0x07,0xff,0x07,0xf7,0xf7,0xf7,0x07,0xf7,0xff,/*息 */0
30、xfe,0xfd,0xe0,0xef,0xe0,0xef,0xe0,0xef,0xe0,0xff,0xf6,0xd7,0xd7,0x97,0xf8,0xff,0xff,0xff,0x0f,0xef,0x0f,0xef,0x0f,0xef,0x0f,0xff,0xff,0x7b,0x6d,0xed,0x0f,0xff,/*工 */0xff,0xc0,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0x00,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
31、0xff,0xff,0x01,0xff,0xff,/*程 */0xf2,0x8e,0xee,0xee,0x02,0xee,0xcf,0xc4,0xab,0xaf,0x6c,0xef,0xef,0xef,0xe8,0xef,0x07,0xf7,0xf7,0xf7,0xf7,0x07,0xff,0x03,0xbf,0xbf,0x03,0xbf,0xbf,0xbf,0x01,0xff,/*学 */0xfe,0xef,0xf3,0xf7,0x80,0xbf,0x70,0xff,0xff,0x80,0xff,0xff,0xff,0xff,0xfd,0xfe,0xf7,0x73,0x37,0x6f,0x0
32、1,0xfb,0x17,0xbf,0x7f,0x01,0x7f,0x7f,0x7f,0x7f,0x7f,0xff,/*院 */0xff,0x07,0x70,0x6b,0x5f,0x5c,0x6f,0x77,0x70,0x56,0x6e,0x7e,0x7d,0x7d,0x7b,0x77,0x7f,0xbf,0x01,0xfb,0xff,0x07,0xff,0xff,0x01,0xdf,0xdf,0xdf,0xdd,0xdd,0xdd,0xe1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x
33、ff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff;/=/名称:delay/说明:延时函数/功能:根据需要取不同的值,实现不同的延时效果/=/void delay()uchar i;for(i=0;i(8-j); /将第 i+1个8*8小块左移 j 位后的移出disp1m=(wordi+1m(8-j); /值与第 i 个相或加在一起,形成左移效果disp2m=(wordi+2m(8-j); /disp3m=(wordi+3m(8-j); /display_word(); /调用显示