PDA

View Full Version : 1-wire read Scratchpad



Slick
- 14th May 2004, 19:16
I am trying to make a reader for ibuttons.
I can't find a good example for what I need. I am looking to read the data in the ibuttons scratchpad memory. The basic part of the code is

spad VAR Byte[16] ' Scratchpad Data
OWOUT portc.0,1,[$CC,$BE] ' send Read Scratchpad
command
OWIN portc.0,2,[STR spad\16] ' read scratchpad
LCDOUT $FE,1, HEX2 spad[0],HEX2 spad[1],HEX2 spad[2],HEX2 spad[3],HEX2 spad[4],HEX2 spad[5],HEX2 spad[6],HEX2 spad[7], HEX2 spad[8],HEX2 spad[9],HEX2 spad[10],HEX2 spad[11],HEX2 spad[12],HEX2 spad[13],HEX2 spad[14],HEX2 spad[15]

When I run code like this or similar the lcd will display
FFFFFFFFFFFFFFFF And when the button is placed it will read
0000000000000000

Any help would be great.
I also plan to convert the results to text once im sure its reading the scratchpad correctly, anytips for that aswell?

CBUK
- 15th May 2004, 20:27
where did you get the owout and owin commands? for PBP+ ive used the oread and owrite. ive been playing with the serial only buttons and the RTC button. using the owrite command followed by the memory access as specified by dallas (its on one of their PDF datasheets on iButton standards) and have managed to get the full access for the serial buttons. by the sound of it you are challenging the key with the wrong access code. the results i get for no button are FF (hex) which is 255 -max value, and when the key was inserted wrong or the port was shorted to ground then i got 0, i also got the same answers if i asked the wrong or received the wrong request code.
one problem i have with the RTC iButton is its in binary and having to try and devide by the correct digit. which is quite amusing so far.....

Slick
- 16th May 2004, 04:05
owout and owin are listed in the manual.
The connections should be fine because I got it to read a serial number.
OWIN Pin, Mode,[ Item... ]
OWOUT Pin, Mode,[ Item...]

Do you see anything wrong with the code?

NavMicroSystems
- 16th May 2004, 16:58
OWIN and OWOUT are the commands to be used.

If you would let me know what kind of iButton you are trying to read i could probably help.

Reading the scratchpad does'nt make much sense unless you have written to it.

See IButton datasheet.

for a quick test:

try to read the family code and serial.

When trying to read the memory only send a "SKIP ROM" command first.

rgds

Slick
- 16th May 2004, 21:09
I replied to you on the list but am posting here in case some1 else see it or searches for an answer in the future.
The Ibuttons are DS-1992.

The company I work for uses the scratchpad memory in them to store "codenames" for laser tag gameplay.
An example of a "members" button of scratchpad data would be
10 31 39 50 61 74 74 79 43 61 6B 65 73 34 38 31
32 36 31 32 30 34 30 30 30 04 30 36 3D 33 03 20
DECODED =
19PattyCakes481
26120400006=3
.

The "non members" button are similar to the data. All the data I need to extract is the "PattyCakes" part. It will be 10 characters long. Skip first 3, read 10, skip last 19.

I have already received the serial number. (got the lcd to display it)

NavMicroSystems
- 17th May 2004, 10:51
When trying to read the scratchpad you send:

OWOUT portc.0,1,[$CC,$BE] ' send Read Scratchpad command

$CC is the "SKIP ROM" command which is ok,
but the "READ SCRATCHPAD" command for the DS1992 is $AA and not $BE


Try the following:

spad VAR Byte[16] ' Scratchpad Data

OWOut portc.0,1,[$cc] 'cmd Skip ROM
OWOut portc.0,0,[$aa] 'cmd Read Scratchpad
OWOut portc.0,0,[$00] 'Start adr 00h

OWIN portc.0,0,[STR spad\16] ' read scratchpad

LCDOUT $FE,1, HEX2 spad[0]....

Slick
- 17th May 2004, 20:02
AWSOME!!

Thanks man, it reads it perfectly.
I do have some other questions if you could help.
How i have it setup now is its in a loop and will send the read and receive data commands and it will display black boxes until a button is placed.
Is their an easy way to check if a button is placed on the reader? or contact is made or something then read the data.

NavMicroSystems
- 17th May 2004, 21:49
If your standard iButton is DS1992:

include a "READ FAMILY CODE" in your loop
IF the result is not "DS1992" skip the display routine
and display "PLACE iBUTTON" instead.

NL2TTL
- 4th March 2005, 12:18
Do you have a same code for the ds1973?