温湿度采集控制电路及C51程序课件.ppt

上传人(卖家):三亚风情 文档编号:2968077 上传时间:2022-06-17 格式:PPT 页数:74 大小:3.13MB
下载 相关 举报
温湿度采集控制电路及C51程序课件.ppt_第1页
第1页 / 共74页
温湿度采集控制电路及C51程序课件.ppt_第2页
第2页 / 共74页
温湿度采集控制电路及C51程序课件.ppt_第3页
第3页 / 共74页
温湿度采集控制电路及C51程序课件.ppt_第4页
第4页 / 共74页
温湿度采集控制电路及C51程序课件.ppt_第5页
第5页 / 共74页
点击查看更多>>
资源描述

1、1第一节 电路图和PCB一、系统构成1、温度湿度采集控制电路2、集中显示电路控制温湿度采集控制电路二、温度湿度采集控制电路温度传感器 1、模拟接口2、数字接口18b2021234ABCD4321DCBATitleNumberRevisionSizeA4Date:29-Mar-2009Sheet of File:C:Documents and SettingslenovoMy Documentsnd.ddbDrawn By:RSTP1.5P1.6P1.7D0D1D2D3D4D5D6D7A8A9A10A11A12A13A14A15X1X2INT0LEDPTTT1RDWRALERXDTXDPSENE

2、A/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P134P145P156P167P178P0039P0138P0237P0336P0435P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10U189C51SW1SW PBR18.2KR21K+E110UF/16VX111.0592.0MHzCX130pCX230pVCCVCCVCCGNDGNDGND5R1RE2DE3D4A6B7VCC8U2175176TXDPTTRXDR

3、485120VCC12485_E2PINCS270.1U12JP2JUMPERAB123J1VCCGND123J2VCCGND123J3VCCGND123J4R3510D1LED12JS1JS1R4510D2LEDVCCLEDR51KAGNDT1CV30.1UF+CV210UF+CV1220UFVin1GND2+5V3IC678N05VCCD61N400712V12JJ1JJ1Q1PNPVCCO1OPTOISO1AGNDR710KR610K1212JS2JS212AGNDRU14.7KRU24.7KRU34.7KRU44.7KVCCCS10.1UFGND312345678ABCD8765432

4、1DCBATitleNumberRevisionSizeA3Date:29-Mar-2009Sheet of File:C:Documents and SettingslenovoMy Documentsnd.ddbDrawn By:RSTD0D1D2D3D4D5D6D7A8A9A10A11A12A13A14A157279_RSTX1X2KEYPTTSCLRDWRALERXDTXDPSENEA/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P134P145P156P167P178P0039P0138P0237P0336P04

5、35P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10U189C51SW1SW PBR21K+E110UF/16VX111.0592.0MHzCX130pCX230pVCCVCCGNDGND5R1RE2DE3D4A6B7VCC8U475176TXDPTTRXDR485120VCC12485_E2PINCS10.1UABVCC1VCC2NC3GND4NC5CS6CLK7DATA8KEY9SG10SF11SE12SD13SC14SB15SA16DP17DIG018DIG119DIG220DIG

6、321DIG422DIG523DIG624CLKO26RC27RESET28DIG725U77279KEYCSCLKDATACSCLKDATAabfcgdeDPY76421910abcdefg5dpdp38com1com2DS8DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS7DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS6DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS5DPY_7-SEG_DPabfcgdeDP

7、Y76421910abcdefg5dpdp38com1com2DS4DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS3DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS2DPY_7-SEG_DPabfcgdeDPY76421910abcdefg5dpdp38com1com2DS1DPY_7-SEG_DPSW55SW PBSW63SW PBSW47SW PBSW39SW PBSW31SW PBSW23SW PBSW15SW PBSW7SW PBSW54SW PBSW62SW PB

8、SW46SW PBSW38SW PBSW30SW PBSW22SW PBSW14SW PBSW6SW PBRL1200RL2200RL3200RL4200RL5200RL6200RL7200RL8200RK710kRK810kRD1100KRD2100KGND8_A8_B8_C8_D8_E8_F8_G8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_G8_F8_E8_D8_C8_B8_A8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_A8_B8_C8_D8_E8_F8_

9、G8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_A8_B8_C8_D8_E8_F8_G8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_DP8_A8_A8_A8_A8_A8_A8_A8_ADIG0DIG1DIG2DIG3DIG4DIG5DIG6DIG7DIG7DIG6DIG5DIG4DIG3DIG2DIG1DIG0DIG7S63S63S55DIG6S55RK610kDIG5S47RK510kDIG4S39S47S39RK310kRK410kDIG3S31DIG2S23RK210kDIG1S15RK110kDIG0S7S31S23

10、S15S7S63S31S55S23S47S15S39S7GNDVCC7279_RSTRC11.5KCC115PGNDVCCR18.2KVCC21X12X23GND4RST5I/O6SCLK7VCC18U6DS1302VCCX232.768KHz1302_SCLK1302_IO1302_RSTBT13.6VGNDA01A12A33GND4SDA5SCL6TE7VCC8U524C16VCCGNDSCLSDARU110KRU210KVCC1302_SCLK1302_IO1302_RSTOC1C111D22D33D44D55D66D77D88D91Q192Q183Q174Q165Q156Q147Q13

11、8Q12U274ALS573D0D1D2D3D4D5D6D7ALEA8A9A10A11A12A010A19A28A37A46A55A64A73A825A924A1021A1123A122CS20A1326WE27RD22D011D112D213D315D416D517D618D719A141U362256D7D6D5D4D3D2D1D0WRAD7AD6AD5AD4AD3AD2AD1AD0A13A14RDAD7AD6AD5AD4AD3AD2AD1AD0A15SDAR3510D1LEDGND12JS1JS1R4510D2LEDVCCLEDLEDR5510D3LEDVCCKEYCV30.1UF+CV

12、210UF+CV1220UFVin1GND2+5V3V178N05VCCVINVCCCS20.1UVCCCS30.1UVCCCS40.1UVCCCS50.1UVCCCS60.1UVCCCS70.1U12JS2JS245678三、集中显示电路控制温湿度采集控制电路1、键盘和数码管显示72792、单片机主控控制电路3、485通信910111213一、温度湿度采集控制电路程序main.c主程序,含继电器控制rs232.c (rs232.h)485通信程序ds18b20.c (ds18b20.h)温度湿度采集程序第二节 器件介绍和C51编程14#include void relay_control(v

13、oid);extern void delay(unsigned char);extern void read_tmp(void);extern void read_tmp_1(void);extern void read_tmp_2(void);extern void read_tmp_3(void);sbit r_control=P35;sbit led=P33;sbit ptt=P14;void rev_ptt(void);void send_ptt(void);extern unsigned char datamain.c15extern unsigned char data sendd

14、ata16;extern unsigned char data revdata8;extern unsigned char data *psenddata;extern unsigned char data *prevdata;extern unsigned char data tmp_l4;extern unsigned char data tmp_h4;unsigned char code me_address=0 x81;unsigned char code temp_table_l21=33,31,30,28,28,28,28,25,25,25,25,25,25,25,21,21,21

15、,21,21,21,21;unsigned char code temp_table_h21=35,33,32,30,30,30,30,28,28,28,28,28,28,28,27,27,27,27,27,27,27;unsigned char data temp_time=20;unsigned int tmp_v;unsigned int test_time=0;extern bit rev_ok;16main() ptt=0; TMOD=0 x20; TL1=0 xf4;TH1=0 xf4; SCON=0 x50;PCON=0 x00; TR1=1; ES=1; EA=1; led =

16、0; prevdata=revdata; psenddata=senddata;17 while(1) read_tmp(); read_tmp_1(); read_tmp_2(); read_tmp_3(); senddata4=(me_address&0 x0f); senddata5=tmp_h0; senddata6=tmp_l0; senddata7=tmp_h1; senddata8=tmp_l1; senddata9=tmp_h2; senddata10=tmp_l2; senddata11=tmp_h3; senddata12=tmp_l3;18 relay_control()

17、; if (!r_control) senddata13=0 xaa; else senddata13=0 x00; if (rev_ok) rev_ok=0; delay(1); ptt=1; delay(1); TI=1; ;19void relay_control(void) tmp_v=(tmp_h0&0 x03)*16+(tmp_l0*.0625)+0.5); if (tmp_v=(temp_table_htemp_time-1) r_control=1; return;20二、集中显示电路控制程序main.c主程序rs232.c (rs232.h)485通信程序7279.C (72

18、79.h)键盘程序ds1302.c (ds1302.h)时钟程序24c64.c (24c64.h)EEROM程序utility.htemp.h21#include #include #include #include main(void) main_init(); I_init(); ttt2=e_read_block(); / ttt1=e_write_block(); if (eromimager0=0 xff) senddata5=20; else store_true=1;senddata5=eromimager7; delay(20);main.c22 while(1) v_get1

19、302(); time_precess(); if(cur_minute!=curtime1) if(number1!=0)|(number2!=0)|(key_press1!=0) key_numcancel(); f2_precess(); delay(20); f3_precess(); delay(20); f4_precess(); delay(9000); ;23void main_init(void) hd7279_rst=0;delay(1500);hd7279_rst=1; led=0; psenddata=senddata;prevdata=revdata; send_by

20、te(cmd_reset); pctime=settime; / v_set1302(pctime); TMOD=0 x20;TL1=0 xf4;TH1=0 xf4; SCON=0 x50;PCON=0 x00; PS=1;EX0=1;TR1=1;ES=1; EA=1;ptt=1;TI=1; key_press=0; v_setcharge(); v_get1302(); cur_second=curtime0;cur_minute=curtime1;cur_hour=curtime2; cur_date=curtime3;cur_month=curtime4;cur_year=curtime

21、7; delay(10000); key_press3=1;24unsigned char h_compute(unsigned char n_w_h,unsigned char n_w_l,unsigned char w_h,unsigned char w_l) unsigned int t1,t2; unsigned char sub_val,temp_val; t1=(int)(n_w_h*16+n_w_l*.0625)+0.5)*10); t2=(int)(w_h*16+w_l*0.0625)+0.5)*10); sub_val=(unsigned char)(t1-t2)/5+0.5

22、); temp_val=(unsigned char)(t1/10); if (sub_val!=0) return(t_htemp_val-1sub_val-1); else return(0);25三、HD7279A器件介绍及C51编程26272829303132333435363738/pin definesbit cs=P15;sbit clk=P16;sbit dat=P17;sbit key=P32;void send_byte(unsigned char out_byte)unsigned char i;cs=0;long_delay();for (i=0;i8;i+)if(ou

23、t_byte&0 x80)dat=1;elsedat=0;clk=1;short_delay();clk=0;short_delay();out_byte=out_byte*2;dat=0;unsigned char receive_byte(void)unsigned char i,in_byte;dat=1;long_delay();for(i=0;i8;i+)clk=1;short_delay();in_byte=in_byte*2;if(dat)in_byte=in_byte|0 x01;clk=0;short_delay();dat=0;return(in_byte);39void

24、write7279(unsigned char cmd,unsigned char dta)send_byte(cmd);send_byte(dta);unsigned char read7279(unsigned char command)send_byte(command);return(receive_byte();void long_delay(void)unsigned char i;for(i=0;i0 x10;i+);void short_delay(void)unsigned char i;for(i=0;i4;i+); 40void display_uh_tmp(unsign

25、ed char s,unsigned char r) int a,b,c; unsigned char s1; c=(int)(s*16+r*0.0625+0.5)*10); a=(int)(c/100); b=(int)(c-a*100)/10); s1=c-a*100-b*10; b=b|0 x80; write7279(0 x88,0 xff); write7279(0 xcc,0 x0c); write7279(0 x87,s1); write7279(0 x86,b); write7279(0 x85,a);41void display_d_tmp(unsigned char s,u

26、nsigned char r) int a,b,c; unsigned char s1; c=(s*16+r*0.0625+0.5)*10; a=(int)(c/100); b=(int)(c-a*100)/10); s1=c-a*100-b*10; b=b|0 x80; write7279(0 xc8,0 x0b); write7279(0 x83,s1); write7279(0 x82,b); write7279(0 x81,a);42void service_int0(void) interrupt 0 /键盘中断 readkey_board();43void readkey_boar

27、d(void) /按键程序 unsigned char key_r_number; if(!key) key_r_number=read7279(cmd_read); while(!key);cur_minute=curtime1; switch(key_r_number) case 6: /f1 key_f1(); break; case 38: /f2 key_f2(); break; case 7: /f3 key_f3();break; case 39: /f4 key_f4();break; case 14: /1 key_num0_9(1);break; case 22: /2 k

28、ey_num0_9(2);break; case 30: /3 key_num0_9(3);break; case 46: /4 key_num0_9(4);break; case 54: /5 key_num0_9(5);break; case 62: /6 key_num0_9(6);break; case 15: /7 key_num0_9(7);break; case 23: /8 key_num0_9(8);break; case 31: /9 key_num0_9(9);break; case 55: /0 key_num0_9(1);break; case 63: /ok key

29、_numok();break; case 47: /cancel key_numcancel(); break case 255: break; default: break; return; 44四、18b20及C51编程454647484950515253ds18b20.c#include #include #include void delay(unsigned char time)unsigned char s;for(s=0;stime;s+);54/first 18b20void write_bit(unsigned char bitval) EA=0; DQ=0; _nop_()

30、;_nop_();if(bitval=1) DQ=1; EA=1; delay(5);DQ=1;55unsigned char ow_reset(void)unsigned char presence;DQ=0; delay(120); DQ=1;delay(10);presence=DQ;delay(20);return(presence);56unsigned char read_byte(void)unsigned char i;unsigned char ii=0;unsigned char value=0;for(i=0;i8;i+) if (read_bit() ii=0 x01i

31、; value|=ii; delay(5);return(value);57bit read_bit(void)bit dat; EA=0; DQ=0; _nop_();_nop_();_nop_();DQ=1; _nop_();_nop_();_nop_();_nop_();_nop_(); _nop_();_nop_(); dat=DQ; EA=1; delay(5);return(dat);58void write_byte(unsigned char val)unsigned char i;unsigned char temp;for(i=0;ii;temp&=0 x01;write_

32、bit(temp);59void read_tmp(void)/ unsigned int a,b; temp=ow_reset(); write_byte(0 xcc); write_byte(0 x44); delay(20); temp=ow_reset(); write_byte(0 xcc); write_byte(0 xbe); delay(20); tmp_l0=read_byte(); tmp_h0=read_byte();60#include /function definevoid delay(unsigned char);/first 18b20void write_bi

33、t(unsigned char);unsigned char ow_reset(void);unsigned char read_byte(void);bit read_bit(void);void write_byte(unsigned char);void read_tmp(void);sbit DQ=P10;ds18b20.h61unsigned char data tmp_l4;unsigned char data tmp_h4;unsigned char data temp;unsigned char data tmp=0;unsigned char data z8;sbit led

34、=P33;sbit z1=P15;62第三节 12864M介绍和GAL逻辑了解12864M液晶;理解单片机总线时序及12864M液晶接口时序学会使用GAL 进行接口逻辑的编程及应用63module wstitle ADDRESS ENCODEdesigner: YXM VER 1.00 2003,9,01 ws device P22V10; ALE,WR,RD,A8,A9,A10,A11,A12,A13,A14,A15 pin 1,2,3,4,5,6,7,8,9,10,11; EOC,CSRAM,CS0,CS1,CS2,CS3,CS4,CS5,ADALE,ADOE,INT0 pin 13,14

35、,15,16,17,18,19,20,21,22,23;equations CSRAM=A15; CS0=WR#A14#A13#A12#!A15; CS1=WR#A14#A13#!A12#!A15; CS2=WR#A14#!A13#A12#!A15; CS3=WR#A14#!A13#!A12#!A15; CS4=RD#!A14#A13#A12#!A15; CS5=RD#!A14#A13#!A12#!A15; ADALE=!WR&A14&A13&!A12&A15; ADOE=!RD&A14&A13&A12&A15; INT0=!EOC;end ws64656667液晶显示模块概述液晶显示模块概述

36、12864M汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。主要技术参数和显示特性:电源:VDD 3.3V+5V(内置升压电路,无需负压);显示内容:128列 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等 68引脚号引脚名称方向功能说明1VSS-模块的电源地2VDD-模块的电源正端3V0-LCD驱动电压输入端4RS(CS)H/L并行的指令并行的指令/数据选择信号

37、;串行的片选信号数据选择信号;串行的片选信号5R/W(SID)H/L并行的读写选择信号;串行的数据口并行的读写选择信号;串行的数据口6E(CLK)H/L并行的使能信号;串行的同步时钟并行的使能信号;串行的同步时钟7DB0H/L数据08DB1H/L数据19DB2H/L数据210DB3H/L数据311DB4H/L数据412DB5H/L数据513DB6H/L数据614DB7H/L数据715PSBH/L并/串行接口选择:H-并行;L-串行16NC空脚17/RETH/L复位 低电平有效18NC空脚19LED_A(LED+5V) 背光源正极20LED_K(LED-OV) 背光源负极6912864M写701

38、2864M读717273module decodertitle ADDRESS ENCODEdesigner:Litao VER 1.12 2006,8,23decoder device P22V10;ALE,WR,RD,A15,A14,A13,A12,A11,A10,A9,A8PIN 1,2,3,4,5,6,7,8,9,10,11;DCS,DRW,CS1,CS2,CS3,DACS,EA,RS,PSB,RWPIN 14,15,16,17,18,19,20,21,22,23;equations EA=(WR$RD)&A15&!A14&!A13&!A12&!A11&!A10; RS=A15&!A1

39、4&!A13&!A12&!A11&!A10&A9; RW=A15&!A14&!A13&!A12&!A11&!A10&A8; PSB=1;end decoder液晶写命令 0 x8000液晶读命令 0 x8100液晶写数据 0 x8200液晶读数据 0 x83007412864时序原理图GAL管脚ABEL程序RSD/I (L/ H) v2(21)RSR/WR/W(H/L ) v4(23)RWEEEA(20)EAWR$RD当为写时,为WR的反;当为读时,为RD的反。这样EA在对和写的时候都有效,( A15&!A14&!A13&!A12&!A11&!A10 )其地址范围为80XX83XXRS=A15&!A14&!A13&!A12&!A11&!A10&A9为高时地址为82XX或83XX,即数据, 80XX或81XX为命令RW=A15&!A14&!A13&!A12&!A11&!A10&A8为高时地址为81XX或83XX,即读操作, 80XX或82XX为写操作写命令 0 x80 xx;读命令 0 x81xx;写数据 0 x82xx;读数据 0 x83xx

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 办公、行业 > 各类PPT课件(模板)
版权提示 | 免责声明

1,本文(温湿度采集控制电路及C51程序课件.ppt)为本站会员(三亚风情)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!


侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|