Shop OBEX P1 Docs P2 Docs Learn Events
Working on 1-Wire SearchROM Method — Parallax Forums

Working on 1-Wire SearchROM Method

I'm working on a 1-Wire SearchROM method in Spin2. I understand how the algorithm works. I am just working out the code. Before I expend any more energy on this task, does anyone know if a solution already exists in Spin2?

Comments

  • I am also working on that. I did it with the BASIC Stamp 2 nearly 20 years ago, but coding in Spin and BASIC is different, hence it's not a easy port. There are C examples available that would probably translate very easily -- I was trying it myself, first.

  • I was using your code to read my DS18B20s and saw you hadn't coded the SearchROM method yet. I thought I would give you a hand. You seem to have a lot on your plate these days. But I can move on to the next task on my list and look forward to your solution.

    Do you sleep?

    The only person I ever met that is as prolific as yourself was Dean Kamen and he didn't have a bedroom in his enormous house. It was rumored that it was the only room in the house that was off limits [besides the guest quarters] and was hidden behind a bookshelf in his library.

  • Do you sleep?

    I try to get enough. Being a bachelor in the age of shutdowns means I spend most of my waking hours at my computer.

    Thank you for the kind words. I enjoy this stuff, and want to keep sharp for when client work does come.

  • There is code written in Tachyon years ago by @MJB to handle this complicated searchROM algorithm. It was quite verbose and would list out the type of chip etc.
    Any use?
    If I can avoid multidrop 1w then I do, preferring to condition and stretch the I2C bus with cheap and precise sensors instead or RS485 if need be.

  • Stephen MoracoStephen Moraco Posts: 303
    edited 2021-08-05 19:58

    In case you don't have search working yet...

    I'm posting the one that I'm using for P2. This is in .spin2 and it is a file used in addition to Jon's excellent jm_1-wire.spin2 access routines.

    This supports:

    • searching for all devices on the wire
    • searching for devices of a single-family id on the wire
    • getting a list of family IDs seen on the wire
    • returning the first N device IDs on the wire

    Here's the demo output from my 5 x DS18B20's in my setup:

    + searchAll(0x00002BEC, 2)
    + owFirst()
    -- searchAll()  RET=2, found=5
    scanROM count = 2
    ** S/N Buffer:
      0x00002BEC: 0x28 0x1C 0xAB 0xD4 0x58 0x20 0x01 0xB5  0x28 0xF6 0x40 0xBA 0x58 0x20 0x01 0x7C 
      0x00002BFC: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
      0x00002C0C: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
    
    + searchAll(0x00002BEC, 10)
    + owFirst()
    -- searchAll()  RET=5, found=5
    scanROM count = 5
    ** S/N Buffer:
      0x00002BEC: 0x28 0x1C 0xAB 0xD4 0x58 0x20 0x01 0xB5  0x28 0xF6 0x40 0xBA 0x58 0x20 0x01 0x7C 
      0x00002BFC: 0x28 0x83 0x8D 0xE9 0x58 0x20 0x01 0x91  0x28 0x27 0x6E 0xC4 0x58 0x20 0x01 0x68 
      0x00002C0C: 0x28 0x37 0x17 0xD0 0x58 0x20 0x01 0x9B  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
    S/N #1 28 1C AB D4 58 20 01 B5 
    S/N #2 28 F6 40 BA 58 20 01 7C 
    S/N #3 28 83 8D E9 58 20 01 91 
    S/N #4 28 27 6E C4 58 20 01 68 
    S/N #5 28 37 17 D0 58 20 01 9B 
    - Found 5 Devices on wire
    - Found 1 family IDs
      -- FamilyID 0x28: 5 device(s)
    
    + searchFamily(0x28, 0x00002BEC, 10)
    + owTargetSetup(0x28)
    -- searchFamily()  RET=5, found=5
    scanROM-Family $28 finds 5 devices
    
    + searchFamily(0x45, 0x00002BEC, 10)
    + owTargetSetup(0x45)
    -- searchFamily()  RET=0, found=5
    scanROM-Family $45 finds 0 devices
    

    Enjoy!

    EDIT: i replaced my file with a newer version which contains an updated 1-wire object from Jon. (his latest)

Sign In or Register to comment.