displaying a digital tem on a PMLCDL from a ds1620
aj_ax24
Posts: 16
i have a 3-1/2" lcd digital panel meter and am trying to configure a digital readout of the temp from my ds1620.· also how could i chang the following code to display Fahrenheit?
' setpoints at -5.5 and +7.5 degrees C
' P13=chip select
'··· high activates the DS1620 to receive data
' P14=serial data clock
' P15=serial SPI data in and out
'
' configure DS1620 for standalone mode
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]12,0]
low 13
pause 10· ' let it write (be sure to allow time!)
'
' set the lower threshold= -5.5 deg C
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]2,-11\9]· ' lower threshold=-11/2=-5.5 deg C
·············· '· the twos complement number is sent correctly as 9 bits
low 13
pause 10· ' let it write
'
·
' set the upper threshold= +7.5 deg C
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]1,15\9]· ' upper threshold=15/2=7.5 deg C
low 13
pause 10
··
·
' setpoints at -5.5 and +7.5 degrees C
' P13=chip select
'··· high activates the DS1620 to receive data
' P14=serial data clock
' P15=serial SPI data in and out
'
' configure DS1620 for standalone mode
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]12,0]
low 13
pause 10· ' let it write (be sure to allow time!)
'
' set the lower threshold= -5.5 deg C
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]2,-11\9]· ' lower threshold=-11/2=-5.5 deg C
·············· '· the twos complement number is sent correctly as 9 bits
low 13
pause 10· ' let it write
'
·
' set the upper threshold= +7.5 deg C
high 13
· shiftout 15,14,lsbfirst,[noparse][[/noparse]1,15\9]· ' upper threshold=15/2=7.5 deg C
low 13
pause 10
··
·
Comments
<EDIT>
If you look at the data table on page 3 of http://rocky.digikey.com/WebLib/Dallas/Dallas%20Web%20Data/DS1620.pdf·you'll see the last bit is the 1/2 C value, this is called fixed format. You'll need to do a signed divide by two to take this out to get a final number in Fahrenheit (signed divide by two (also known as arithmetic shift right) preserves the leftmost bit, keeping a negative number in 2's compliment·negative). This should be done before doing the above operations.
</EDIT>
Post Edited (Paul Baker) : 3/31/2005 11:06:49 PM GMT