Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __DTMP_DRIVER_H__
00013 #define __DTMP_DRIVER_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #pragma systemFile
00036
00037
00038 const float _a[] = {0.003357042, 0.003354017, 0.0033530481, 0.0033536166};
00039 const float _b[] = {0.00025214848, 0.00025617244, 0.00025420230, 0.000253772};
00040 const float _c[] = {0.0000033743283, 0.0000021400943, 0.0000011431163, 0.00000085433271};
00041 const float _d[] = {-0.000000064957311, -0.000000072405219, -0.000000069383563, -0.000000087912262};
00042
00043
00044
00045 bool DTMPreadTemp(tSensors link, float &temp);
00046 bool DTMPreadTempK(tSensors link, float &temp);
00047 bool DTMPreadTempF(tSensors link, float &temp);
00048
00049
00050
00051
00052
00053
00054
00055
00056 bool DTMPreadTemp(tSensors link, float &temp) {
00057 float _tempK = 0.0;
00058 if (!DTMPreadTempK(link, _tempK))
00059 return false;
00060
00061 temp = _tempK - 273;
00062 return true;
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072 bool DTMPreadTempK(tSensors link, float &temp) {
00073
00074 byte i = 0;
00075 int val = 0;
00076 float RtRt25 = 0.0;
00077 float lnRtRt25 = 0.0;
00078
00079
00080 if (SensorType[link] != sensorAnalogInactive)
00081 return false;
00082
00083
00084 val = SensorValue[link];
00085 RtRt25 = (float)val / (1023 - val);
00086 lnRtRt25 = log(RtRt25);
00087
00088 if (RtRt25 > 3.277)
00089 i = 0;
00090 else if (RtRt25 > 0.3599)
00091 i = 1;
00092 else if (RtRt25 > 0.06816)
00093 i = 2;
00094 else
00095 i = 3;
00096
00097 temp = 1.0 / (_a[i] + (_b[i] * lnRtRt25) + (_c[i] * lnRtRt25 * lnRtRt25) + (_d[i] * lnRtRt25 * lnRtRt25 * lnRtRt25));
00098
00099 return true;
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109 bool DTMPreadTempF(tSensors link, float &temp) {
00110 float _tempK = 0.0;
00111 if (!DTMPreadTempK(link, _tempK))
00112 return false;
00113
00114 temp = 32 + ((_tempK - 273) * 9) / 5;
00115
00116 return true;
00117 }
00118
00119 #endif // __DTMP_DRIVER_H__
00120
00121
00122
00123
00124
00125