Rev 22 | Rev 24 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 22 | Rev 23 | ||
---|---|---|---|
Line 213... | Line 213... | ||
213 | // must wait > 0.22 seconds between conversion attempts as this is the measurement time |
213 | // must wait > 0.22 seconds between conversion attempts as this is the measurement time |
214 | // |
214 | // |
215 | 215 | ||
216 | FunctionalState CHT_Enable = ENABLE; |
216 | FunctionalState CHT_Enable = ENABLE; |
217 | 217 | ||
- | 218 | #define CORR 3 |
|
- | 219 | ||
218 | uint8_t CHT_Timer[2] = |
220 | uint8_t CHT_Timer[2] = |
219 | { 0, 0 }; // two temperature readings |
221 | { 0, 0 }; // two temperature readings : from two sensors |
- | 222 | ||
- | 223 | ||
220 | uint16_t CHT_Observations[2] = |
224 | uint16_t CHT_Observations[2] = |
221 | { 0, 0 }; |
225 | { 0, 0 }; |
222 | 226 | ||
223 | void ProcessCHT(int instance) |
227 | void ProcessCHT(int instance) |
224 | { |
228 | { |
Line 241... | Line 245... | ||
241 | 245 | ||
242 | uint16_t obs = (buffer[0] << 8) | buffer[1]; |
246 | uint16_t obs = (buffer[0] << 8) | buffer[1]; |
243 | 247 | ||
244 | // good observation if the status bit is clear, and the reading is less than 1023 |
248 | // good observation if the status bit is clear, and the reading is less than 1023 |
245 | 249 | ||
- | 250 | uint16_t temp_c = obs>>5; |
|
- | 251 | ||
246 | uint8_t good = ((obs & 4) == 0) && ((obs>>5)<1023); |
252 | uint8_t good = ((obs & 4) == 0) && (temp_c > 0) && (temp_c < 250); |
247 | 253 | ||
248 | if (good) |
254 | if (good) |
249 | { |
255 | { |
250 | CHT_Observations[instance] = obs >> 5; |
256 | CHT_Observations[instance]=temp_c; |
- | 257 | ||
251 | } |
258 | } |
- | 259 | ||
252 | } |
260 | } |
253 | 261 | ||
254 | plx_sendword(PLX_X_CHT); |
262 | plx_sendword(PLX_X_CHT); |
255 | PutCharSerial(&uc1, instance); |
263 | PutCharSerial(&uc1, instance); |
256 | plx_sendword(CHT_Observations[instance]); |
264 | plx_sendword(CHT_Observations[instance]); |