DS1620 thermometer
Kiwi
Posts: 85
hello,
I have added a DS1620 into my application. I now can read the data out of the DS1620. I have a little problem of converting the·tempvalue (2complement)·into degrees. Does anybody have any suggestion of how it shoud be done. I am not USSING SX/B nut plain Sx - intructions.
Thanks
Kurt
I have added a DS1620 into my application. I now can read the data out of the DS1620. I have a little problem of converting the·tempvalue (2complement)·into degrees. Does anybody have any suggestion of how it shoud be done. I am not USSING SX/B nut plain Sx - intructions.
Thanks
Kurt
Comments
Invert all bits (XOR $FF), then add 1 (INC).
For example 255 invert all bits gives 0, then add 1 gives 1 (255=-1)
Another good way to learn, is to write a very simple SX/B program that does what you want. Then compile it and look at the output.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"A problem well defined, is a problem·half solved."
·
; I am going to assume that you have loaded the 9-bit temperature
; value into the following two 8-bit registers
temp_hi···ds·1·; HI byte - only care about the least signifcant bit of this byte
temp_lo···ds·1·; LO byte
; The code below will take the 9-bit value in temp_hi and temp_lo and create
; a signed magnitude value in the following two variables
temp_sign··=·temp_hi.0·; Least significant bit of temp_hi will be used as sign bit
temp_magnitude·= ·temp_lo··; Will re-use the lower byte as the magnitude
; Read the temperature into temp_hi and temp_lo with your existing code
; If the most significant bit of the 9-bit temperature is set
; then you have a negative value so the magnitude needs to be inverted
··sb temp_sign
··jmp [noparse]:p[/noparse]ositive_temp··; Sign-bit not set so the value is positive
··not temp_magnitude··; Value is negative so invert the magnitude portion
··inc temp_magnitude
[noparse]:p[/noparse]ositive_temp
; The DS1620's resolution is 1/2 degree Celcius so you need to divide the magnitude
; by 2 (shift right by 1) to get the value of the temperature in degrees
··clc
··rr temp_magnitude··; temp_magnitude now has temp in degrees
; If you want, you can look at the carry flag for 0.5 degree accuracy
;· Carry set means that the temperature ends with .5
;· Carry clear means that the temperature ends with .0
That is what i did, but i have the impression that somethings is wrong during the shift in of the Data that comes from the ds1620. Even when i read the controlregister, it was set for 3 wire communication $02, i get something back like $88.
I will take a further look into the program, and i can figure it out i will post it
Thanks
Kurt
Kurt