Shop OBEX P1 Docs P2 Docs Learn Events
checking for tranceiver signal periodically — Parallax Forums

checking for tranceiver signal periodically

LAZY EYELAZY EYE Posts: 4
edited 2012-05-24 00:34 in BASIC Stamp
Could I possibly ask you guys a question?

I've bought a couple of the parallax tranceivers (#27982) to communicate with a C++ app through a PIC-USB interface I've made. All is well, I can communicate a number of commands to the remote board but the stamp has a few other jobs to do and I don't know how to check for an incoming RF feed periodically. I found the source code for transmission/error checking on the parallax website, the only issue I have is the program stays in a loop waiting for a start-bit... this circuit also needs to be monitoring a thermistor and cds values,
  ' Wait for preamble, then receive data and crc value
  SERIN Tx,Baud,[WAIT ("U!"), packet, strLen, STR string\strLen,
                 rcvdCrc.LOWBYTE,rcvdCrc.HIGHBYTE]

I've tried a few approaches but to no avail. Would really appriciate some input...and I can post the full code listings if it would help


thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-23 16:07
    As a general rule, a Stamp can do only one thing at a time and this includes processing serial data, like in a SERIN statement. When the Stamp is not in a SERIN statement, the serial input is completely ignored. Sometimes a Stamp program can interleave different functions, like issuing R/C servo control pulses about 50 times a second and checking sensor information in between producing servo pulses, but that doesn't work for serial input. You could use an external serial input buffer like these. The other way to handle this is to have the Stamp become the master. It polls the PC for any new requests and the PC doesn't transmit anything until the Stamp queries it by sending some kind of special character sequence. That way the PC knows that the Stamp is ready to receive information.
  • LAZY EYELAZY EYE Posts: 4
    edited 2012-05-23 16:19
    Ah OK. I've written a bi-directional data bus to communicate between the USB-PIC and the stamp on the transmitting end, would it just be easier to get a pic to look after the sensory aspects on the receving end and just use the stamps to send/receive data?


    ...but sorry, just to clarify my question, I was just wondering if the stamp would always have the 'wait' for an niput, or whether there was a method of simply checking if a flag as been raised to get the stamps attention from the tranceiver, without having to pause on the SERIN statement
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-23 20:27
    Not really. If you use an external serial input buffer, you can check a signal from that to see if there's anything in its buffer, but the Stamp by itself doesn't even see the input from the transceiver when it's not executing a SERIN and a SERIN effectively stops the Stamp from doing anything else while it's waiting for a character. There are provisions for a timeout in the SERIN statement, but that won't do what you want. You could program your PIC to do what Protean Logic's serial buffer does. I suspect it's just a pre-programmed PIC.
  • LAZY EYELAZY EYE Posts: 4
    edited 2012-05-24 00:34
    That makes things a little less straight forward, but shouldn't be a problem. Thanks for the help Mike
Sign In or Register to comment.