Added diode calibration
This commit is contained in:
parent
69e409a28d
commit
985484179b
10
lab_3/main.c
10
lab_3/main.c
@ -66,16 +66,16 @@ uint16_t adc_run_conversion(uint8_t adc_selection) {
|
||||
/** @brief Converts an ADC value from a measurement on an LM35 into a temperature.
|
||||
*/
|
||||
int8_t lm35_convert(uint16_t adc_reading) {
|
||||
return (float) (adc_reading * ADC_VREF / ADC_RESOLUTION) / LM35_SENSITIVITY;
|
||||
return (adc_reading * ADC_VREF / ADC_RESOLUTION) / LM35_SENSITIVITY;
|
||||
}
|
||||
|
||||
/** @brief Converts and ADC value from a measurement on a diode into a temperature.
|
||||
* TODO
|
||||
*/
|
||||
int8_t diode_convert(uint16_t adc_reading) {
|
||||
// Do some funky math here
|
||||
|
||||
return 0;
|
||||
// This could be collapsed but it doesn't really matter
|
||||
int16_t value_diff = adc_reading - DIODE_VALUE_25C;
|
||||
int16_t temp_diff = value_diff / DIODE_SENSITIVITY;
|
||||
return temp_diff + 25;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
@ -13,8 +13,8 @@
|
||||
#define ADC_VREF 1.1
|
||||
#define ADC_RESOLUTION 1023 // (2^ 10 - 1, 10 bits resolution)
|
||||
|
||||
#define DIODE_VALUE_0C // ADC value for diode at 0C
|
||||
#define DIODE_SENSITIVITY 0.0025 // V / degree C, tuneable
|
||||
#define DIODE_VALUE_25C 436 // ADC value for diode at 0C
|
||||
#define DIODE_SENSITIVITY -1.85 // ADC value / degree C, tuneable
|
||||
|
||||
#define LM35_SENSITIVITY 0.01 // V / degree C, see LM35 datasheet
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user