BS1-IC troubles, a little more..
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
).· 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·
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](http://forums.parallax.com/images/smilies/nono.gif)
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
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
Thanks for your time,
GH
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 ???
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.
Flow charts are very helpful in this regard.· Verbalizing in unexcited, non-programming terms can help, too.
I appreciate your effort.
best regards
Gary
·