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

no warranty for any of the provided information

## tableInterpol

Is used by:

It is a usual procedure to have some characteristic curve as set of points. With respect to some specific input value the appropriate interval has to be identified and the neighbouring values have to be interpolated.

If the input value exceeds the intervall of points, the result may either be saturated to the last defined value or extrapolated from the last two points, depending on \$mode.

\$points is a list of points defining the characteristic curve. Each point consists of a x value as input and a y value for the depending result.

```<?php
/* published under GPL www.gnu.org/licenses/gpl.html */
function tableInterpol(\$points,\$x,\$mode){
\$NoPoints=count(\$points);
/* test out of interval */
switch(\$mode){
case "saturate":
\$xmin=\$points["x"];
\$ymin=\$points["y"];
\$xmax=\$points[\$NoPoints-1]["x"];
\$ymax=\$points[\$NoPoints-1]["y"];
if(\$x<=\$xmin){
\$y=\$ymin;
return \$y;
}
if(\$x>=\$xmax){
\$y=\$ymax;
return \$y;
}
break;
case "extrapolate":
default:
\$xmin=\$points["x"];
\$ymin=\$points["y"];
\$xminp1=\$points["x"];
\$yminp1=\$points["y"];
\$xmax=\$points[\$NoPoints-1]["x"];
\$ymax=\$points[\$NoPoints-1]["y"];
\$xmaxm1=\$points[\$NoPoints-2]["x"];
\$ymaxm1=\$points[\$NoPoints-2]["y"];
if(\$x<=\$xmin){
\$y=\$ymin+(\$yminp1-\$ymin)/(\$xminp1-\$xmin)*(\$x-\$xmin);
return \$y;
}
if(\$x>=\$xmax){
\$y=\$ymax+(\$ymax-\$ymaxm1)/(\$xmax-\$xmaxm1)*(\$x-\$xmax);
return \$y;
}
}
/* interpolate table */
for(\$p=0;\$p<\$NoPoints;\$p++){
\$xLeft=\$points[\$p]["x"];
\$yLeft=\$points[\$p]["y"];
\$xRight=\$points[\$p+1]["x"];
\$yRight=\$points[\$p+1]["y"];
if(\$xLeft<\$x AND \$x<=\$xRight){
\$y=\$yLeft+(\$yRight-\$yLeft)/(\$xRight-\$xLeft)*(\$x-\$xLeft);
return \$y;
} #fi
} #p
}

/*
\$solarPumpOnDuration['x']=60;  \$solarPumpOnDuration['y']=5;
\$solarPumpOnDuration['x']=100; \$solarPumpOnDuration['y']=25;
echo " 5 = ".tableInterpol(\$solarPumpOnDuration,50,"saturate")."\n";
echo "15 = ".tableInterpol(\$solarPumpOnDuration,80,"saturate")."\n";
echo "25 = ".tableInterpol(\$solarPumpOnDuration,110,"saturate")."\n";
echo " 0 = ".tableInterpol(\$solarPumpOnDuration,50,"extrapolate")."\n";
echo "15 = ".tableInterpol(\$solarPumpOnDuration,80,"extrapolate")."\n";
echo "30 = ".tableInterpol(\$solarPumpOnDuration,110,"extrapolate")."\n";
*/
?>```

## 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. 