DS18B20 DS2484 drivers

One Wire temperature sensor

DavidG
Benutzer
Avatar
Gender: n/a
Location: Kurrajong (Sydney) NSW
Posts: 22
Registered: 10 / 2005
Subject:

DS18B20 DS2484 drivers

 · 
Posted: 16.08.2018 - 16:23  ·  #1
I want to connect some DS18B20 temperature sensors to an AVR (ATMega) using the Dallas 1 Wire (which is what these sensors use :-) ).

I plan to use the DS2484 I2C to One Wire bridge chip to remove the critical one wire timing requirements from the AVR. The DS2484 is a handy chip but it is very low level, so you have to send commands for each 1 wire bit over the I2C.

Has anyone used these chips and therefore written some drivers?

(There seems to be lots of Arduino code around).
golf
Benutzer
Avatar
Gender:
Location: Donauwörth
Age: 71
Posts: 256
Registered: 11 / 2009
Subject:

Re: DS18B20 DS2484 drivers

 · 
Posted: 16.08.2018 - 20:25  ·  #2
hallo DavidG

For only 1 DS18B20 you can try my simple DS18B20-Program.

golf
Attachments
//
// hier nur Test eines DS18B20 , angeschlossen an EPC2
// PCB LDC1000 für Drehposition Erkennung der Motorsteuerung
//

program DS18B20;

{$NOSHADOW}
{ $WG} {global Warnings off}

Device = XMega8E5, VCC = 3.3;
{ $BOOTRST $20000} {Reset Jump to $20000}

import XMegaSupport,SerportD0; //

From System Import LongWord,float;

define
// The XMegas don't provide any Oscillator fuses.
// So the application must setup the desired values
// possible OSC types: extXTAL, extClock, ext32kHz, int32Khz, int2MHz, int32MHz

//>> CPU=32MHz, PeripherX4=32MHz, PeripherX2=32MHz
OSCtype = int32MHz,
PLLmul = 4,
prescB = 1,
prescC = 1;

// SysTick = 10; // msec
StackSize = $0300, iData;
FrameSize = $0300, iData;

SerPortD0 = 115200, ParNone, Stop1, Databit8; // an Motorcontrol über RS485 ISL83078
TxBufferD0 = 8, iData;
RxBufferD0 = 8, iData;

implementation

{$EEPROM}
var

{$IDATA}

const

{--------------------------------------------------------------}
{ Type Declarations }
type

//--------------------------------------------------------------
const

//--------------------------------------------------------------
{ Var Declarations }
{$IDATA}
var

SecCounter: byte;

i:byte;
ch: char;

CmdStr: String[16];
LCmdStr: byte;

Sekbol: boolean;

DS1820_Wire[@PortC,2] : bit;
DS1820_Readbit[@PinC,2] : bit;
DS1820_Dir[@DDRC,2] : bit;
DS1820Temperatur: integer;// word;
DS1820Celsius: float;

//--------------------------------------------------------------
{ functions }
procedure DS1820write0; Forward;
procedure DS1820write1; Forward;
procedure DS1820readTemperatur; Forward;
//-------------------------------------------------------------------------------------------------------------------------

procedure InitPorts; //
begin

// REMAPC:= $10; // Funktion des UART an Portpin6,7 statt 2,3
REMAPD:= $10; // Funktion des UART an Portpin6,7 statt 2,3
Filename: DS18B20.PAS
Filesize: 13.03 KB
Title: DS18B20.pas
Information: simple demo DS18B20
Download counter: 145
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: DS18B20 DS2484 drivers

 · 
Posted: 19.08.2018 - 02:30  ·  #3
...or this Robert Sander's unit lost in the old forum.
Attachments
program Ds1820ToI2C;
(******************************************************************************
ATS16
Bildet eine Bridge zwischen I²C und 1Wire DS1820
*******************************************************************************
Kann über I²C angesteuert werden und liest bis zu acht DS1820 aus
-------------------------------------------------------------------------------
Die Temperatursensoren hängen an den Ports D0..D6 und B0. An jedem Port darf
maximal ein Temperatursensor angeschlossen werden.

Es existiert ein Befehl zum starten eines Wandlungsvorgangs. Es wird
nacheinander allen acht Sensoren der Befehl zur Konvertierung gegeben. Nach
einer Wartezeit von 750ms werden nacheinander alle Scratchpads (9 Bytes pro
Sensor) eingelesen. Diese Werte stehen dann zum Abruf bereit.

Folgende I²C Befehle werden akzeptiert:
0 : Gibt zusätzlich ein Byte mit angeschlossenen Sensoren aus
1..8 : Wählt aus, ab wo beim nächsten Lesevorgang gelesen wird.

Zum Auslesen ist folgende Prozedur sinnvoll:
Master sendet $00 -> Slave beginnt die Wandlung
Master wartet 1s
Master liest 1 + 8*9 = 73 Bytes auf einmal ein

*******************************************************************************
Autor: RS Robert Sander
*******************************************************************************
Datei : DS1820.PAS
Zielsystem : Atmel Tiny2313
*******************************************************************************
Datum Autor Änderung
----------- -------- --------------------------------------------------------
2006-10-23 RS Erste version
2006-10-27 RS Redesign zur Speicheroptimierung
2006-10-31 RS Freigabe
******************************************************************************)


{$NOSHADOW}
{ $W+ Warnings} {Warnings off}

Device = Tiny2313, VCC=3.3;

Define_Fuses
Override_Fuses;
FuseBits0 = [SUT0];
FuseBits1 = [BODLEVEL1, SPIEN]; //
LockBits0 = [];
Filename: ds1820.pas
Filesize: 14.29 KB
Title:
Download counter: 198
DavidG
Benutzer
Avatar
Gender: n/a
Location: Kurrajong (Sydney) NSW
Posts: 22
Registered: 10 / 2005
Subject:

Re: DS18B20 DS2484 drivers

 · 
Posted: 21.08.2018 - 14:35  ·  #4
Thanks guys, I will check them out. I would still like a driver for the DS2484 though. Might have to write one.
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 16 · Cache Hits: 15   80   95 · Page-Gen-Time: 0.030059s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI