Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Dallas DS18S20

 
Post new topic   Reply to topic    Forum Index -> General
Author Message
super-d



Joined: 16 Mar 2008
Posts: 3

Posted: 23 March 2008, 14:09 PM    Post subject: Dallas DS18S20 Reply with quote

I am having problems using the DS18S20 temperature sensor. I had it working on both the BX24 and ZX24. Then I moved my project to another bench and it has stopped working on both processors.

I'm using the exact same code below and the temp is always -0.5C. On the BX24 it uses parasite power and it will alway return +85C. I've tried different DS1820s and get the same results.

Is there a good way to troubleshoot and find out where the problem is? I've checked and double checked but as far as I can tell it is hooked up correctly for the ZX24 code and it is the only thing hooked up to the processor. Also, I was told these are DS18S20 but on the side of the TO-92 package it says DS1820? Shouldn't it be a DS18S20?

Any help will be greatly appreciated.
TIA
David

Code:

' This code is intended for the DS18S20 temperature chip
' operating in the externally powered mode (i.e. not
' powered parasitically via the DQ line).  The code assumes
' the presence of a single device on the 1-wire bus.

Const owPin as Byte = 13   ' the pin to which the DQ line is connected

Sub Main()
   Dim temp as Single
   temp = readTemp()
   Debug.Print "The temperature is "; Fmt(temp, 1); "*C"
End Sub

'
'' readTemp
'
' Request a temperature conversion and read the result.  The
' return value is in degrees Centigrade.
'
Function readTemp() as Single
   Dim b as Byte
   Dim data(1 to 9) as Byte

   ' initialize the 1-wire interface (return value is the "presence" bit)
   b = Reset1Wire(owPin)

   ' initiate a conversion
   data(1) = &Hcc      ' "skip ROM" command
   data(2) = &H44      ' conversion command
   Call Put1WireData(owPin, data, 2)
   
   ' delay to allow for the conversion
   Call Delay(0.750)

   ' send another reset pulse
   b = Reset1Wire(owPin)

   ' prepare to read the data
   data(1) = &Hcc      ' "skip ROM" command
   data(2) = &Hbe      ' "read scratchpad" command
   Call Put1WireData(owPin, data, 2)

   ' read the data
   Call Get1WireData(owPin, data, 9)

   ' send another reset pulse
   b = Reset1Wire(owPin)
   
   ' compute the temperature
   Dim ival as Integer Alias data(1)
   readTemp = CSng(ival) / 2.0
End Function
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 23 March 2008, 15:09 PM    Post subject: Re: Dallas DS18S20 Reply with quote

super-d wrote:
as far as I can tell it is hooked up correctly
My conjecture is that it is not hooked up correctly or the 'owPin' constant doesn't match the connection. On my test setup, if I change the owPin setting to a different pin (one that it is not connected to) the result returned is -0.5*C. When I switch it back I get a reasonable temperature value.

super-d wrote:
on the side of the TO-92 package it says DS1820? Shouldn't it be a DS18S20?
Mine is marked the same way. According to the Maxim website, the DS1820 is no longer available, superseded by the DS18S20.
Back to top
super-d



Joined: 16 Mar 2008
Posts: 3

Posted: 23 March 2008, 16:04 PM    Post subject: Reply with quote

Thanks Don. It was on the right pin (13) BUT I had pins 1 and 3 reversed.... needless to say I lost a DS1820 and after replacing it, I'm getting accurate readings. I was using the datasheet for the pin layout but some how managed to reverse them.

Thanks again.
David
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> General Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group