Index: firmware/FSC/src/interpol.c
===================================================================
--- firmware/FSC/src/interpol.c	(revision 10102)
+++ firmware/FSC/src/interpol.c	(revision 10753)
@@ -7,4 +7,5 @@
 //#include "application.h"
 #include "num_conversion.h"
+#include "math.h"
 //-----------------------------------------------------------------------------
 /*
@@ -302,2 +303,216 @@
 return read_adc();
 }
+
+
+ float calc_temp(U32 adcword)
+ {
+  U8  temprange = 17;
+  
+  float temp=NAN;
+  const U32 min = 0x404054;
+  const U32 max = 0x8CAF50;
+  const U32 s	= 0x4C6F0;		//(max-min)/16 = s(lice)
+
+ if  (adcword >= (min + 8*s))
+   {
+     if  (adcword >= (min + 12*s))
+	   {
+	     if  (adcword >= (min + 14*s))
+		   {
+			 if   (adcword >= (min + 15*s)) 
+			   { 
+			     if (adcword < max)
+				   {
+		            temprange = 16;
+				   }
+			   }
+			 else
+			   {
+				 temprange = 15;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 13*s))
+			    {
+				  temprange = 14;
+				}
+			  else
+			    {
+				  temprange = 13;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 10*s))
+		   {
+			 if  (adcword >= (min + 11*s))
+			   {
+				 temprange = 12;
+			   }
+			 else
+			   {
+				 temprange = 11;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 9*s))
+			    {
+				  temprange = 10;
+				}
+			  else
+			    {
+				  temprange = 9;
+				}
+		   }   
+	   }
+   } 
+ else
+ {
+     if  (adcword >= (min + 4*s))
+	   {
+	     if  (adcword >= (min + 6*s))
+		   {
+			 if  (adcword >= (min + 7*s))
+			   {
+				 temprange = 8;
+			   }
+			 else
+			   {
+				 temprange = 7;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 5*s))
+			    {
+				  temprange = 6;
+				}
+			  else
+			    {
+				  temprange = 5;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 2*s))
+		   {
+			 if  (adcword >= (min + 3*s))
+			   {
+				 temprange = 4;
+			   }
+			 else
+			   {
+				 temprange = 3;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + s))
+			    {
+				  temprange = 2;
+				}
+			  else
+			    { 
+				  if  (adcword > min)
+				    {
+				      temprange = 1;
+ 					}
+				}
+		   }   
+	   }
+   } 
+
+
+ switch (temprange)
+  {
+    case 1:{ // Temp. Range [-50°C , -34.375°C[
+      temp = ((float)adcword / 20764.727846 - 252.7721); 		//20764.727846 - 252.7721
+	  }
+    break;
+
+    case 2:{ // Temp. Range [-34.375°C , -18.75°C[
+      temp = ((float)adcword / 20658.049789 - 253.8995);		//20658.049789 - 253.8995
+	  }
+    break;
+
+    case 3:{ // Temp. Range [-18.75°C , -3.125°C[		
+      temp = ((float)adcword / 20557.997603 - 255.0436);		//20557.997603 - 255.0436
+	  }
+    break;
+
+    case 4:{ // Temp. Range [-3.125°C , 12.5°C]
+      temp = ((float)adcword / 20462.362624 - 256.2209); 		//20462.362624 - 256.2209
+	  }
+    break;
+
+    case 5:{ // Temp. Range [12.5°C , 28.125°C]
+      temp = ((float)adcword / 20367.745024 - 257.4692);		//20367.745024 - 257.4692
+	  }
+    break;
+	
+    case 6:{ // Temp. Range [28.125°C , 43.75°C]
+      temp = ((float)adcword / 20273.127424 - 258.8021);		//20273.127424 - 258.8021
+	  }
+    break;
+	
+    case 7:{ // Temp. Range [43.75°C , 59.375°C]
+      temp = ((float)adcword / 20178.509824 - 260.2208);		//20178.509824 - 260.2208
+	  }
+    break;
+	
+    case 8:{ // Temp. Range [59.375°C , 75°C]
+      temp = ((float)adcword / 20083.892224 - 261.7265);		//20083.892224 - 261.7265
+	  }
+    break;
+	
+    case 9:{ // Temp. Range [75°C , 90.625°C]
+      temp = ((float)adcword / 19989.274624 - 263.3203);		//19989.274624 - 263.3203
+	  }
+    break;
+	
+    case 10:{ // Temp. Range [90.625°C , 106.25°C]
+      temp = ((float)adcword / 19894.657024 - 265.0037);		//19894.657024 - 265.0037
+	  }
+    break;
+	
+    case 11:{ // Temp. Range [106.25°C , 121.875°C]
+      temp = ((float)adcword / 19800.039424 - 266.7778);		//19800.039424 - 266.7778
+	  }
+    break;
+	
+    case 12:{ // Temp. Range [121.875°C , 137.5°C]
+      temp = ((float)adcword / 19705.421824 - 268.6439);		//19705.421824 - 268.6439
+	  }
+    break;
+	
+    case 13:{ // Temp. Range [137.5°C , 153.125°C]
+      temp = ((float)adcword / 19610.804224 - 270.6035);		//19610.804224 - 270.6035
+	  }
+    break;
+	
+    case 14:{ // Temp. Range [153.125°C , 168.75°C]
+      temp = ((float)adcword / 19516.186624 - 272.6578);		//19516.186624 - 272.6578
+	  }
+    break;
+	
+    case 15:{ // Temp. Range [168.75°C , 184.375°C]
+      temp = ((float)adcword / 19421.569024 - 274.8082);		//19421.569024 - 274.8082
+	  }
+    break;
+	
+    case 16:{ // Temp. Range [184.375°C , 200°C]
+      temp = ((float)adcword / 19326.951424 - 277.0562);		//19326.951424 - 277.0562
+	  }
+    break;
+    default:
+		break;
+  }// end of switch case statement
+  return temp;
+
+ }
+
+
