DEBUG/DATAIN looping code problem
Archiver
Posts: 46,084
Hello Stampers,
I have been happily sending data from the stamp BS-2 for awhile now, and have
also learned how to interface with relays thanks to Shaun Wilsons site. My
last hurdle is a way to do both at the same time. I have now reached a point
where the program outputs the correct data,....but only once, then quits
looping for an unknown reason. I have noticed that the serin part doesnt
appear to be affected ( it keeps looping and checking for new data) but only
one measurement seems to be sent from the stamp.
When I comment out the serin line, data is sent continuously, so that tells
me my looping structure is basically set correctly. Therefore the problem must
lie with SERIN and DEBUG being used together.
1. I have tried using SEROUT.....same results
2. Tried using REVERSE to reset the pin from output to input
3. Reread instructions about all of these commands, but did not see any
pitfalls listed
here is an excerpt from my code, I have omitted all but what I think is
relevant but whould be happy to post it all if needed.
datain var byte'contains a 0 or a 1
pin con 16 'stamps dedicated serial input pin
baud con $4054 '9600 baud
light var word 'variable light intensity
Loop:
'code to get the variables etc, no problem here
'below is problem area
debug "<LITE=",dec light,">" 'output to PC/debug window
serin pin,baud, [noparse][[/noparse]datain] 'input to see if PC sent relay on cmd
if datain = "@" then onA 'circuit A on
if datain = "#" then offA 'circuit A off
if datain = "$" then onB 'circuit B on
if datain = "^" then offB 'circuit B off
if datain = " " then Loop 'if nothing, return to main loop
onA:
high 11 'make pin 11 high
goto loop
onB:
high 10 'make pin 10 high
goto loop
offA:
low 11 'make pin 11 low
goto loop
offB:
low 10 'make pin 10 low
goto loop
Any sugggestions are appreciated
Dave
P.S. the goofy characters that activate the relay are my lame attempt to use
data that would never be sent normally, ( if simple numbers are used, it
interferes with the data that Im sending ) if someone knows a more effective
way I would surely appreciate it.
[noparse][[/noparse]Non-text portions of this message have been removed]
I have been happily sending data from the stamp BS-2 for awhile now, and have
also learned how to interface with relays thanks to Shaun Wilsons site. My
last hurdle is a way to do both at the same time. I have now reached a point
where the program outputs the correct data,....but only once, then quits
looping for an unknown reason. I have noticed that the serin part doesnt
appear to be affected ( it keeps looping and checking for new data) but only
one measurement seems to be sent from the stamp.
When I comment out the serin line, data is sent continuously, so that tells
me my looping structure is basically set correctly. Therefore the problem must
lie with SERIN and DEBUG being used together.
1. I have tried using SEROUT.....same results
2. Tried using REVERSE to reset the pin from output to input
3. Reread instructions about all of these commands, but did not see any
pitfalls listed
here is an excerpt from my code, I have omitted all but what I think is
relevant but whould be happy to post it all if needed.
datain var byte'contains a 0 or a 1
pin con 16 'stamps dedicated serial input pin
baud con $4054 '9600 baud
light var word 'variable light intensity
Loop:
'code to get the variables etc, no problem here
'below is problem area
debug "<LITE=",dec light,">" 'output to PC/debug window
serin pin,baud, [noparse][[/noparse]datain] 'input to see if PC sent relay on cmd
if datain = "@" then onA 'circuit A on
if datain = "#" then offA 'circuit A off
if datain = "$" then onB 'circuit B on
if datain = "^" then offB 'circuit B off
if datain = " " then Loop 'if nothing, return to main loop
onA:
high 11 'make pin 11 high
goto loop
onB:
high 10 'make pin 10 high
goto loop
offA:
low 11 'make pin 11 low
goto loop
offB:
low 10 'make pin 10 low
goto loop
Any sugggestions are appreciated
Dave
P.S. the goofy characters that activate the relay are my lame attempt to use
data that would never be sent normally, ( if simple numbers are used, it
interferes with the data that Im sending ) if someone knows a more effective
way I would surely appreciate it.
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
You use serin on the program port (port16)
The debug command also uses port16 at 9600 baud
so your serin baud must be 9600 also.
Have you tried to replace debug with the serout command?
Have you tried a small pause statement between debug and serin? (pause 100
should do)
Also place a goto loop statement after the last if datain=" " just in case
some odd character is received.
Also useful is to set datain to a known value just before the serin command
(datain="Z" for example)
Does the error occur immediately or right after you turn on the relay?
Regards peter
Oorspronkelijk bericht
Van: Dave [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7GWs9FlDLzUgrW1HtIFPPNKdkArS7g3p-FeCwSGyQZiEIUvPOx66EtuvOaDJ6hgfv4fRTXxiUCC_GiZT]samhell@s...[/url
Verzonden: zondag 16 december 2001 16:15
Aan: basicstamps@yahoogroups.com
Onderwerp: [noparse][[/noparse]basicstamps] DEBUG/DATAIN looping code problem
Hello Stampers,
I have been happily sending data from the stamp BS-2 for awhile now, and
have also learned how to interface with relays thanks to Shaun Wilsons
site. My last hurdle is a way to do both at the same time. I have now
reached a point where the program outputs the correct data,....but only
once, then quits looping for an unknown reason. I have noticed that the
serin part doesnt appear to be affected ( it keeps looping and checking for
new data) but only one measurement seems to be sent from the stamp.
When I comment out the serin line, data is sent continuously, so that
tells me my looping structure is basically set correctly. Therefore the
problem must lie with SERIN and DEBUG being used together.
1. I have tried using SEROUT.....same results
2. Tried using REVERSE to reset the pin from output to input
3. Reread instructions about all of these commands, but did not see any
pitfalls listed
here is an excerpt from my code, I have omitted all but what I think is
relevant but whould be happy to post it all if needed.
datain var byte'contains a 0 or a 1
pin con 16 'stamps dedicated serial input pin
baud con $4054 '9600 baud
light var word 'variable light intensity
Loop:
'code to get the variables etc, no problem here
'below is problem area
debug "<LITE=",dec light,">" 'output to PC/debug window
serin pin,baud, [noparse][[/noparse]datain] 'input to see if PC sent relay on cmd
if datain = "@" then onA 'circuit A on
if datain = "#" then offA 'circuit A off
if datain = "$" then onB 'circuit B on
if datain = "^" then offB 'circuit B off
if datain = " " then Loop 'if nothing, return to main loop
onA:
high 11 'make pin 11 high
goto loop
onB:
high 10 'make pin 10 high
goto loop
offA:
low 11 'make pin 11 low
goto loop
offB:
low 10 'make pin 10 low
goto loop
Any sugggestions are appreciated
Dave
P.S. the goofy characters that activate the relay are my lame attempt to
use data that would never be sent normally, ( if simple numbers are
used, it interferes with the data that Im sending ) if someone knows a
more effective way I would surely appreciate it.
[noparse][[/noparse]Non-text portions of this message have been removed]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
I forgot to mention,
use the timeout feature to jump to a debug statement
The bs2sx has 0.4uS ticks so a timeout of 10000 would
Give you a timeout of 4 seconds
Serin pin,baud,10000,noinput,[noparse][[/noparse]datain]
Noinput:
Debug "no input",cr
Goto loop
Regards peter
Oorspronkelijk bericht
Van: peter verkaik [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AxbE5i48nafiuYcH65ka1HcinpezzFmKWRf-ollE-ZjT03fvDaXK5izQ84DP27SllUYMy-C86DE01EUVe8s8cf0]peterverkaik@b...[/url
Verzonden: maandag 17 december 2001 2:45
Aan: basicstamps@yahoogroups.com
Onderwerp: RE: [noparse][[/noparse]basicstamps] DEBUG/DATAIN looping code problem
Hi,
You use serin on the program port (port16)
The debug command also uses port16 at 9600 baud
so your serin baud must be 9600 also.
Have you tried to replace debug with the serout command?
Have you tried a small pause statement between debug and serin? (pause 100
should do)
Also place a goto loop statement after the last if datain=" " just in case
some odd character is received.
Also useful is to set datain to a known value just before the serin command
(datain="Z" for example)
Does the error occur immediately or right after you turn on the relay?
Regards peter
Oorspronkelijk bericht
Van: Dave [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=uxP76C6clhisx4AJKM6X1u26BoFjW6lx2XIbLWRKmuJhREJ239azlK1YY6YDsj1fzcsUqWEgAeBLt4c]samhell@s...[/url
Verzonden: zondag 16 december 2001 16:15
Aan: basicstamps@yahoogroups.com
Onderwerp: [noparse][[/noparse]basicstamps] DEBUG/DATAIN looping code problem
Hello Stampers,
I have been happily sending data from the stamp BS-2 for awhile now, and
have also learned how to interface with relays thanks to Shaun Wilsons
site. My last hurdle is a way to do both at the same time. I have now
reached a point where the program outputs the correct data,....but only
once, then quits looping for an unknown reason. I have noticed that the
serin part doesnt appear to be affected ( it keeps looping and checking for
new data) but only one measurement seems to be sent from the stamp.
When I comment out the serin line, data is sent continuously, so that
tells me my looping structure is basically set correctly. Therefore the
problem must lie with SERIN and DEBUG being used together.
1. I have tried using SEROUT.....same results
2. Tried using REVERSE to reset the pin from output to input
3. Reread instructions about all of these commands, but did not see any
pitfalls listed
here is an excerpt from my code, I have omitted all but what I think is
relevant but whould be happy to post it all if needed.
datain var byte'contains a 0 or a 1
pin con 16 'stamps dedicated serial input pin
baud con $4054 '9600 baud
light var word 'variable light intensity
Loop:
'code to get the variables etc, no problem here
'below is problem area
debug "<LITE=",dec light,">" 'output to PC/debug window
serin pin,baud, [noparse][[/noparse]datain] 'input to see if PC sent relay on cmd
if datain = "@" then onA 'circuit A on
if datain = "#" then offA 'circuit A off
if datain = "$" then onB 'circuit B on
if datain = "^" then offB 'circuit B off
if datain = " " then Loop 'if nothing, return to main loop
onA:
high 11 'make pin 11 high
goto loop
onB:
high 10 'make pin 10 high
goto loop
offA:
low 11 'make pin 11 low
goto loop
offB:
low 10 'make pin 10 low
goto loop
Any sugggestions are appreciated
Dave
P.S. the goofy characters that activate the relay are my lame attempt to
use data that would never be sent normally, ( if simple numbers are
used, it interferes with the data that Im sending ) if someone knows a
more effective way I would surely appreciate it.
[noparse][[/noparse]Non-text portions of this message have been removed]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/