DS1620 and celsius degrees below 0 ?
Mikael S
Posts: 60
With the code below i read the temperature in celsius from a DS1620, and it works fine until the temperature goes under 0 degrees. Then i get a strange result!
Im going to present the tempreature on a LED display, its because of that i have to separate the digits.
Im going to present the tempreature on a LED display, its because of that i have to separate the digits.
Repeat Temperature.Start(0,1,2) cData := Temperature.gettempc tensValue := (cData/100) onesValue := (cData/10)-((cData/100)*10) debug.start(31, 30, 0, 9600) debug.dec(tensValue) debug.dec(onesValue) debug.str(string(" C")) debug.tx(13)
Comments
This fix the sign bit so you can do normal math on it. As Tracy pointed out, the raw value is in 0.5 degree units. Multiply that by 5 to get 0.1 degree units with 0.5 degrees of resolution. From there everything is pretty easy.
So its already does that for me.
My problem is that i need to get the answer in two separate digits (to present it on a LED display).