Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DS18B20 Error - Pic Assembler

Status
Not open for further replies.

Wp100

Well-Known Member
Hi all,

Bit of a strange problem, wondered if anyone else had experienced it.

Not wanting to waste time, again, trying to do my own code to read the DS18B20 I opted to use the free code from this project Digital Clock/Date/Thermometer with PIC16F628/PIC16F84 and DS18S20/DS18B20

I simply converted the code to run on the 18F4520 at 4 meg and all seemed to work well.
I could icsp the chip and run or even use PK2 debugger without any errors.

However if I switch off and repower the circiut the first temp returned is 85c instead of room temp at 20c.

I have done various tests using 85c counter traps and it only occurrs at power up.
I can delay for 5 seconds before reading the sensor but it still returns 85c that one time.

If I force the program to Reset by the menu left open timeout routine it still does not sense 85c so I think that excludes any problem in the early part of my main program code.

While the error is easily overcome by software it would be good to know the cause of the problem in case there is a more underlying fault.


thanks
 

Attachments

  • ds18sb20.asm
    7.6 KB · Views: 234
Hi all,

Bit of a strange problem, wondered if anyone else had experienced it.

Not wanting to waste time, again, trying to do my own code to read the DS18B20 I opted to use the free code from this project Digital Clock/Date/Thermometer with PIC16F628/PIC16F84 and DS18S20/DS18B20

I simply converted the code to run on the 18F4520 at 4 meg and all seemed to work well.
I could icsp the chip and run or even use PK2 debugger without any errors.

However if I switch off and repower the circiut the first temp returned is 85c instead of room temp at 20c.

I have done various tests using 85c counter traps and it only occurrs at power up.
I can delay for 5 seconds before reading the sensor but it still returns 85c that one time.

If I force the program to Reset by the menu left open timeout routine it still does not sense 85c so I think that excludes any problem in the early part of my main program code.

While the error is easily overcome by software it would be good to know the cause of the problem in case there is a more underlying fault.


thanks

hi,
This may help.

85 decimal is 55h which is %101010, drop the 1st bit and it becomes %001010 = 21decimal.

I would guess that the DS18S20 MSB is being read as a '1' after power up.????
 
Hi Eric,

Nice thought, but it still returns 85c for the first time with the ambient temp in the 50s,40s, 30s or 20s as just tested.
 
Hi Mike,

Thank for that - sounds like its either a few folk have got the code similarly wrong or there is a quirk with those sensors ...?
I'm only using mine on a 2 mtr lead.

Can indeed do the dummy read but just wanted to confirm it wasn't some basic code error that might cause problems later on.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top