ntc热敏电阻测温、12864显示

合集下载

12864点阵型液晶显示屏的基本原理与使用方法(很详细)

12864点阵型液晶显示屏的基本原理与使用方法(很详细)

12864点阵型液晶显示屏的基本原理与使用方法(很详细)点阵LCD的显示原理在数字电路中,所有的数据都是以0和1保存的,对LCD控制器进行不同的数据操作,可以得到不同的结果。

对于显示英文操作,由于英文字母种类很少,只需要8位(一字节)即可。

而对于中文,常用却有6000以上,于是我们的DOS前辈想了一个办法,就是将ASCII表的高128个很少用到的数值以两个为一组来表示汉字,即汉字的内码。

而剩下的低128位则留给英文字符使用,即英文的内码。

那么,得到了汉字的内码后,还仅是一组数字,那又如何在屏幕上去显示呢?这就涉及到文字的字模,字模虽然也是一组数字,但它的意义却与数字的意义有了根本的变化,它是用数字的各位信息来记载英文或汉字的形状,如英文的'A'在字模的记载方式如图1所示:图1“A”字模图而中文的“你”在字模中的记载却如图2所示:图2“你”字模图12864点阵型LCD简介12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。

可完成图形显示,也可以显示8×4个(16×16点阵)汉字。

管脚号管脚名称LEVER管脚功能描述1VSS0电源地2VDD+5.0V电源电压3V0-液晶显示器驱动电压4D/I(RS)H/L D/I=“H”,表示DB7∽DB0为显示数据D/I=“L”,表示DB7∽DB0为显示指令数据5R/W H/L R/W=“H”,E=“H”数据被读到DB7∽DB0R/W=“L”,E=“H→L”数据被写到IR或DR 6E H/L R/W=“L”,E信号下降沿锁存DB7∽DB0R/W=“H”,E=“H”DDRAM数据读到DB7∽DB0 7DB0H/L数据线8DB1H/L数据线9DB2H/L数据线10DB3H/L数据线11DB4H/L数据线12DB5H/L数据线13DB6H/L数据线14DB7H/L数据线15CS1H/L H:选择芯片(右半屏)信号16CS2H/L H:选择芯片(左半屏)信号17RET H/L复位信号,低电平复位18VOUT-10V LCD驱动负电压19LED+-LED背光板电源20LED--LED背光板电源表1:12864LCD的引脚说明在使用12864LCD前先必须了解以下功能器件才能进行编程。

使用无字库12864液晶模块制作温湿度计

使用无字库12864液晶模块制作温湿度计

使用无字库12864液晶模块制作温湿度计日历钟就摇身一变成为一个小小温湿度计啦。

虽然气象要素很多,不过我们最常用的就是气温和湿度。

一个是冷热程度,一个是环境空气中含水蒸气的多少。

一般家用温度计很常见,湿度计就比较少,以前有一种干湿球温度计,但是用起来比较麻烦,准确度也不高。

现在应用电子技术我们就可以做一个可以同时显示温度、湿度、时间的小仪器,放在家里以便随时监测我们的小环境。

它的特点如下:1.在单片机ATMega8L-8PU(以下简称M8)和日历钟电路DS1302的基础上,使用一个在工厂经过精密校准的数字式温度、湿度传感器AM2301作为探头;2.当24小时连续工作时,纵然工作电流仅为几毫安,也不宜使用纽扣电池供电。

这次选用可充电的3.6V聚合物锂电池,使它的放置地点可以不受电源限制,可以在室内,也可以在不受阳光直射和雨水接触的室外;3.具有文字和图形界面,可以显示温度和湿度数值,以及12小时内的湿度变化记录曲线,为什么是湿度曲线呢?因为气温的变化规律一般比较稳定,湿度就不一样了,我们可以从湿度变化趋势估计一下未来的晴雨可能,这比看燕子飞高飞低要靠谱些吧?两个界面用按键切换;4.具备锂电池线性充电电路,通过USB接口从外部取得5V电源,一边供给充电,一边维持电路继续工作;全部元器件安装在一块70mm×90mm的小万用板上,正面、背面外形见图1、图2。

正面左边那个黑色小乌龟壳就是温湿度探头。

图2 电路板背面元器件分布和连线电路原理电路见图3。

图形点阵液晶、单片机M8、时钟电路DS1302和上次小小日历钟基本相同,不再重复。

有两点稍稍不同:1.液晶的控制虽然还是通过M8的PD口,但具体接线有所改变,不再占用两根串口线PD0和PD1,目的是为今后可能和外部通信预留接口。

这好办,编程时重新定义即可;。

汉昇HS12864B液晶显示模块使用说明书

汉昇HS12864B液晶显示模块使用说明书

HS12864B液晶显示模块使用说明书感谢您关注和使用我们的液晶产品。

如果您在使用中有任何疑问,请拨打我们的客户服务热线寻求技术支持和获取相关资料,我们竭诚为您服务。

您可以登录我们的网站了解最新产品信息。

或者您可以在我公司网站的留言簿栏目留下您宝贵的意见。

深圳汉昇实业有限公司SHENZHEN HANSHENG INDUSTRIAL CO.,LTD地址:深圳市南山区西丽镇官龙工业村东区18栋5楼邮编:518055公司主页:联系电话:传真:一、 概述HS12864B 使用KS0108(或其兼容芯片)作为控制器,适配M6800系列时序,具有8位标准数据总线。

可显示各种字符及图形。

每个KS0108拥有64×64位(512字节)的显示RAM ,HS12864B 显示屏上的64×64点,显示RAM 中的数据直接作为显示驱动信号。

HS12864B 具有操作指令简单,低功耗的特点。

HS12864B 采用COB 工艺制作。

说明:HS12864B 有STN 黄绿膜,蓝膜以及FSTN 产品可选,LED 背光有多种颜色可选。

用户还可以根据需要自己选定常温、宽温或者超宽温产品。

二、 外形结构1. 外形图2.114-?2. 主要外形尺寸项 目 标 准 尺 寸单 位模 块 体 积 93.0L ×70.0W ×13.0(max )H mm视 域 70.7×38.8 mm 行 列 点 阵 数 128×64 dots 点 距 离 0.48×0.48 mm 点 大 小0.52×0.52 mm三、 硬件说明1. 接口定义管脚符号电平功能描述1 CS1 L 片选信号1,低有效,对应左半屏64×64点2 CS2 L 片选信号2,低有效,对应右半屏64×64点与CSA,CSB不可同时使用3 VSS 0V 电源地4 VDD 5.0V 供电电源,5.0V5 V0 负压 LCD驱动电压输入端(对比度调节)6 RS H/L 寄存器选择端高:数据寄存器低:命令寄存器7 R/W H/L 读/写信号高:读操作低:写操作8 E H,H->L 使能信号9 ~16 DB0~DB7H/L 数据线17 CSA H 片选信号1,高有效,对应左半屏64×64点18 CSB H 片选信号2,高有效,对应右半屏64×64点与CS1,CS2不可同时使用19 /RST H/L 复位信号,低有效20 V out 负压负压输出端21 LEDA 5.0V 背光正极22 LEDK 0V 背光负极说明:HS12864B有两套片选信号,分别是CS1,CS2和CSA,CSB,分别是低有效和高有效,以适应不同用户的需求。

液晶12864

液晶12864

0
0
1
1
0
0
0
0

0
0
◆页(PAGE)设置指令(0xb8)
RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0
0
1
0
1
1
1
0
0
0
◆列地址(Y Address)设置指令(0x40)
RW
RS
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0
0
1
0
1
1
1
0
0
0
◆读状态指令
LCD驱动负电压 LED背光板电源
20
LED-
LED背光板电源
12864的DDRAM地址
XY地址计数器实际上是作为DDRAM的地址指针,X地址计数器为 DDRAM的页指针,Y地址计数器为DDRAM的Y(列)地址指针。 X地址计数器没有记数功能,只能用指令设置。Y地址计数器具有循环 记数功能,各显示数据写入后,Y地址自动加1,Y地址指针从0到63。
◆写数据指令
RW RS
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0
1
要写的数据
注:EN的下降沿
◆写命令指令
RW RS
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0
0
要写的数据
注:EN的下降沿
◆读数据指令
RW 1
RS 1
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 读显示的数据
数据线 数据线 数据线 数据线 数据线
12 13
DB5 DB6

12864LCD上显示温湿度

12864LCD上显示温湿度

12864LCD显示温湿度第一种方式:/**********************DHT11与12864LCD************************/ #include <>#define uchar unsigned char#define uint unsigned intuchar lcd_x,lcd_y,data_byte=0,count;uint TH_data,TL_data,RH_data,RL_data,CK_data;uint TH_temp,TL_temp,RH_temp,RL_temp,CK_temp;uchar num;sbit RS = P2^0;;uchar wendu[6];uchar shidu[6];/********************************************************1ms延时函数********************************************************/void delay(int z){ int x,y;for(x=z;x>0;x--)for(y=125;y>0;y--); }/********************************************************50us延时函数********************************************************/void delay_50us(uint t){uint j;for(;t>0;t--)for(j=19;j>0;j--);}/********************************************************50ms延时函数********************************************************/ void delay_50ms(uint t){uint j;for(;t>0;t--)for(j=6245;j>0;j--);}/********************************************************12864液晶写指令********************************************************/ void write_12864com(uchar com){ lcdrs=0;lcdrw=0;delay_50us(1);P0=com;lcden=1;delay_50us(10);lcden=0;delay_50us(2);}/********************************************************12864液晶写数据********************************************************/ void write_dat(ucha r dat) { lcdrs=1;lcdrw=0;delay_50us(1);P0=dat;lcden=1;delay_50us(10);lcden=0;delay_50us(2); }/********************************************************12864液晶初始化********************************************************/void init12864lcd(void) {delay_50ms(2);write_12864com(0x30);delay_50us(4);write_12864com(0x30);delay_50us(4);write_12864com(0x0f);delay_50us(4);write_12864com(0x01);delay_50us(240);write_12864com(0x06);delay_50us(10);write_12864com(0x0c);delay_50us(10); }/********************************************************12864液晶显示函数********************************************************/ void display1(void){uchar i;write_12864com(0x80);for(i=0;i<18;i++){write_dat(table2[i]);delay_50us(1); } }/********************************************************12864液晶显示函数********************************************************/ void display2(void){uchar i;write_12864com(0x90);for(i=0;i<18;i++){write_dat(table3[i]);delay_50us(1); } }/********************************************************12864液晶显示函数********************************************************/ void display3(void){ uchar i;write_12864com(0x88);for(i=0;i<8;i++){ write_dat(table4[i]);delay_50us(1); }}/********************************************************12864液晶显示函数********************************************************/ void displaywendu(void){ uchar i;write_12864com(0x94);for(i=0;i<3;i++){ write_dat(wendu[i]);delay_50us(1);}for(i=0;i<1;i++){write_dat(table5[i]);delay_50us(1);}for(i=4;i<5;i++){write_dat(wendu[i]);delay_50us(1); } }/********************************************************12864液晶显示函数********************************************************/ void displayshidu(void) {uchar i;write_12864com(0x8C);for(i=0;i<3;i++) {write_dat(shidu[i]);delay_50us(1); }for(i=0;i<1;i++){ write_dat(table5[i]);delay_50us(1);}for(i=4;i<5;i++){write_dat(shidu[i]);delay_50us(1);} }/********************************************************SHT11写字节程序********************************************************/char s_write_byte(unsigned char value){unsigned char i,error=0;for (i=0x80;i>0;i>>=1) //高位为1,循环右移{ if (i&value) DATA=1; //和要发送的数相与,结果为发送的位else DATA=0;SCK=1;_nop_();_nop_();_nop_(); //延时3usSCK=0;}DATA=1; //释放数据线SCK=1;error=DATA; //检查应答信号,确认通讯正常_nop_();_nop_();_nop_();SCK=0;DATA=1;return error; //error=1 通讯错误}/********************************************************SHT11读字节程序********************************************************/char s_read_byte(unsigned char ack){unsigned char i,val=0;DATA=1; //释放数据线for(i=0x80;i>0;i>>=1) //高位为1,循环右移{SCK=1;if(DATA)val=(val|i); //读一位数据线的值SCK=0; }DATA=!ack; //如果是校验,读取完后结束通讯;SCK=1;_nop_();_nop_();_nop_(); //延时3usSCK=0;_nop_();_nop_();_nop_();DATA=1; //释放数据线return val; }/********************************************************SHT11启动传输********************************************************/void s_transstart(void){DATA=1;SCK=0; //准备_nop_();SCK=1;_nop_();DATA=0;_nop_();SCK=0;_nop_();_nop_();_nop_();SCK=1;_nop_();DATA=1;_nop_();SCK=0; }/********************************************************SHT11连接复位********************************************************/void s_connectionreset(void){ unsigned char i;DATA=1;SCK=0; //准备for(i=0;i<9;i++) //DATA保持高,SCK时钟触发9次,发送启动传输,通迅即复位{ SCK=1;SCK=0;}s_transstart(); //启动传输}/********************************************************SHT11温湿度检测********************************************************/char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsign ed char mode){unsigned error=0;unsigned int i;s_transstart(); //启动传输switch(mode) //选择发送命令{ case TEMP : error+=s_write_byte(MEASURE_TEMP);break; //测量温度case HUMI : error+=s_write_byte(MEASURE_HUMI);break; //测量湿度default : break;}for (i=0;i<65535;i++)if(DATA==0) break; //等待测量结束if(DATA) error+=1;// 如果长时间数据线没有拉低,说明测量错误*(p_value) =s_read_byte(ACK); //读第一个字节,高字节(MSB)*(p_value+1)=s_read_byte(ACK); //读第二个字节,低字节(LSB)*p_checksum =s_read_byte(noACK); //read CRC校验码return error; // error=1 通讯错误}/********************************************************SHT11温湿度值标度变换及温度补偿********************************************************/ void calc_sth10(flo at *p_humidity ,float *p_temperature){const float C1=; // 12位湿度精度修正公式const float C2=+; // 12位湿度精度修正公式const float C3=; // 12位湿度精度修正公式const float T1=+; // 14位温度精度5V条件修正公式const float T2=+; // 14位温度精度5V条件修正公式float rh=*p_humidity; // rh: 12位湿度float t=*p_temperature; // t: 14位温度float rh_lin; // rh_lin: 湿度linear值float rh_true; // rh_true: 湿度ture 值float t_C; // t_C : 温度℃t_C=t* - 40; //补偿温度rh_lin=C3*rh*rh + C2*rh + C1; //相对湿度非线性补偿rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //相对湿度对于温度依赖性补偿if(rh_true>100)rh_true=100; //湿度最大修正if(rh_true<rh_true=; //湿度最小修正*p_temperature=t_C; //返回温度结果*p_humidity=rh_true; //返回湿度结果}/********************************************************主函数********************************************************/void main(void){unsigned int temp,humi;value humi_val,temp_val; //定义两个共同体,一个用于湿度,一个用于温度unsigned char error; //用于检验是否出现错误unsigned char checksum; //CRCinit12864lcd();display1();display2();display3();s_connectionreset(); //启动连接复位while(1){error=0; //初始化error=0,即没有错误error+=s_measure((unsigned char*)&,&checksum,TEMP); //温度测量error+=s_measure((unsigned char*)&,&checksum,HUMI); //湿度测量if(error!=0) s_connectionreset(); ////如果发生错误,系统复位else{=(float); //转换为浮点数=(float); //转换为浮点数calc_sth10(&,&; //修正相对湿度及温度temp=*10;humi=*10;wendu[0]=temp/1000+'0'; //温度百位wendu[1]=temp%1000/100+'0'; //温度十位wendu[2]=temp%100/10+'0'; //温度个位wendu[3]=0x2E; //小数点wendu[4]=temp%10+'0'; //温度小数点后第一位displaywendu();shidu[0]=humi/1000+'0'; //湿度百位shidu[1]=humi%1000/100+'0'; //湿度十位shidu[2]=humi%100/10+'0'; //湿度个位shidu[3]=0x2E; //小数点shidu[4]=humi%10+'0'; //湿度小数点后第一位displayshidu(); }Delay(800);//等待足够长的时间,以现行下一次转换}}。

12864系列点阵型液晶显示模块

12864系列点阵型液晶显示模块

12864系列点阵型液晶显⽰模块12864系列点阵型液晶显⽰模块⼀、OCM12864液晶显⽰模块概述⼀、OCM12864液晶显⽰模块概述1.OCM12864液晶显⽰模块是128×64点阵型液晶显⽰模块,可显⽰各种字符及图形,可与CPU直接接⼝,具有8位标准数据总线、6条控制线及电源线。

采⽤KS0107控制IC。

2.外观尺⼨:113×65×11mm(ocm12864-1), 93×70×10mm(ocm12864-2)78×70×10mm(ocm12864-3),3.视域尺⼨:73.4×38.8mm(ocm12864-1) 70.7×38mm(ocm12864-2),64×44mm(ocm12864-3)4.重量:⼤约 gl 补充说明:外观尺⼨可根据⽤户的要求进⾏适度调整。

⼆、最⼤⼯作范围1、逻辑⼯作电压(Vcc):4.5~5.5V2、电源地(GND):0V3、LCD驱动电压(Vee):0~-10V4、输⼊电压:Vee~Vdd5、⼯作温度(Ta):0~55℃(常温) / -20~70℃(宽温)6、保存温度(Tstg):-10~65℃三、电⽓特性(测试条件 Ta=25,Vdd=5.0+/-0.25V)1、输⼊⾼电平(Vih):3.5Vmin2、输⼊低电平(Vil):0.55Vmax3、输出⾼电平(Voh):3.75Vmin九、读写模块程序举例l 写指令⼦程序(INST)SETB ECLR D_ICLR R_WMOV P1, ACLR ERETl 写数据⼦程序(DATA)SETB ESETB D_ICLR R_WMOV P1, ACLR ERETl 写⼀页显⽰RAM数据(假设指令⼦程序为INST,数据⼦程序为DATA)MOV A,#0B8HLCALL INST ;置页地址为0页MOV A,#40HLCALL INST ;置列地址为0列MOV R2,#40HMOV R1,#00HMOV DPTR,#ADDRLOOP:MOV A,R1MOVC A,@A+DPTRLCALL DATAINC R1DJNZ R2, LOOP12864系列点阵型液晶显⽰模块⼀、OCM12864液晶显⽰模块概述⼀、OCM12864液晶显⽰模块概述1.OCM12864液晶显⽰模块是128×64点阵型液晶显⽰模块,可显⽰各种字符及图形,可与CPU直接接⼝,具有8位标准数据总线、6条控制线及电源线。

12864液晶显示模块概述

12864液晶显示模块概述

TC
13,000
Address setup time
TAS
1,500
Address hold time
TAH
1,500
Data setup time
TDDR
1,000
Unit KHz UNIT
ns ns ns ns ns ns ns
ns ns ns ns
使用说明书
Data hold time Enable pulsewidth Enable rise/fall time
2、 “RE”为基本指令集与扩充指令集的选择控制位元,当变更“RE”位元后,往后的指令集将维 持在最后的状态,除非再次变更“RE”位元,否则使用相同指令集时,不需每次重设“RE”位元。
72us
读出 RAM
从 内 部 RAM 读 取 资 料
的值
1 1 D7 D6 D5 D4 D3 D2 D1 D0 (DDRAM/CGRAM/IRAM/GDRAM)
72us
指令表—2:(RE=1:扩充指令集)
指令
指令码
RS RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
说明
执行时间 (540KHZ)
8 RS
H/L H: Data L: Instruction Code
9 NC
- 空脚
10 /RST
H/L Reset Signal 低电平有效
注K
背光源负极(LED-OV)
引脚 名称 11 DB0 12 DB1 13 DB2 14 DB3 15 DB4 16 DB5 17 DB6 18 DB7 19 NC 20 NC
A
方向 说明 I/O 数据 0 I/O 数据 1 I/O 数据 2 I/O 数据 3 I/O 数据 4 I/O 数据 5 I/O 数据 6 I/O 数据 7

泛海三江DH-9908N型组合式电气火灾监控探测器说明书

泛海三江DH-9908N型组合式电气火灾监控探测器说明书
1000±20
4
图8 温度传感器尺寸规格(单位mm)
剩余电流传感器接线
探测器具有一路剩余电流(漏电流)采样通道,对应端子位号为9-10号,外接剩余电流互感器,不区分极 性,剩余电流互感器一次侧额定电流1A,二次侧额定电流0.5mA,变比2000。外接剩余电流互感器型号如表4所 示。
表4 配接剩余电流互感器列表 型号
端子说明 第1路(T1)温度传感器输入端,无极性
第2路(T2)温度传感器输入端,无极性
第3路(T3)温度传感器输入端,无极性
第4路()温度传感器输入端,无极性
剩余电流互感器输入端,无极性
RS-485通信端口A RS-485通信端口B 探测器AC220V电源端口,无极性
故障状态继电器输出,常开触点,故障后闭合 火警状态继电器输出,常开触点,火警后闭合 零线输入端 三相电C相电压输入端 三相电B相电压输入端 三相电A相电压输入端 三相电C相电流(互感器同名端)输入端 三相电C相电流(互感器异名端)输出端 三相电B相电流(互感器同名端)输入端 三相电B相电流(互感器异名端)输出端 三相电A相电流(互感器同名端)输入端 三相电A相电流(互感器异名端)输出端
6. 通信
通讯端口:RS-485 2线半双工 通讯地址:1~247 校验位:无/奇/偶
网络协议:LwM2M 频段:B1/B3/B5/B8
RS-485有线通信 通讯波特率:4800bps/9600bps/19200bps/115200bps; 默认为9600 bps 通讯协议:Modbus-RTU 数据位:8bits,停止位:1bits ; 默认为无校验
NB-IoT 无线通信 模式:LTE Cat NB1 速度:LTE Cat Nb1: 最大62.5kbps 上行速率

12864液晶说明书(含源程序)

12864液晶说明书(含源程序)

FYD12864液晶中文显示模块(一) (一)概述 (3)(二)(二)外形尺寸1 方框图 (3)2 外型尺寸图 (4)(三)(三)模块的接口 (4)(四)(四)硬件说明 (5)(五) 指令说明 (7)(五)(五)读写操作时序 (8)(六)(六)交流参数 (11)(七)(七)软件初始化过程 (12)(八)(八)应用举例 (13)(九)(九)附录1半宽字符表 (20)2 汉字字符表 (21)一、概述FYD12864-0402B是一种具有4位/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块;其显示分辨率为128×64, 内置8192个16*16点汉字,和128个16*8点ASCII字符集.利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。

可以显示8×4行16×16点阵的汉字. 也可完成图形显示.低电压低功耗是其又一显著特点。

由该模块构成的液晶显示方案与同类型的图形点阵液晶显示模块相比,不论硬件电路结构或显示程序都要简洁得多,且该模块的价格也略低于相同点阵的图形液晶模块。

基本特性:●●低电源电压(VDD:+3.0--+5.5V)●●显示分辨率:128×64点●●内置汉字字库,提供8192个16×16点阵汉字(简繁体可选)●●内置 128个16×8点阵字符●●2MHZ时钟频率●●显示方式:STN、半透、正显●●驱动方式:1/32DUTY,1/5BIAS●●视角方向:6点●●背光方式:侧部高亮白色LED,功耗仅为普通LED的1/5—1/10 ●●通讯方式:串行、并口可选●●内置DC-DC转换电路,无需外加负压●●无需片选信号,简化软件设计●●工作温度: 0℃ - +55℃ ,存储温度: -20℃ - +60℃二、方框图3、外形尺寸图三、模块接口说明*注释1:如在实际应用中仅使用串口通讯模式,可将PSB接固定低电平,也可以将模块上的J8和“GND”用焊锡短接。

基于12864的万年历加温度显示设计

基于12864的万年历加温度显示设计

基于12864的万年历加温度显示设计摘要本设计将制作一种基于单片机控制的带实时温度显示、具有定时功能的电子万年历。

传统的电子日历大都体积大,功耗大,显示不准确等特点。

为了缩小体积,减小功耗,使其变得小巧灵敏,本设计加入了时钟芯片DS1302,可对时间进行准确记时,同时可设置定时时间,实现定时功能。

另外本设计具有显示实时温度的功能。

传统的温度传感器系统大都采用放大、调理、A/D转换,转换后的数字信号送入计算机处理,处理电路复杂、可靠性相对较差,占用计算机的资源比较多。

本设计将采用DS18B20一线制数字温度传感器,可将温度信号直接转换成数字信号送给微处理器,电路简单,成本低,实现了时间温度同时显示的效果。

最后,温度和时间都将通过12864液晶显示器进行显示。

测试表明系统达到了设计要求的各项功能,各部分工作正常。

关键词时钟/温度检测/单片机/温度MICROCONTROLLER-BASHED CALENDER AND TEMPERATURE DISPLAY DESIGNABSTRACTThis design creates an electronic calendar with real-time temperature display and timing function based on single chip control. Most of traditional calendars are characterized by large size, high power consumption and inaccurate display. In order to reduce volume and power consumption and make calendars become small and exquisite, the design adds a clock chip DS1302, which can accurately record the time and set a regular time to achieve timing function. In addition, this design displays real-time temperature function. Traditional temperature sensor system is mostly amplified, recuperated and A / D converted. The converted digital signal is input the computer to be processed, but the processing circuit is complicated with relatively poor reliability and occupies more resources of the computer. This design uses the DS18B20 first-line system digital temperature sensor to directly convert the temperature signal into digital signal and send it the microprocessor, whose circuit is simple and low cost, achieving the displayed effect of time and temperature simultaneously. Finally, the temperature and time will be displayed through the 12864 liquid crystal display. The test indicates that the system has reached various functions of the design requirements and each part operates smoothly.KEY WORDS clock, temperature detection, SCM, temperature目录中文摘要 (I)英文摘要.................................................................................................... I I 1概论. (1)1.1万年历发展背景 (1)1.2电子万年历的特点 (1)1.3国内外现状、发展 (1)2系统基本方案选择和论证 (2)2.1单片机芯片的选择方案和论证 (2)2.2显示模块的选择方案和论证 (3)2.3时钟芯片的选择方案和论证 (4)2.4温度传感器的选择方案和论证 (4)2.5电路设计最终方案确定 (5)3系统硬件电路设计 (6)3.1系统功能模块划分 (6)3.2各单元模块功能分析及模块电路设计 (6)3.2.1时钟模块 (6)3.2.2 温度模块 (7)3.2.3显示模块 (10)3.2.5 独立键盘模块 (18)3.2.6蜂鸣器模块 (19)3.2.7单片机模块 (20)3.3电路原理图的绘制和电路的焊接 (23)3.3.1原理图绘制软件PROTEL (23)3.3.2 PCB制作 (23)3.3.3 元器件的焊接 (24)4 系统软件设计 (26)4.1 万年历软件系统的流程图 (26)4.2温度信息的采集 (27)4.3时钟的读取 (30)4.3.1 DS1302控制字节的说明 (30)4.3.2 DS1302时间日期寄存器及相应位定义 (31)4.3.3 DS1302数据的输入和输出 (31)4.3.4 DS1302读写部分(程序)部分 (32)4.4温度的显示控制 (32)4.5键盘模块 (34)4.6蜂鸣器模块 (34)5设计总结 (35)致谢 (36)参考文献 (37)附录 (38)1 概论1.1 万年历发展背景随着电子技术的发展,人类不断研究,不断创新纪录。

CM12864-16说明书 12864应用

CM12864-16说明书 12864应用

CM12864-16说明书12864应用规格书LCD12864点阵屏控制芯片KS0108/0107兼容LMB12864FBC LM12864FFC LM12864LDY LM12864LFW OCM12864-5CM12864-16BLWAA-5V(蓝底白字)型号:CM12864-16SLWDA-5V(绿底黑字)CM12864-16FLWAA-5V(白底黑字)一.基本特征:(1)电压:3.0-3.3V/4.8-5V(2)STN反射/正视透射模式/半透(3)显式模式:蓝底白字、绿底黑字、蓝底黑字白底黑字、白底蓝字(4)显式角度:6/12/9点钟直视(5)驱动方式:1/32Dvty;1/6Bias(6)工作温度(Ta):-20℃~+70℃,存储温度:-25℃~+75℃(7)背光特征:LED背光(白色/黄绿色)(8)模块封装方式:COB(9)连接方式:并口(KS0108控制芯片)二.产品参数:三.限定参数:四.平面尺寸图:五.原理图:六.引脚描述:七.直流特性:技术支持136********szcj5808@ 八:接口时序:九.控制指令表:十.应用:十一.实物图片:十二.产品规格多样化:十三.程序参考:(并口测试程序)ORG0000HLJMP MAINORG0003HLJMP ZHONGDUANORG0035HZHONGDUAN:LCALL DELAYCLR EAJB P3.2,$SETB EALCALL DELAYRETICS1EQU P2.3CS2EQU P2.4DI EQU P2.0RW EQU P2.1E EQU P2.2DATA1EQU50HDATA2EQU51HDATA3EQU52H;***********写左半屏命令******************** WRITE_COMMAND_L:CLR CS1CLR RWCLR DIMOV P1,DATA1SETB ECLR ESETB CS1RET;***********写左半屏数据********************WRITE_DATA_L:CLR CS1CLR RWSETB DIMOV P1,DATA2SETB ECLR ESETB CS1RET;***********写右半屏命令********************WRITE_COMMAND_R:CLR CS2CLR RWCLR DIMOV P1,DATA1SETB E;DATA BE LOCKED IN FALL ASIDE CLR ESETB CS2;CHIP SELECTRET;***********写右半屏数据********************WRITE_DATA_R:CLR CS2CLR RWSETB DIMOV P1,DATA2SETB ECLR ESETB CS2RET;**********延时程序*******************MS40:MOV R7,#0E8HMS2:MOV R6,#0FFHMS1:DJNZ R6,MS1DJNZ R7,MS2RETDELAY:MOV R5,#07HDELAY1:LCALL MS40DJNZ R5,DELAY1RET;************************************MAIN:MOV P2,#0FFHMOV SP,#60HSETB EASETB EX0SETB IT0MOV DATA1,#3EH;DISPLAY OFFLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#3FH;DISPLAY ONLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#0C0H;Z START LINELCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#0B8H;PAGE ADDRESS0LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40H;Y ADDRESS0LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DPTR,#CHINESE2MOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M27:MOV DATA1,DATA3LCALL WRITE_COMMAND_LMOV DATA1,#40HLCALL WRITE_COMMAND_LMOV R2,#64L27:CLR AMOVC A,@A+DPTRMOV DATA2,ALCALL WRITE_DATA_LINC DPTRDJNZ R2,L27INC DATA3DJNZ R1,M27MOV DPTR,#CHINESE1MOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M28:MOV DATA1,DATA3LCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_RMOV R2,#64L28:CLR AMOVC A,@A+DPTRMOV DATA2,ALCALL WRITE_DATA_RINC DPTRDJNZ R2,L28INC DATA3DJNZ R1,M28LCALL DELAYMOV DPTR,#CHINESE4MOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M29:MOV DATA1,DATA3LCALL WRITE_COMMAND_LMOV DATA1,#40HLCALL WRITE_COMMAND_LMOV R2,#64L29:CLR AMOVC A,@A+DPTRMOV DATA2,ALCALL WRITE_DATA_LINC DPTRDJNZ R2,L29INC DATA3DJNZ R1,M29MOV DPTR,#CHINESE3MOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M30:MOV DATA1,DATA3LCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_RMOV R2,#64L30:CLR AMOVC A,@A+DPTRMOV DATA2,ALCALL WRITE_DATA_RINC DPTRDJNZ R2,L30INC DATA3DJNZ R1,M30LCALL DELAYMOV R1,#8MOV DATA3,#0B8H;PAGE0MOV DATA1,DATA3M21:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40H;COLUMN0LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#64L21:MOV DATA2,#0AAHLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L21INC DATA3DJNZ R1,M21LCALL DELAYMOV R1,#8MOV DATA1,DATA3M22:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#64L22:MOV DATA2,#55HLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L22INC DATA3DJNZ R1,M22LCALL DELAYMOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M23:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#32L23:MOV DATA2,#0FFHLCALL WRITE_DATA_LLCALL WRITE_DATA_RMOV DATA2,#00HLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L23INC DATA3DJNZ R1,M23LCALL DELAYMOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M24:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#32L24:MOV DATA2,#00HLCALL WRITE_DATA_LLCALL WRITE_DATA_RMOV DATA2,#0FFHLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L24INC DATA3DJNZ R1,M24LCALL DELAYMOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M25:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#32L25:MOV DATA2,#0AAHLCALL WRITE_DATA_LLCALL WRITE_DATA_RMOV DATA2,#55HLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L25INC DATA3DJNZ R1,M25LCALL DELAYMOV R1,#8MOV DATA3,#0B8HMOV DATA1,DATA3M26:MOV DATA1,DATA3LCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV DATA1,#40HLCALL WRITE_COMMAND_LLCALL WRITE_COMMAND_RMOV R2,#32L26:MOV DATA2,#55HLCALL WRITE_DATA_LLCALL WRITE_DATA_RMOV DATA2,#0AAHLCALL WRITE_DATA_LLCALL WRITE_DATA_RDJNZ R2,L26INC DATA3DJNZ R1,M26LCALL DELAYLJMP MAIN;纵向取模,字节倒序CHINESE1:DB0FFH,001H,021H,0A1H,021H,061H,0B1H,011H,011H,0D1H,081H,001H,001H,081H,061H,041H DB001H,001H,001H,001H,001H,001H,0E1H,0A1H,0A1H,0A1H,0A1H,0A1H,0A1H,0E1H,001H,001H DB001H,001H,001H,021H,021H,021H,0E1H,011H,011H,001H,021H,0C1H,001H,001H,0F1H,001H DB001H,001H,081H,081H,081H,0F1H,081H,081H,001H,081H,081H,081H,0F1H,081H,081H,081H DB0FFH,000H,008H,008H,08BH,068H,0FDH,02AH,049H,088H,088H,002H,021H,010H,088H,076H DB024H,000H,000H,0F0H,050H,050H,057H,052H,0F2H,002H,002H,0F2H,052H,057H,050H,050H DB0F0H,000H,041H,021H,019H,007H,0FFH,005H,049H,040H,042H,02CH,020H,020H,0FFH,010H DB010H,000H,010H,010H,008H,0FFH,004H,002H,000H,00CH,034H,0C4H,0C7H,024H,01CH,004H DB0FFH,000H,002H,001H,000H,000H,08FH,080H,080H,085H,004H,002H,002H,001H,000H,000H DB000H,000H,000H,007H,002H,002H,002H,002H,007H,000H,000H,007H,002H,002H,002H,002H DB007H,000H,000H,000H,000H,000H,00FH,080H,080H,000H,000H,000H,000H,000H,08FH,000H DB000H,000H,000H,004H,008H,087H,000H,004H,004H,002H,001H,000H,080H,001H,002H,006H DB0FFH,000H,041H,045H,059H,043H,0EDH,050H,048H,046H,044H,010H,008H,084H,043H,0B2H DB020H,000H,000H,080H,080H,080H,0BFH,095H,095H,015H,015H,095H,095H,0BFH,080H,080H DB080H,000H,008H,009H,0C9H,039H,0FFH,028H,048H,000H,011H,066H,000H,000H,0FFH,080H DB080H,000H,084H,084H,044H,0FFH,024H,014H,000H,064H,0A4H,024H,03FH,024H,0E4H,024H DB0FFH,000H,010H,008H,004H,003H,07FH,001H,002H,02CH,024H,010H,011H,008H,004H,003H DB001H,000H,000H,03FH,012H,012H,012H,012H,03FH,000H,000H,03FH,012H,012H,012H,012H DB03FH,000H,002H,001H,000H,000H,07FH,000H,002H,002H,002H,001H,001H,001H,07FH,000H DB000H,000H,000H,020H,040H,03FH,000H,020H,020H,010H,009H,006H,006H,009H,010H,030H DB0FFH,000H,020H,0A0H,020H,060H,0B0H,010H,010H,0D0H,080H,000H,000H,080H,060H,040H DB000H,000H,000H,000H,000H,000H,0E0H,0A0H,0A0H,0A0H,0A0H,0A0H,0A0H,0E0H,000H,000H DB000H,000H,000H,020H,020H,020H,0E0H,010H,010H,000H,020H,0C0H,000H,000H,0F0H,000H DB000H,000H,080H,080H,080H,0F0H,080H,080H,000H,080H,080H,080H,0F0H,080H,080H,080HDB0FFH,000H,008H,008H,08BH,068H,0FDH,02AH,049H,088H,088H,002H,021H,010H,088H,076HDB024H,000H,000H,0F0H,050H,050H,057H,052H,0F2H,002H,002H,0F2H,052H,057H,050H,050HDB0F0H,000H,041H,021H,019H,007H,0FFH,005H,049H,040H,042H,02CH,020H,020H,0FFH,010HDB010H,000H,010H,010H,008H,0FFH,004H,002H,000H,00CH,034H,0C4H,0C7H,024H,01CH,004HDB0FFH,080H,082H,081H,080H,080H,08FH,080H,080H,085H,084H,082H,082H,081H,080H,080HDB080H,080H,080H,087H,082H,082H,082H,082H,087H,080H,080H,087H,082H,082H,082H,082HDB087H,080H,080H,080H,080H,080H,08FH,080H,080H,080H,080H,080H,080H,080H,08FH,080HDB080H,080H,080H,084H,088H,087H,080H,084H,084H,082H,081H,080H,080H,081H,082H,086H/*DB0FFH,0FFH,003H,023H,0A3H,023H,063H,0B3H,013H,013H,0D3H,083H,003H,003H,083H,063HDB043H,003H,003H,003H,003H,003H,0E3H,0A3H,0A3H,0A3H,0A3H,0A3H,0A3H,0E3H,003H,003H DB003H,003H,003H,023H,023H,023H,0E3H,013H,013H,003H,023H,0C3H,003H,003H,0F3H,003HDB003H,003H,083H,083H,083H,0F3H,083H,083H,003H,083H,083H,083H,0F3H,083H,083H,083HDB0FFH,0FFH,000H,008H,008H,08BH,068H,0FDH,02AH,049H,088H,088H,002H,021H,010H,088HDB076H,024H,000H,0F0H,050H,050H,057H,052H,0F2H,002H,002H,0F2H,052H,057H,050H,050HDB0F0H,000H,041H,021H,019H,007H,0FFH,005H,049H,040H,042H,02CH,020H,020H,0FFH,010HDB010H,000H,010H,010H,008H,0FFH,004H,002H,000H,00CH,034H,0C4H,0C7H,024H,01CH,004HDB0FFH,0FFH,000H,002H,001H,000H,000H,00FH,000H,000H,005H,004H,002H,002H,001H,000HDB000H,000H,000H,007H,002H,002H,002H,002H,007H,000H,000H,007H,002H,002H,002H,002HDB007H,000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H,00FH,000HDB000H,000H,000H,004H,008H,007H,000H,004H,004H,002H,001H,000H,000H,001H,002H,006HDB0FFH,0FFH,000H,082H,08AH,0B2H,086H,0DBH,0A1H,091H,08DH,088H,020H,010H,008H,086H DB064H,040H,000H,000H,000H,000H,07EH,02AH,02AH,02AH,02AH,02AH,02AH,07EH,000H,000H DB000H,000H,010H,012H,092H,072H,0FEH,051H,091H,000H,022H,0CCH,000H,000H,0FFH,000HDB000H,000H,008H,008H,088H,0FFH,048H,028H,000H,0C8H,048H,048H,07FH,048H,0C8H,048HDB0FFH,0FFH,000H,020H,010H,008H,006H,0FFH,002H,004H,058H,048H,020H,022H,011H,008HDB007H,002H,000H,07FH,025H,025H,025H,025H,07FH,000H,000H,07FH,025H,025H,025H,025HDB07FH,000H,004H,002H,001H,000H,0FFH,000H,004H,004H,004H,002H,002H,002H,0FFH,001HDB001H,000H,001H,041H,080H,07FH,000H,040H,040H,020H,013H,00CH,00CH,012H,021H,060HDB0FFH,0FFH,000H,010H,050H,090H,030H,0D8H,008H,088H,068H,040H,000H,080H,040H,030HDB020H,000H,000H,000H,000H,000H,0F0H,050H,050H,050H,050H,050H,050H,0F0H,000H,000HDB000H,000H,080H,090H,090H,090H,0F0H,088H,088H,000H,010H,060H,000H,000H,0F8H,000HDB000H,000H,040H,040H,040H,0F8H,040H,040H,000H,040H,040H,040H,0F8H,040H,040H,040HDB0FFH,0FFH,000H,004H,084H,045H,034H,0FEH,015H,024H,0C4H,044H,001H,010H,088H,044HDB03BH,012H,000H,0F8H,028H,028H,02BH,029H,0F9H,001H,001H,0F9H,029H,02BH,028H,028HDB0F8H,000H,020H,010H,00CH,003H,0FFH,002H,024H,020H,021H,016H,010H,010H,0FFH,008HDB008H,000H,008H,008H,004H,0FFH,002H,001H,000H,006H,09AH,062H,063H,092H,00EH,002HDB0FFH,0FFH,0C0H,0C1H,0C0H,0C0H,0C0H,0C7H,0C0H,0C0H,0C2H,0C2H,0C1H,0C1H,0C0H,0C0H DB0C0H,0C0H,0C0H,0C3H,0C1H,0C1H,0C1H,0C1H,0C3H,0C0H,0C0H,0C3H,0C1H,0C1H,0C1H,0C1H DB0C3H,0C0H,0C0H,0C0H,0C0H,0C0H,0C7H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C7H,0C0H DB0C0H,0C0H,0C0H,0C2H,0C4H,0C3H,0C0H,0C2H,0C2H,0C1H,0C0H,0C0H,0C0H,0C0H,0C1H,0C3H */CHINESE2:DB081H,001H,001H,041H,041H,041H,041H,041H,0C1H,071H,041H,041H,041H,041H,041H,041H DB041H,001H,0E1H,021H,021H,0E1H,021H,001H,0E1H,0A1H,0A1H,0A1H,0A1H,0A1H,0E1H,001H DB001H,001H,001H,001H,001H,001H,0E1H,041H,001H,001H,0E1H,001H,001H,001H,001H,001H DB001H,001H,021H,021H,021H,021H,021H,021H,021H,021H,021H,021H,021H,0E1H,001H,0FFHDB000H,000H,020H,010H,008H,004H,0FEH,093H,092H,092H,092H,092H,092H,0FEH,000H,000H DB000H,000H,0FFH,000H,023H,044H,038H,000H,0FFH,004H,00CH,034H,0C4H,024H,017H,000H DB000H,000H,010H,008H,004H,083H,040H,038H,010H,000H,000H,041H,086H,00CH,018H,008H DB000H,001H,0F9H,049H,049H,049H,049H,049H,049H,0F9H,001H,000H,000H,0FFH,000H,0FFHDB002H,000H,000H,000H,000H,000H,00FH,000H,000H,080H,002H,004H,00CH,007H,000H,000H DB000H,000H,00FH,000H,000H,000H,000H,000H,00FH,004H,002H,000H,000H,001H,002H,006H DB002H,000H,000H,002H,007H,002H,002H,002H,003H,001H,001H,001H,007H,003H,000H,000H DB000H,000H,001H,000H,000H,000H,000H,000H,000H,000H,000H,002H,004H,003H,000H,0FFHDB004H,000H,000H,082H,042H,022H,0F2H,09AH,096H,093H,092H,092H,092H,0F2H,002H,002H DB002H,000H,0FFH,001H,019H,027H,0C1H,000H,0FFH,025H,065H,0A5H,025H,025H,0BFH,000H DB000H,000H,080H,040H,020H,018H,007H,0C2H,080H,000H,007H,008H,030H,060H,0C0H,040H DB000H,008H,0C9H,049H,049H,049H,049H,049H,049H,0C9H,009H,001H,001H,0FFH,000H,0FFHDB010H,000H,001H,000H,000H,000H,07FH,004H,004H,004H,014H,024H,064H,03FH,000H,000H DB000H,000H,07FH,000H,001H,002H,001H,000H,07FH,020H,010H,001H,006H,009H,010H,030H DB010H,000H,000H,010H,038H,014H,012H,011H,018H,008H,008H,00AH,03CH,018H,000H,000H DB000H,000H,00FH,002H,002H,002H,002H,002H,002H,007H,000H,010H,020H,01FH,000H,0FFHDB080H,000H,000H,040H,040H,040H,040H,040H,0C0H,070H,040H,040H,040H,040H,040H,040H DB040H,000H,0E0H,020H,020H,0E0H,020H,000H,0E0H,0A0H,0A0H,0A0H,0A0H,0A0H,0E0H,000H DB000H,000H,000H,000H,000H,000H,0E0H,040H,000H,000H,0E0H,000H,000H,000H,000H,000H DB000H,000H,020H,020H,020H,020H,020H,020H,020H,020H,020H,020H,020H,0E0H,000H,0FFHDB000H,000H,020H,010H,008H,004H,0FEH,093H,092H,092H,092H,092H,092H,0FEH,000H,000H DB000H,000H,0FFH,000H,023H,044H,038H,000H,0FFH,004H,00CH,034H,0C4H,024H,017H,000H DB000H,000H,010H,008H,004H,083H,040H,038H,010H,000H,000H,041H,086H,00CH,018H,008H DB000H,001H,0F9H,049H,049H,049H,049H,049H,049H,0F9H,001H,000H,000H,0FFH,000H,0FFHDB082H,080H,080H,080H,080H,080H,08FH,080H,080H,080H,082H,084H,08CH,087H,080H,080HDB080H,080H,08FH,080H,080H,080H,080H,080H,08FH,084H,082H,080H,080H,081H,082H,086HDB082H,080H,080H,082H,087H,082H,082H,082H,083H,081H,081H,081H,087H,083H,080H,080HDB080H,080H,081H,080H,080H,080H,080H,080H,080H,080H,080H,082H,084H,083H,080H,0FFH/*DB083H,003H,043H,043H,043H,043H,043H,0C3H,073H,043H,043H,043H,043H,043H,043H,043HDB003H,0E3H,023H,023H,0E3H,023H,003H,0E3H,0A3H,0A3H,0A3H,0A3H,0A3H,0E3H,003H,003H DB003H,003H,003H,003H,003H,0E3H,043H,003H,003H,0E3H,003H,003H,003H,003H,003H,003HDB003H,023H,023H,023H,023H,023H,023H,023H,023H,023H,023H,023H,0E3H,003H,0FFH,0FFHDB000H,020H,010H,008H,004H,0FEH,093H,092H,092H,092H,092H,092H,0FEH,000H,000H,000HDB000H,0FFH,000H,023H,044H,038H,000H,0FFH,004H,00CH,034H,0C4H,024H,017H,000H,000HDB000H,010H,008H,004H,083H,040H,038H,010H,000H,000H,041H,086H,00CH,018H,008H,000HDB001H,0F9H,049H,049H,049H,049H,049H,049H,0F9H,001H,000H,000H,0FFH,000H,0FFH,0FFHDB002H,000H,000H,000H,000H,00FH,000H,000H,000H,002H,004H,00CH,007H,000H,000H,000HDB000H,00FH,000H,000H,000H,000H,000H,00FH,004H,002H,000H,000H,001H,002H,006H,002HDB000H,000H,002H,007H,002H,002H,002H,003H,001H,001H,001H,007H,003H,000H,000H,000HDB000H,001H,000H,000H,000H,000H,000H,000H,000H,000H,002H,004H,003H,000H,0FFH,0FFHDB008H,000H,004H,084H,044H,0E4H,034H,02CH,027H,024H,024H,024H,0E4H,004H,004H,004HDB000H,0FEH,002H,032H,04EH,082H,000H,0FEH,04AH,0CAH,04AH,04AH,04AH,07EH,000H,000H DB000H,000H,080H,040H,030H,00EH,084H,000H,000H,00EH,010H,060H,0C0H,080H,080H,000HDB010H,092H,092H,092H,092H,092H,092H,092H,092H,012H,002H,002H,0FEH,000H,0FFH,0FFHDB020H,002H,001H,000H,000H,0FFH,009H,009H,009H,029H,049H,0C9H,07FH,000H,000H,000HDB000H,0FFH,000H,002H,004H,003H,000H,0FFH,040H,020H,003H,00CH,012H,021H,060H,020HDB000H,001H,020H,070H,028H,024H,023H,031H,010H,010H,014H,078H,030H,001H,000H,000HDB000H,01FH,004H,004H,004H,004H,004H,004H,00FH,000H,020H,040H,03FH,000H,0FFH,0FFHDB040H,000H,020H,020H,020H,020H,0A0H,060H,038H,020H,020H,020H,020H,020H,020H,020HDB000H,0F0H,010H,090H,070H,010H,000H,0F0H,050H,050H,050H,050H,050H,0F0H,000H,000HDB000H,000H,000H,000H,080H,070H,020H,000H,000H,070H,080H,000H,000H,000H,000H,000HDB080H,090H,090H,090H,090H,090H,090H,090H,090H,090H,010H,010H,0F0H,000H,0FFH,0FFHDB000H,010H,008H,004H,002H,0FFH,049H,049H,049H,049H,049H,049H,0FFH,000H,000H,000HDB000H,0FFH,000H,011H,022H,01CH,000H,0FFH,002H,006H,01AH,062H,092H,00BH,000H,000HDB000H,008H,004H,082H,041H,020H,01CH,088H,080H,080H,0A0H,0C3H,086H,00CH,004H,000HDB000H,0FCH,024H,024H,024H,024H,024H,024H,07CH,000H,000H,000H,0FFH,000H,0FFH,0FFHDB0C1H,0C0H,0C0H,0C0H,0C0H,0C7H,0C0H,0C0H,0C0H,0C1H,0C2H,0C6H,0C3H,0C0H,0C0H,0C0H DB0C0H,0C7H,0C0H,0C0H,0C0H,0C0H,0C0H,0C7H,0C2H,0C1H,0C0H,0C0H,0C0H,0C1H,0C3H,0C1H DB0C0H,0C0H,0C1H,0C3H,0C1H,0C1H,0C1H,0C1H,0C0H,0C0H,0C0H,0C3H,0C1H,0C0H,0C0H,0C0H DB0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C1H,0C2H,0C1H,0C0H,0FFH,0FFH*/CHINESE3:DB0FFH,001H,001H,001H,001H,001H,001H,0E1H,081H,001H,001H,021H,0E1H,021H,021H,0C1H DB001H,0C1H,021H,021H,021H,061H,001H,021H,0E1H,021H,021H,0C1H,001H,021H,0E1H,021H DB0A1H,061H,001H,021H,0E1H,021H,0A1H,061H,001H,081H,041H,021H,021H,061H,001H,021H DB0E1H,001H,001H,0E1H,021H,021H,021H,0E1H,021H,021H,001H,081H,041H,021H,021H,061HDB0FFH,000H,000H,000H,000H,010H,01FH,004H,007H,01CH,010H,010H,01FH,011H,011H,00EH DB000H,00FH,010H,010H,010H,008H,000H,010H,01FH,010H,010H,00FH,000H,010H,01FH,011H DB013H,018H,000H,010H,01FH,011H,003H,000H,000H,007H,008H,010H,012H,00EH,002H,010H DB01FH,001H,001H,01FH,010H,010H,010H,01FH,010H,010H,000H,007H,008H,010H,012H,00EH DB0FFH,000H,000H,000H,000H,0E0H,010H,010H,010H,0E0H,000H,000H,020H,0F0H,000H,000H DB000H,060H,010H,010H,090H,060H,000H,020H,010H,090H,090H,060H,000H,000H,0C0H,020H DB0F0H,000H,000H,0F0H,090H,090H,090H,010H,000H,0E0H,090H,090H,0B0H,000H,000H,030H DB010H,090H,070H,010H,000H,060H,090H,090H,090H,060H,000H,0E0H,010H,010H,010H,0E0H DB0FFH,000H,000H,000H,000H,007H,008H,008H,008H,007H,000H,000H,008H,00FH,008H,000H DB000H,00CH,00AH,009H,008H,008H,000H,004H,008H,008H,008H,007H,000H,001H,002H,002H DB00FH,00AH,000H,004H,008H,008H,008H,007H,000H,007H,008H,008H,008H,007H,000H,000H DB000H,00FH,000H,000H,000H,007H,008H,008H,008H,007H,000H,000H,00DH,009H,009H,007H DB0FFH,000H,000H,000H,000H,000H,0C0H,038H,0E0H,000H,000H,008H,0F8H,048H,048H,0B0H DB000H,0F0H,008H,008H,008H,018H,000H,008H,0F8H,008H,008H,0F0H,000H,008H,0F8H,048H DB0E8H,018H,000H,008H,0F8H,048H,0E8H,018H,000H,0E0H,010H,008H,088H,098H,080H,008H DB0F8H,040H,040H,0F8H,008H,008H,008H,0F8H,008H,008H,000H,0E0H,010H,008H,088H,098HDB0FFH,000H,000H,000H,000H,004H,007H,001H,001H,007H,004H,004H,007H,004H,004H,003H DB000H,003H,004H,004H,004H,002H,000H,004H,007H,004H,004H,003H,000H,004H,007H,004H DB004H,006H,000H,004H,007H,004H,000H,000H,000H,001H,002H,004H,004H,003H,000H,004H DB007H,000H,000H,007H,004H,004H,004H,007H,004H,004H,000H,001H,002H,004H,004H,003H DB0FFH,000H,000H,000H,000H,0F8H,004H,004H,004H,0F8H,000H,000H,008H,0FCH,000H,000H DB000H,018H,084H,044H,024H,018H,000H,008H,004H,024H,024H,0D8H,000H,040H,0B0H,088H DB0FCH,080H,000H,03CH,024H,024H,024H,0C4H,000H,0F8H,024H,024H,02CH,0C0H,000H,00CH DB004H,0E4H,01CH,004H,000H,0D8H,024H,024H,024H,0D8H,000H,038H,044H,044H,044H,0F8HDB0FFH,080H,080H,080H,080H,081H,082H,082H,082H,081H,080H,080H,082H,083H,082H,080H DB080H,083H,082H,082H,082H,082H,080H,081H,082H,082H,082H,081H,080H,080H,080H,080H DB083H,082H,080H,081H,082H,082H,082H,081H,080H,081H,082H,082H,082H,081H,080H,080H DB080H,083H,080H,080H,080H,081H,082H,082H,082H,081H,080H,080H,083H,082H,082H,081HCHINESE4:DB001H,021H,0E1H,021H,081H,061H,021H,021H,0E1H,021H,001H,001H,001H,0E1H,0E1H,001H DB0E1H,0E1H,001H,021H,0E1H,081H,021H,0E1H,021H,0C1H,021H,021H,021H,0C1H,001H,021H DB0E1H,021H,021H,0C1H,001H,0C1H,021H,021H,021H,0C1H,001H,021H,0E1H,021H,021H,0C1H DB001H,0C1H,021H,021H,021H,061H,001H,061H,021H,0E1H,021H,061H,001H,001H,001H,0FFHDB002H,010H,01FH,011H,006H,018H,010H,010H,01FH,010H,010H,010H,018H,01FH,001H,01EH DB001H,01FH,000H,010H,01FH,011H,006H,01FH,000H,00FH,010H,010H,010H,00FH,000H,010HDB01FH,011H,001H,000H,000H,00FH,014H,014H,038H,02FH,000H,010H,01FH,011H,003H,01CH DB010H,018H,011H,011H,012H,00CH,000H,000H,010H,01FH,010H,000H,000H,000H,000H,0FFHDB000H,0E0H,010H,010H,010H,0E0H,000H,000H,020H,0F0H,000H,000H,000H,060H,010H,010H DB090H,060H,000H,020H,010H,090H,090H,060H,000H,000H,0C0H,020H,0F0H,000H,000H,0F0H DB090H,090H,090H,010H,000H,0E0H,090H,090H,0B0H,000H,000H,030H,010H,090H,070H,010H DB000H,060H,090H,090H,090H,060H,000H,0E0H,010H,010H,010H,0E0H,000H,000H,000H,0FFHDB000H,007H,008H,008H,008H,007H,000H,000H,008H,00FH,008H,000H,000H,00CH,00AH,009H DB008H,008H,000H,004H,008H,008H,008H,007H,000H,001H,002H,002H,00FH,00AH,000H,004H DB008H,008H,008H,007H,000H,007H,008H,008H,008H,007H,000H,000H,000H,00FH,000H,000H DB000H,007H,008H,008H,008H,007H,000H,000H,00DH,009H,009H,007H,000H,000H,000H,0FFHDB080H,008H,0F8H,048H,0A0H,018H,008H,008H,0F8H,008H,000H,000H,000H,0F8H,078H,080H DB078H,0F8H,000H,008H,0F8H,060H,088H,0F8H,008H,0F0H,008H,008H,008H,0F0H,000H,008H DB0F8H,048H,048H,030H,000H,0F0H,008H,008H,008H,0F0H,000H,008H,0F8H,048H,0C8H,030H DB000H,030H,048H,048H,088H,018H,000H,018H,008H,0F8H,008H,018H,000H,000H,000H,0FFHDB000H,004H,007H,004H,001H,006H,004H,004H,007H,004H,004H,004H,006H,007H,000H,007H DB000H,007H,000H,004H,007H,004H,001H,007H,000H,003H,004H,004H,004H,003H,000H,004H DB007H,004H,000H,000H,000H,003H,005H,005H,00EH,00BH,000H,004H,007H,004H,000H,007H DB004H,006H,004H,004H,004H,003H,000H,000H,004H,007H,004H,000H,000H,000H,000H,0FFHDB000H,0F8H,004H,004H,004H,0F8H,000H,000H,008H,0FCH,000H,000H,000H,018H,084H,044H DB024H,018H,000H,008H,004H,024H,024H,0D8H,000H,040H,0B0H,088H,0FCH,080H,000H,03CH DB024H,024H,024H,0C4H,000H,0F8H,024H,024H,02CH,0C0H,000H,00CH,004H,0E4H,01CH,004H DB000H,0D8H,024H,024H,024H,0D8H,000H,038H,044H,044H,044H,0F8H,000H,000H,000H,0FFHDB080H,081H,082H,082H,082H,081H,080H,080H,082H,083H,082H,080H,080H,083H,082H,082H DB082H,082H,080H,081H,082H,082H,082H,081H,080H,080H,080H,080H,083H,082H,080H,081H DB082H,082H,082H,081H,080H,081H,082H,082H,082H,081H,080H,080H,080H,083H,080H,080H DB080H,081H,082H,082H,082H,081H,080H,080H,083H,082H,082H,081H,080H,080H,080H,0FFHEND有技术团队,有需要可技术支持!。

12864LCD上显示温湿度.

12864LCD上显示温湿度.

12864LCD显示温湿度第一种方式:/**********************DHT11与12864LCD************************/ #include <reg52.h>#define uchar unsigned char#define uint unsigned intuchar lcd_x,lcd_y,data_byte=0,count;uint TH_data,TL_data,RH_data,RL_data,CK_data;uint TH_temp,TL_temp,RH_temp,RL_temp,CK_temp;uchar num;sbit RS = P2^0;//并行指令,数据选择信号sbit RW = P2^1;//读写信号sbit EN = P2^2;//并行使能信号sbit PSB = P2^3;//并串口选择信号sbit RST = P2^5;//复位信号sbit io = P1^0;//DHT11总线void read_io();//开始信号,读数据并校验void delay(uint a);//延时函数void LCD_init();//LCD初始化程序void write_cmd(uchar cmd);//写指令void write_data(uchar dat);//写数据bit check_busy();//检测LCD忙信号//void clear_gcrom();//清除GCROMvoid delay1();//10us延时void lcd_dis_code(uint cmd_addr,uchar num,uchar dis[]);//显示函数void lcd_pos(unsigned char X,unsigned char Y);//LCD显示位置计算uchar code lcd[]={"温湿度检测系统"};uchar code lcd1[]={" 温度:"};uchar code lcd2[]={" 湿度:"};uchar code lcd3[]={"℃"};uchar code lcd4[]={"%RH"};uchar str1[]={" "};uchar str2[]={" "};void main(){uchar k,j;LCD_init();lcd_dis_code(0x80,16,lcd);lcd_dis_code(0x88,9,lcd1);lcd_dis_code(0x98,9,lcd2);lcd_dis_code(0x8e,2,lcd3);lcd_dis_code(0x9e,5,lcd4);while(1){read_io();//读取温湿度数据//clear_gcrom();//湿度for(k=0; k<2; k++){lcd_pos(4,k+4);write_data(str1[k]);}//clear_gcrom();//温度for(j=0; j<2; j++){lcd_pos(3,j+4);write_data(str2[j]);}delay(500);}}void delay1()//延时10us{unsigned char i;for(i=0; i<3; i++);}void lcd_pos(unsigned char X,unsigned char Y){unsigned char pos;if ( X == 1 ){ pos = 0x80 ; }else if ( X == 2 ){ pos = 0x90 ; }else if ( X == 3 ){ pos = 0x88 ; }else{ pos = 0x98 ; }write_cmd(Y | pos);//数据指针=80+地址变量}/**********************DHT11模块**********************/ uchar receive_byte()//接收一个字节{uchar i,temp;for(i=0;i<8; i++){count = 2;while((!io) && count++)//等待50us低电平结束,并防止死循环temp = 0;delay1();delay1();delay1();if (io==1){temp = 1;count = 2;while(io && count++);}elsetemp = 0;data_byte<<=1;data_byte|=temp;}return (data_byte);}void read_io()//开始信号,读数据并校验{io = 0;delay(18);//主机拉低18msio = 1;//DATA总线由上拉电阻拉高主机延时20usdelay1();delay1();delay1();delay1();io = 1;//主机设置为输入高电平,判断从机响应信号if(!io){count = 2;while((!io)&&count++);//判断DHT11发出80us低电平响应信号是否结束count = 2;while(io && count++);//判断DHT11拉高总线80us高电平是否结束RH_temp = receive_byte();RL_temp = receive_byte();TH_temp = receive_byte();TL_temp = receive_byte();CK_temp = receive_byte();io = 1;num = (RH_temp + RL_temp + TH_temp + TL_temp);//数据校验if(num == CK_temp){RH_data = RH_temp;RL_data = RL_temp;TH_data = TH_temp;TL_data = TL_temp;CK_data = CK_temp;}}//湿度整数部分str1[0] = (char)(0x30 + RH_data/10);str1[1] = (char)(0x30 + RH_data%10);//温度整数部分str2[0] = (char)(0x30 + TH_data/10);str2[1] = (char)(0x30 + TH_data%10);}/**********************E N D**********************//**********************12864模块程序**********************/ /*void clear_gcrom(){uchar i,j,k;lcd_x = 0x80;lcd_y = 0x80;write_cmd(0x34);for(i = 0 ; i < 2 ; i++) //上下两屏幕{for(j = 0 ; j < 32 ; j++){write_cmd(lcd_y+j);write_cmd(lcd_x);for(k = 0 ; k < 16 ; k++){write_data(0x00);}}lcd_x = 0x88;}write_cmd(0x36);write_cmd(0x30);}*/void lcd_dis_code(uint cmd_addr,uchar num,uchar dis[]) {uint i;write_cmd(cmd_addr);for(i=0; i<num; i++)write_data(dis[i]);}void LCD_init(){PSB = 1;RST = 0;delay(5);RST = 1;delay(5);write_cmd(0x34);//扩充指令delay(5);write_cmd(0x30);//基本指令delay(5);write_cmd(0x0c);//显示开关光标delay(5);write_cmd(0x01);//清屏delay(5);}bit check_busy(){bit temp;RS = 0;RW = 1;EN = 1;delay(5);temp = (bit)(P0&0x80); //按位与操作EN = 0;return (temp);}void write_cmd(uchar cmd){while(check_busy());RS = 0;RW = 0;EN = 0;delay(5);P0 = cmd;delay(5);EN = 1;delay(5);EN = 0;}void write_data(uchar dat){while(check_busy());RS = 1;RW = 0;EN = 0;P0 = dat;delay(5);EN = 1;delay(5);EN = 0;}void delay(uint a){uchar i;while(a--){for(i=0; i<113; i++);}}/**********************E N D**********************/第二种编程方式,其实大体都差不了多少#include <reg52.h> #include <intrins.h>/******************************************************** 宏定义********************************************************/#define uint unsigned int#define uchar unsigned char#define noACK 0#define ACK 1#define STATUS_REG_W 0x06#define STATUS_REG_R 0x07#define MEASURE_TEMP 0x03#define MEASURE_HUMI 0x05#define RESET 0x1eenum {TEMP,HUMI};typedef union //定义共用同类型{unsigned int i;float f;}value;/********************************************************位定义********************************************************/sbit lcdrs=P2^0;sbit lcdrw=P2^1;sbit lcden=P2^2;sbit SCK = P1^0;sbit DA TA = P1^1;/********************************************************变量定义********************************************************/uchar table2[]="SHT11 温湿度检测";uchar table3[]="温度为:℃";uchar table4[]="湿度为:";uchar table5[]=".";uchar wendu[6];uchar shidu[6];/******************************************************** 1ms延时函数********************************************************/void delay(int z){ int x,y;for(x=z;x>0;x--)for(y=125;y>0;y--); }/******************************************************** 50us延时函数********************************************************/void delay_50us(uint t){uint j;for(;t>0;t--)for(j=19;j>0;j--);}/********************************************************50ms延时函数********************************************************/void delay_50ms(uint t){uint j;for(;t>0;t--)for(j=6245;j>0;j--);}/********************************************************12864液晶写指令********************************************************/void write_12864com(uchar com){ lcdrs=0;lcdrw=0;delay_50us(1);P0=com;lcden=1;delay_50us(10);lcden=0;delay_50us(2);}/********************************************************12864液晶写数据********************************************************/ void write_dat(uchar dat) { lcdrs=1;lcdrw=0;delay_50us(1);P0=dat;lcden=1;delay_50us(10);lcden=0;delay_50us(2); }/********************************************************12864液晶初始化********************************************************/void init12864lcd(void) {delay_50ms(2);write_12864com(0x30);delay_50us(4);write_12864com(0x30);delay_50us(4);write_12864com(0x0f);delay_50us(4);write_12864com(0x01);delay_50us(240);write_12864com(0x06);delay_50us(10);write_12864com(0x0c);delay_50us(10); }/******************************************************** 12864液晶显示函数********************************************************/void display1(void){uchar i;write_12864com(0x80);for(i=0;i<18;i++){write_dat(table2[i]);delay_50us(1); } }/******************************************************** 12864液晶显示函数********************************************************/void display2(void){uchar i;write_12864com(0x90);for(i=0;i<18;i++){write_dat(table3[i]);delay_50us(1); } }/******************************************************** 12864液晶显示函数********************************************************/void display3(void){ uchar i;write_12864com(0x88);for(i=0;i<8;i++){ write_dat(table4[i]);delay_50us(1); }}/******************************************************** 12864液晶显示函数********************************************************/void displaywendu(void){ uchar i;write_12864com(0x94);for(i=0;i<3;i++){ write_dat(wendu[i]);delay_50us(1);}for(i=0;i<1;i++){write_dat(table5[i]);delay_50us(1);}for(i=4;i<5;i++){write_dat(wendu[i]);delay_50us(1); } }/******************************************************** 12864液晶显示函数********************************************************/void displayshidu(void) {uchar i;write_12864com(0x8C);for(i=0;i<3;i++) {write_dat(shidu[i]);delay_50us(1); }for(i=0;i<1;i++){ write_dat(table5[i]);delay_50us(1);}for(i=4;i<5;i++){write_dat(shidu[i]);delay_50us(1);} }/******************************************************** SHT11写字节程序********************************************************/char s_write_byte(unsigned char value){unsigned char i,error=0;for (i=0x80;i>0;i>>=1) //高位为1,循环右移{ if (i&value) DATA=1; //和要发送的数相与,结果为发送的位else DA TA=0;SCK=1;_nop_();_nop_();_nop_(); //延时3usSCK=0;}DA TA=1; //释放数据线SCK=1;error=DATA; //检查应答信号,确认通讯正常_nop_();_nop_();_nop_();SCK=0;DA TA=1;return error; //error=1 通讯错误}/******************************************************** SHT11读字节程序********************************************************/char s_read_byte(unsigned char ack){unsigned char i,val=0;DA TA=1; //释放数据线for(i=0x80;i>0;i>>=1) //高位为1,循环右移{SCK=1;if(DATA)val=(val|i); //读一位数据线的值SCK=0; }DA TA=!ack; //如果是校验,读取完后结束通讯;SCK=1;_nop_();_nop_();_nop_(); //延时3usSCK=0;_nop_();_nop_();_nop_();DA TA=1; //释放数据线 return val; }/******************************************************** SHT11启动传输********************************************************/void s_transstart(void){DATA=1;SCK=0; //准备_nop_();SCK=1;_nop_();DATA=0;_nop_();SCK=0;_nop_();_nop_();_nop_();SCK=1;_nop_();DATA=1;_nop_();SCK=0; }/******************************************************** SHT11连接复位********************************************************/void s_connectionreset(void){ unsigned char i;DA TA=1;SCK=0; //准备for(i=0;i<9;i++) //DA TA保持高,SCK时钟触发9次,发送启动传输,通迅即复位{ SCK=1;SCK=0;}s_transstart(); //启动传输 }/********************************************************SHT11温湿度检测********************************************************/char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode){unsigned error=0;unsigned int i;s_transstart(); //启动传输switch(mode) //选择发送命令{ case TEMP : error+=s_write_byte(MEASURE_TEMP);break; //测量温度case HUMI : error+=s_write_byte(MEASURE_HUMI);break; //测量湿度default : break;}for (i=0;i<65535;i++)if(DATA==0) break; //等待测量结束if(DATA) error+=1; // 如果长时间数据线没有拉低,说明测量错误*(p_value) =s_read_byte(ACK); //读第一个字节,高字节 (MSB)*(p_value+1)=s_read_byte(ACK); //读第二个字节,低字节 (LSB)*p_checksum =s_read_byte(noACK); //read CRC校验码return error; // error=1 通讯错误 }/******************************************************** SHT11温湿度值标度变换及温度补偿********************************************************/ void calc_sth10(float *p_h umidity ,float *p_temperature){const float C1=-4.0; // 12位湿度精度修正公式const float C2=+0.0405; // 12位湿度精度修正公式const float C3=-0.0000028; // 12位湿度精度修正公式const float T1=+0.01; // 14位温度精度 5V条件修正公式const float T2=+0.00008; // 14位温度精度 5V条件修正公式float rh=*p_humidity; // rh: 12位湿度float t=*p_temperature; // t: 14位温度float rh_lin; // rh_lin: 湿度 linear值float rh_true; // rh_true: 湿度 ture值float t_C; // t_C : 温度℃t_C=t*0.01 - 40; //补偿温度rh_lin=C3*rh*rh + C2*rh + C1; //相对湿度非线性补偿rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //相对湿度对于温度依赖性补偿if(rh_true>100)rh_true=100; //湿度最大修正if(rh_true<0.1)rh_true=0.1; //湿度最小修正*p_temperature=t_C; //返回温度结果*p_humidity=rh_true; //返回湿度结果 }/******************************************************** 主函数********************************************************/ void main(void){unsigned int temp,humi;value humi_val,temp_val; //定义两个共同体,一个用于湿度,一个用于温度unsigned char error; //用于检验是否出现错误unsigned char checksum; //CRCinit12864lcd();display1();display2();display3();s_connectionreset(); //启动连接复位while(1){error=0; //初始化error=0,即没有错误error+=s_measure((unsigned char*)&temp_val.i,&checksum,TEMP); //温度测量error+=s_measure((unsigned char*)&humi_val.i,&checksum,HUMI); //湿度测量if(error!=0) s_connectionreset(); ////如果发生错误,系统复位else{humi_val.f=(float)humi_val.i; //转换为浮点数temp_val.f=(float)temp_val.i; //转换为浮点数calc_sth10(&humi_val.f,&temp_val.f); //修正相对湿度及温度 temp=temp_val.f*10;humi=humi_val.f*10;wendu[0]=temp/1000+'0'; //温度百位wendu[1]=temp%1000/100+'0'; //温度十位wendu[2]=temp%100/10+'0'; //温度个位wendu[3]=0x2E; //小数点wendu[4]=temp%10+'0'; //温度小数点后第一位displaywendu();shidu[0]=humi/1000+'0'; //湿度百位shidu[1]=humi%1000/100+'0'; //湿度十位shidu[2]=humi%100/10+'0'; //湿度个位shidu[3]=0x2E; //小数点shidu[4]=humi%10+'0'; //湿度小数点后第一位displayshidu(); }Delay(800);//等待足够长的时间,以现行下一次转换}}。

电设大赛智能家居

电设大赛智能家居
6)设有固定螺栓孔,方便安装;
7)小板PCB尺寸:3.2cm x 1.4cm;
8)使用宽电压LM393比较器;
图四湿度传感器
可以使用数字量输出口进行环境温度粗调,使用模拟量输出口进行环境的温度的细调。细调时使用的模拟量需要AD转换后才能被单片机采集。
使用湿度传感器HR202模块来测量环境的湿度。其主要特点是:
6)制造工艺简单,成本更低;
7)发光效率更高,能耗更低;
与LCD相比其优势主要体现在以下方面:
OLED可以自身发光,而LCD则不能。所以OLED比LCD要亮得多,另外,OLED对比度更大,色彩效果更加丰富;LCD需要背景灯光点亮,而OLED在需要点亮的单元才加电,并且电压很低,因此更加节能;OLED所需材料很少,制造工艺简单,量产时的成本要比LCD节省百分之二十;OLED没有视角范围的限制,可视角一般可以达到160度,重量也比LCD轻的多;
图十二 控制显示节点软件设计流程图
3.3执行节点的硬件框图
执行节点主要是响应周围环境的变化。控制显示模块把监测节点发送过来的信号与参考值相比较之后,判断出周围环境的变化趋势,并将控制信号发送给执行节点,执行节点根据控制信号对风扇或者LED进行调节。与控制节点相比,执行节点没有OLED显示模块,但是它多了风扇和电灯。本试验中风扇采用电机来代替,电灯采用LED来代替。电机需要电机驱动来进行直接控制,STC89C52通过调节PWM对电机进行调速。电灯的亮度也是采用PWM来进行亮度调节。执行节点的整个硬件框图如图十所示。
蓝牙虽然也能实现近距离无线通信,但是由于目前蓝牙只能实现一对一的双机通信连接,一旦一个蓝牙与另一个蓝牙建立连接后,无法再与其他的蓝牙进行通信。另一方面,STC89C52只有一个串口,一个单片机只能连接一个蓝牙。同时蓝牙的传输速率远不及NRF20L01+的传输速率,而且一个蓝牙的价格是NRF24L01+的好几倍。因此综合考虑,我们选择NRF24L01+进行无线通信。

基于128×64点阵液晶显示的智能温度控制器的设计与实现

基于128×64点阵液晶显示的智能温度控制器的设计与实现

3 0 3 ;2 深圳 市拓 普 微 科技 开发 有 限公 司 ,广 东 深 圳 0 10 .
绍 了 L 0 3液 晶显示模块的功能特性 、接 口电路及应 用程序 。实验 中应 用 D 1 B 0温度 传感 器实现 温度信 M3 3 S82 号 的采集 ,并把采集到 的信号传送给单片机 ,单片机将信号进行处理完成相应 的智能控制 ,同时将环境温 度 、
李 志广 ,张
( . 河北 工业 大学 理 学院 ,天 津 1
5 85 ) 1 0 7
摘 要 :以智 能 温 度 控 制 器 的设 计 实 验 为 依 托 ,文 章 给 出 了 一 套 液 晶 显 示 模 块 驱 动 实 验 的设 计 方 案 ,详 细 介
辉 王永 学 , ,张志 东
De in a d i l me t t n o h n e l e tt mp r t r sg n mp e n a i ft e i t l g n e e a u e o i
c n r le a e n 1 8 4 d tma r i u d c y t ld s l y o to lr b s d o 6 o ti l i r sa ip a 2 x x q
t s,t e i tra e cr ui,a d t e a p iai n p o r m ft e L 0 i e h n ef c ic t n h p lc t r g a o h M3 33 LCM r n r d c d i e al n o a e i to u e n d ti.I
a d t e r n mitd t h n h n ta s t o t e MCU.Th e e e tmpe au esg a r c s ig a d t e i tli e tc nr la e p r r t r i n lp o e sn n h n elg n o to r e —

BS18B20温度值12864波形显示

BS18B20温度值12864波形显示

/******************************************************************************* ******************************************************************************** *******///程序说明:本程序为12864(st7920)驱动程序,只实现了最简单的显示功能//端口设置:RS、RW、EN分别为P0口的0、1、2,数据口为P2口用取模软件取的图形或汉字必须是逐行取的,因为本函数是在液晶上逐行打点的/******************************************************************************* ******************************************************************************** ******/#include<reg51.h>#include<intrins.h> //内含-NOP-函数#include<stdlib.h> //内含rand()函数#define uchar unsigned char#define uint unsigned int//**********宏定义所需指令#define BASIC_SET 0x30#define EXTEND_SET 0x34#define DRAW_ON 0x36#define DRAW_OFF 0x34//*************端口定义sbit LCD_RS = P2^5;sbit LCD_RW = P2^6;sbit LCD_EN = P2^7;sbit DS=P3^3; //定义温度DS18B20接口,详情见原理图//************变量定义uchar code t0[]="温度 . ℃";uchar code t1[]="0123456789"; //利用一个温度表解决温度显示乱码uchar i,k,a,b;//****************短延时void delay(uint k){uint i;uchar j;for(i = 0; i < k ;i ++)for(j = 0; j < 10 ;j ++);}//***********12864写指令函数void write_com(uchar cmd){LCD_RS = 0;LCD_RW = 0;P0 = cmd;delay(5);LCD_EN = 1;delay(5);LCD_EN = 0;}//********12864写数据函数void write_dat(uchar dat){LCD_RS = 1;LCD_RW = 0;P0 = dat;delay(5);LCD_EN = 1;delay(5);LCD_EN = 0;}//****************从LCD中读数据uchar read_dat(void){uchar temp;P0 = 0XFF; //释放数据线LCD_RS = 1; //数据LCD_RW = 1; // 读模式LCD_EN = 1; //E为高电平进行读数据或指令delay(1);temp = P0;LCD_EN = 0;return temp;}//******************************************************** //设置光标(地址)函数//参数说明:x---为行号,y为列号//********************************************************void set_cursor(unsigned char x, unsigned char y){unsigned char i;switch(x) //确定行号{case 0x00: i=0x80; break; //第一行case 0x01: i=0x90; break; //第二行case 0x02: i=0x88; break; //第三行case 0x03: i=0x98; break; //第四行default : break;}i = y+i; //确定列号write_com(i);}//********************************************************//显示字符函数//********************************************************void display_char(unsigned char Alphabet){write_dat(Alphabet); //写入需要显示字符的显示码}//********************************************************//指定位置显示字符串函数//参数说明:x为行号,y为列号//********************************************************void display_string(unsigned char x,unsigned char y,unsigned char *Alphabet) {unsigned char i=0;set_cursor(x,y); //设置显示的起始地址while(Alphabet[i]!='\0'){write_dat(Alphabet[i]); //写入需要显示字符的显示码i++;}}//***************************************************************************以下为GDRAM绘图部分************************************************************************////*********************绘图显示的清屏函数(因清屏指令在画图时不能用)------------------------------------------------------------------------------注意!!!!!!!void gui_clear(){uchar i , j , k;write_com(EXTEND_SET);//扩展指令集,8位数据传输write_com(DRAW_OFF);//绘图显示关闭for(i = 0; i < 2; i ++)//分上下两屏写{for(j = 0; j < 32; j ++){write_com(0x80 + j);//写y坐标delay(1);if(i == 0) //写x坐标{write_com(0x80);delay(1);}else //写下半屏{write_com(0x88);delay(1);}for(k = 0; k < 16; k ++)//写一整行数据{write_dat(0x00);//写高字节write_dat(0x00);//写低字节delay(1);}}}write_com(DRAW_ON);//打开绘图显示write_com(BASIC_SET);//打开基本指令集}//***********(给定坐标并打点的)任意位置打点函数void lcd_set_dot(uchar x,uchar y){uchar x_byte,x_bit;//确定在坐标的那一字节哪一位uchar y_ping , y_bit;//确定在坐标的哪一屏哪一行uchar tmph , tmpl;//定义两个临时变量,用于存放读出来的数据write_com(EXTEND_SET);//扩展指令集write_com(DRAW_OFF);//绘图显示关闭x_byte = x / 16;//算出在哪一字节,注意一个地址是16位的x_bit = x % 16;//& 0x0f;//算出在哪一位y_ping = y / 32;//确定在上半屏还是下半屏,0代表上半屏,1代表下半屏y_bit = y % 32;//& 0x1f;//确定在第几行write_com(0X80 + y_bit);//先写垂直地址(最高位必须)write_com(0x80 + x_byte + 8 * y_ping);//水平坐标,下半屏坐标起始地址为0x88,(+8*y_ping)就是用来确定上半屏还是下半屏read_dat();//预读取数据tmph = read_dat();//读取当前显示高8位数据tmpl = read_dat();//读取当前显示低8位数据delay(1);write_com(0x80 + y_bit);//读操作会改变AC,所以重新设置一下write_com(0x80 + x_byte + 8 * y_ping);delay(1);if(x_bit < 8){write_dat(tmph | (0x01 << (7 - x_bit)));//写高字节,因为坐标是从左向右的,GDRAM高位在昨,低位在右write_dat(tmpl);//原低位数据送回}else{write_dat(tmph);//原高位数据送回write_dat(tmpl | (0x01 << (15 - x_bit)));}write_com(DRAW_ON); //打开绘图显示write_com(BASIC_SET);//回到基本指令集}//************画水平线函数**********************************////x0、x1为起始点和终点的水平坐标,y为垂直坐标***************////**********************************************************// void gui_hline(uchar x0, uchar x1, uchar y){uchar bak;//用于对两个数互换的中间变量,使x1为大值if(x0 > x1){bak = x1;x1 = x0;x0 = bak;}do{lcd_set_dot(x0 , y);//从左到右逐点显示x0 ++;}while(x1 >= x0);}//***********画竖直线函数***********************************// //x为起始点和终点的水平坐标,y0、y1为垂直坐标***************// //**********************************************************// void gui_rline(uchar x, uchar y0, uchar y1){uchar bak;//用于对两个数互换的中间变量,使y1为大值if(y0 > y1){bak = y1;y1 = y0;y0 = bak;}do{lcd_set_dot(x , y0);//从上到下逐点显示y0 ++;}while(y1 >= y0);}//*********任意两点间画直线*********************************// //x0、y0为起始点坐标,x1、y1为终点坐标**********************// //**********************************************************//void gui_line(uchar x0 , uchar y0 , uchar x1 , uchar y1){char dx;//直线x轴差值char dy;//直线y轴差值char dx_sym;//x轴增长方向,为-1时减值方向,为1时增值方向char dy_sym;//y轴增长方向,为-1时减值方向,为1时增值方向char dx_x2;//dx*2值变量,用于加快运算速度char dy_x2;//dy*2值变量,用于加快运算速度char di; //决策变量if(x0 == x1)//判断是否为垂直线{gui_rline(x0 , y0 , y1);//画垂直线return;}if(y0 == y1)//判断是否为水平线{gui_hline(x0 , x1 , y0);//画水平线return;}dx = x1 - x0;//求取两点之间的差值dy = y1 - y0;//****判断增长方向,或是否为水平线、垂直线、点*//if(dx > 0)//判断x轴方向dx_sym = 1;else{if(dx < 0)dx_sym = -1;else{gui_rline(x0 , y0 , y1);return;}}if(dy > 0)//判断y轴方向dy_sym = 1;else{if(dy < 0)dy_sym = -1;else{gui_hline(x0 , x1 , y0);return;}}/*将dx、dy取绝对值***********/dx = dx_sym * dx;dy = dy_sym * dy;/****计算2倍的dx、dy值*******/dx_x2 = dx * 1;//我改为了一倍,这样才跟真实的两点对应dy_x2 = dy * 1;/***使用bresenham法进行画直线***/if(dx >= dy)//对于dx>=dy,使用x轴为基准{di = dy_x2 - dx;while(x0 != x1){lcd_set_dot(x0,y0);x0 +=dx_sym;if(di < 0)di += dy_x2;//计算出下一步的决策值else{di += dy_x2 - dx_x2;y0 += dy_sym;}}lcd_set_dot(x0, y0);//显示最后一点}else //对于dx<dy使用y轴为基准{di = dx_x2 - dy;while(y0 != y1){lcd_set_dot(x0, y0);y0 += dy_sym;if(di < 0)di += dx_x2;else{di += dx_x2 - dy_x2;x0 += dx_sym;}}lcd_set_dot(x0, y0);//显示最后一点}}//***************************************************************************以上为自定义字库部分**************************************************************////****************12864初始化函数void lcd_init(){write_com(0x30);//基本指令操作,8位并口delay(1);write_com(0x06);//设置为游标右移,DDRAM地址加一,画面不动delay(1);write_com(0x0c);//显示开,关光标delay(1);write_com(0x01);//清除lcd显示内容delay(1);}//5ms延时void Delay5Ms(void){unsigned int TempCyc = 5552;while(TempCyc--);}//400ms延时void Delay400Ms(void){unsigned char TempCycA = 5;unsigned int TempCycB;while(TempCycA--){TempCycB=7269;while(TempCycB--);};}/*************DS18B20温度读取模块*************/void tmpDelay(int num)//延时函数{while(num--) ;}void Init_DS18B20()//初始化ds1820{unsigned char x=0;DS = 1; //DS复位tmpDelay(8); //稍做延时DS = 0; //单片机将DS拉低tmpDelay(80); //精确延时大于 480usDS = 1; //拉高总线tmpDelay(14);x=DS; //稍做延时后如果x=0则初始化成功 x=1则初始化失败tmpDelay(20);}unsigned char ReadOneChar()//读一个字节{unsigned char i=0;unsigned char dat = 0;for (i=8;i>0;i--){DS = 0; // 给脉冲信号dat>>=1;DS = 1; // 给脉冲信号if(DS)dat|=0x80;tmpDelay(4);}return(dat);}void WriteOneChar(unsigned char dat)//写一个字节{unsigned char i=0;for (i=8; i>0; i--){DS = 0;DS = dat&0x01;tmpDelay(5);DS = 1;dat>>=1;}}unsigned int Readtemp()//读取温度{unsigned char a=0;unsigned char b=0;unsigned int t=0;float tt=0;Init_DS18B20();WriteOneChar(0xCC); // 跳过读序号列号的操作WriteOneChar(0x44); // 启动温度转换Init_DS18B20();WriteOneChar(0xCC); //跳过读序号列号的操作WriteOneChar(0xBE); //读取温度寄存器a=ReadOneChar(); //连续读两个字节数据 //读低8位b=ReadOneChar(); //读高8位t=b;t<<=8;t=t|a; //两字节合成一个整型变量。

12864显示原理

12864显示原理

12864显示原理12864显示原理是指12864液晶显示屏的工作原理和特点。

在深入了解12864显示原理之前,我们首先要了解液晶显示屏的基本结构和工作原理。

液晶显示屏是一种利用液晶材料的光学特性来显示图像的平面显示器件。

它由玻璃基板、液晶材料、驱动电路和偏光片等组成。

其中,12864显示屏是指屏幕分辨率为128×64的液晶显示屏。

它广泛应用于电子仪器、仪表、通讯设备、汽车电子等领域。

12864显示原理的核心是液晶材料的电光效应。

液晶材料具有两个特性,扭曲结构和双折射。

当施加电场时,液晶分子会发生扭曲,改变光的传播路径,从而实现像素点的亮暗变化。

通过合理的驱动电路,可以控制每个像素点的亮度,从而显示出所需的图像。

在12864显示原理中,驱动电路起着至关重要的作用。

它主要由控制器、驱动芯片和接口电路组成。

控制器负责接收外部信号并生成显示数据,驱动芯片则负责将显示数据转化为对液晶的驱动信号,接口电路则负责与外部系统进行通信。

通过这些部件的协同工作,才能实现12864显示屏的正常工作。

除了驱动电路,偏光片也是12864显示原理中不可或缺的部分。

偏光片可以过滤出特定方向的光线,使得液晶显示出清晰的图像。

在实际应用中,偏光片的选择和安装位置对显示效果有着重要的影响。

总的来说,12864显示原理是液晶显示技术的一个重要分支,它通过液晶材料的电光效应和驱动电路的协同作用,实现了图像的高质量显示。

在实际应用中,我们需要根据具体的场景和要求,选择合适的液晶显示方案,并合理设计驱动电路和偏光片,以实现最佳的显示效果。

通过对12864显示原理的深入了解,我们可以更好地应用液晶显示技术,提高产品的竞争力,为用户带来更好的视觉体验。

同时,也可以为液晶显示技术的进一步发展提供有益的参考和借鉴。

希望本文对您理解12864显示原理有所帮助,谢谢阅读!。

18B20温度采集LCD12864显示

18B20温度采集LCD12864显示

18B20温度采集LCD12864显示基于单片机STC89C51的温度显示系统的设计引言随着电子技术,特别是随大规模集成电路的产生而出现的微型计算机技术的飞速发展,人类生活发生了根本性的改变。

如果说微型计算机的出现使现代科学研究得到了质的飞跃,那么可以毫不夸张地说,单片机技术的出现则是给现代工业测控领域带来了一次新的技术革命。

目前,单片机以其体积小、重量轻、抗干扰能力强、对环境要求不高、高可靠性、高性能价格比、开发较为容易,在工业控制系统、数据采集系统、智能化仪器仪表、办公自动化等诸多领域得到极为广泛的应用,并已走人家庭,从洗衣机、微波炉到音响、汽车,到处都可见到单片机的踪影。

因此,单片机技术开发和应用水平已逐步成为一个国家工业发展水平的标志之一。

本课题研究的内容就是以单片机为主要控制元件,通过温度传感器DS18B20实现对温度的测量,并通过LCD12864直接显示所测温度。

1、设计任务用温度传感器DS18b20检测空气中的温度,STC89C51采集DS18B20的数据并通过LCD12864显示实时温度。

2、系统硬件设计2.1 系统方框图见图2-1.图3-1 系统方框图2.2 各模块方案的选择方案一:采用热电偶或热敏电阻作感温元件,但热电偶需冷端补偿,电路设计复杂,热敏电阻虽然精度较高,但需要标准稳定电阻匹配才能使用,而且重复性、可靠性都比较差。

方案二:采用集成温度传感器 DS18B20 。

该传感器结构简单,不需外接电路,数据传输采用one-wire。

总线,可用一根 I/O数据线即供电又传输数据,在-10 ℃ --+85℃范围内精度为±0.5℃,分辨率较高,重复性和可靠性好。

故采用方案二。

方案一:采用数码管显示。

数码管亮度高、体积小、重量轻,但其显示信息简单、有限,在本题目中应用受到很大的限制。

方案二:采用液晶显示。

液晶显示功耗低,轻便防震。

采用液晶显示界面友好清晰,操作方便,显示信息丰富。

基于语音控制技术的简易智能家居系统设计

基于语音控制技术的简易智能家居系统设计

• 131•介绍了基于单片机STC15的简易智能家居系统的软硬件设计。

通过XFS5152CE模块实现语音识别和语音播放功能,采用热敏电阻MF52-3950及其相关电路来测量温度,通过12864液晶显示模块来显示系统数据,通过按键来设置温度的阈值,通过继电器等对各种电器设备进行控制,该系统具有一定的实用价值。

1 系统总体结构利用语音识别与控制技术实现对家用电器的控制是智能家居的研究热点。

通过语音控制技术,能够更有效地进行人机通讯,提高家居的便利性。

(贾小龙,基于语音控制技术的智能家居控制系统设计:中国设备工程,2018)这里提出了基于语音识别技术的简易智能家居系统,该系统可以通过语音对各种电器设备进行控制,给家居生活提供更加便利的生活环境。

该系统以STC15为整个系统的核心处理器,通过XFS5152CE模块实现语音识别和语音播放功能。

各种传感器采集环境中的各种状态,如温度、湿度、有害气体浓度等。

STC15负责接收语音识别信息、传感器信息、键盘信息,经过处理,控制各种电器设备。

控制电器设备的方式有多种,本系统实现了通过继电器的开关来控制电器的开关,通过PWM信号来控制风扇的转速。

2 硬件设计本简易智能家居系统采用STC15单片机作为微控制单元,MF52热敏电阻模块组成温度测量电路,单片机读取温度数值,并能通过LCD模块进行温度显示。

用户可以通过键盘模块输入密码及阈值温度,单片机根据当前的温度及阈值温度来控制电机的转速,进而控制风扇的转速。

用户通过语音模块XFS5152CE模块来控制当前系统处于正常运行、暂停或停止状态,同时播报系统所处的状态。

时钟模块用于记录实时时钟,采用PCF8563来实现(图1)。

2.1 单片机控制模块单片机最小系统以STC15W1K16S为核心,并由复位、晶振和电源这三部分电路构成。

STC15W1K16S是宏晶科技公司生产的低电压、高性能CMOS 8位单片机,片内含16KB的可反复擦写的程序存储器和1KB的随机存取数据存储器,采用增强型8051内核,速度比传统8051快7~12倍,采用低功耗设计,有低速模式、空闲模式及掉电模式。

基于PID算法的温度实时控制

基于PID算法的温度实时控制

基于PID算法的温度实时控制樊恩东;陈湘萍【摘要】为了解决温度控制的高精度问题,设计了一种基于PID算法的温度控制方法,该方法通过NTC负温度系数的传感器检测当前温度,然后用ADC0832进行采集,12864液晶显示屏对相关信号实时显示,AT89S52单片机对各个模块协同处理与控制,最后由CPU控制继电器输出PWM信号,实现了对设定温度的迅速准确响应.通过PID算法的控制结果表明,该方法能有效的应用于需要对温度快速准确控制的应用场合.【期刊名称】《电子世界》【年(卷),期】2016(000)019【总页数】2页(P113-114)【关键词】AT89S52单片机;PID;ADC0832;12864【作者】樊恩东;陈湘萍【作者单位】贵州大学电气工程学院;贵州大学电气工程学院【正文语种】中文随着微电子技术和计算机技术的发展,温度控制系统在智能化、自适应、参数自整定等方面都取得了显著的成果。

对于具有大滞后性的温度控系统的设计,逐步趋向于对高精度以及智能化的要求。

本文采用单片机为硬件核心结合PID控制算法,通过在每个周期输出两路PWM信号来控制继电器的通断时间,以此来调整升温或者降温的占空比,并且通过定时器实时地将温度的变化、设定温度、当前模式等相关信息在12864液晶显示屏上显示[1]。

实现了超调量小,响应速度快的温度控制。

在本次设计中,以AT89S52单片机为主控芯片,当ADC0832采集的温度值与设定温度值不相等时,CPU就会将这个差值进行运算,调整一个控制周期内需要升降温的时间。

然后继电器就会闭合相应的电路,以此实现一次温度控制。

如果设定温度低于或者高于规定的门限值,蜂鸣器会发出警报。

为了使该系统智能化,电路设计了程序下载端口,可以直接通过串口去更新程序,方便系统功能的改变[2]。

本次设计中,设定了3个独立按键,分别用于模式设定、温度加与减。

也可以直接由上位机发送指令来修改设定值。

系统框图如图1所示。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include "msp430g2553.h"
#define SID BIT3
#define SCLK BIT4
#define CS BIT5
#define LCDPORT P1OUT
#define SID_H LCDPORT |= SID
#define SID_L LCDPORT &= ~SID
}
if((kk<=2102.52)&&(kk>1965.72))
{
temp[0]=0x35;
temp[1]=0x30;
}
if(kk<1965.72)
{
{
SCLK_H; delay(5);
SCLK_L; delay(5);//同步脉冲高五 位置1
}
if(b123==1)
{//------写数据
SID_L; delay(5);
SCLK_H; delay(5);
SCLK_L; delay(5);
wr_lcd(0x00,0x0c); //开显示,关游标
//0x00代表写指令,0x01代表写数据
}
void w_d()
{
if(kk>5004.08)
{
temp[0]=0x32;
temp[1]=0x34;
}
if((kk<=5004.08)&&(kk>4633.91))
}
if((kk<=2583.32)&&(kk>2409.96))
{
temp[0]=0x34;
temp[1]=0x34;
}
if((kk<=2409.96)&&(kk>2249.9))
{
temp[0]=0x34;
temp[1]=0x36;
}
if((kk<=2249.9)&&(kk>2102.52))
{
temp[0]=0x34;
temp[1]=0x38;
__bis_SR_register(GIE);
kj=ADC10MEM;
kk=3500/(kj*1.5/1023)-1000;
w_d();
lcd_show(0,1,"当前温度:");
lcd_show(1,1,temp);
}
}
P1DIR = 0xFD;
lcd_int();
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON+ ADC10IE;
__enable_interrupt();
TACCR0 = 30;
temp[0]=0x35;
temp[1]=0x35;
}
temp[2]=0x43;
temp[3]=0x00;
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
SID_H; delay(5);
SCLK_H; delay(5);
SCLK_L; delay(5);
SID_L; delay(5);
SCLK_H; delay(5);
SCLK_L; delay(5);
}
else if(b123==0)
ADC10CTL1 = INCH_1;
ADC10AE0 |= 0x02;
P1DIR |= 0x01;
while(1)
{
ADC10CTL0 |= ENC + ADC10SC;
SCLK_L; delay(5);
}
for(j123=0;j123<2;j123++)
{
for(i123=0;i123<4;i123++) //8位数据的高4位
{
C123=d123&a123;
if(C123==0)
{
SID_L; delay(5);
char temp[4];
float kk;
void delay(unsigned char ms)
{
for(i=ms;i>0;i--)
for(j=120;j>0;j--);
}
void wr_lcd (unsigned char dat,unsigned char content)//读lcd
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(CPUOFF);
//kj=ADC10MEM;
}
#pragma vector=TIMER0_A0_VECTOR
{
temp[0]=0x33;
temp[1]=0x30;
}
if((kk<=3984.17)&&(kk>3698.91))
{
temp[0]=0x33;
temp[1]=0x32;
}
{//------写指令
SID_L; delay(5);
SCLK_H; delay(5);
SCLK_L; delay(5);
SCLK_H; delay(5);
SCLK_L; delay(5);
SCLK_H; delay(5);
{
temp[0]=0x34;
temp[1]=0x30;
}
if((kk<=2768.73)&=0x34;
temp[1]=0x32;
temp[1]=0x36;
}
if((kk<=3196.5)&&(kk>2972.61))
{
temp[0]=0x33;
temp[1]=0x38;
}
if((kk<=2972.61)&&(kk>2768.73))
if((kk<=3698.91)&&(kk>3437.11))
{
temp[0]=0x33;
temp[1]=0x34;
}
if((kk<=3437.11)&&(kk>3196.5))
{
temp[0]=0x33;
address=j;
wr_lcd(0x00,address);
}
else if(x==0x03)
{
j=0x98+y;
address=j;
wr_lcd(0x00,address);
}
while(ptr[L]!=0x00)
{
if(j==0)
{
wr_lcd(0x00,0x80);
}
if(j==16)
{
wr_lcd (0x00,0x90);
}
if(j==32)
{
wr_lcd (0x00,0x88);
}
if(j==48)
{
wr_lcd (0x00,0x98);
#define SCLK_H LCDPORT |= SCLK
#define SCLK_L LCDPORT &= ~SCLK
#define CS_H LCDPORT |= CS
#define CS_L LCDPORT &= ~CS
unsigned char i,j;
unsigned int kj;
}
if(j==64)
{
;
}
wr_lcd (0x01,ptr[L]);
L++;
}
}
void lcd_int()//LCD初始化
{
CS_L; //cs_off;
SID_L; //sid_off ;
SCLK_L; //sclk_off;
{
SCLK_H; delay(5);
SCLK_L; delay(5);
}
}
CS_L;
SCLK_L;
SID_H;
delay(5);
}
void lcd_show(unsigned char x, unsigned char y,char *ptr)//LCD显示
{
unsigned char address,L=0,j=0; //L=0;如果不初始化,显示对不上位
if(x<=1)
{
j=x*16+y;
address=j+0x80;
wr_lcd(0x00,address);
}
else if(x==0x02)
{
j=0x88+y;
TACCTL0 |= CCIE;
TACTL = TASSEL_2 | MC_1;
LPM0;
TACCTL0 &= ~CCIE;
__disable_interrupt();
{
temp[0]=0x32;
temp[1]=0x36;
}
if((kk<=4633.91)&&(kk>4294.94))
{
相关文档
最新文档