Or in native units do this:
Code:
double P=200;
double T=1000;
double SetPoint;
void main(void){
SetPoint = T - 1024*floor(0.5+(T-P)/1024);
printf("P=%f T=%f SetPoint=%f \n",P,T,SetPoint);
}
Output:
Code:
P=200.000000 T=1000.000000 SetPoint=-24.000000
If the sensor goes from 0 to 1023, then you have to go backward 224 steps (not 223) from 200 to get to 1000.
(Because 0 is equivalent to 1024, just as 0 is equivalent to 360 degrees).