1Set up the Raspberry Pi
2Electrical Connection of Sensores and Actuators
3Set up the Connection
4Heating Control

no warranty for any of the provided information

HV_readTemperatures

Is used by:
HV_loop

This function uses the wiringPi library via an PHP extension to read the sensor values from SPI bus.

To get rid of sensor jittering the values are damped - which causes a small time delay. At 'init' mode the filters are set to the actual values, while 'read' mode adds the actual values - which is equivalent to a low pass.

In this file the assoziation of sensors to specific AD-channels is coded.

To gain the resistance of the temperature sensor R_T relative to the voltage dividing resistor R_S one may calculate:
I = U_5V / (R_T+R_S) = U_S / R_S
R_T = (U_5V / U_S - 1) * R_S

And put this resistance into the characteristic curve of the temperature sensor.

My collector sensor is a PT1000 while the other sensors are of type KTY. In the manual of the old heating control I found a characteristic curve of KTY sensors, but figured out that the results do not match the analog sensors of flow and return close to the tank. Therefore I did my own calibration by putting the sensors into a water bath at different temperatures and drew the curve of resistances against multiple reference temperature measurements.

Instead of calculating the resistance from the AD-channel value and putting this to the characteristic curve, it is computational more efficient to create characteristic curves which gain the temperature directly from the AD-channel value. (These curves are of course valid for my hardware settings only.)
T_ADC

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function HV_readTemperatures($runState){
  include_once("tableInterpol.php");
  static $Rcoll;
  static $RtHot;
  static $Rret;
  static $Rflow;
  static $RtLow;
  static $Roven;
  $chip=0;
  $weight=0.1; /* weight = Delta_t/tau */
  if($runState=="init"){
    $freq=2000000;
    $success = wiringPi_SPI_Setup($chip,$freq);
  }
  for($i=0;$i<8;$i++){
    $ADC[$i]=wiringPi_SPI_readMCP3208Channel($chip, $i);
  } #i
  switch($runState){
  case "init":
    $Rcoll = $ADC[3]; #wiringPi_SPI_readMCP3208Channel($chip, 3);
    $RtHot = $ADC[6]; #wiringPi_SPI_readMCP3208Channel($chip, 6);
    $Rret  = $ADC[5]; #wiringPi_SPI_readMCP3208Channel($chip, 5);
    $Rflow = $ADC[4]; #wiringPi_SPI_readMCP3208Channel($chip, 4);
    $RtLow = $ADC[7]; #wiringPi_SPI_readMCP3208Channel($chip, 7);
    $Roven = $ADC[2]; #wiringPi_SPI_readMCP3208Channel($chip, 2);
    break;
  case "read":
    $Rcoll = (1.0-$weight)*$Rcoll+$weight*$ADC[3];
    $RtHot = (1.0-$weight)*$RtHot+$weight*$ADC[6];
    $Rret  = (1.0-$weight)*$Rret +$weight*$ADC[5];
    $Rflow = (1.0-$weight)*$Rflow+$weight*$ADC[4];
    $RtLow = (1.0-$weight)*$RtLow+$weight*$ADC[7];
    $weight = $weight/100.0; /* NTC needs more damping */
    $Roven = (1.0-$weight)*$Roven+$weight*$ADC[2];
    break;
  }

  /* convert resistance to temperature 
   http://en.wikipedia.org/wiki/Pt1000#Standard_resistance_thermometer_data
   ADC = Us/U5V = 4096*Rs / (Rs +RT) 
   T=f(R)=F(ADC) is contained in characteristic curve
  */

  $PointsPt1000[0]["x"] =2274.6; $PointsPt1000[0]["y"]=-10;
  $PointsPt1000[1]["x"] =2234.1; $PointsPt1000[1]["y"]=0;
  $PointsPt1000[2]["x"] =2195.2; $PointsPt1000[2]["y"]=10;
  $PointsPt1000[3]["x"] =2157.7; $PointsPt1000[3]["y"]=20;
  $PointsPt1000[4]["x"] =2121.6; $PointsPt1000[4]["y"]=30;
  $PointsPt1000[5]["x"] =2086.7; $PointsPt1000[5]["y"]=41.5;
  $PointsPt1000[6]["x"] =2053.1; $PointsPt1000[6]["y"]=53.0;
  $PointsPt1000[7]["x"] =2020.7; $PointsPt1000[7]["y"]=64.5;
  $PointsPt1000[8]["x"] =1989.3; $PointsPt1000[8]["y"]=76.0;
  $PointsPt1000[9]["x"] =1959.1; $PointsPt1000[9]["y"]=87.5;
  $PointsPt1000[10]["x"]=1929.7; $PointsPt1000[10]["y"]=99.0;
  $PointsPt1000[11]["x"]=1901.4; $PointsPt1000[11]["y"]=110.5;
  $PointsPt1000[12]["x"]=1873.9; $PointsPt1000[12]["y"]=122.0;
  $PointsPt1000[13]["x"]=1772.4; $PointsPt1000[13]["y"]=168.0;

  /* KTY own calibration */
  $PointsFlow[0]["x"] =2440.9; $PointsFlow[0]["y"] =-10;
  $PointsFlow[1]["x"] =2343.6; $PointsFlow[1]["y"] =0;
  $PointsFlow[2]["x"] =2250.8; $PointsFlow[2]["y"] =10;
  $PointsFlow[3]["x"] =2162.5; $PointsFlow[3]["y"] =20;
  $PointsFlow[4]["x"] =2078.5; $PointsFlow[4]["y"] =30;
  $PointsFlow[5]["x"] =1998.5; $PointsFlow[5]["y"] =40;
  $PointsFlow[6]["x"] =1922.3; $PointsFlow[6]["y"] =50;
  $PointsFlow[7]["x"] =1849.8; $PointsFlow[7]["y"] =60;
  $PointsFlow[8]["x"] =1780.8; $PointsFlow[8]["y"] =70;
  $PointsFlow[9]["x"] =1715.1; $PointsFlow[9]["y"] =80;
  $PointsFlow[10]["x"]=1652.6; $PointsFlow[10]["y"]=90;
  $PointsFlow[11]["x"]=1593.0; $PointsFlow[11]["y"]=100;

  /* NTC at oven */
  $PointsNTCoven[0]["x"] =   35.6; $PointsNTCoven[0]["y"] =10;
  $PointsNTCoven[1]["x"] =  509.0; $PointsNTCoven[1]["y"] =20;
  $PointsNTCoven[2]["x"] = 1082.2; $PointsNTCoven[2]["y"] =30;
  $PointsNTCoven[3]["x"] = 1489.0; $PointsNTCoven[3]["y"] =40;
  $PointsNTCoven[4]["x"] = 1761.5; $PointsNTCoven[4]["y"] =50;
  $PointsNTCoven[5]["x"] = 1949.8; $PointsNTCoven[5]["y"] =60;
  $PointsNTCoven[6]["x"] = 2085.6; $PointsNTCoven[6]["y"] =70;
  $PointsNTCoven[7]["x"] = 2187.2; $PointsNTCoven[7]["y"] =80;

  $T["coll"] = tableInterpol($PointsPt1000, $Rcoll,"extrapolate");
  $T["tLow"] = tableInterpol($PointsFlow,   $RtLow,"extrapolate");
  $T["tHot"] = tableInterpol($PointsFlow,   $RtHot,"extrapolate");
  $T["flow"] = tableInterpol($PointsFlow,   $Rflow,"extrapolate");
  $T["ret"]  = tableInterpol($PointsFlow,   $Rret ,"extrapolate");
  $T["fire"] = tableInterpol($PointsNTCoven,$Roven,"extrapolate");

  #echo $Rcoll."\t".$RtLow."\t".$RtHot."\t".$Rflow."\t".$Rret."\t".$Roven."\n";
   
  return $T;
}
?>
1HV_Admin_Login
2HV_colorMap
3HV_config
4HV_convertASCII
5HV_getSunPrediction
6HV_heatingControl
7HV_loop
8HV_readOperationState
9HV_readTemperatures
10HV_restart
11HV_serviceLog
12HV_setActuators
13HV_setParameters
14HV_showHouse
15HV_showLog
16HV_showRawValues
17HV_showWeatherForecast
18HV_thermos200
19HV_ventProg
20HV_writeLog
21index
22MoistAir
23readFilenames
24readNamedData
25tableInterpol

 

gnuplot

gnuplot is used to visualise the results - via script you can do infinite diagrams in 1 second.
Run 'test' in gnuplot to get an owerview of the available line- and symbolstyles.

Login
Valid HTML 4.01!