jibun24
Newbie
Offline
Posts: 13
Thank You
-Given: 0
-Receive: 0
|
|
« Reply #3 on: November 13, 2005, 02:08:33 14:08 » |
|
Thank you for your help.
I have updated all my code with the new cristal (10 Mhz), and all the code is working fine except the DS18B20. You will find bellow my code ans somes informations for good understanding.
Some informations -The DS18B20 use 12 bits Analog/digital converter -In 12 bits mode the DS18B20 need 0,75 s time conversion -The bit 11 of the ScratchPad give the sign of the temperature -When the temperature is negative, you must do the complement of data for get the good temperature value. -The Float KT=0.0625 -The variable TMPRC is a word -The byte MES is init to zero -The procedure DS1820 is called every second
DS1820: 'Temperature Acquisition If MES=1 then 'temperature calculation in progress OREAD TRC, 4, [FMES] 'reading bit end of temperature calculation IF FMES=0 then return 'Calculation of temperature not finished OWRITE TRC, 1, [$CC, $BE] 'Send command for put results in ScratchPad OREAD TRC, 2,[TMPRC.LOWBYTE,TMPRC.HIGHBYTE] 'Temperature reading (ScratchPad) MES=0 ' Temperature acquisition of DS18B20 finished 'Temperature conversion in degree Celsus IF TMPRC.11 = 1 then 'negative température, The bit 11 of ScratchPad give the signe TZ1N=~TMPRC 'complement for get the good temperature value TZ1N= TZ1N * KT 'In 12Bits mode the DS18B20 have a résolution of 0.0625 per degree Celsius TZ1=TZ1N * -1 'Put negative temperature else 'Positive température TZ1= TMPRC * KT 'In 12Bits mode the DS18B20 have a résolution of 0.0625 per degree Celsius EndIF EndIF If MES=0 then OWRITE TRC, 1, [$CC, $44] ' Send request fot temperature calculation, 12 bits by default MES=1 'temperature calculation in progress EndIf Return
|