Hi,
Just trying to use a DS18B20, but it always hangs on the Find operation. Tried several different samples of code and it always fails the same way, the code I am using at the moment is:
Device = 18F4520
Clock = 25
// some LCD options...
#option LCD_DATA = PORTD.4 // Assign the LCD connections
#option LCD_EN = PORTD.3 //
#option LCD_RS = PORTD.2 //
// import LCD library...
Include "LCD.bas"
Include "convert.bas"
Include "DS18B20.bas"
Dim
TempA As ShortInt,
TempB As Word
// Start Of Program...
DelayMS(150) // Let the LCD warm up
LCD.Cls // Clear the LCD screen
LCD.WriteAt(1,1,"Starting") // Send some text to the LCD
DelayMS(1000)
SetPin(PORTC.0)
LCD.WriteAt(1,1,"have setpin")
DelayMS(500)
If DS18B20.Find Then
While true
LCD.Cls
LCD.WriteAt(1,1,"Found DS18B20")
DelayMS(1000)
Wend
Else
lcd.cls
LCD.WriteAt(1,1,"No device found")
DelayMS(1000)
EndIf
It stops on the find regardless of whether I have a DS18B20 connected or not; surley if nothing is connected to PortC0 then it should return false not hang, surley it doen;t search indefinatley? Also I notice that whilst it is running the find if I pull the connection between C0 and the DS18B20 then it shows device found; however if I run it with it disconnected then connect it during the Find it returns no device found. Not sure if this means anything or is just noise etc during the connection / disconnection.
It is a brand new DS18B20, not the 'par' variant, and is connected directly to ground, and +5v, and has a 4.7k pull up resistor between DQ and Vdd.
I have read elsewhere that hanging on Find is always a hardware issue, but 1) I cant identify any hardware problems and 2) I would expect it return not found eventually if nothing is connected.
Any ideas?
Thanks,
Anthony
DS18B20 hangs on Find
Moderators: David Barker, Jerry Messina
-
- Posts: 6
- Joined: Wed Oct 07, 2009 10:43 am
have to disconnect it to get it to work
Hi, just an update to say that I added in the code to read the temp, and once it has appeared to hang if I disconnect then reconnect the DS18B20 data / pic connection not only does it get found but goes on to read the temp ok.
I am not the only person to find this, as per this previous thread:
http://www.sfcompiler.co.uk/forum/viewt ... ght=ds1820
Anthony
I am not the only person to find this, as per this previous thread:
http://www.sfcompiler.co.uk/forum/viewt ... ght=ds1820
Anthony
-
- Posts: 6
- Joined: Wed Oct 07, 2009 10:43 am
trace during find
Hi,
Still struggling to get the find to work without disconnecting / connecting the data pin.
Put a scope on the data pin during the endless find operation and got the following:
Anyone got any ideas whats going on, as I am all out of ideas?
Thanks
Anthony
Still struggling to get the find to work without disconnecting / connecting the data pin.
Put a scope on the data pin during the endless find operation and got the following:
Anyone got any ideas whats going on, as I am all out of ideas?
Thanks
Anthony