PDA

View Full Version : Stuck with 85C temp on ds18b20



revelator
- 2nd April 2009, 18:24
One more time...and disregard previous post from yesterday

Now that I have a cold solder joint fixed, I'm talking to a ds18b20 (w/3 ft. wires) using a 16f876 running at 20Mhz with latest PBP 2.5.

Serial #, fam code, etc. reads fine using Rentron's code.

Can't figure out why the startup temp 85C (185F) is stuck using the posted Rentron code (partial code shown changed to accomodate a 2-line lcd ...)

Is there a magic step to unlock the scratchpad from startup temp? Any ideas on what to try next?

thanks in advance...

---------------------------------------------------------------------

'* Notes : Changed Original code for 16x2 serial LCD. *
'* : Display F deg only. Using Lab X2 w/ 16F876-20/SP *
'* : *
'************************************************* *

DEFINE OSC 20 ' We're using a 20MHz oscillator

Comm_Pin VAR PortC.0 ' One-wire Data-Pin "DQ" on PortC.0
Busy VAR BIT ' Busy Status-Bit
R_Temp VAR WORD ' RAW Temperature readings
Lo_ByteR var R_Temp.Byte0
Hi_ByteR var R_Temp.Byte1
TempC VAR WORD ' Temp in deg C
TempF VAR WORD ' Temp in deg F
Float VAR WORD ' Holds remainder for + temp C display
Cold_Bit VAR R_Temp.Bit11' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Real_Cold CON 1 ' Define Real_Cold = 1
BAUD CON 16468 ' N9600 for serial LCD
DISP VAR PortB.0 ' Pin to drive serial LCD
Deg CON 223 ' Data to display Deg ° symbol
CLR CON 1 ' CLR LCD command
LINE1 CON 128 ' LCD line #1
LINE2 CON 192 ' LCD line #2
'LINE3 CON 148 ' LCD line #3
'LINE4 CON 212 ' LCD line #4
INS CON 254 ' LCD command mode parameter
Sign VAR BYTE ' +/- sign for temp display
Dummy VAR BYTE ' Dummy for Div32


Pause 500
SEROUT2 DISP,BAUD, [INS,CLR]
SerOut2 DISP, BAUD, ["My display"] ' Display "Hello"
Pause 1000 ' Wait .5 second

Start_Convert:

OWOUT Comm_Pin, 1, [$CC, $44]' Skip ROM search & do temp conversion

Wait_Up:

OWIN Comm_Pin, 4, [Busy] ' Read busy-bit
IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..!
OWOUT Comm_Pin, 1, [$CC, $BE]' Skip ROM search & read scratchpad memory
OWIN Comm_Pin, 2, [Lo_ByteR, Hi_ByteR]' Read two bytes / end comms
SEROUT2 DISP,BAUD, [INS,CLR]
GOSUB Convert_Temp
pause 500
GOTO Start_Convert

Convert_Temp: ' +32.0 to +257 F
IF Cold_Bit = Real_Cold THEN Yikes ' If Cold_Bit = 1, it's below "0" deg C
Sign = "+"
Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
Dummy = 1125 * R_Temp
TempF = DIV32 100
IF TempF >6795 THEN ' Over 99.5 deg F..?
TempF = TempF + 3200
SEROUT2 DISP,BAUD, [INS,LINE1, " TempF = ",Sign,DEC TempF DIG 4,_
DEC TempF DIG 3,DEC TempF DIG 2,".",DEC2 TempF,Deg,"F "]
ELSE
TempF = TempF + 3200
SEROUT2 DISP,BAUD, [INS,LINE1, " TempF = ",Sign,DEC TempF DIG 3,_
DEC TempF DIG 2,".",DEC2 TempF,Deg,"F "]
ENDIF
pause 500
TempC = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
Float = ((Lo_ByteR & $0F) * 625) ' Lower 4-bits of result * 625
'changed IBIN to display 12 bits only due to display limit of 16
SEROUT2 DISP,BAUD, [INS,LINE2, "R=", IBIN12 R_Temp]
pause 2000
RETURN

Darrel Taylor
- 3rd April 2009, 05:01
Is there any chance that the DS18B20 was installed backwards at ANY point in your testing?
They really don't like being hooked up backwards, even for a few mS.

When the power pin is fried, you can still access the scratchpad memory. But as soon as you try to make it do a conversion, it putters out.

Here's a little test program to see if the device is getting power thru the VDD pin or via parasitic from the data pin.
http://www.picbasic.co.uk/forum/showthread.php?p=43254#post43254

If it comes back showing "Parasite", and you know for sure there is power on PIN 3 of the DS18B20 (measure with voltmeter), then the VDD pin is no longer functioning.

You can still use a toasted part by using the parasitic power method, but external power will no longer work on that device, and the temperature may be off by around 2.5°C, requiring software calibration.

Depends on what the test program says.
<br>

revelator
- 3rd April 2009, 18:09
Thank you Darrel,

I see that you've been here answering questions patiently for many and for a few years. Kudos to you ....

The code tells me: Diag Done = 1, Power is parasite, Family $28

I doubt I hooked these backwards. They were connected to molex 3-pin connectors. Although it is possible to do, I doubt I have inserted with the connection with alignment prong backwards. The two ds18b20 samples from Maxim were both built exactly the same connected to 3ft wire. What I did not do, perhaps, was to ground myself when handling. I'll buy a few more and try again.

I do not intend to use in parasitic because the application calls for a little safety factor in case of temps above 200 F.

Attached is the code massaged to my needs (and for future rookies like me). Also, wanted to see the best way to display code within a post.

Can Anyone tell me how do I reply with code pasted onto a window with the side scroll bar feature I have seen others use?

-rev

Acetronics2
- 3rd April 2009, 19:39
Hi,

Just got samples from Dallas ...

May be a little thing, but the parasite devices Markings are very , very discrete ...

Just a little "P" added to 18B20 ...

so, error is easy ...

Alain

Darrel Taylor
- 3rd April 2009, 19:50
May be a little thing, but the parasite devices Markings are very , very discrete ...
Just a little "P" added to 18B20 ...

There ya go. I totally forgot they can be ordered "Parasite only".


Can Anyone tell me how do I reply with code pasted onto a window with the side scroll bar feature I have seen others use?

Scroll down to the bottom of the page. In the "Posting Rules" box, there's a link to BB code.
There's all kinds of stuff you can do in your post.

For the code box it's ...
program goes here