Shop OBEX P1 Docs P2 Docs Learn Events
SERIN echo — Parallax Forums

SERIN echo

Sarten-XSarten-X Posts: 32
edited 2007-03-27 20:56 in BASIC Stamp
Is it correct or normal that, on a BS2px in a Super Carrier board, when sending data to be received by SERIN, I get the data I send echoed back to the sending device? At first I thought this was a cabling problem, but the stamp receives programming just fine. I'm using this program:

Main:

SEROUT 16, Baud, [noparse][[/noparse]"Command: ", CR]
SERIN 16, Baud, [noparse][[/noparse]DEC InputData]
ON InputData GOSUB Main, c_high, c_low, c_pause, c_pulsout, c_scsbr, c_sc

GOTO Main




The rest of the code doesn't matter. As a further example:

Main:
DEBUGIN B0
DEBUG B0
GOTO Main




Running this code brings up a pre-configured debug window. Entering "hi" in the top box results in "hhii" in the bottom. With the cable disconnected from the stamp, entering data in the top box doesn't display anything in the bottom.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-27 14:51
    This is normal when using "pin" 16 or DEBUG and has to do with the way the programming port is set up.
  • Sarten-XSarten-X Posts: 32
    edited 2007-03-27 14:54
    Thanks. I figured you'd be the first to respond... I saw your name in the list of online users...

    This bothers me. I'm trying to send & receive data so the stamp can be controlled by a PC, and all the signals are being messed up. Also, when trying to receive data, all the command strings are returned along with the data I want, which means I'll have to parse out the useless stuff. Ugh.

    Thanks, though.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-27 15:04
    Hello,

    All your PC application has to do is ignore everything it sends and there will be no problems…Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-27 15:57
    It's possible to add a small MAX232 based converter with a DB-9 connector, and use two of the other I/O pins of the BS2 for serial communications with the PC. This is not as convenient, I admit.

    www.kronosrobotics.com sells a nice module for about $8.00 I believe.
  • Sarten-XSarten-X Posts: 32
    edited 2007-03-27 16:26
    Chris: The data I get isn't reliable enough to just ignore what I've sent, or so it seems. I'll try it, though.

    I have several BS1 serial adapters at my disposal. Would I be able to use one of those?
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-27 16:51
    I don't think so. The BS1 "Serial Adapter" is supposed to convert a serial port into the parallel port signals the BS1 wants in order to program it.

    Wait, let me check...

    Interesting.· If on the PC side you set DTR high (+5 to +10 volts), and RTS low (-5 to -10 volts) (these provide the +- 10 volts needed by the adapter) then it looks like you COULD use the BS1 serial adapter as a level shifter.

    DTR high is the default for Hyperterminal.· I'm not so sure about RTS low, though.· You could do it programatically, of course.

    Post Edited (allanlane5) : 3/27/2007 5:00:23 PM GMT
  • Sarten-XSarten-X Posts: 32
    edited 2007-03-27 20:31
    As Chris suggested, I added a feature to my code (a easy-to-use frontend for the RXTX serial library in Java) to ignore matching bytes in the order they were sent out. While not a perfect solution (some bytes can arrive out of order, and it still doesn't solve the problem of jumbled messages), it is good enough to use for event polling (I'm checking to see when a flywheel's speed exceeds a given point, using a motor as a generator, two LEDs, a photocell, and RCTIME).

    If anyone's interested, I'd be happy to send out the code.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-27 20:56
    Filtering what you output is typically the best solution since the BASIC Stamp cannot do anything while it is receiving bytes, and since the PC UART/FIFO immediately gets the echo. What this means is if you send a packet consisting of 10 bytes and immediately disregard the first 10 bytes in the FIFO buffer then you should be able to receive a response from the Stamp Module no problem. It will take some time to send a reply and the bytes you sent will already be in the FIFO. The only reason this wouldn’t work is if you weren’t clearing from the FIFO what you just sent. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.