Hi, Rich
I have a DS1820 "on board" ... I look at that.
Here is an excerpt of my test program:
'************************************************* ****************************
' Start temperature conversion
'************************************************* ****************************
mainloop: OWOut DQ, 1, [$CC, $44 ]
'************************************************* ****************************
' Check for still busy converting ( ~ 4500 times ... )
'************************************************* ****************************
waitloop:
INPUT DQ
If NOT DQ Then waitloop
'************************************************* ****************************
' Read the temperature
'************************************************* ****************************
OWOut DQ, 1, [$CC, $BE ]
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
'************************************************* ****************************
' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
'************************************************* ****************************
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)+ offset
Lcdout $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"C"
'************************************************* ****************************
' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature)
'************************************************* ****************************
temperature = (temperature */ 461) + 3200
Lcdout $fe, $c0, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"F"
the major thing is see is here :
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
as you receive more than 16 bits ... and your "buffer" is only 16 bits.
The Scratchpad is always FULLY read ( 8 bytes ), so you must skip the last locations.
see datasheet on page 8 for scratchpad details.
Alain
Last edited by Acetronics2; - 2nd October 2007 at 14:12.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks