Shop OBEX P1 Docs P2 Docs Learn Events
1-Wire and SearchROM — Parallax Forums

1-Wire and SearchROM

John CoutureJohn Couture Posts: 370
edited 2006-01-18 02:05 in General Discussion
Does anyone have a short 1-Wire SearchROM program that will sequentially display several ROM serial #'s on a standard Parallax LCD?

The 1-Wire program under OWReset does a ReadROM routine not a SearchROM routine.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture

San Diego Miramar College

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-01 14:33
    If you're wanting to search a 1-wire buss to determine the serial numbers of the devices connected... there's no such thing as a "short" search -- it's a bit convoluted (I know after struggling through the Dallas docs to write such a program for the BS2p).· I've not ported my BS2p program to the SX but I think it could probably be done without too much hassle.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • John CoutureJohn Couture Posts: 370
    edited 2006-01-02 21:33
    Ok, fair enough.· I do have a couple of questions about how to convert code from·BS2P to SX/B that·I hope the forum can help me with.·
    ·
    For those that want to follow along, some background.·
    ·
    1-Wire Weather Station
    ·
    In Feb 2002 Jon Williams wrote an article "Weather on the Wire" on how to read the 1 wire data from an AAG Weather Station .· These nifty devices are about $80 and contain an anenometer along with·wind direction and temperature sensors.· The article referenced an Apr 2001 article entitled "Searching the 1-Wire Bus" that showed how to search the 1-Wire network for all available nodes.· That article was written for the BS2P.
    ·
    Updating to today's world
    ·
    For those of you that missed it, the Jan 2006·issue of Nuts & Volts·has a great article by Jon Williams on generic input/output routines using·SX/B (i.e. TX_OUT, RX_BYTE, etc).
    ·
    As you may have guessed by now, I·got one of those weather stations for Christmas and am trying to get it working (I REALLY don't want to have to buy an BS2P when I have·a drawerful of SX chips).·
    ·
    Ok, down to business.· The entire listing is attached for those interested.· I updated the BS2P 1-Wire search code to the best of my ability.· Some of the techniques·in the BS2P code are foreign to me. Thus:
    ·
    '====================================
    Question #1:
    Under the SearchDone: label it has:
    ·
    ·· FOR offset = 0 TO 7
    ······WRITE (addr + offset),tempROM(offset)
    ····· ' write serial number to caller
    ·· NEXT
    '=====================================
    ·
    SX/B does not have a WRITE command nor does it allow compound statements.· Presumably this is supposed to update a memory location with a value.
    ·
    I was thinking something like:
    ·
    ·· FOR offset = 0 to 7
    ····· temp4 = @addr + offset
    ····· @temp4 = tempROM(offset)
    ·· NEXT
    ·
    but the compiler didn't like that.· How do you update a location in memory using an offset?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-02 23:36
    You might want to write a program that dumps the serial numbers to a terminal -- that way you only need an eight-byte array to store the current serial number.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • John CoutureJohn Couture Posts: 370
    edited 2006-01-17 18:19
    Jon,

    I'm stuck.· I'm not having any luck with porting your program so I figured I try and·reduce a·SearchROM routine·to something where I can at least get something from the AAG WS.· So far I'm only getting zeroes, even right after the RESET which implies a short.· AAG WS is connected to GND and to RB.2 (DQ constant).· The DS2450 does show +5 for the HIGH DQ command (one second) and ground on the AAG WS seems to be good.

    Main:
    ·· tris_b=%00000000········ ' Set pin direction 0=Output, 1=input
    ·· HIGH DQ················· ' Charge the AAG capacitor (DQ is RB.2)
    ·· wait_ms 250,4··········· '·· for one second
    ·· MyCount = 0············· ' Initialize all my counters
    ·· Result = 0
    ·· ROMidx = 0
    ·· NextBit = 0

    Main2:
    ·· LCDPos 20··············· ' using 4x20 LCD, position cur at beg of line 2
    ·· TX_Out "············· "· ' clear the line with spaces
    ·· LCDPos 20··············· ' position again at beginning of line
    ·· TX_HEX2 MyCount········· ' display # of tries
    ·· TX_Out "-"·············· ' display a dash
    ·· OWRESET DQ,Result······· ' Reset bus and read result
    ·· Result = Result + $30··· ' Convert Result into ASCII
    ·· TX_OUT Result··········· ' Display Result on LCD
    ·· OWWRByte DQ,SearchROM··· ' Now send command to search
    ·· Result = 0·············· ' Clear

    ReadBit:
    ·· OWRDBit DQ,Result.1····· ' Read a bit
    ·· OWRDBit DQ,Result.0····· ' Read another bit
    ·· Result = Result + $30··· ' Convert Result into ASCII
    ·· TX_Out Result··········· ' Display Result on LCD
    ·· Result = 0·············· ' Clear Result for next read

    WriteNextBit:
    ·· inc ROMidx·············· ' increment the bit position I'm using
    ·· OWWRBit DQ,NextBit.0···· ' write a zero (eventually this will flip-flop)
    ·· if ROMidx < 64 then ReadBit ' later this will be changed to 64 bits

    PackupAndStartAgain:············
    ·· wait_ms 250,10·········· ' wait about 2.5 seconds
    ·· ROMidx = 0·············· ' try again
    ·· inc MyCount
    ·· goto Main2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • John CoutureJohn Couture Posts: 370
    edited 2006-01-18 02:05
    Ok, making progress. I reread your Feb 2002 article and realized I forgot the 1K pullup resistor. Above program shows more than zeroes and now on to looking at your search program again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
Sign In or Register to comment.