Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __TIR_H__
00013 #define __TIR_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #pragma systemFile
00037
00038 #ifndef __COMMON_H__
00039 #include "common.h"
00040 #endif
00041
00042 #define TIR_I2C_ADDR 0x0E
00043 #define TIR_AMBIENT 0x00
00044 #define TIR_OBJECT 0x01
00045 #define TIR_SET_EMISSIVITY 0x02
00046 #define TIR_GET_EMISSIVITY 0x03
00047 #define TIR_CHK_EMISSIVITY 0x04
00048 #define TIR_RESET 0x05
00049
00050
00051 #define TIR_EM_SKIN_LIGHT 5660
00052 #define TIR_EM_SKIN_DARK 8380
00053 #define TIR_EM_GLASS 9200
00054 #define TIR_EM_CANDLE_SOOT 9500
00055
00056 #define tempFactor 0.02
00057
00058
00059 float TIRreadAmbientTemp(tSensors link);
00060 float TIRreadObjectTemp(tSensors link);
00061 bool TIRsetEmissivity(tSensors link, int emissivity);
00062 bool TIRresetSensor(tSensors link);
00063
00064 tByteArray TIR_I2CRequest;
00065 tByteArray TIR_I2CReply;
00066
00067
00068
00069
00070
00071
00072 float TIRreadAmbientTemp(tSensors link) {
00073 float tempData;
00074
00075 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00076
00077 TIR_I2CRequest[0] = 2;
00078 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00079 TIR_I2CRequest[2] = TIR_AMBIENT;
00080
00081 if (!writeI2C(link, TIR_I2CRequest, TIR_I2CReply, 2))
00082 return 0;
00083
00084 wait1Msec(1);
00085
00086 tempData = (float)(((TIR_I2CReply[1]) << 8) + TIR_I2CReply[0]);
00087 tempData = (tempData * tempFactor) - 0.01;
00088 return tempData - 273.15;
00089 }
00090
00091
00092
00093
00094
00095
00096 float TIRreadObjectTemp(tSensors link) {
00097 float tempData;
00098
00099 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00100
00101 TIR_I2CRequest[0] = 2;
00102 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00103 TIR_I2CRequest[2] = TIR_OBJECT;
00104
00105 if (!writeI2C(link, TIR_I2CRequest, TIR_I2CReply, 2))
00106 return 0;
00107
00108 wait1Msec(1);
00109 tempData = (float)(((TIR_I2CReply[1]) << 8) + TIR_I2CReply[0]);
00110 tempData = (tempData * tempFactor) - 0.01;
00111 return tempData - 273.15;
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 long TIRreadEmissivity(tSensors link) {
00121 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00122
00123 TIR_I2CRequest[0] = 2;
00124 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00125 TIR_I2CRequest[2] = TIR_GET_EMISSIVITY;
00126
00127 if (!writeI2C(link, TIR_I2CRequest, TIR_I2CReply, 2))
00128 return 0;
00129
00130 return (long)TIR_I2CReply[0] + ((long)TIR_I2CReply[1] << 8);
00131 }
00132
00133
00134
00135
00136
00137
00138
00139 long TIRcheckEmissivity(tSensors link) {
00140 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00141
00142 TIR_I2CRequest[0] = 2;
00143 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00144 TIR_I2CRequest[2] = TIR_CHK_EMISSIVITY;
00145
00146 if (!writeI2C(link, TIR_I2CRequest, TIR_I2CReply, 2))
00147 return 0;
00148
00149 return TIR_I2CReply[0] + (TIR_I2CReply[1] << 8);
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159 bool TIRsetEmissivity(tSensors link, int emissivity) {
00160 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00161
00162 TIR_I2CRequest[0] = 4;
00163 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00164 TIR_I2CRequest[2] = TIR_SET_EMISSIVITY;
00165 TIR_I2CRequest[4] = (emissivity >> 8) & 0xFF;
00166 TIR_I2CRequest[3] = emissivity & 0xFF;
00167
00168 return writeI2C(link, TIR_I2CRequest);
00169 }
00170
00171
00172
00173
00174
00175
00176
00177 bool TIRresetSensor(tSensors link) {
00178 memset(TIR_I2CRequest, 0, sizeof(tByteArray));
00179
00180 TIR_I2CRequest[0] = 2;
00181 TIR_I2CRequest[1] = TIR_I2C_ADDR;
00182 TIR_I2CRequest[2] = TIR_RESET;
00183
00184 return writeI2C(link, TIR_I2CRequest);
00185 }
00186
00187 #endif // __TIR_H__
00188
00189
00190
00191
00192
00193
00194