Problem with DS18s20, only showing -1.05 Solved!

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Sat May 09, 2009 6:37 pm

I can verify that using the SF examples and the DS18B20.bas library with a DS18B20 works.


I used the swordfish DS18S20 library...
Make sure you change your code to

Code: Select all

Include "DS18B20.bas"
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Sat May 09, 2009 8:52 pm

Grrr still nothing!

Damn i`m getting frustrated here.. i almost spend a day trying to get this thing working!

Bah!

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Sun May 10, 2009 1:04 pm

Do you have some other hardware you can test this on?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Sun May 10, 2009 1:35 pm

CharlieM wrote:Do you have some other hardware you can test this on?
Not at the moment.

I tryed it with the sample code from the wiki..
Now i get 85.00C :roll: ..

Is the code correct:?

Code: Select all

Device = 18F452
Clock = 40
Config OSC = HSPLL 
 

#option GLCD_MODEL = S1D13700    
#option GLCD_MODE = 8080         // GLCD interface mode - 6800 or 8080
#option GLCD_DATA = PORTD        // data port
#option GLCD_RD = PORTE.2        // RD pin - 8080 mode
#option GLCD_WR = PORTE.1        // WR pin - 8080 mode
#option GLCD_A0 = PORTE.0        // A0 pin
#option GLCD_CS = PORTC.4        // chip select
#option GLCD_RES = PORTC.5       // reset pin 

#option ow_pin = PORTB.0
  
Include "GLCD.bas" 
Include "DS18B20.BAS"  
Include "convert.bas" 
Include "Utils.bas"            
Include "FixedFont.bas"  

Dim pos1 As Byte

Const Sensor_A(8) As Byte = ($28, $5F, $A9, $CD, $01, $00, $00, $DB)
Const Sensor_B(8) As Byte = ($28, $DC, $9C, $CD, $01, $00, $00, $3E)


Sub DisplaySensor(ByRefConst pID() As Byte)
   Dim TempA As ShortInt
   Dim TempB As Word
   RomID = pID
   Convert
   GetTemp(TempA, TempB)
   WriteAt(20, pos1, DecToStr(TempA),".",DecToStr(TempB,1),"C")
End Sub


// program start...
High(PORTC.2)
High(PORTB.4)
GLCD.SetFont(Fixed)
 Cls(1)
While true
   pos1 = 100
   DisplaySensor(Sensor_A)
   pos1 = 120
   DisplaySensor(Sensor_B)
   DelayMS(1000)
Wend

I have a 10mhz crystal running @ 40 mhz PLL. Can that be a problem?

I also changed the sample code from the wiki, so it would display the temp. on my GLCD. Have i done this correctly?

Also, when i disconnect one DS18B20 it shows -1.0C...

Geetz,
Gert

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Mon May 11, 2009 8:00 pm

Succes! :lol: .

Finally a reading!!!

I don't understand it but i have a good reading with 2 DS18S20 sensors.

I used the following code:

Code: Select all

Device = 18F452
Clock = 40
Config OSC = HSPLL


#option GLCD_MODEL = S1D13700    
#option GLCD_MODE = 8080         // GLCD interface mode - 6800 or 8080
#option GLCD_DATA = PORTD        // data port
#option GLCD_EN = PORTE.2        // EN pin - 6800 mode
#option GLCD_RD = PORTE.2        // RD pin - 8080 mode
#option GLCD_RW = PORTB.1        // RW pin - 6800 mode
#option GLCD_WR = PORTE.1        // WR pin - 8080 mode
#option GLCD_A0 = PORTE.0        // A0 pin
#option GLCD_CS = PORTC.4        // chip select
#option GLCD_RES = PORTC.5       // reset pin
#option ow_pin = PORTB.0

// import modules...
Include "tahoma.bas"  
Include "GLCD.bas" 
Include "DS18s20.bas"
Include "convert.bas"

Dim pos1 As Byte

Const Sensor_A(8) As Byte = ($10, $E7, $E7, $9E, $01, $08, $00, $F5)
Const Sensor_B(8) As Byte = ($10, $88, $9A, $9E, $01, $08, $00, $93)


Sub DisplaySensor(ByRefConst pID() As Byte)
   Dim TempA As ShortInt
   Dim TempB As Byte
   RomID = pID
   Convert
   GetTemp(TempA, TempB)
   WriteAt(20, pos1, DecToStr(TempA),".",DecToStr(TempB,1),"C")
End Sub


// program start...
High(PORTC.2)
High(PORTB.4)
GLCD.SetFont(tahoma)
 Cls(1)
While true
   pos1 = 100
   DisplaySensor(Sensor_A)
   pos1 = 120
   DisplaySensor(Sensor_B)
   
Wend
What i don't understand is, why doesn't the DS18B20 give me anything with the same code :S..

Strange!

Ah well i can get on with my project, takes an extra wire to hook up the DS18S20 but its working :D.

Anyone an idea why the DS18B20 wont give me a reading?

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Mon May 11, 2009 9:26 pm

:oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops:

Guys, i have a confession to make...

The reason why the DS18B20 does'nt give me anything :

Its a -PAR version :oops: :oops: :oops:

The par version is Parasitic power Only

So its needs to be connected like this:
Image

Stupid me :S.

Thanks for all your help!

Greetz,
Gert

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Wed May 13, 2009 3:04 am

Gert,

You'll need to power up the signal line so there is enough current stored to make a temperature measurement. It's pretty simple to do in parasitic mode.

PortC.1 is tied to this transistor in my code.

Code: Select all

        DS18B20.Convert() 
        
        High(PORTC.1) 
        DelayMS(750) 
        Low(PORTC.1) 
        
        DS18B20.GetTemp(TempA, TempB) 
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Wed May 13, 2009 2:59 pm

Thank you very much!

Gert

Post Reply