I've just started attempting to interface my one wire part and have a
couple of questions. The first is that I found a file in the Yahoo
files suggesting it would look for 1-wire parts. I'm getting the
following errors (among others)
owout OWpin, present, [SearchROM]
-ERROR In Line another.bas: 103: Expected A Variable, found OWpin,
present, [SearchROM]
loop
-ERROR In Line another.bas: 123: LOOP Without WHILE, found end of line
owin OWpin, ReadROM, [ROMData\8]
-ERROR In Line another.bas: 135: Expected A Variable, found OWpin,
ReadROM, [ROMData\8]
The format of the owout and owin seems to be a bit different from the
manual and what works. Is this an older version of basic or is this
just not an ARMExpress version of the code?
Thanks,
Jim.
From this site:
http://tech.groups.yahoo.com/group/ARMexpress/links
iButton Identification http://www.ckuehnel.ch/ARMexpress.html>
A description of iButton identification as explanation to the source
1wire_id.bas
Linked to this site:
http://www.ckuehnel.ch/Download/1wire_id.zip
One Wire
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: One Wire
I have the following code that works for my DS18B20 temperature
transducer. It's the only one wire part that I have.
#include
CONST OWpin = 13 ' 1-wire device pin
CONST ReadROM = $33 ' Read ROM Command
CONST SearchROM = $F0 ' Search ROM Comand
CONST SkipROM = $CC ' Search ROM Comand
CONST ReadScratch = $BE ' Search ROM Comand
CONST Convert = $44 ' Conver temp command
' -----[ Variables ]--------------------------------------------------
'
DIM ROMData (10) as string
dim value$ (10)
dim number$ (10)
dim address$ (8)
present = owout (OWpin, 1, chr(SearchROM)) 'search rom
wait(200)
if(present = 1)
print "Found device"
owin (OWpin, 1, chr(ReadROM),9,ROMData)
print "Rom data after search rom"
for i = 0 to 8
print hex(ROMData(i))
next i
wait(500)
value$=chr(SkipROM)+chr(Convert)
present = owout (OWpin, 2, value$)
wait(100)
print "Print scratchpad"
value$=chr(SkipROM)+chr(ReadScratch)
owin (OWpin, 2, value$,9,ROMData)
for i = 0 to 8
print hex(ROMData(i))
next i
endif
c = ROMData(0)
c = c + ROMData(1)*256
c = c /16
print "Temp is ";c;" degrees C"
The one wire documentation talks about using the search rom code to get
a list of all the devices on the wire. Since I don't have a second
device to test with, I was wondering how that data would appear? I'm
guessing that the size of the data returned might be 9*N where N is the
number of devices found? In that case, one should dimension the array
to accommodate a maximum number of devices expected.
Assuming I'm correct, ROMData in the above example could be dimensioned
for 90 and the owin might look like:
owin (OWpin, 1, chr(ReadROM),90,ROMData)
Now if my assumption is still correct, how do I know how many devices
are on the wire? Will owin clear all unused bytes in ROMData?
Thanks,
Jim.
The output from the above program looks like:
Executing...
Found device
Rom data after search rom
28
d7
67
18
2
0
0
74
ff
Print scratchpad
b0
1
4b
46
7f
ff
10
10
3a
Temp is 27 degrees C
(I'm in the room next to the furnace. It's only 4C outside.
transducer. It's the only one wire part that I have.
#include
CONST OWpin = 13 ' 1-wire device pin
CONST ReadROM = $33 ' Read ROM Command
CONST SearchROM = $F0 ' Search ROM Comand
CONST SkipROM = $CC ' Search ROM Comand
CONST ReadScratch = $BE ' Search ROM Comand
CONST Convert = $44 ' Conver temp command
' -----[ Variables ]--------------------------------------------------
'
DIM ROMData (10) as string
dim value$ (10)
dim number$ (10)
dim address$ (8)
present = owout (OWpin, 1, chr(SearchROM)) 'search rom
wait(200)
if(present = 1)
print "Found device"
owin (OWpin, 1, chr(ReadROM),9,ROMData)
print "Rom data after search rom"
for i = 0 to 8
print hex(ROMData(i))
next i
wait(500)
value$=chr(SkipROM)+chr(Convert)
present = owout (OWpin, 2, value$)
wait(100)
print "Print scratchpad"
value$=chr(SkipROM)+chr(ReadScratch)
owin (OWpin, 2, value$,9,ROMData)
for i = 0 to 8
print hex(ROMData(i))
next i
endif
c = ROMData(0)
c = c + ROMData(1)*256
c = c /16
print "Temp is ";c;" degrees C"
The one wire documentation talks about using the search rom code to get
a list of all the devices on the wire. Since I don't have a second
device to test with, I was wondering how that data would appear? I'm
guessing that the size of the data returned might be 9*N where N is the
number of devices found? In that case, one should dimension the array
to accommodate a maximum number of devices expected.
Assuming I'm correct, ROMData in the above example could be dimensioned
for 90 and the owin might look like:
owin (OWpin, 1, chr(ReadROM),90,ROMData)
Now if my assumption is still correct, how do I know how many devices
are on the wire? Will owin clear all unused bytes in ROMData?
Thanks,
Jim.
The output from the above program looks like:
Executing...
Found device
Rom data after search rom
28
d7
67
18
2
0
0
74
ff
Print scratchpad
b0
1
4b
46
7f
ff
10
10
3a
Temp is 27 degrees C
(I'm in the room next to the furnace. It's only 4C outside.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: One Wire
> The one wire documentation talks about using the search rom code to get
> a list of all the devices on the wire. Since I don't have a second
> device to test with, I was wondering how that data would appear? I'm
> guessing that the size of the data returned might be 9*N where N is the
> number of devices found? In that case, one should dimension the array
> to accommodate a maximum number of devices expected.
When the one-wire library was written, it didn't envision the multidrop one-wire
installations, not sure how it would handle it, or what it would take to do
that. But you do have the source in ONEWIRE.bas
this link on the Maxim site explains how multidrop works
http://www.maxim-ic.com/app-notes/index.mvp/id/187
> a list of all the devices on the wire. Since I don't have a second
> device to test with, I was wondering how that data would appear? I'm
> guessing that the size of the data returned might be 9*N where N is the
> number of devices found? In that case, one should dimension the array
> to accommodate a maximum number of devices expected.
When the one-wire library was written, it didn't envision the multidrop one-wire
installations, not sure how it would handle it, or what it would take to do
that. But you do have the source in ONEWIRE.bas
this link on the Maxim site explains how multidrop works
http://www.maxim-ic.com/app-notes/index.mvp/id/187