Shop OBEX P1 Docs P2 Docs Learn Events
BS1-IC troubles, a little more.. — Parallax Forums

BS1-IC troubles, a little more..

Gary HoffmannGary Hoffmann Posts: 10
edited 2009-12-08 03:41 in BASIC Stamp
Well almost..

I·have been going around with this for a few weeks off and on as time permitted and some of you guys where kind enough to throw your words of wisdom towards me.· Thnaks for your time on this.

The issue was to use·a BS1-IC to look at one input and depending on the input state go into two (2) different "routines", I called relayloop (1 or 2).
Initial problem was that I could not figure out how to "hold" the processor after one loop and "finding" the input pin (0) still at same state...All is well now, however...

I can load the program (oh by the way I have pin0 tied to ground via a 10K resistor) and operate it for 3,5, 10 times "whatever" .. all of a sudden it hangs and will not operate properly anymore.· There is no corelation between how many times I exersize the program and its "hanging".· It may happen after the 7th time or after about 3 times.· This acts as if a pin is floating like·with the·"old" CMOS chip projects (40xx series.. been there..14 chips on a project one "stinking" pin floating..total mayhem nono.gif ).· In any event, I enclosed the code I have written, what am I overlooking here, why is this "bugger" hanging every so often at random.· I do not have any external interference, eg. RF, or noise from·a florecent light·or such I know of...The input is clean...

Any Idea ??

Thanks

Gary


INIT:
DIRS = %00001111·····························'set ports in/out 0/1 respectivly
B0 = 0············································· 'B0 to B4 cleared, also word 4 set to zero
B1 = 0
B2 = 0
B3 = 0
B4 = 0
W4 = 0
B0 = PIN0··········································'Directive for byte 0 to follow state of pin0

START:
IF PIN0 = 0 THEN RELAYLOOP1············· 'Instruction for state of PIN0. Both Relayloops will be used to drive
IF PIN0 = 1 THEN RELAYLOOP2············· 'Transisotrs and in turn relays.
RELAYLOOP1:···································· 'Label
PAUSE 10
HIGH 7
PAUSE 1000
HIGH 6
PAUSE 1000
LOW 7
LOW 6
PAUSE 10
IF PIN0 = 0 THEN LOOP1···················· 'Instruction TO look at PIN0. IF PIN0 = 0, Loop1 (a waiting loop)
····················································· 'Same for loop2.
RELAYLOOP2:
PAUSE 10
HIGH 5
PAUSE 1000
LOW 5
PAUSE 1000
IF PIN0 = 1 THEN LOOP2
LOOP1:
IF PIN0 = 0 THEN LOOP1··················· 'Waiting loop,waiting for state on PIN) to chance....
IF PIN0 = 1 THEN RELAYLOOP2
LOOP2:
IF PIN0 = 1 THEN LOOP2
IF PIN0 = 0 THEN RELAYLOOP1·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-07 00:26
    Note: Saying "B0 = PIN0" doesn't make byte 0 follow pin 0. It does a one-time assignment of the value of pin 0 to B0.

    I'm just guessing, but you've got a lot of places where you're testing for PIN0 to be in one state, then later testing for the opposite state. What if the switch changes between the two statements? I suggest that you make the 2nd statement of each pair into a GOTO instead like:

    IF PIN0 = 0 THEN LOOP1
    GOTO RELAYLOOP2
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-12-07 01:00
    hmmm..what a concept...Yes you are right Mike the switch DOES change between the two statements, Mike, thanks a bunch..let me digest what you stated here and I will "report" back. I am having an absolute "ball" here..honestly, I went running this PM and I had the whole program in my head and went through it a million times...and it "worked" a million times hahaha..

    Thanks for your time,

    GH
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-12-08 02:13
    Hello Mike,



    well I tried it and no success...··

    There has to be a way where the pin0 value will be stored as it toggles, thereafter used for comparison and depending on the state a "step" must be taken....·I just have not figured it out yet...





    Greetings



    Gary



    P.S. what if· I place a instruction at the rend of each relayloop ...B0 = Pin0..wonder if that would force my state ???
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-08 02:45
    1) "B0 = Pin0" is just an assignment statement to a variable. Why are you using it?

    2) How about providing a new version of your source program?

    3) How about a new description of what you're trying to do?

    Remember that if you test for "IF PIN0 = 1 THEN Label1", then the next statement is executed when PIN0 = 0. The transfer of control to "Label1" does not happen and the "IF" statement falls through to the next statement.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-12-08 02:58
    It's kind of difficult to talk about programming in programming terms with a guy who's admittedly behind the curve.

    Flow charts are very helpful in this regard.· Verbalizing in unexcited, non-programming terms can help, too.
  • Gary HoffmannGary Hoffmann Posts: 10
    edited 2009-12-08 03:41
    Mike,· Thanks for your time.

    I appreciate your effort.

    best regards

    Gary
    ·
Sign In or Register to comment.