TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136544 times)
  2. FAT32 Library (69737 times)
  3. Network Ethernet Library (55844 times)
  4. USB Device Library (46178 times)
  5. Network WiFi Library (41803 times)
  6. FT800 Library (40990 times)
  7. GSM click (28923 times)
  8. PID Library (26385 times)
  9. mikroSDK (26284 times)
  10. microSD click (25299 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Example

Article: The DS18(S)20, DS18B20, DS1820 Lib and OW_Utilities Lib usage

Rating:

3

Author: dany

Last Updated: 2016-02-23

Package Version: 1.0.0.0

Example: 1.0.0.0

Category: Measurement

Downloaded: 1203 times

Followed by: 1 user

License: MIT license  

The DS18(S)20, DS18B20 device usage plus the DS1820 Lib and OW_Utilities Lib usage. Also some errors in the mE example (compiler help) are stated.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Article: The DS18(S)20, DS18B20, DS1820 Lib and OW_Utilities Lib usage" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Article: The DS18(S)20, DS18B20, DS1820 Lib and OW_Utilities Lib usage" changes.

Do you want to report abuse regarding "Article: The DS18(S)20, DS18B20, DS1820 Lib and OW_Utilities Lib usage".

  • Information
  • Comments (0)

Example Blog

Description of how to use the digital tempsensor DS1820, DS18S20 and DS18B20 together with the DS1820 library (http://www.libstock.com/projects/view/104/tempsensors) and the OW_Utilities library (http://www.libstock.com/projects/view/823/ow-utilities).

mE compiler help errors in the one_wire library example:

1. The waiting time between starting the temperature conversion in the DS18x20 and reading out its temperature is only 120 microseconds. The DS18S20 datasheet shows it can take up to 750 millisecs to convert the temperature to a value. So, the code should look like:

//--- Perform temperature reading

Ow_Reset(PORTE, 2); // Onewire reset signal

Ow_Write(PORTE, 2, 0xCC); // Issue command SKIP_ROM

Ow_Write(PORTE, 2, 0x44); // Issue command CONVERT_T

Delay_ms(750); // <---- in stead of delay_us(120)

Ow_Reset(PORTE, 2);

Ow_Write(PORTE, 2, 0xCC); // Issue command SKIP_ROM

Ow_Write(PORTE, 2, 0xBE); // Issue command READ_SCRATCHPAD

temp := Ow_Read(PORTE, 2);

temp := (Ow_Read(PORTE, 2) shl 8) + temp;

 

//--- Format and display result on Lcd

...

The other delay in the main loop can be left out: Delay_ms(520);

The other delay in the main loop can be left out: Delay_ms(520);

 


   

 

2. The "shift" of the temperature value of the DS18x20 is NOT dependant on the resolution, but on the DS18x20 type: DS18S20 or DS18B20.

In the DS18S20 case the shift is always 1, in the DS18B20 case, the shift is always 4, irrespective of the resolution.

So, this code is NOT correct:

const RES_SHIFT = TEMP_RESOLUTION - 8;

it should be something like this:

var Res_Shift: byte;

...

if DS1820_Family = 'B'  // DS18B20

then Res_Shift := 4

else Res_Shift = 1;

 

See http://www.libstock.com/projects/view/104/tempsensors for the definition of "DS1820_Family".

Of course the variable Res_Shift can also be set manually to 1 or 4 depending on the type of DS18x20 used.

 


 

 

3. The comment on the DS18x20 resolution is wrong:

// Set TEMP_RESOLUTION to the corresponding resolution of used DS18x20 sensor:

// 18S20: 9 (default setting; can be 9,10,11,or 12)

// 18B20: 12

It should be:

// 18S20: 9 

// 18B20: 12 (default setting; can be 9,10,11,or 12)

   

ALSO FROM THIS AUTHOR

PIC Command Line Editor

5

Capable of, like a modem, receiving, editing and executing one (command) line of input. The code in this example project shows a command line editor that can be used in servers (big word) you build, based on PICs.

[Learn More]

LCD

11

* 2 (alternative) libs to drive LCD's (4 bits connections): - One lib specific for 2x16, - one more generic (upto 4 rows, 16-20 chars per row). * A library to drive LCD via I2c (PCF2116 based, 1 to 4 rows, 12 or 24 chars per row * A library to drive standard LCD's via I2c * A library to drive standard LCD's via SPI.

[Learn More]

OW_Utilities for PIC32

5

This library provides the basic one-wire search ROM and search ALARM routines, e.g. for the DS1820, the DS18S20 and the DS18B20.

[Learn More]