]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
further describing calibration values
authorJan Michel <j.michel@gsi.de>
Wed, 5 Aug 2015 16:11:33 +0000 (18:11 +0200)
committerJan Michel <j.michel@gsi.de>
Wed, 5 Aug 2015 16:11:33 +0000 (18:11 +0200)
pt100/tempmeas.c

index 72decf0fd83857a83363ac2c7b948cf8d5f10a46..8a1b0c9349f52fd01072fbb350d9d7759676f132 100644 (file)
@@ -7,12 +7,15 @@ uint8_t measurement_step;
 
 //factors: gain_current has 2^29, ADC has 2^7 steps per mV
 //hence shift by 36 necessary, 6 as part of multiplication by 1E6
+//gain_current is defined as 2^29/(Gain*Current)
+//offset_res is defined as difference of offset resistor to 100 Ohm
+//output is difference to 100 Ohm in mOhm
 int16_t adc_to_res(int16_t adc, uint8_t chan) {
   int32_t value;
   value = (int32_t)adc * (uint32_t)calib_settings.gain_current;
-  value >>= 14;
+  value /= 16384;
   value *= 15625;
-  value >>= 16;
+  value /= 65536;
   value += calib_settings.offset_res[chan];
   return (int16_t)value;
   }
@@ -24,12 +27,12 @@ int16_t adc_to_res(int16_t adc, uint8_t chan) {
 int32_t res_to_temp(int16_t res) {
   int32_t result = -1;
   int32_t t = (int32_t)res * 41919;
-  result += t >> 14;
+  result += t / 16384;
   
   t = (int32_t)res * res;
-  t >>= 7;
+  t /= 128;
   t *= 135;
-  result += t >> 20;
+  result += t / 1048576;
   
   return result;
   }