DS18B20 Returning 0!

Panda1989

Member
Hi, I made a quick circuit to test the functionality of my code.

Here's the schematic:


Here's the code:
Code:
symbol temp = b1
symbol mintemp = 0
symbol maxtemp = 60

main:
	readtemp 0,temp
	
	if temp = 0 then
	  high 5
	elseif temp > 0 then
	  if temp < 60 then
	    high 6
	  else
	    high 7
	  endif
	endif
	
	pause 1000
goto main
The seven segment display indicates that the temperature sensor is returning 0. Have I connected it all correctly, or is this a faulty sensor?

Thanks!
 

ylp88

Senior Member
So pin 15?
No. Have you looked at the quoted page (command information for the READTEMP command)? A nice diagram is shown there.

EDIT: I also hope you've supplied an "abridged" schematic. You seem to be missing a few power pin conenctions, a reset pull-up resistor and your programming interface (or at least an appropriate pull-down on the serial in pin).

ylp88
 
Last edited:

Dippy

Moderator
I think Panda has mis-read eclectic's post. When eclecttic said "c.4k7..." he didn't mean anything to do with the pin ident C.4. He meant "about" i.e. "circa" as in eclectic was born in circa 1854.

So, as said , connect a 4k7 resistor (about 4k7) between the data line and your +V line.

Coincidentally there is a similar thread with the same confusion where several references are made to reading the Basic Manual page 128 which have seemingly been ignored.

Dunno why you have a pot in your circuit. And if you read page 128 you'd wonder too :)
 

Panda1989

Member
Thanks for all of your help. I've adjusted my test circuit accordingly:


Is this correct? I'm using a pre-built circuit to download data onto a chip, so a download port isn't needed.

Went to Maplin today to get some resistors, among other things, and the guy gave me a 470 Ohm instead of a 4.7k. Colour-blind I guess. I'll go there again tomorrow.
 

Dippy

Moderator
Why have you got 'reset' connected to the data line?
What are your resonator/crystal connections doing?
Please read the manuals and have another go.
 

BCJKiwi

Senior Member
The link between the bottom on the 4k7 Resistor and the DS18B20 is required for the DS18B20.
A completely separate connection between leg1 (reset) and 5V using another 4k7 resistor is required. These two sub circuits cannot same the same 4k7.

Since the internal resonator appears to be used, the connections from legs 9 and 10 to ground should be removed.

Don't know what the dual 7 seg display module wiring is but if typical, then there are 8 connections for each subunit - one for each of the 7 segs plus one for the DP. There is also the common anode + or cathode - depending on the device.
Suggest you source a circuit for the device you have which will show the pinout (most have a part number on the side, a search on the internet for that part number should give you what you need). The circuit shows 18 pins, 2 x 8 plus 2 x anode or cathode which suggests two standard 7 segment displays side by side in a single housing.

Typically to light up a single 7 segment display module 8 output pins would be required so more connections are needed!

@ Dippy - Posts crossed, is this too much spoon feeding!?
 
Last edited:

Panda1989

Member
Why have you got 'reset' connected to the data line?
What are your resonator/crystal connections doing?
Please read the manuals and have another go.
There wasn't a symbol for a resonator in my CAD software, so just imagine a resonator there going to 0v.

I've made the DS18B20 and the reset pin go through separate 4k7 resistors.
 

Panda1989

Member
Oh and the dual display is wired up correctly, I've merely shown it that way in the schematic to show that I've got three different indicators, as described in my first post. Thus, there was no need to wire all the pins up.
 

BCJKiwi

Senior Member
So 3 individual segments of one 7 seg are being used as if they were 3 discrete LEDs - right?

An external resonator is being used.

Having re-wired the DS18B20 and reset correctly - does it now work??
 

Panda1989

Member
So 3 individual segments of one 7 seg are being used as if they were 3 discrete LEDs - right?

An external resonator is being used.

Having re-wired the DS18B20 and reset correctly - does it now work??
Yes, that's right :)

I need to go to Maplin tomorrow to get those resistors, will post back then.

Thanks for all the help, and sorry if I'm a little slow; electronics is definitely not my strongest area.
 

hippy

Technical Support
Staff member
Not sure what you're doing with Legs 9 and 10 which should be a resonator.

Also the 4K7 pull-up for Input 1 cannot also be used as the 4K7 pull-up for Reset ( leg 1 ). You need two separate pull-ups.
 

Panda1989

Member
Not sure what you're doing with Legs 9 and 10 which should be a resonator.

Also the 4K7 pull-up for Input 1 cannot also be used as the 4K7 pull-up for Reset ( leg 1 ). You need two separate pull-ups.
Quoting post #12:
There wasn't a symbol for a resonator in my CAD software, so just imagine a resonator there going to 0v.

I've made the DS18B20 and the reset pin go through separate 4k7 resistors.
Thanks for all of your help.
 
Top