]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
LCD can be switched off, automatic detection of connection threshold
authorJan Michel <j.michel@gsi.de>
Fri, 21 Aug 2015 14:48:05 +0000 (16:48 +0200)
committerJan Michel <j.michel@gsi.de>
Fri, 21 Aug 2015 14:48:05 +0000 (16:48 +0200)
pt100/main.c
pt100/main.h
pt100/tempmeas.c

index 523cd233cb720d060d3784323628ed8977e96471..b192ea4d999fed8b7c8d7aee5cfdfd16f13c519a 100644 (file)
@@ -40,6 +40,7 @@ void read_calib() {
   calib_settings.nominal_offset = eeprom_read(8);  
   calib_settings.gain_current   = eeprom_read(9);
   calib_settings.period         = eeprom_read(10);
+  calib_settings.uselcd         = eeprom_read(11);
   }
 
 /******************
@@ -188,7 +189,8 @@ int main(void) {
     next_step = 0;
     if (measurement_active) {do_measurement_step();}
     if (next_second && !measurement_active) {
-      lcd_update();
+      if(calib_settings.uselcd)
+        lcd_update();
       next_second = 0;
       }
     if(key_was_pressed(1<<KEY_1)) {}
index 9beadfdfda16e7ef9678e37cd6068ead510a05a8..68bcc541b8375fea7e1d98f9dd0492f10384448e 100644 (file)
@@ -60,4 +60,5 @@ struct calib_t {
   uint16_t    nominal_offset;       //approximate offset resistor, in Ohm, 100 as default
   uint16_t    gain_current;         //2^29 / (gain * current[uA])  (about 53700)
   uint16_t    period;               //measurement period in timer ticks (2ms)
+  uint16_t    uselcd;               //set to 0 to disable LCD
   };
index baaeed03edd6e54fa0bda5a30180c30f11db3cfa..50ab0bfa037195a36db73268249c1e5c0fda992b 100644 (file)
@@ -6,7 +6,7 @@
 uint8_t measurement_step = 0;
 uint8_t current_channel = 0;
 uint8_t num_connected_sensors = 8;
-const uint16_t connect_threshold = 0xd000;
+uint16_t connect_threshold = 0xffff;
 
 //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
@@ -109,8 +109,8 @@ uint16_t SPI_transceive_16bit(uint16_t data){
 //35 send ADC temperature
  
     // should be
-    // (5 - 2.2E3 * 410E-6) / 2 = 2.049 V if on
-    // (5 - 2.2E3 *  10E-6) / 2 = 2.489 V if off
+    // (5 - 2.2E3 *  400E-6) / 2 = 2.049 V if on
+    // (5 - 2.2E3 *  400E-6) / 2 = 2.489 V if off
     // -> compare to 2.27 V or (2.27/2.56)*2^16 = 58112
  
 void do_measurement_step(void) {
@@ -159,6 +159,14 @@ void do_measurement_step(void) {
       }
     current_channel += 1;
     }
+  else if(measurement_step == 33) {
+    ADCSRA |= (1<<ADSC); //start ADC conversion
+    }
+  else if(measurement_step == 34) {   
+    con = ADCL;
+    con += (ADCH<<8);
+    connect_threshold = con - 7000;
+    }
   measurement_step += 1;
   if(measurement_step == 36) {
     measurement_step = 0;