Shop OBEX P1 Docs P2 Docs Learn Events
DS18B20 and BS2 — Parallax Forums

DS18B20 and BS2

BenjBenj Posts: 66
edited 2008-06-16 15:52 in BASIC Stamp
I have a project that I need to connect four DS18B20 temperature sensors to a BS2. I have found a few examples on how to connect them to a BS2P in a "one-wire" setup, but can't seem to locate any info on how to connect them to a regular BS2 in any configuration. It would be ideal to connect them in series so I have to run less wire to the remote DS18B20 locations, but I have extra I/O's so I could connect them not in series if necessary. Does anyone have any info? (I already have some BS2's and since a BS2P costs $80, I would like to do it without spending the extra $$)

I found the following code on how to connect them to a BS2P40, but don't know how to do the same thing on a BS2:

' {$STAMP BS2P}

' {$PBASIC 2.5}
' {$PORT COM1}
Temp VAR Word 'Holds the temperature value
TH VAR Byte
TL VAR Byte
Config VAR Byte
Reserved1 VAR Byte
Reserved2 VAR Byte
Reserved3 VAR Byte
CRC VAR Byte
Point VAR Byte
x VAR Word
Start:
AUXIO
OWOUT 8, 1, [noparse][[/noparse]$CC, $44] 'Send Calculate Temperature command
CheckForDone: 'Wait until conversion is done
PAUSE 25
OWIN 8, 4, [noparse][[/noparse]Temp] 'Here we just keep reading low pulses until
IF Temp = 0 THEN CheckForDone 'the DS1820 is done, then it returns high.
OWOUT 8, 1, [noparse][[/noparse]$CC, $BE] 'Send Read ScratchPad command
OWIN 8, 2, [noparse][[/noparse]Temp.LOWBYTE,Temp.HIGHBYTE,TH,TL,Config]
' Format Data
' S S S S S B6 B5 B4 : B3 B2 B1 B0 B-1 B-2 B-3 B-4
' Convert LowByte To Point
Temp = Temp & $0FFF
DEBUG DEC temp/16,"."
x =(Temp << 4) & $00ff
x = 10000 */ x
DEBUG DEC4 x,CR
GOTO start

Comments

Sign In or Register to comment.