Listen to BUTTON and SERIN at same time?
J.We
Posts: 15
I'm trying to get my BSsx to listen to a BUTTON and Serial command SERIN·at the same time?·They are off course on·different·I/Os and they work fine separate. My coding experience is·limited and this is the first time I use BS, please, is there anyone who can give me some advice on how to code this?
·
I can send serial commands from pc via BS to control a step motor and I want to get my BS to listen to the BUTTON at the same time! I'm trying to get around this problem but the commands SERIN and BUTTON seems to get stuck "in their own listening" until something happens only on their pin! What can I do to make the BS to listen to both of them? Can I maybe set some priority on them?
·
Thanks in advance!
//jw
·
I can send serial commands from pc via BS to control a step motor and I want to get my BS to listen to the BUTTON at the same time! I'm trying to get around this problem but the commands SERIN and BUTTON seems to get stuck "in their own listening" until something happens only on their pin! What can I do to make the BS to listen to both of them? Can I maybe set some priority on them?
·
Thanks in advance!
//jw
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· The BASIC Stamp is a single-thread device...You can only do one thing at a time.· You could, however, monitor the serial port for a short time using a time-out, then monitor the button by reading the state of the input pin within a loop.· This might work, depending on baud rate, how often the button needs to be check, etc.· It would work better if you use a pulse-stretcher, such as a 555 timer on the button input too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Ok, I think the time-out will solve some of my problems.. But there isn’t any time-out on the BUTTON. So, one way to solve this is to have an extern buffer? Do you know any projects who have tried this? Any recommendations or other advises?
·
Chris, can you explain more what you mean: "It would work better if you use a pulse-stretcher, such as a 555 timer on the button input too. "·
Many thanks!
Regards//jw
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· What I meant was, watch the input(s) using the IN0, IN1 or for multiple inputs INA, etc.· Then within the loop also do your SERIN routine with a timeout.· Depending on how much time you spend watching the serial port, you may need to stretch your input pulse, but the easier solution is to just cut the time you spend waiting for SERIN, although I wasn't sure how fast/often you have data coming in.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com