Picaxe-08M and DS18B20

Jamie#1

New Member
I have successfully connected 3 DS18B20 temperature sensors to a picaxe-08m and they work fine, but the problem is the range. With IN 1 and IN 4, I can connect the DS18B20 sensors over 300 feet away, but with IN 2, the range is limited to much less, maybe 50 feet. I am using 1500 ohm pullup resistors and also a separate power lead to the sensors. It appears as if there is something different with IN 2 that is affecting the range. Also, if the sensors are connected on a very short loop on IN 1 and IN 4, the pullup resistors can vary over a wide range, even up to 150 kohms, however on IN 2, the pullup resistor needs to be very close to 4700 ohms. So the questions is, what is different with IN 2 and how can I make it the same as IN 1 and IN 4?
 

westaust55

Moderator
Welcome to the PICAXE forum.

From a glance through the PIC datasheet,
http://ww1.microchip.com/downloads/en/DeviceDoc/41211D_.pdf
I cannot spy anything immediately obvious as to why one general purpose IO pin should have limitations/variations compared to the other two.

EDIT:
okay possible correction, from page 6, IO2 is a schmitt Trigger type input whereas IO1 and IO4 are TTL compatible, so tentatively signal voltage levels with longer wires are coming into play.
 
Last edited:

hippy

Technical Support
Staff member
Welcome to the PICAXE Forum.

In 1 and In 4 are TTL logic inputs while In 2 is ST ( Schmitt Trigger ). This probably explains the difference as the software will be the same regardless of pin accessed.

If it is pin type there will be very little you can do other then to add some sort of interface into the In 2 signal line ( which would have to be bi-directional ).

This issue would probably also affect other PICAXE which have ST-type pins ...

http://www.picaxeforum.co.uk/showthread.php?t=8609
 

Jamie#1

New Member
Thank you very much hippy for your quick reply. I will have to deal with this input the way it is and maybe make some sort of interface as you suggested. And also thanks to Westaust55. By the way, I did some more testing on these ports and on IN 2 can get a range of at least 50 meters on cat5 wire with a 1500 ohm pullup and on IN 1 and IN 4 can get at least 161 meters and possibly even more but I ran out of wire. The picaxe-8m chip is really a great marvel of electronics!
 

fernando_g

Senior Member
My two yen on the subject.

A 1k5 pullup will require a tad over 3 mA of current sinking, which is perfectly within the device ratings.

However...With temperature sensors, one must minimize its self-heating. I've not really tested this particular device, but have seen app notes from other vendors, where great emphasis is placed on operating the sensor at the lowest current draw possible. I recall seeing recommendations that it should be kept below 1 mA for best accuracy.

Again, this limitation may or may not be applicable to your project, but just wanted to make you aware of it...

And yes, the 08M is a wonderful device.
 

hippy

Technical Support
Staff member
Westaust55 has done a lot of investigation on the one-wire protocol and must be applauded for that -

http://www.picaxeforum.co.uk/showthread.php?t=15306

Although one-wire protocol isn't directly available on the 08M it is the basis of the READTEMP commands so a lot of that information will be applicable.

The difference between TTL and ST inputs is that TTL flips between high and low at a somewhat fixed point while ST flips, having gone above a certain level, only when it then goes below another lower level, and similarly only flips again when back above the level required. If voltages end up not crossing both those two levels the input never flips and comms doesn't work correctly which I suspect is happening here.

Type of cable, its resistance and capacitance, pull-ups and lots of things can affect what happens on the bus line and length of cable can become a major issue.

A scope will be a useful tool to have to look at the bus line to see exactly what is happening there.

What might be an easier alternative to trying to add active interfaces to a problematic line ( if pull-ups and/or pull-downs don't work ) is to move to an alternative PICAXE which has a suitable number of TTL inputs, or to use multiple PICAXE's in some sort of network.
 

Jamie#1

New Member
Thanks hippy. I looked at Westaust55's info and this is great information. As you mentioned, I think I may try multiple picaxes's in a network of some type, but that is something I may do later. For now, I am going to use IN 1 and IN 2 and think my user will be satisfied with one sensor that can be used on a longer section of cat5 and one sensor on a shorter section.
 

westaust55

Moderator
In your CAT-5 cable, make sure that all spare cores are NOT earthed/grounded. grounding each spare core adds to the capacitance loading on the signal wire which will degrade network performance.

On the Maxim website, have a look at the circuit presented in application notes
  • AN148 Guidelines for Reliable Long Line 1-Wire® Networks
  • AN244 Advanced 1-Wire Network Driver

These show various circuits to improve the drive capability for longer 1-Wire networks.

Even a simple bi-directional level shifting circuit using a 2N7000 may help to keep the signal at the PICAXE chip at acceptable voltage levels.

I have not delved into use of these types of circuit as yet for 1-Wire,
but have built simple 2N7000 based bi-directional level shifting circuits as per old Philips app notes for the i2c comms bus.
 
Last edited:

westaust55

Moderator
1-Wire data line slew control

The attached schematic for improving the slew control (rate at which the data line returns to the high state) may be useful.

The diagram comes from Tech Brief No1 by Dan Awtrey of Maxim
 

Attachments

inglewoodpete

Senior Member
On it's own, the slew control circuit shown above would stop a 1-wire bus from working, due to the signal inversion. Also, it is unidirectional where a 1-wire bus needs to be bidirectional.

I haven't read the document but I imagine it would describe how to restore the polarity on a bidirectional bus.

It may be appropriate to use an i2c bus extender chip, which is bidirectional.
 

westaust55

Moderator
effect of pull-up resistor

My two yen on the subject.

A 1k5 pullup will require a tad over 3 mA of current sinking, which is perfectly within the device ratings.
With a 5.0 Volt supply, a 1.5 kOhm pull-up resistor will only supply around 1.5 mA.
(3mA presumes the other end of the resistor is at 0 volts).

Most 1-Wire devices have a minimum operating voltage of 2.8V (some are higher). So, if parasitically powered, we must respect this minimum voltage and it is still required for the data signal when separately powered devices are used, albeit that the current demand is lower.

The available current is derived from:
(Vcc – Vmin ) / Rpullup
= (5 – 2.8) / 1500 == > 1.466 mA
 
Top