Welcome to the Parallax Discussion Forums, sign-up to participate.

Nomadic0
Posts: **8**

Hey guys, in testing my temp chip, I wanted to know why I am getting a reading of 40 (room temp) for my temp gauge. I have it set up (with the analog to dig converter) like the pot in page 45 of this doc

https://www.parallax.com/downloads/basic-analog-and-digital-text

I am also using the sample program below it (but using DEC instead on BIN8)

On the bright side, it is reacting positively to heat

Thanks

https://www.parallax.com/downloads/basic-analog-and-digital-text

I am also using the sample program below it (but using DEC instead on BIN8)

On the bright side, it is reacting positively to heat

Thanks

## Comments

5 Commentssorted by Date Added Votes21,3500Vote UpVote Down-Phil

Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.-Antoine de Saint-Exupery6,1030Vote UpVote DownTo keep it simple, each bit represents 19.53 millivolts. That is 5000 millivolts reference divided into 256 steps. So, one bit represents about 2°F and 40 bits (as you found) represents about 19.53*40 = 781 millivolts or 78.1°F. You'd be pretty close by multiplying the binary value times two to get °F.

There more accurate ways to do the math. The text shows one, here is another: The */ operator implicitly divides by 256, so the result comes out the same as if it were (for example) degF = 40 * 5000 / 256 = 781. The Stamp can't compute 40 * 5000 directly because of the 65535 limit of a 16 bit word, but */ gets around that.

80Vote UpVote DownI was also looking around and have failed to find a way to display a decimal in a DEBUG statement

Is this possible?

I appreciate all the feedback

6,1030Vote UpVote DownIn the example where answer is 781 millivolts representing 78.1 °F, You could do as follows:

DEBUG DEC milliVolts/10, ".", DEC1 milliVolts, "degF"

The integer division throws out the ones digit, and the DEC1 calls it out.

80Vote UpVote DownI really appreciate it!