1-wire read Scratchpad


Closed Thread
Results 1 to 9 of 9
  1. #1
    Slick's Avatar
    Slick Guest

    Default 1-wire read Scratchpad

    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?

  2. #2
    CBUK's Avatar
    CBUK Guest


    Did you find this post helpful? Yes | No

    Default

    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.....

  3. #3
    Slick's Avatar
    Slick Guest


    Did you find this post helpful? Yes | No

    Default

    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?

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Slick's Avatar
    Slick Guest


    Did you find this post helpful? Yes | No

    Default

    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)

  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    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]....

  7. #7
    Slick's Avatar
    Slick Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    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.

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Do you have a same code for the ds1973?

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts