Shop OBEX P1 Docs P2 Docs Learn Events
Accessing different pins with the One Wire commands — Parallax Forums

Accessing different pins with the One Wire commands

djmullendjmullen Posts: 10
edited 2007-06-28 21:05 in General Discussion
Hi!

I'm writing a program that will read two DS1820 digital thermometers.· The DS1820s are on separate output pins.· Is there anyway to make·the OW*** instructions work with more than one·pin?·

In other words, I want to write·a subroutine which will read a DS1820 and I'd like to pass the pin to be read in a variable.· That way I can set a variable, call the subroutine and read the inside DS1820, then change the variable and call the subroutine again and read the·outside DS1820.

Is this possible?
Thanks,
Dave

P.S. By OW*** instructions, I mean OWRDBIT,·OWRDBYTE, OWRESET, OWWRBYTE and OWWRBIT·

Comments

  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-06-28 16:25
    No, not without writing custom instructions which is completely possible as I wrote 1-wire functions in SX/B before the OW* commands existed. That said, having two circuits kind of defeats the idea of "one wire" doesn't it? If both devices are coming back to the same SX why can't they be on the same physical connection? Is it that you don't want to deal with the 1W serial number? I can't blame you there -- big headache and why I don't deal with 1W devices unless I'm forced to.
  • djmullendjmullen Posts: 10
    edited 2007-06-28 18:49
    That's what I was afraid of, but thanks anyway. This is my first experience with One-Wire and probably my last. I looked at the 64 bit serial numbers and decided to use a separate pin for each device. Much simpler and saves RAM.

    I've also discovered that the OW**** instructions eat ram hugely. I ended up writing subroutines for every OWinstruction I use and using an IF-THEN-ELSE to send the instruction to the proper device.
    doOWRESET:
    IF Direction = 0 THEN
    OWRESET RC.0
    ELSE
    OWRESET RC.1
    ENDIF
    RETURN

    That lets you handle two devices and saves a ton of ram, but it's clumsy. But, considering the price, I'm not complaining.
  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-06-28 21:05
    The OW commands are timing based so yes, they can chew through your program space in a hurry. What I suggest is that you create "shell" calls so that each of those commands gets compiled just one time. I don't have a 1-wire example, the but program that attached does the same thing with I2C commands to save space.
Sign In or Register to comment.