Shop OBEX P1 Docs P2 Docs Learn Events
bs24p as logic controller? — Parallax Forums

bs24p as logic controller?

kelvin jameskelvin james Posts: 531
edited 2005-02-01 15:05 in BASIC Stamp
I was thinking of a possible way a bsp24 could act as a simple logic controller reading inputs. Without getting into code here, here is the workflow
set the the required input pins to be polled, wait for any of those to activate the reading of all the pins state, apply the logical operator math to determine a course of action, if conditions are not met then return to polling, if conditions are met then run that program slot and return to the main polling. This would just act as a kind of a software interrupt to get the stamp to perform a certain function if the inputs matched the logic( AND,OR, XOR, NOT,etc.) From what i have read, the upper bytes of the scratch pad ram monitor the pin state during polling which would be read back to apply the logic math to, but in what form is it being read back? I would assume it would be in the form of DIRS (a 16 bit value of ones and zeros), but i am not sure. Is there any reason this would not work? Of course it won't monitor the pins during an output operation, but it does not matter. I realize the overall speed would not be that fast, but it should be sufficient for my purpose. I guess it could possibly be done by a bunch of ifs,thens, elses and whatnot, this just looked more effecient overall. It would be nice to have this option to work with. If anyone has some input, it would be greatly appreciated.
kelvin

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-01 15:05
    PBASIC, like most programming languages, has binary operators that you can apply directly. With bit-level access to variables you could write statments like:

    AlarmOut = LowLevel AND AlarmEnable

    The elements called AlarmOut, LowLevel, and AlarmEnable are aliases for IO pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.