Shop OBEX P1 Docs P2 Docs Learn Events
Serial communication — Parallax Forums

Serial communication

SANSAN Posts: 29
edited 2008-10-23 18:26 in BASIC Stamp
I want to send data to the Basic Stamp through serial port.
when i tried with SERIN() command i wouldn't receive any data.
can you help me to connect by Basic Stamp with PC through serial port using any of I/O pins?
Help me with the connection and codes.
I am sending the data using RoboRealm serial option.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-21 19:10
    The Stamp Basic Manual describes how to do this in the chapter on the SERIN statement (page 395?) and the chapter on the DEBUGIN statement.
    If you still have problems, you will need to post a schematic showing how you're connecting the Stamp and your PC and a listing of your program
    (both as attachments to your reply).
  • SANSAN Posts: 29
    edited 2008-10-22 18:58
    Sir I still have problem. the basic stamp 2 module does not receive any signal.
    my basic stamp code is -
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    x VAR Byte
    DO
    SERIN 0,16780,[noparse][[/noparse]DEC2 x]
    IF x=10 THEN
    HIGH 15
    ELSE
    LOW 15
    ENDIF
    LOOP

    and in the RoboRealm vb-script code is -

    width = GetVariable("IMAGE_WIDTH")
    center = width / 2
    size = GetVariable("COG_BOX_SIZE")
    'if size <> "" then
    cogx = GetVariable("COG_X")
    if cogx < center-5 then
    testx = 10
    elseif cogx > center+5 then
    testx = 20
    end if
    SetVariable "LEFT_MOTOR", CInt(testx)

    in serial module i am sending the variable -
    [noparse][[/noparse]LFT_MOTOR]
    in baudmode 9600

    I am using laptop with Windows vista and USB to Serial converter

    I am using the same connection shown in the Basic Stamp Manual pg- 395 [noparse][[/noparse]I/P = pin 3, pin 1,4,6 shorted and pin 5 = VSS]

    RoboRealm sending the variable but the basic stamp does not response.

    Sir please help me.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-10-22 19:04
    Yup, the "Programming Port" is on "SERIN 16, 16780, [noparse][[/noparse]DEC X]", not on "SERIN 0, ..."
  • SANSAN Posts: 29
    edited 2008-10-23 10:33
    Sorry sir,
    but where,I mean which port I should connect the TX pin (Pin 3) of the RS232 port.
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-10-23 11:38
    If you are using the Stamp's built-in serial port, you use "16".

    However, it would be easier to just use "DEBUG" and "DEBUGIN" to do what you're doing, I think. With those, you don't have to worry about Baud or which pin to use - just leave the Stamp connected as you do when programming it. You should definitely read those sections of the Stamp manual.
  • SANSAN Posts: 29
    edited 2008-10-23 18:26
    Thank you very much sir.
    It is working.
Sign In or Register to comment.