|
Hi I tried to convert my BasicStamp integer math to Atom floating point math After a long time, I fond my correct formula. It should be like this: “tempC = (float tHigh fdiv (float tHigh fadd float tLow)fsub 0.32) fdiv 0.0047â€
the biggest problem was the New IDE 5.3.1.0 it did not accept integer math. The older version 02.2.1.1 accepted it. (why??) I used the first time the Atom and did not aspect such problem und it needed some time before I got the idea to change to the older version.
I used 6 SMT 160 For someone who like to use the SMT 160, here is a subroutine : Heinz
' 6 Stück SMT160-30 (one-pin pulse-width temperature sensor) 'Temperature in °C proportional to the (highpuls / (high puls + lowpuls))
Ta_Pin ...... CON AX3 'Fühler 6 TvB_Pin .... CON p27 'Fühler 5 TvH_Pin .... CON p26 ' 4 TrB_Pin .... CON p25 ' 3 TrH_Pin .... CON p24 ' 2 Ti_Pin ....... CON p23 'Fühler 1
'***** Variables **************************** Tpin .......... VAR byte 'Pin nummer f Temp Messung tHigh ....... VAR long 'Pulslänge vom High Puls tLow ....... VAR long pWidth ...... VAR long TempC ...... VAR long x .......... VAR byte
cr.............. con 13
start: TPin=Ti_Pin gosub getTemp
goto start getTemp: tHigh = 0: tLow = 0 FOR x = 1 TO 10 PULSIN TPin, 1, pWidth tHigh = tHigh + pWidth PULSIN Tpin, 0, pWidth tLow = tLow + pWidth NEXT tempC =(float tHigh fdiv (float tHigh fadd float tLow)fsub 0.32) fdiv 0.0047 DEBUG ["Temp_I = ", real TempC," °C",CR] 'real number 8 digid tempC = tempC fmul 10.0 ' tempC = int tempC DEBUG ["Temp_I = ", dec TempC," °C",CR] ...... 'integer number 3 digit ................... return ...................................' later needed
|