Shop OBEX P1 Docs P2 Docs Learn Events
Pulse Detection with BS2 — Parallax Forums

Pulse Detection with BS2

coder1024coder1024 Posts: 9
edited 2006-07-01 01:47 in BASIC Stamp
I'm using the BS2 with the HomeWork board and interfacing with a separate circuit.· I'm using an input pin to watch a "data ready" output pin from the other circuit.· Most of the time this pin is logic high.· When a byte of data is available, the other circuit will pulse this output (drop low then high again).

What is the best way to have the BS2 wait for a pulse from the other circuit?· I thought a loop which just continues while the pin is high might work, but I'm worried about whether or not it'll miss it.

The POLL series of commands looked like it might be the way to go, but they're not provided for the BS2.

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2006-07-01 00:43
    While its waiting, have the stamp loop around a short loop. Something like this: This is not real code, just enough to give you the idea. Depending on the time between the 'data available' pulse and when data starts flowing, this should work.

    starthere:
    if in1 = 0 then goto getnewdata
    goto starthere

    getnewdata:
    serin 2, baudrate,[noparse][[/noparse]'data description goes here']
    goto starthere

    The other way to do this is to use the WAIT parameter with the SERIN command. If your data string has some identifiable characters, let the stamp watch for them then grab the data following. See the Help file.

    Cheers
  • coder1024coder1024 Posts: 9
    edited 2006-07-01 01:45
    Something I missed before was that the other circuit is outputting CMOS. I'm wondering now if there's a chance that its just not dropping the voltage low enough to be seen as logic false by the stamp's input pin...

    its times like this that I wish I had a good oscilliscope smile.gif
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-01 01:47
    With SEROUT there's an Fpin (parameter) which could be used as a pulse detector.· [noparse][[/noparse]Whether active HI or LO depends on whether you are going to use inverted or true logic... so, you may have to invert your pulse, depending.]
Sign In or Register to comment.