Code Monkey home page Code Monkey logo

ds18b20's Introduction

DS18B20

High resolution temperature measurement without any library and doing high speed multitasking in the background!

#DEBUG enabled in Config.h: (Serial Monitor)


Search devices ...
  FOUND: ROM = 10 94 91 2D 3 8 0 93   Chip = DS18S20  or older DS1820
  FOUND: ROM = 28 B5 45 E1 4 0 0 91   Chip = DS18B20
2 devices found

Dev:0  Conversion time(ms): 604  Job2-Count: 9816  Part0: 2455  Part1: 2455  Part2: 2455  Part3: 620  MaxWait: 252
  Data = 30 0 4B 46 FF FF B 10 83 
                               v
     ...........................
     .
     v
CRC 83
0  Temperature = 21.6125 21.6125 Celsius 
Dev:1  Conversion time(ms): 600  Job2-Count: 19460  Part0: 4866  Part1: 4866  Part2: 4866  Part3: 597  MaxWait: 360
  Data = 81 1 4B 46 7F FF F 10 71 
CRC 71
1  Temperature = 21.6125 21.6125 Celsius 
Dev:0  Conversion time(ms): 604  Job2-Count: 29170  Part0: 7293  Part1: 7293  Part2: 7293  Part3: 601  MaxWait: 360
  Data = 30 0 4B 46 FF FF B 10 83 
CRC 83

Even the CRC-calculation is done without library.
Multitasking: DoJob2() is called about 10.000 times per 0.6 seconds.
DoJob2() is a simple state machine to demonstrate (cooperative) multitasking without any OS.
Part3 is called every ms with sufficient precision to simulate an RTOS task.

Advantage: Taskswitches are done at defined points - YOU decide where taskswitches are possible, not a timer.

Example:

Test Image 1

    Blue    1. Device raw
    RED     1. Device filtered
    Orange  2. Device raw
    Magenta 2. Device filtered
    Green   Average of 1. and 2. Device

There are a lot of programs around to read temperatures from 1 wire DS1820, DS18B20, DS18S20 devices

Why another one ?

  1. This program does NOT use any library ! Libraries are good to get simple access to devices. But they hide what is going on behind the scene. And sometimes you want to understand what they are doing. Normally Wire- and Dallas-libraries are used.

  2. This program searches for connected one-wire slaves and uses all found DS18(B)20-devices. Perfect for measuring temperatures in different roms. It will run even if one device breaks !

  3. Normally temperatures are changing slowly compared to the speed of measurements. But you always get noise at least of +/- 1 bit.
    This program shows a simple but efficient method to filter the measured values to get smooth curves and rise the overall resolution.

  4. Most libraries just work with fixed delays (depending on resolution) internaly. Here we call a state machine function [ DoJob2() ] while waiting for measurements to complete (about 600 ms for 12 bit resolution!)

    DoJob2() is called about 16000 times per second ! It is devided in 4 parts - it is possible to call 4 Functions in a round robin fashion. It is garanteed, that the maximum delay from one call to another is less than 400 µs.

    Using this simple multitasking most of the CPU time may be used for other jobs than measuring temperatures.

Enjoy it.

Heating a room with 1000W electric heater with bimetal temperature switch

Heating a room with 1000W electric heater with bimetal temperature switch

ds18b20's People

Contributors

macleod-d avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

freemanr7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.