Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20656

BASCOM-AVR : 18B20 errors : REPLY

$
0
0
Lower value resistors have been suggested. I doubt is 5k1 is significantly different from 4k7 at 5v. In the last 2 hours with a stiffer pullup, i had 6 errors, so I have now changed my code to the following. [code:1:d89a16c166] read18b20: 'Dim DS18B20_integer_temp As Integer Dim DS18B20_Sc(9) As Byte 'AT DS18B20_integer_temp OVERLAY Dim mytemperature as integer dim mytemperaturesingle as single dim W as word w = 1wirecount() if w <> 1 then incr tempb print #1 , "count error" end if 1wreset 'reset the device if err <> 0 then incr tempb print #1 , "reset error" end if 1wwrite &HCC 'skip-address all devices 1wwrite &H44 'convert T wait 1 1wreset if err <> 0 then incr tempb print #1 , "reset error" end if 'convert 1wwrite &HCC 'skip rom command 1wwrite &HBE 'read scratchpad Ds18b20_sc(1) = 1wread(9) tempw = crc8(Ds18b20_sc(1) , 8) if Ds18b20_sc(9) <> tempw then print #1 , "crc error" print #1 , "CRC=" ; tempw print #1 , "byte9=" ; Ds18b20_sc(9) incr tempb end if mytemperature = makeint(Ds18b20_sc(1) , Ds18b20_sc(2)) mytemperaturesingle = mytemperature * .0625 print #1 , mytemperaturesingle ; if mytemperaturesingle > 30 or mytemperaturesingle < 10 then incr tempb print #1 , "temperature error" end if print #1 , " Errors = " ; tempb return [/code:1:d89a16c166] In the last hour since the code change, i have seen 5 errors: They are: ( note that there hundreds of good reads between each of these errors. i have only copied a few reads either side of each error. I am using hyperterminal to capture all responses) Its interesting to note a temperature error accompanied by a CRC error. The correct CRC for 19.3125 Degrees is decimal 201 The CRC for 19.25 degrees is 228. The 2 data results so far would suggest that the device sent the correct CRC and the processor calculated the wrong CRC (from bad received data?) This would suggest that either 400mm of cable is picking up noise ( Hmm?) or the processor is making receive errors. Any thoughts people?? [list:d89a16c166]19.25 Errors = 0 19.3125 Errors = 0 crc error CRC=21 byte9=201 19.3125 Errors = 1 19.25 Errors = 1 19.3125 Errors = 1 19.3125 Errors = 1 ' ' ' 19.3125 Errors = 1 count error 19.3125 Errors = 2 . . . 19.3125 Errors = 2 19.3125 Errors = 2 19.3125 Errors = 2 crc error CRC=158 byte9=228 51.25temperature error Errors = 4 19.25 Errors = 4 19.25 Errors = 4 19.3125 Errors = 4 . . . 19.0 Errors = 4 19.0 Errors = 4 18.9375 Errors = 4 count error 19.0 Errors = 5 18.9375 Errors = 5 19.0 Errors = 5 19.0 Errors = 5 18.9375 Errors = 5 . . . [/list:u:d89a16c166]

Viewing all articles
Browse latest Browse all 20656

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>