Shop OBEX P1 Docs P2 Docs Learn Events
OUT15 = IN14 - should it work? — Parallax Forums

OUT15 = IN14 - should it work?

charlieknoxcharlieknox Posts: 27
edited 2006-03-18 00:00 in BASIC Stamp
I am detecting relative temperature with a voltage divider, half of which is a thermistor.· I'm just using the fact that the stamp input pin (14) transitions from low to high at around 1.45 volts.· I want to drive a transistor switch into saturation (P15)·to energize a relay to turn on a heater.

I am monitoring the input (P14)·and output (P15) with a DEBUG command, and the two go hand-in-hand from 0 to 1 with OUT15 = IN14, but the LED I've got on the output of P15 will not light up when DEBUG says IN14 and OUT15 are both high (1).· The LED works fine across Vss and Vdd, just won't come on when plugged into P15.· Any ideas??· This worked fine a year ago, but as they say, "That was then, this is now".

Thanks!

Charlie

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-17 20:26
    You need to make P15 an output before the output register gets connected to the actual pin. Put LOW 15 ahead of your comparison to make the pin an output an initialize it low; after that your code will make P15 follow P14.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • charlieknoxcharlieknox Posts: 27
    edited 2006-03-17 21:54
    The above would explain why the 1-liner HIGH15 lit the LED when I was testing.

    In the interest of learning more about how the Stamp works, what is the DEBUG window seeing, when it claims OUT15 is a 1?· Is it·1 in one table, but not another?· Or just a half-hearted 1?· Just curious.

    On another note, I see the new BS editor has the PIN command, for example CS·· PIN· 3.· In the programming reference (back of Basic Analog & Digital), it tells me this is better than CS·· CON·· 3.· There's got to be more to the story, I'm guessing, in terms of advantage of PIN over CON.

    Thank you for your quick response!jumpin.gif

    Charlie
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-17 22:09
    Charlie -

    The nicest thing about the PIN command, other than the fact that it makes more practical sense, is that it will set the assigned pin to INPUT or OUTPUT intelligently, relieving the programmer of remembering to do so. Many of the more sophisticated PBASIC Commands (SERIN, SEROUT, etc) will do that for you on their own, but some of the primatives (HIGH, LOW) do not.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 3/17/2006 10:18:26 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-18 00:00
    OUT15 is·a bit in the output register (OUTS) -- but that doesn't mean it's connected to P15; that only happens if DIR15 is set to 1, and when DIR15 is zero the pin is an input and doesn't give two hoots about what's in OUT15.

    Using the PIN definition would not change anything in this program as the comparison and assignment was directly with bits and did not involve any of the functions that require the DIRS bit to be in a specific state.· BTW, HIGH and LOW do in fact set the respective DIRS bit to %1, making the pin an output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.