     // inter- and extrapolation
     ddelta=ad[analogChannel].delta.digital ;
     adelta=ad[analogChannel].delta.analog;
-    ad[analogChannel].measured.analog  = digital * adelta / ddelta; 
+
+    ad[analogChannel].measured.analog  = ad[analogChannel].mincal.analog +
+      (digital - ad[analogChannel].mincal.digital) * adelta / ddelta;
+
     ad[analogChannel].changed=0;
     if ((abs(ad[analogChannel].measured.analog - ad[analogChannel].prev.analog)) > ad[analogChannel].diff.analog) {
       ad[analogChannel].prev.analog = ad[analogChannel].measured.analog;




struct ad adArr[]= {
  {0,"boiler",  0,0,0.0,0,0.5,0,0.0,1023,120.0,0,0.0,0,0.0},
  {1,"ambient", 0,0,0.0,0,0.5,0,0.0,1023,60.0,0,0.0,0,0.0},
  {2,"hothousewater",0,0,0.0,0,0.5,0,0.0,1023,100.0,0,0.0,0,0.0},
  {3,"radiator",0,0,0.0,0,0.5,0,0.0,1023,60.0,0,0.0,0,0.0}
};

int readAdChannels(struct ad *ad, int cnt);

    ad[analogChannel].delta.digital=ad[analogChannel].maxcal.digital - ad[analogChannel].mincal.digital;
    ad[analogChannel].delta.analog=ad[analogChannel].maxcal.analog - ad[analogChannel].mincal.analog;
  }
}


