File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 18
18
//Steinhart-Hart constants
19
19
#define MAX_ADC_COUNT 4095U
20
20
#define ABSOLUTE_ZERO 273.15
21
- #define NOMINAL_TEMPERATURE 25U
21
+ #define NOMINAL_TEMPERATURE 298.15
22
22
#define NOMINAL_RESISTANCE 10000U
23
23
#define B_COEFFICIENT 3950U
24
24
25
- #define VOLTAGE_SUPPLY 5U
25
+ #define VOLTAGE_SUPPLY 5
26
+ #define MAX_VOLTAGE 3.3
26
27
#define R10K 10000U
27
28
28
29
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ void get_lim_data(uint8_t lim_temps[NUM_LIMS]) {
29
29
}
30
30
31
31
uint8_t get_temp (uint16_t adc_value ) {
32
- uint32_t voltage_in = adc_value * (VOLTAGE_SUPPLY / MAX_ADC_COUNT );
33
- uint32_t thermistor_resistance = voltage_in * R10K / (VOLTAGE_SUPPLY - voltage_in );
32
+ uint32_t voltage_in = adc_value * (MAX_VOLTAGE / MAX_ADC_COUNT );
33
+ uint32_t thermistor_resistance = (voltage_in * R10K ) / (VOLTAGE_SUPPLY - voltage_in );
34
+
35
+ uint8_t temp_steinhart = - ABSOLUTE_ZERO + (NOMINAL_TEMPERATURE * B_COEFFICIENT )/(NOMINAL_TEMPERATURE
36
+ * log (thermistor_resistance / R10K ) + B_COEFFICIENT );
34
37
35
- uint8_t temp_steinhart = - ABSOLUTE_ZERO + (1.0 /((1.0 / (NOMINAL_TEMPERATURE + ABSOLUTE_ZERO )) + (log (thermistor_resistance / NOMINAL_RESISTANCE ) / B_COEFFICIENT )));
36
38
return temp_steinhart ;
37
39
}
You can’t perform that action at this time.
0 commit comments