1-wire troubles
Archiver
Posts: 46,084
Rob-
Can you get something real simple like the Read ROM or Read
Control Register command to work? Can you describe your hardware
configuration (pull-up resistor etc.) and show some of your 1-Wire
code? Maybe somebody will see a problem. I haven't used a BS2p with
a '2890, but I know it works fine with a lot of other 1-Wire
devices--every one I ever tried it with.
Here's some code that should read and display the ROM serial ID and
control register (assumes the '2890 is the only device on the bus):
' Universal 1-Wire ROM commands (see Dallas Semiconductor documentation)
READ_ROM CON $33
SKIP_ROM CON $CC
MATCH_ROM CON $55
SEARCH_ROM CON $F0
SEARCH_FUNC CON $EC
' I/O pin constants
BUS CON 15 ' 1-Wire bus
' OWIN, OWOUT constants
RESET_NONE CON 0
RESET_PRE CON 1
RESET_POST CON 2
RESET_BOTH CON 3
' conventional variables
in_byte VAR BYTE(10)
i VAR BYTE
'**************************************************************************
' read ROM-based identifier...this will work with any 1-Wire device...
' also serves as means to determine identifier if unknown...must be
' only device on the bus or READ ROM will not work right...
'
' 1-Wire transactions summary:
' ---> [noparse][[/noparse]reset]
' ---> READ ROM
' <--- 8 Serial # identifier bytes
' ---> [noparse][[/noparse]reset]
' ---> SKIP ROM
' ---> READ CONTROL REGISTER command
' <--- feature register contents
' <--- control register contents
'**************************************************************************
OWOUT BUS,RESET_PRE,[noparse][[/noparse]READ_ROM] ' send READ ROM
OWIN BUS,RESET_NONE,[noparse][[/noparse]STR in_byte\8] ' read 8-byte serial identifier
DEBUG CR,"Serial # "
FOR i = 7 TO 0 ' display identifier high order
DEBUG HEX2 in_byte(i) ' byte first
NEXT
OWOUT BUS,RESET_PRE,[noparse][[/noparse]SKIP_ROM] ' send SKIP ROM
OWOUT BUS,RESET_NONE,[noparse][[/noparse]$AA] ' send read control register cmd
OWIN BUS,RESET_POST,[noparse][[/noparse]in_byte\2] ' read control register
DEBUG CR, HEX2 in_byte(1) ' display control register
I hope that helps.
Steve
Can you get something real simple like the Read ROM or Read
Control Register command to work? Can you describe your hardware
configuration (pull-up resistor etc.) and show some of your 1-Wire
code? Maybe somebody will see a problem. I haven't used a BS2p with
a '2890, but I know it works fine with a lot of other 1-Wire
devices--every one I ever tried it with.
Here's some code that should read and display the ROM serial ID and
control register (assumes the '2890 is the only device on the bus):
' Universal 1-Wire ROM commands (see Dallas Semiconductor documentation)
READ_ROM CON $33
SKIP_ROM CON $CC
MATCH_ROM CON $55
SEARCH_ROM CON $F0
SEARCH_FUNC CON $EC
' I/O pin constants
BUS CON 15 ' 1-Wire bus
' OWIN, OWOUT constants
RESET_NONE CON 0
RESET_PRE CON 1
RESET_POST CON 2
RESET_BOTH CON 3
' conventional variables
in_byte VAR BYTE(10)
i VAR BYTE
'**************************************************************************
' read ROM-based identifier...this will work with any 1-Wire device...
' also serves as means to determine identifier if unknown...must be
' only device on the bus or READ ROM will not work right...
'
' 1-Wire transactions summary:
' ---> [noparse][[/noparse]reset]
' ---> READ ROM
' <--- 8 Serial # identifier bytes
' ---> [noparse][[/noparse]reset]
' ---> SKIP ROM
' ---> READ CONTROL REGISTER command
' <--- feature register contents
' <--- control register contents
'**************************************************************************
OWOUT BUS,RESET_PRE,[noparse][[/noparse]READ_ROM] ' send READ ROM
OWIN BUS,RESET_NONE,[noparse][[/noparse]STR in_byte\8] ' read 8-byte serial identifier
DEBUG CR,"Serial # "
FOR i = 7 TO 0 ' display identifier high order
DEBUG HEX2 in_byte(i) ' byte first
NEXT
OWOUT BUS,RESET_PRE,[noparse][[/noparse]SKIP_ROM] ' send SKIP ROM
OWOUT BUS,RESET_NONE,[noparse][[/noparse]$AA] ' send read control register cmd
OWIN BUS,RESET_POST,[noparse][[/noparse]in_byte\2] ' read control register
DEBUG CR, HEX2 in_byte(1) ' display control register
I hope that helps.
Steve
Comments
with a DS2890 digital pot device. I've tried about 100 different
strings/hex/bin combinations, but I cant set the wiper position or read it.
I've tried both of the DS2890 I have and neither works.
Also I could really use some example code in PBASIC to work with 1-wire
devices.. The BS2 manual is horrible in the 1-wire area, with one 1 example
using a DS1820 which even modified doesn't help with my DS2890 problem.
I've followed the data sheet, followed the manual, and I'm still without
control of my DS2890. the only thing easy about 1-wire it seems is
remembering the pinouts....
-Rob
a little or, at least, to get started. If you are using a BS2p40 make sure
you use the AUXIO command when using auxillary board pins and MAINIO command
(default) when using main board pins.
Chuck
setup for 1-wire DS2890
'see Dallas datasheet pages 16 and 17
x var byte(9)
w var byte
y var byte
z var byte
p var nib
p=8:w=44:z=2
pause 500
gosub LCDINIT
owout z,1,[noparse][[/noparse]$3c] 'overdrive mode
owout z,9,[noparse][[/noparse]$33]
owin z,10,[noparse][[/noparse]str x\8]
lcdcmd p,1
lcdout p,0,[noparse][[/noparse]"BASIC Stamp2P reads"]
lcdout p,192,[noparse][[/noparse]"DALLAS 1-Wire code"]
lcdcmd p,148
debug cls
for y=0 to 7
lcdout p,0,[noparse][[/noparse]hex2 x(y)]
debug hex2 x(y),cr
next
owout z,9,[noparse][[/noparse]$cc,$55,$0c]
owin z,8,[noparse][[/noparse]y]
debug hex2 y,cr
owout z,8,[noparse][[/noparse]$96]
owin z,8,[noparse][[/noparse]y]
debug hex2 y,cr
owout z,9,[noparse][[/noparse]$cc,$0f,$7f]
owin z,8,[noparse][[/noparse]y]
debug hex2 y,cr
owout z,8,[noparse][[/noparse]$96]
owin z,8,[noparse][[/noparse]y]
debug hex2 y,cr
owout z,9,[noparse][[/noparse]$cc,$c3]
owin z,8,[noparse][[/noparse]y]
owout z,8,[noparse][[/noparse]$c3]
owin z,8,[noparse][[/noparse]y]
owout z,8,[noparse][[/noparse]$99]
owin z,10,[noparse][[/noparse]y]
stop
'initialize LCD
LCDINIT
lcdcmd p,48 'set function
pause 5
lcdcmd p,48
pause 1
lcdcmd p,48
pause 1
lcdcmd p,32
pause 1
lcdcmd p,w
pause 1
lcdcmd p,8 'display off
lcdcmd p,12 'display on
lcdcmd p,6 'set mode
lcdcmd p,1
return
[/font]