DS1620 temperature sensor in high resolution mode
Hello has anyone got any code examples to use the DS1620 in hight res mode and displaying the result on a 16x2 LCD. I have been trying to modify the melabs ds1620 example using an example of basic stamp code for high res mode and I keep on getting very strange results.
Here is the code example from melabs
http://www.melabs.com/resources/samp...pbp/temp3x.bas
Here is the code from the high res basic stamp (About half way down the page
http://www.emesystems.com/OL2d1620.htm
Any help you be much appreciated as I have been trying most of last weekend and I feel like riping my hair out. :)
The code I am currently using
Here is the code I have mashed together using the BS and Picbasic examples. I keep on getting very strange numbers in the 1000's. I have allready set the registers in the DS1620 eeprom.
Here is the app note from dallas about the increased res functions of the ds1620
http://pdfserv.maxim-ic.com/en/an/archive/AN68.pdf
Define LOADER_USED 1
Include "MODEDEFS.BAS"
' Define LCD pins
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 5
' Alias pins
RST var PORTA.0 ' Reset pin
DQ var PORTA.1 ' Data pin
CLK var PORTA.2 ' Clock pin
' Allocate variables
j var byte
i var word
x var word
remain var word
slope var word
degC var word
Low RST ' Reset the device
PAUSE 500
Low PORTA.4 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start
Lcdout $fe, 1, "Temp in C" ' Display sign-on message
mainloop:
RST = 1 ' Enable device
Shiftout DQ, CLK, LSBFIRST, [$ee] ' Start conversion
RST = 0
Pause 1000 ' Wait 1 second for conversion to complete
RST = 1
Shiftout DQ, CLK, LSBFIRST, [$AC] ' Send read command
Shiftin DQ, CLK, LSBPRE, [x] ' Read 9 bit temperature
RST = 0
IF x.bit7=0 then pause 1000
RST = 1
Shiftout DQ, CLK, LSBFIRST, [$AA] ' Send read command
Shiftin DQ, CLK, LSBPRE, [x\9] ' Read 9 bit temperature
RST = 0
x.byte1= -x.bit8 ' extend sign
degc=x*5 ' compute to 10ths, +/- 0.5 degree C
RST = 1 ' get the count remaining DS1620
shiftout DQ, CLK,lsbfirst,[$A0]
shiftin DQ, CLK,lsbpre,[remain\9]
RST = 0
RST =1 ' get the counts per degree
shiftout DQ, CLK,lsbfirst,[$A9]
shiftin DQ, CLK,lsbpre,[slope\9]
RST =0
x=slope-remain*10/slope ' compute 1/100ths degree
degc=degc+550/10*100+x-552 ' adjust temperature to 1/100ths
pause 1000
' Display the decimal temperature
LCDout $fe, 1, rep "-"\degc.bit15,dec abs degc/10,".",dec1 abs degc
goto mainloop ' Do it forever
End