Correction in resistor calculation
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "measure.h"
|
||||
#include "PontCoopScheduler.h"
|
||||
@ -49,7 +50,14 @@ void measureCollectAndProcessConversion(void *handleArg) {
|
||||
|
||||
// process adcValue
|
||||
// store result in variable temperature
|
||||
float r = ((((float)N_MAX) / ((float)n)) - 1.0) * R_REF;
|
||||
float r = 0.0;
|
||||
if (n == 0) {
|
||||
r = 0.0;
|
||||
} else if (n == N_MAX) {
|
||||
r = FLT_MAX;
|
||||
} else {
|
||||
r = R_REF / ((((float)N_MAX) / ((float)n)) - 1.0);
|
||||
}
|
||||
float t = (r / PT1000_R0 - 1) / PT1000_Coeff;
|
||||
|
||||
uint8_t temperature = (uint8_t)t;
|
||||
|
Reference in New Issue
Block a user