Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:49 14 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : DS18B20 clock speed and accuracy problem

Author Message
rogersan
Regular Member

Joined: 10/04/2015
Location: Australia
Posts: 79
Posted: 02:04am 20 Apr 2015
Copy link to clipboard 
Print this post

I have found that the DS18B20 will not work with the Micromite above a clock speed of 30 MHz, although Geoff has 40 MHz in his documentation. Above 30 MHz the DS18B20 function causes the program to terminate with no error message. Has anyone else found this problem?

Also I found the the temperature reading from the DS18B20 can read up to 3 degrees high (compared with the temperature reading from a BMP180). I suspect self heating so I changed the read rate to once every 5 seconds which seemed to improve matters. However the temperature reading from the DS18B20 still drifts high sometimes, it does not seem consistent. Has anyone else found this?

Thank you for any suggestions. I asked Geoff but he did not know of any problems.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9593
Posted: 03:21am 20 Apr 2015
Copy link to clipboard 
Print this post

I've used the 18B20's at 40MHz - the default MM speed, and had no issues.

In my simple application, I was reading the sensor in a loop, so I was checking it repeatedly at 40MHz and never had program drop outs.

I know this does not really help you, but just thought I would mention it.

Are you able to post your 18B20 code?
Smoke makes things work. When the smoke gets out, it stops!
 
rogersan
Regular Member

Joined: 10/04/2015
Location: Australia
Posts: 79
Posted: 03:33am 20 Apr 2015
Copy link to clipboard 
Print this post

My code was
Cpu 40
Dim temp1
LCD INIT 3,4,5,6,7,9
LCD CLEAR
Do
Temp1=DS18B20(15)
LCD 1,1,Str$(temp1,2,1)
Pause 5000
Loop
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10247
Posted: 04:17am 20 Apr 2015
Copy link to clipboard 
Print this post

Have you got a "real" DS18B20 or a "Chinese" one?

Real ones definitely work at all CPU speeds.

Are you using a 4.7K pullup on the DS18B20 data pin?
 
rogersan
Regular Member

Joined: 10/04/2015
Location: Australia
Posts: 79
Posted: 10:16am 20 Apr 2015
Copy link to clipboard 
Print this post

I bought the DS18B20 from an Australian supplier so I can go back to him and ask. Can you tell if it is a Chinese one from the markings on the TO91 package?
 
rogersan
Regular Member

Joined: 10/04/2015
Location: Australia
Posts: 79
Posted: 10:19am 20 Apr 2015
Copy link to clipboard 
Print this post

I do have a 4.7 K ohm pull up resistor to 3.3 volts on the data pin of the DS18B20.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 12:47pm 20 Apr 2015
Copy link to clipboard 
Print this post

Back in November last year I did some tests with various CPU speeds and Temperatures.
The test was to play with CLOCKTRIM but I was using a DS18B20 so it is relevant.

http://www.thebackshed.com/forum/forum_posts.asp?TID=7087&PN=23

The DS18B20 'should' be working OK

Jim

VK7JH
MMedit
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2933
Posted: 01:08pm 20 Apr 2015
Copy link to clipboard 
Print this post

A few things to check/confirm:

1> What version of MMBasic are you running? And out of interest; which processor? MX150 or MX170?

2> You mention you have a 4K7 to 3v3 on the data pin; what about the connections on the other two (outside) pins - do they both go to GND (as shown on page 17 in the user manual); or is one going to +v? If so, what voltage?

3> What length cable have you got between MM and the sensor? Any dry joints?

4> If you're using a breadboard then carefully check connections! There have been several instances of bad connection strips inside 'cheaper' breadboards - DO a continuity check

5> Is your power supply capable of supplying enough power? If using a USB-to-TTL adaptor's 3v3 output then there may not be quite enough power. The MM will draw around 30mA at 40MHz so you may be nearing the maximum limit resulting in 'poor' readings (compared to lower frequencies that will draw less current resulting in 'valid' readings) - worth checking!

As others here have already said on this thread, there are no problems reading the DS18B20 at 40MHz so it should be working for you.

If all the above checks out ok then I suspect you have a 'faulty' sensor. Do you have another one to try?

Please feed back with your progress . . . . .

WW
Edited by WhiteWizzard 2015-04-21
 
rogersan
Regular Member

Joined: 10/04/2015
Location: Australia
Posts: 79
Posted: 04:45pm 21 Apr 2015
Copy link to clipboard 
Print this post

Thank everyone for the advice on the DS18B20. The one I bought is marked

DALLAS
18B20
1415C4
+942AA

If you look at the Maxim Datasheet (they took over Dallas Semiconductor some years ago) the part should be marked

MAXIM
18B20

So I do not know why my part is marked DALLAS. Are some parts from Maxim still marked DALLAS? Perhaps the part I bought is an old one.

Strangely the part I have is now working, even with a Micromite speed of 48 MHz. It is also gives a temperature reading similar to a BMP180, they are within 0.3 degrees of each other at 22 degrees C.

I have the ground and Vdd pins of the DS18B30 to ground and the data pin to 3.3 volts via a 4.3 k ohm resistor.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9593
Posted: 06:04pm 21 Apr 2015
Copy link to clipboard 
Print this post

Perhaps you just had a factory dud - the first one you tried.
Not common, but it can happen.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025