#include #include typedef unsigned int uint; typedef unsigned char uchar; typedef unsigned short WORD; float code RTD_TAB_PT100[151] = // 表格是以1度为一步,即-20, -19, -18..... { 88.22, 88.62 ,88.62, 89.40, 89.80, 90.19, 90.59, 90.98, 91.37, 91.77, // -30 ~ -21 92.16, 92.55, 92.95, 93.34, 93.73, 94.12, 94.52, 94.91, 95.30, 95.69, // -20 ~ -11 96.09, 96.48, 96.87, 97.26, 97.65, 98.04, 98.44, 98.83, 99.22, 99.61, // -10 ~ -1 100.00,100.39,100.78,101.17,101.56,101.95,102.34,102.73,103.13,103.51, // 0 9 103.90,104.29,104.68,105.07,105.46,105.85,106.24,106.63,107.02,107.49, // 10 19 ~ ~ 107.79,108.18,108.57,108.96,109.35,109.73,110.12,110.51,110.90,111.28, // 20 ~ 29 111.67,112.06,112.45,112.83,113.22,113.61,113.99,114.38,114.77,115.15, // 30 ~ 39 115.54,115.93,116.31,116.70,117.08,117.47,117.86,118.24,118.62,119.01, 49 119.40,119.78,120.16,120.55,120.93,121.32,121.70,122.09,122.47,122.86, 59 123.24,123.62,124.01,124.39,124.77,125.16,125.54,125.92,126.31,126.69, 69 127.07,127.45,127.84,128.22,128.60,128.98,129.37,129.75,130.13,130.51, 79 130.89,131.27,131.66,132.04,132.42,132.80,133.18,133.56,133.94,134.32, 89 134.70,135.08,135.46,135.84,136.22,136.60,136.98,137.36,137.74,138.12, 99 138.50,138.88,139.26,139.64,140.02,140.39,140.77,141.15,141.53,141.91, 109 // 40 // 50 // 60 // 70 // 80 // 90 // 100 ~ ~ ~ ~ ~ ~ ~ 142.29,142.66,143.04,143.42,143.80,144.17,144.55,144.93,145.31,145.68, // 110 ~ 119 146.06 // 120 }; //float code RTD_TAB_PT100[41] = // 表格是以5度为一步,即-50, -45, - 40..... //{ // 80.31, 82.29, 84.27 ,86.25, 88.22, 90.19, 92.16, 94.12, 96.09, 98.04, // -50 ~ -5 // 100.00,101.95,103.90,105.85,107.79,109.73,111.67,113.61,115.54,117.47, // 0 ~ 45 // 119.40,121.32,123.24,125.16,127.08,128.99,130.90,132.80,134.71,136.61, // 50 ~ 95 // 138.51,140.40,142.29,144.18,146.07,147.95,149.83,151.71,153.58,155.46, // 100 ~ 145 // 157.33 // 50 //}; sbit beep = P3^5; //----------------ADS1110地址、配置字-----------------// #define ADS1110_WR_ADDRESS 0x92 // 1001 001 0 写 #define ADS1110_RD_ADDRESS 0x93 // 1001 001 1 读 #define ADS1110_CONFIG_REG 0x8C // 连续转换模式,16bit精度,PGA=1 sbit ADS1110_SDA = P1^5; // 模拟I2C数据传输位 sbit ADS1110_CLK = P1^6; // 模拟I2C时钟控制位 //uchar TMR_H, TMR_L; // AD转换高8位,和低8位 uint AD_Result[25]; unsigned long nTmp; //*** HD7279 函数定义 *** void long_delay(void); // 长延时 void short_delay(void); // 短暂延时 void delay10ms(unsigned char); // 延时10MS void write7279(uchar, uchar); // 写入到HD7279 uchar read7279(uchar); // 从HD7279读出 void send_byte(uchar); // 发送一个字节 uchar receive_byte(void); // 接收一个字节 sbit cs =P0^7; // cs at P1.4 sbit clk=P0^6; // clk 连接于 P1.5 sbit dat=P0^5; // dat 连接于 P1.2 sbit key=P0^4; // key 连接于 P1.3 sbit Hight_LED = P4^6; sbit Low_LED = P4^1; //****** HD7279A 指令 ****** #define CMD_RESET 0xa4 #define CMD_TEST 0xbf #define DECODE0 0x80 #define DECODE1 0xc8 #define CMD_READ 0x15 #define UNDECODE 0x90 #define RTL_CYCLE 0xa3 #define RTR_CYCLE 0xa2 #define RTL_UNCYL 0xa1 #define RTR_UNCYL 0xa0 #define ACTCTL 0x98 #define SEGON 0xe0 #define SEGOFF 0xc0 #define BLINKCTL 0x88 //-------- AT24C04 变量声明 --------- sbit _24C02_SCL = P2^6; //AT24C04的时钟 sbit _24C02_SDA = P2^5; //AT24C04的数据 uchar BUF[16]; //数据缓存区 uint code nDefaultDATA[] = {// nLowTMP nHightTMP nTMPAdj 480, 650, 0 // 默认设置 }; uint nSettingDATA[3] = {0, 0, 0}; // 当前设置 void Delay5us(); void AT24C04_Start(); void AT24C04_Stop(); void AT24C04_SendACK(bit ack); bit AT24C04_RecvACK(); void AT24C04_SendByte(uchar dat); uchar AT24C04_RecvByte(); void AT24C04_ReadPage(); void AT24C04_WritePage(); //****** 红外接收 ****** sbit IRIN = P3^3; //红外接收器数据线 uchar IRCOM[7]; uchar nFlag = 0; uchar nMode = 1; // nMode 0 1 // mean NULL nLowTMP nHightTMP uint nLowTMP = 480; // 最低温度设定 uint nHightTMP = 650; // 最高温度设定 char nTMPAdj = 0; // 温度修正 void send_ad_result(uchar temp); 2 3 nTMPAdj /*********************************************************************************** ************************************************************************************ ////////////////////////////////HD 7279 函数//////////////////////////////////////// ************************************************************************************ ************************************************************************************/ void write7279(uchar cmd, uchar dta) { cs = 0; send_byte (cmd); send_byte (dta); cs = 1; } uchar read7279(uchar command) { cs = 0; send_byte(command); return(receive_byte()); cs = 1; } void send_byte( uchar out_byte) { uchar i; cs=0; long_delay(); for (i=0;i<8;i++) { if (out_byte&0x80) { dat=1; } else { dat=0; } clk=1; short_delay(); clk=0; short_delay(); out_byte=out_byte*2; } dat=0; } uchar receive_byte(void) { uchar i, in_byte; dat=1; // set to input mode long_delay(); for (i=0;i<8;i++) { clk=1; short_delay(); in_byte=in_byte*2; if (dat) { in_byte=in_byte|0x01; } clk=0; short_delay(); } dat=0; return (in_byte); } void delay10ms(uint time) { uchar a,b,c; //误差 -0.000000000001us uint i; for (i=0;i