Shop OBEX P1 Docs P2 Docs Learn Events
one wire protocol — Parallax Forums

one wire protocol

littlerichlittlerich Posts: 27
edited 2007-10-04 08:45 in BASIC Stamp
I have done a quick search of the forum and can't find a +ve search

I have one of the AWG weather stations which has the Dallas One Wire protocol. Three sensors being wind speed, direction and temp.

The windows software from memory has a search feature and will return the unique id codes form the three sensors.

Has anyone seen a project done in the BS2 for this product?

I'm pretty new and a bit daunted by working out the steps to get to the result of being able to poll the devices, store result in mini logger type functionality.

Any ideas appreciated
Cheers
Rich

Comments

  • GadgetmanGadgetman Posts: 2,436
    edited 2007-10-03 10:22
    The easiest solution is to go for a BS2p or related model as these all support the 1-wire protocol.
    Doing bit-banging on a plain BS2 is something I wouldn't even contemplate.

    Depending on the type of 1-wire devices used, you may not need to use the IDs very often.
    If there's only ONE device on the line, you can always use the 'Skip ROM' command.
    This can also be used if you want to give the same order to ALL devices on the net at the same time.
    If the next command BYTE is an 'unknown' command, the 1-wire devices will just ignore it and wait for the next 'Reset and address' sequence. Devices which recognise the Byte will of course start executing it.
    (I don't know which devices are in use in that weatherstation, though)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • littlerichlittlerich Posts: 27
    edited 2007-10-03 10:46
    oops my mistake I do have a BS2P

    So if I only really want to read one of three devices on the line can I talk to that one only if I know its ID?

    Also if anyone else reads this with some experience on the AWG One Wire Weather Station do you know the maths to convert the data to m/s-1 as I have found some code but the returned data is in mph.

    thanks Gadgetman

    cheers
    rich
  • GadgetmanGadgetman Posts: 2,436
    edited 2007-10-03 12:06
    If the device uses THE SAME Command Byte to start the 'read' operation as one of the others, then yes, you'll need to know its ID.

    It's not that difficult to read the ID, though.
    (It's usually laser-etched onto the IDs, if you don't want to write a short program to scan for it)

    If you want to scan, separate the devices from each other(so that there are only one on the line) and use OWIN to send a $33 command. The device will respond with its ID.
    The 'Search ROM' function is not something you'd really want to try...
    (I once implemented it on a PDA using a language called OPL and the listing is... not nice... )

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-10-03 15:23
    Take a look HERE, where Rusty posted his refinements of a OW search algorithm that Jon Williams had published in N&V magazine.

    It really is easier to do what Gadgetman suggested, and discover the ID of each separate device, and then tie them together into a network. The search feature is needed mainly when you will be adding and removing OW devices regularly, but in the case of a fixed weather station, that will not be the case.

    Your other question was how to convert,
    meters_per_second = miles_per_hour * 0.44722

    On the Stamp, that becomes,
    mps = mph ** 29309
    Note the **. That is implicit calculation of 29309/65536 (=0.44722)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Fe2o3FishFe2o3Fish Posts: 170
    edited 2007-10-03 16:27
    Unless AAG (or the others who furthered the W/S) has radically
    redesigned the DalSemi weather station, there are more than just
    three 1-wire devices in there. Sure, the temperature is just one
    device and the wind speed is simply a counter, as I recall. On the
    other hand, wind direction is a collection of 8 "switches" and which
    of those 8 inputs is NORTH is determined by an initial alignment
    procedure. I also seem to recall there were a few other addressable
    1-wire chips in there, at least one of which was a 2407 switch.

    The code that Tracy alludes to is intended to be placed into a
    separate section of EEPROM on a BS2p-style processor and it will
    walk the entire 1-wire network (unless you limit how many devices
    it finds or you run out of EEPROM). But, as Tracy states, you'd only
    need to do this once and everytime you exchange/add/remove a
    1-wire device from the net.

    Also, some good sources to check out are:
    Have phun!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rusty-
    --
    Rusty Haddock = AE5AE = rusty@fe2o3.lonestar.org
    **Out yonder in the Van Alstyne (TX) Metropolitan Area**
    Microsoft is to software what McDonalds is to gourmet cooking
  • littlerichlittlerich Posts: 27
    edited 2007-10-04 08:45
    Thanks for the help, I look forward to trying it in the next week.

    Cheers
    Rich
Sign In or Register to comment.