Dallas Temperature

Status
Not open for further replies.

Nantonos

Well-known member
The Libraries page lists Dallas Temperature as working for Teensy 2.0; the entries for Teensy++ 2.0 and Teensy 3.0 are blank. It also says the version is 3.4.0.

My sketches/libraries folder had a copy of version 3.7.2. The change.txt stated that this was
VERSION 3.7.2 BETA
DATE: 6 DEC 2011
A major change for this version is the addition of non-blocking temperature requests. Instead of asking for the value and then stalling the main loop for up to 750ms (at the highest bit depth) a request to measure is sent and later, the value is retrieved in a second transaction.

Looking on GitHub, this library seems to have been renamed to Arduino-Temperature-Control-Library although it still only covers the Dallas series of sensors. The version number has not increased but the Git history shows changes as recent as April 2014.

The DS18B20 can be wired one of three ways. One is Fig.5 in the datasheet, conventional powering, the three pins being connected to GND, an input pin, and Vcc respectively with a 4k7 pullup from the data pin to Vcc. This is the mode I used in tests.

A second way is Fig.4 in the datasheet, the third pin is connected to GND and parasite power is collected when the data line is high, stored in a capacitor, and used to power the device when the data line is low. The datasheet notes that this blocks the OneWire bus, and requires a MOSFET "strong pullup" (controlled by a second pin on the MCU) to be activated within 10ms of a temperature conversion or scratch RAM read, until the value is returned. The datasheet notes that in this mode, the voltage required for a logic high is +3.0V to the lower of (5.5V, Vcc + 0.3V) compared to conventional powering where logic high starts from +2.2V. It is also unstable at temperatures over 100°C.

The third method, which is what you will see many examples of by googling Arduino DS18B20 is like Fig.4 except ignoring the whole thing about the strong pullup MOSFET. Note that the datasheet does not allow this wiring.

I downloaded this latest version and installed it, removing the earlier version. Tested with Arduino (1.0.5r2) Teensyduino (1.19) and Teensy 2.0 on breadboard with DS18B20, power via USB, using the WaitForConversion2 example sketch which measures the blocking time at various bit depths. This worked correctly; showing increasing measurement times as bit depth incremented from 9 to 12 bits and similar temperature readings over bit depth and over time. The temperature values were similar to the value on an external thermometer.

I then swapped in a Teensy++ 2.0, recompiled, and this worked the same way.

I had a look at the library and saw much use of things like uint8_t, uint16_t and the like. No AVR register stuff.

I swapped in a Teensy 3.0 and powered the DS18B20 with the 3V3 output of the Teensy. Again, this gave correct results with the same timings relative to bit depths and similar temperatures.

I didn't have a Teensy 3.1 handy with pins, that wasn't tied up in another project.

I suggest that teensyduino 1.20 includes the latest GitHub version of Arduino-Temperature-Control-Library and that the libraries page is updated to show correct operation on all boards. The libraries list doesn't link to a separate page for this library but if one is created, I suggest that it document the two official, datasheet methods of powering, warns against the unstable third method, and recommends convential over parasitic powering especialy for use at 3V3.

Code:
T 2.0

 Temperature: 24.0
  Resolution: 9
Idle counter: 92

 Temperature: 24.00
  Resolution: 10
Idle counter: 186

 Temperature: 24.000
  Resolution: 11
Idle counter: 372

 Temperature: 23.8750
  Resolution: 12
Idle counter: 745

 Temperature: 24.0
  Resolution: 9
Idle counter: 93

 Temperature: 23.75
  Resolution: 10
Idle counter: 185

 Temperature: 24.000
  Resolution: 11
Idle counter: 372

 Temperature: 23.8750
  Resolution: 12
Idle counter: 744

T++ 2.0

 Temperature: 24.0
  Resolution: 9
Idle counter: 93

 Temperature: 24.25
  Resolution: 10
Idle counter: 186

 Temperature: 24.250
  Resolution: 11
Idle counter: 372

 Temperature: 24.1875
  Resolution: 12
Idle counter: 744

 Temperature: 24.0
  Resolution: 9
Idle counter: 92

 Temperature: 24.25
  Resolution: 10
Idle counter: 185

 Temperature: 24.250
  Resolution: 11
Idle counter: 372

 Temperature: 24.1875
  Resolution: 12
Idle counter: 745

T3.0

 Temperature: 24.0
  Resolution: 9
Idle counter: 93

 Temperature: 24.00
  Resolution: 10
Idle counter: 187

 Temperature: 24.125
  Resolution: 11
Idle counter: 373

 Temperature: 24.0625
  Resolution: 12
Idle counter: 748

 Temperature: 24.0
  Resolution: 9
Idle counter: 93

 Temperature: 24.00
  Resolution: 10
Idle counter: 186

 Temperature: 24.125
  Resolution: 11
Idle counter: 374

 Temperature: 24.0000
  Resolution: 12
Idle counter: 748
 
Status
Not open for further replies.
Back
Top