Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting decimal number to 16 bit temperature binary

I have a question about conversion.
In a document about DS18B20 temperature sensor i need to convert 18.25C to binary.
Can someone explain how to do it.
This is the examples i have

I tried looking for answers on the internet but i can’t find anything similar.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like the binary value is the decimal temperature in increments of 0.0635 degrees (0.5 = 0.0625*8 = 0008h, 10.125 = 0.0625*162 = 00A2h)

so the conversion for 18.25 would be

18.25/0.0625 = 292 = 0124h = 0000 0001 0010 0010

Or, since 1/0.0625 = 16, you could convert it by multiplying by 16:

18.25 * 16 = 292 = 0124h = 0000 0001 0010 0010
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading