要求控制系统可同时检测控制4个点,2个温度、2个湿度数据。
4.2 技术参数
主要技术参数:
工作电源:+5V;
工作环境:温度0-80℃,湿度 RH 50-99%;
控制范围:温度 10-40℃(可调);湿度 RH 60-99%(可调);
控制精度:温度≤±1℃;湿度≤ RH ±10%;
控制方式:可通过键盘设置上下限预定值;
显示:采用数码管显示;
4.3 程序设计
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code dispcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,
0xf8,0x80,0x90,0x89,0xbf,0xc6};
sbit EOC=P1^4;sbit CLK=P1^5;sbit ADDR=P1^6;sbit CS=P1^7;sbit SDO=P3^3;sbit VOICE=P2^0;sbit LED=P2^0;
float temp1,temp2,hum1,hum2;float higher_limit=28.0,lower_limit=25.0; uchar average_count;uint time_count; uint alarm_count; uchar flag_display; uchar flag_alarm;
void delay(uint i)
{while(i--);}
float read1543(uchar port)
{float ad;uint i,ad1;uchar al=0,ah=0;CS=1; CLK=0;CS=0; port<<=4;
for (i=0;i<4;i++) {ADDR=(bit)(port&0x80);CLK=1;delay(10);CLK=0;port<<=1;} for (i=0;i<6;i++) {CLK=1;CLK=0;}CS=1; _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();