Hi Tom,
PBP can't handle fractions very well, the "**" and "*/" operators however makes it possible. 9/5 is 1.8 which PBP will trunctate to 1, not very useful. The "**" operator can handle the fractional part, this operaton makes an "invisible" division by 65536. 0.8*65536=52428.8 which we round up to 52429. Since your Dec_temp variable contains the temerature in tenths of a degree your formula needs to be ......
Dec_tempf=Dec_temp*(9/5) + 320 'Farenheit * 10
We rewrite this to ...
Dec_tempf=Dec_temp*1.8 + 320 'Farenheit * 10
Which is the same as .....
Dec_tempf=Dec_temp*1+Dec_temp*0.8 + 320 'Farenheit * 10
Using "**", we end up with ......
Dec_tempf=Dec_temp + Dec_temp**52429 + 320
Another thing, you can replace ......
' read data for temperature Temp
SSD4= (ssmax[24]>>4)
SSD3= (ssmax[24] & $f)
SSD2= (ssmax[23]>>4)
SSD1= (ssmax[23] & $f)
' convert to Decimal:
Dec_temp=(ssd4*4096)+(ssd3*256)+(ssd2*16)+ssd1
...... with ......
Dec_temp.highbyte = ssmax[24]
Dec_temp.lowbyte = ssmax[23]
/Ingvar
Bookmarks