Ive got a problem with some code math, ive got some code that should work but i would like to get it a little more accurate and or just better.
Heres the issue,
A temprature is set into a variable called HighTemp
The PWM needs to have a minimum Pulse Width of 25%
The PWM needs to increase when Hightemp is greater than say 100 degrees and reaches 100% at 125 degrees
Temps read are from 60 to 140 degrees, so even at 60 the PWM should be at 25%

existing code:
Code:
HighTemp = ((HighTemp - 100)* 16) + 55
if HighTemp > 255 then HighTemp = 255
HPWM 1, HighTemp, 1000 'Freq = 1khz, HighTemp max is 255
so if HighTemp = 70 then
70 - 100 = 0, 0 * 16 = 0, 0 + 55 = 55, so PWM is set to 55 (roughly 20%)

if HighTemp = 101 then
101 - 100 = 1, 1 * 16 = 16, 16 + 55 = 81
and hereafter each degree increments the setting by 16. its kind of inacurate, I would like to replace this code with better code/math