Shop OBEX P1 Docs P2 Docs Learn Events
basic SX , interrupt functions ? — Parallax Forums

basic SX , interrupt functions ?

sunilsunil Posts: 5
edited 2005-06-09 22:11 in BASIC Stamp
Hi,

I am using a basic stamp 2 sx .

The stamp is waiting for a serial signal , but at the same time has to be allerted if a button is being pressed. Is there a way to do this, also is there any provision for interrupts.
Thanks

Sunil

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-09 17:10
    No interrupts.·

    There are two things you can do: 1) you can use flow-control with your SERIN statement so the external device doesn't try to send anything when the BASIC Stamp is not ready, or 2) you can use a timeout in SERIN to escape out of it if nothing shows up.·

    To catch your button input you can either latch it with a flip-flop or, as I've done a couple times, you can "stretch" the button input with a simple 555 circuit, using an extra pin on the BASIC Stamp to reset the 555 after the input is scanned.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • sunilsunil Posts: 5
    edited 2005-06-09 17:13
    Actually I cannot stop the serial process, once it has started , it has to wait for atleast 5 seconds, but at the same time I need to be able to recognize as soon as a button is pressed.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-09 17:24
    You need some sort of hardware serial buffer, then, because the BASIC Stamp uses software serial routines (which is why it works on any pin) and it cannot be interrupted once it is receiving data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-06-09 21:47
    Sunil, have you considered using the SXes?

    Ryan
  • Vern GranerVern Graner Posts: 337
    edited 2005-06-09 22:11
    This may also depend on what your definiton of "at the same time" is. smile.gif If a short delay is allowable from the time the button is pressed till the time you poll for the button state, you could use some pretty clever polling code created by Jon and shared/discussed in the ParallaxEFX area detailed in this thread:

    http://forums.parallax.com/showthread.php?p=537937

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
Sign In or Register to comment.