Shop OBEX P1 Docs P2 Docs Learn Events
BS1-IC help if you could — Parallax Forums

BS1-IC help if you could

Gary HoffmannGary Hoffmann Posts: 10
edited 2009-11-03 03:23 in BASIC Stamp
Hello folks,
·
Looking at all these posts on here I am almost embarrassed to ask for help with my little (I guess ever so basic) project I am attempting to make to operate.· I have played with the BC1 about 8 years ago but since than have not had the chance to work/play with it again until now..
·
This is the project…· I am picking up a signal of a decoder board (remote door lock) .· There is only one pin of interest on this board and it either goes high or low and stays in that state, until the next lock/unlock command occurs.· This either high or low signal I would like to use to drive a transistor and related paraphernalia, it in itself also not a hard thing to do…
·
I have written the basic instructions as such that I have two inputs via dirs and 6 outputs…
Allow me to give a brief listing of where I am floundering…..
·
dirs = 0011111
·
if pin 0 = 0 than relay1
if pin 0 = 1 than relay1
·
relay1: high 5
Pause 1000
High 6
Pause 1500
Low 5
Low 6
·
Relay2:
·
High 4
Pause 1000
High 3
Pause 1500
Low 4
Low 3
·
·
Here is the problem…How can I stop the program from running continuesly once it “sees” a state of pin 0 ?· That is, the instruction should only be executed one time until another chance on pin 0 occurs.· The way it is now of course it runs and runs regardless of high or low on pin 0..··
·
Sorry guys/girls..basic stuff you say· ….
·
Thanks for the help
·
Gary
·
·
·
·
·
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-26 00:48
    The general notion is that you have states made up of different loops. The initial state has the stamp waiting until pin 0 becomes high. Once it becomes high, the program jumps to a different loop where the program waits for pin 0 to become low. It's only on the jump from loop 1 to loop 2 where the program does anything. Look here:

    state0:
    ' do something as long as pin 0 is low
    if in0 = 0 then state0 ' stay here if pin 0 low

    action0to1:
    ' do something once for each leading edge of a pulse on pin 0

    state1:
    ' do something as long as pin 0 is high
    if in0 = 1 then state1 ' stay here if pin 0 high

    action1to0:
    ' do something once for each trailing edge of a pulse on pin 0
    goto state0
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-10-26 10:16
    Hello Mike,

    Thank you for your note. I will check it out in the next few days as time permitts and let you know. Thanks for the fast reply

    Gary
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-11-03 03:16
    Hello again Mike,



    Got some time this evening to get back into this "issue".· Here is what I have chanced and still no difference ....

    Dirs = %00001111

    Start: If PIN0 = 0 then relay1



    relay1: Pause 1500···· 'just a pause for me to get ready to "see"..

    HIGH 4

    Pause 1500

    HIGH 5

    PAUSE 1500

    LOW 4

    LOW 5

    IF PIN0 = 1 THEN Relay2·· 'This is supposed to be the "conditional" statement where I hoped the program would stop and wait

    ··································· 'until or if said state is reached.



    This is not the case, the Controller continues happy as can be on its way to toggle the pins 4 and 5 as long as pin0 is held low...If I force pin0 high as in "IF pin0 = 1 then relay2...nothing happens.· Basically I repeated the
    "relay1" routine only that I had a very short pause, so that I can see the transition on the scope..



    Any thoughs ???



    Thanks



    GH
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-11-03 03:19
    Please let me clarify what I wanted to say in my last sentence of my previous post..."basically I repeated the "relay1' routine (called relay2) only that I had very short pause values in relay2 so that I could see the pins toggle..
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-03 03:23
    I think you need to look again at what I wrote and see what happens on paper when in0 goes high or low. Figure out what the "do something" things should be for your application.
Sign In or Register to comment.