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.

Has anyone tried this project?

Status
Not open for further replies.
https://www.electro-tech-online.com/articles/digital-temerature-sensor.409/

I thought I would give this a try to experiment with the one wire sensors. I had a few issues compiling it with MPLAB 8.91 and had to delete and re-arrange to get it build. Once programmed, I built the circuit. Upon power up it displays "000.0" then it displays "2.8" degrees C (34F) and it's about 19 C (67) in my house. If it matters I have a DS1820 instead of the DS18B20 if that matters. It appears to respond to changes in temperature its just way off. The code I modified is attached and the original code is in the link. I get this message from the builder:

Message[305] C:\PK2 LESSONS\LPC DEMO BOARD\16F628A TEMP GAUGE\16F628A.ASM 343 : Using default destination of 1 (file).

Did I mess something in the code? I also had to change a few things in the _config line.
 

Attachments

  • 16f628a.asm
    25.4 KB · Views: 151
Last edited:
If it matters I have a DS1820 instead of the DS18B20 if that matters.

It does matter. The data format is different. If I remember correctly, DS1820 and DS18S20 transmit number in 1/2 degrees, but DS18B20 transmits number in 1/16 degrees.
 
I have used the ds18b20 in a few projects, its a usefull chip.
Yes the temp is stored as a hex value, and the fraction as a hex value, and that is affected by what resolution you have the device setup to.
I use a lookup table to work out the fraction of a degree, and a hex to bcd or ascii converter to work out the temp.
Do you have it wired up for 2 or 3 wire?

I couldnt be bothered writing the code so I stole it off the net, and it looks the same as the code you linked to, the only change I made was to make it so it didnt hang up if there was no reply from the sensor, and of course the section that converts the values to bcd or ascii.
 
I have used the ds18b20 in a few projects, its a usefull chip.
Yes the temp is stored as a hex value, and the fraction as a hex value, and that is affected by what resolution you have the device setup to.
I use a lookup table to work out the fraction of a degree, and a hex to bcd or ascii converter to work out the temp.
Do you have it wired up for 2 or 3 wire?

I couldnt be bothered writing the code so I stole it off the net, and it looks the same as the code you linked to, the only change I made was to make it so it didnt hang up if there was no reply from the sensor, and of course the section that converts the values to bcd or ascii.
Three wire as per the circuit in the link. I just realized the digi-key bag the sensor came in says DS18S20+T&R whereas DS1820 is clearly visible on the device. I notice this circuit will hang up and display the latest value if it loses communication the the sensor.
 
I just realized the digi-key bag the sensor came in says DS18S20+T&R whereas DS1820 is clearly visible on the device.

If you read the binary output you can see the difference. DS18S20 has a correction field which lets you translate the results to 1/16-th. DS1820 didn't. You're unlikely to have DS1820. They're old.
 
I was a little concerned for a moment then, as I got a bag full from china dead cheap, but concern over I just checked them, they are ds18b20's.

The fraction register isnt only 1/16's, it depends on the accuracy setup you defined, also the time to aquire depends on the setup accuracy too, your better starting a conversion then handlig it when the device is done, interrupts makes this more efficient.
 
Just swapped in a 18B20, now all it does is read "85.0". I like it warm in my house but not that warm. No change in the display with heat. I also noticed the displays don't read "000.0" upon power up with this sensor.
 
Just swapped in a 18B20, now all it does is read "85.0". I like it warm in my house but not that warm. No change in the display with heat. I also noticed the displays don't read "000.0" upon power up with this sensor.

85 is the default value at boot-up. Looks like you do not issue the temperature conversion command, don't wait long enough after it, or perhaps your DS18B20 is defective.
 
85 is the default value at boot-up. Looks like you do not issue the temperature conversion command, don't wait long enough after it, or perhaps your DS18B20 is defective.
Could be bad, new out of the package from Digi-Key. What does the temperature conversion command look like?
 
Hi,

This assembly project is good, have used its DS18b20 routine many times.

http://bogdi.ro/electronics/digital clock/
I tried that one too but I couldn't get anything to display. I had to jack around with the code a little because I was using different micros. I have the correct ones now and I may try it again.

If I may ask, which version did you use? Its a little confusing as to which micro to use in the 16F628 version, the 628 or 628a.
 
Last edited:
I tried that one too but I couldn't get anything to display. I had to jack around with the code a little because I was using different micros. I have the correct ones now and I may try it again.

If I may ask, which version did you use? Its a little confusing as to which micro to use in the 16F628 version, the 628 or 628a.


Hi,

It was some time ago , I simulated the whole project code ok, then just used his 18b20 subroutine ported over on to a 18F chip, as I was having difficulty trying to program the ds18b20 from scratch.

As NorthGuy has said , the timings /delays/sequences are very keen for those sensors and you must have a 1sec+ delay between each successive read.
Also ensure nothing else in your program is using an Interrupt that could affect its routine/ timings.

Search this forum as I'm sure the DS18b20 sensor has been looked at in Assembly before with a working set of code.
 
85 degrees is a common error for the ds, often its caused by not leaving enough time for the conversion to take place as mentioned.
I had the 85 degree problem and not matter what couldnt fix it, then it just went away never did find what it was.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top