How do I set resolution for DS18S20?

SethP

Member
I'm using TMEX to read the DS18S20, exactly as the data sheet says. COUNT_REMAIN is always zero. In the 1-wire viewer, you can select the resolution and it flashes "setting resolution". I looked at the view source, and it appears to be set something on the device, but I couldn't determine exactly what it sends. There is nothing in the data sheet about this.

So, how do I get the extended resolution?

Thanks!

Seth
 
You're right - there's nothing in the spec sheet because it doesn't exist. The DS18S20 always samples at 12 bits. The basic resolution is 9 bits and the extended resolution is 12 bits when you use the formula.

The DS18B20 resolution can be configured for 9,10,11,12 bits and you don't need to mess with any formulas, but its not 100% compatible with the DS18S20.

If you've got a DS18S20 and always getting 0 for COUNT_REMAIN, I would verify that you're actually reading all 9 bytes of the scratchpad.
What are you getting for COUNT_PER_C?, scratchpad(7). It should always be 16.

' send read scratch command
TMTouchByte xxSessionHandle, &HBE
' read scratch
For i = 0 To 7
scratchpad(i) = TMTouchByte(xxSessionHandle, &HFF)
Next i
crcbyte = TMTouchByte(xxSessionHandle, &HFF)
 
I went back and checked my code with a brand new DS18S20, and it's working perfectly -- COUNT_REMAIN and COUNT_PER_C are correct, and my results match the one wire viewer.

I suspect I damaged my first DS18S20, and that caused the problem. The CRC check passed, which is why I thought perhaps I had to set something. I also fried a DS18B20 by hooking up Vdd to +12 instead of +5. The temp readings are rather funny as they continually vary by about 75 degrees.

I'm using TMBlockStream instead of TMTouchByte in a loop as it makes the code slightly simpler.

Thank you for the input.

Seth

You're right - there's nothing in the spec sheet because it doesn't exist. The DS18S20 always samples at 12 bits. The basic resolution is 9 bits and the extended resolution is 12 bits when you use the formula.

The DS18B20 resolution can be configured for 9,10,11,12 bits and you don't need to mess with any formulas, but its not 100% compatible with the DS18S20.

If you've got a DS18S20 and always getting 0 for COUNT_REMAIN, I would verify that you're actually reading all 9 bytes of the scratchypad.
What are you getting for COUNT_PER_C?, scratchpad(7). It should always be 16.

' send read scratch command
TMTouchByte xxSessionHandle, &HBE
' read scratch
For i = 0 To 7
scratchpad(i) = TMTouchByte(xxSessionHandle, &HFF)
Next i
crcbyte = TMTouchByte(xxSessionHandle, &HFF)
 
Back
Top