Shop OBEX P1 Docs P2 Docs Learn Events
rs-232 problems using pulsin/pulsout — Parallax Forums

rs-232 problems using pulsin/pulsout

ArchiverArchiver Posts: 46,084
edited 2004-04-15 16:15 in General Discussion
I would like to communicate with my bs2 and/or bs1 via a rs-232 cable
but have had no luck when using the pulsin/pulsout commands unless I
use pins states 16-31 (for the bs2). All the examples I've seen
state that I should be able to use 0, 1, or 2, ... but I can't get
this to work. I've put a 22kohm resistor in series for the I/O
connection to avoid sending more than 5 volts over the cable. I'm
trying to use hyperterminal and it does work when I use "DEBUGIN" so
I have all the setting correct for ht.

here's code that works:

***********************

baudmode CON 84 'serial code to set baudrate
'for the BSII baudmode(noninverted):
9600=>84
'see page 277 BASIC Stamp Manual
'Initialize
indata VAR Byte(6)
i VAR Byte
indata(6) = 0
i = 0

DEBUG CLS, "starting...", CR

'Basic I/O loop
top:
'serin works for 16 - 31
SERIN 32, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
'5 characters or carraige
RETURN
SEROUT 32, baudmode,[noparse][[/noparse]CR] 'send carraige return
SEROUT 32, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
response
i = i + 1
GOTO top
***********************

here's code that doesn't work:

***********************

baudmode CON 84 'serial code to set baudrate
'for the BSII baudmode(noninverted):
9600=>84
'see page 277 BASIC Stamp Manual
'Initialize
indata VAR Byte(6)
i VAR Byte
indata(6) = 0
i = 0

DEBUG CLS, "starting...", CR

'Basic I/O loop
top:

SERIN 1, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
'5 characters or carraige
RETURN
SEROUT 1, baudmode,[noparse][[/noparse]CR] 'send carraige return
SEROUT 1, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
response
i = i + 1
GOTO top

***********************

Any suggestins?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-09 16:30
    To use the programming port as a serial connection with the BS2 (does
    not work with BS1), you must specify pin 16 in your program. If you
    consult the online Help for DEBUG and DEBUGIN you will see that it shows
    the equivalent SEROUT and SERIN instructions for using the programming
    port.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: lortrick [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=cL5AwltMdl3o-wITWM6yh2ZLCow1gHWBOk9ywPYL3ueocfT3JniJdGBhftq6SEg_Ak6DOQmhx7dt]lortrick@y...[/url
    Sent: Friday, April 09, 2004 7:33 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] rs-232 problems using pulsin/pulsout


    I would like to communicate with my bs2 and/or bs1 via a rs-232 cable
    but have had no luck when using the pulsin/pulsout commands unless I
    use pins states 16-31 (for the bs2). All the examples I've seen
    state that I should be able to use 0, 1, or 2, ... but I can't get
    this to work. I've put a 22kohm resistor in series for the I/O
    connection to avoid sending more than 5 volts over the cable. I'm
    trying to use hyperterminal and it does work when I use "DEBUGIN" so
    I have all the setting correct for ht.

    here's code that works:

    ***********************

    baudmode CON 84 'serial code to set baudrate
    'for the BSII baudmode(noninverted):
    9600=>84
    'see page 277 BASIC Stamp Manual
    'Initialize
    indata VAR Byte(6)
    i VAR Byte
    indata(6) = 0
    i = 0

    DEBUG CLS, "starting...", CR

    'Basic I/O loop
    top:
    'serin works for 16 - 31
    SERIN 32, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    '5 characters or carraige
    RETURN
    SEROUT 32, baudmode,[noparse][[/noparse]CR] 'send carraige return
    SEROUT 32, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    response
    i = i + 1
    GOTO top
    ***********************

    here's code that doesn't work:

    ***********************

    baudmode CON 84 'serial code to set baudrate
    'for the BSII baudmode(noninverted):
    9600=>84
    'see page 277 BASIC Stamp Manual
    'Initialize
    indata VAR Byte(6)
    i VAR Byte
    indata(6) = 0
    i = 0

    DEBUG CLS, "starting...", CR

    'Basic I/O loop
    top:

    SERIN 1, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    '5 characters or carraige
    RETURN
    SEROUT 1, baudmode,[noparse][[/noparse]CR] 'send carraige return
    SEROUT 1, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    response
    i = i + 1
    GOTO top

    ***********************

    Any suggestins?




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.

    Yahoo! Groups Links







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-15 16:00
    Ok, I've have that working. I hadn't realized (from reading many
    doc) that the programming port wasn't a full featured serial port
    that would allow for commands such as

    serout N, baudmode, [noparse][[/noparse]"test"]

    where N is 0-15 and baudmode is bps for BS2

    This must mean that I'll need to add a serial connector to my board
    and attached to some serout pin to communicate through something like
    hyperterminal without specifying pin 16?

    Would you suggest that I go in the direction of your online pdf
    document for "RS-232 DCE AppMod (#29120)? It states that I should be
    able to select any available stamp I/O pin for serial connections.

    Thanks. I was getting concerned that I had burnt out some of the
    pins while exploring serout (and serin with resistor).

    Patrick




    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > To use the programming port as a serial connection with the BS2
    (does
    > not work with BS1), you must specify pin 16 in your program. If you
    > consult the online Help for DEBUG and DEBUGIN you will see that it
    shows
    > the equivalent SEROUT and SERIN instructions for using the
    programming
    > port.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: lortrick [noparse][[/noparse]mailto:lortrick@y...]
    > Sent: Friday, April 09, 2004 7:33 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] rs-232 problems using pulsin/pulsout
    >
    >
    > I would like to communicate with my bs2 and/or bs1 via a rs-232
    cable
    > but have had no luck when using the pulsin/pulsout commands unless
    I
    > use pins states 16-31 (for the bs2). All the examples I've seen
    > state that I should be able to use 0, 1, or 2, ... but I can't get
    > this to work. I've put a 22kohm resistor in series for the I/O
    > connection to avoid sending more than 5 volts over the cable. I'm
    > trying to use hyperterminal and it does work when I use "DEBUGIN"
    so
    > I have all the setting correct for ht.
    >
    > here's code that works:
    >
    > ***********************
    >
    > baudmode CON 84 'serial code to set baudrate
    > 'for the BSII baudmode(noninverted):
    > 9600=>84
    > 'see page 277 BASIC Stamp Manual
    > 'Initialize
    > indata VAR Byte(6)
    > i VAR Byte
    > indata(6) = 0
    > i = 0
    >
    > DEBUG CLS, "starting...", CR
    >
    > 'Basic I/O loop
    > top:
    > 'serin works for 16 - 31
    > SERIN 32, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    > '5 characters or carraige
    > RETURN
    > SEROUT 32, baudmode,[noparse][[/noparse]CR] 'send carraige return
    > SEROUT 32, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    > response
    > i = i + 1
    > GOTO top
    > ***********************
    >
    > here's code that doesn't work:
    >
    > ***********************
    >
    > baudmode CON 84 'serial code to set baudrate
    > 'for the BSII baudmode(noninverted):
    > 9600=>84
    > 'see page 277 BASIC Stamp Manual
    > 'Initialize
    > indata VAR Byte(6)
    > i VAR Byte
    > indata(6) = 0
    > i = 0
    >
    > DEBUG CLS, "starting...", CR
    >
    > 'Basic I/O loop
    > top:
    >
    > SERIN 1, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    > '5 characters or carraige
    > RETURN
    > SEROUT 1, baudmode,[noparse][[/noparse]CR] 'send carraige return
    > SEROUT 1, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    > response
    > i = i + 1
    > GOTO top
    >
    > ***********************
    >
    > Any suggestins?
    >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject
    > and Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-15 16:15
    Yes, it will -- you just have to specify 16 for N (in your note below)
    and understand that the programming port has an level-shifter/inverter
    on it to make it more friendly with the external RS-232 world (when you
    use DEBUG and DEBUGIN, you're doing SEROUT and SERIN on pin 16 at 9600
    baud).

    Just understand that the design of the level shifter on the programming
    port "borrows" power from the RS-232 line, so anything sent to the that
    port gets echoed back. To deal with this in HyperTerminal just turn off
    the local display. Then, when you press a key in HyperTerminal, its
    appearance on your screen means that it went to the BASIC Stamp and was
    echoed back.

    If the echo is a hassle or you want to add flow-control, the RS-232
    AppMod will take care of that for you -- but you'll be using at least
    two (four with FC) of your BASIC Stamp IO pins.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: lortrick [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=mTYBuOWNucUuGvIv0B289MIHZxbvaGxmBdjPkIL8ujYTsbXZBbV5ORWXORMCXBJiD-DLSItbxvuewyM]lortrick@y...[/url
    Sent: Thursday, April 15, 2004 10:01 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: rs-232 problems using pulsin/pulsout


    Ok, I've have that working. I hadn't realized (from reading many
    doc) that the programming port wasn't a full featured serial port
    that would allow for commands such as

    serout N, baudmode, [noparse][[/noparse]"test"]

    where N is 0-15 and baudmode is bps for BS2

    This must mean that I'll need to add a serial connector to my board
    and attached to some serout pin to communicate through something like
    hyperterminal without specifying pin 16?

    Would you suggest that I go in the direction of your online pdf
    document for "RS-232 DCE AppMod (#29120)? It states that I should be
    able to select any available stamp I/O pin for serial connections.

    Thanks. I was getting concerned that I had burnt out some of the
    pins while exploring serout (and serin with resistor).

    Patrick




    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > To use the programming port as a serial connection with the BS2
    (does
    > not work with BS1), you must specify pin 16 in your program. If you
    > consult the online Help for DEBUG and DEBUGIN you will see that it
    shows
    > the equivalent SEROUT and SERIN instructions for using the
    programming
    > port.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: lortrick [noparse][[/noparse]mailto:lortrick@y...]
    > Sent: Friday, April 09, 2004 7:33 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] rs-232 problems using pulsin/pulsout
    >
    >
    > I would like to communicate with my bs2 and/or bs1 via a rs-232
    cable
    > but have had no luck when using the pulsin/pulsout commands unless
    I
    > use pins states 16-31 (for the bs2). All the examples I've seen
    > state that I should be able to use 0, 1, or 2, ... but I can't get
    > this to work. I've put a 22kohm resistor in series for the I/O
    > connection to avoid sending more than 5 volts over the cable. I'm
    > trying to use hyperterminal and it does work when I use "DEBUGIN"
    so
    > I have all the setting correct for ht.
    >
    > here's code that works:
    >
    > ***********************
    >
    > baudmode CON 84 'serial code to set baudrate
    > 'for the BSII baudmode(noninverted):
    > 9600=>84
    > 'see page 277 BASIC Stamp Manual
    > 'Initialize
    > indata VAR Byte(6)
    > i VAR Byte
    > indata(6) = 0
    > i = 0
    >
    > DEBUG CLS, "starting...", CR
    >
    > 'Basic I/O loop
    > top:
    > 'serin works for 16 - 31
    > SERIN 32, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    > '5 characters or carraige
    > RETURN
    > SEROUT 32, baudmode,[noparse][[/noparse]CR] 'send carraige return
    > SEROUT 32, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    > response
    > i = i + 1
    > GOTO top
    > ***********************
    >
    > here's code that doesn't work:
    >
    > ***********************
    >
    > baudmode CON 84 'serial code to set baudrate
    > 'for the BSII baudmode(noninverted):
    > 9600=>84
    > 'see page 277 BASIC Stamp Manual
    > 'Initialize
    > indata VAR Byte(6)
    > i VAR Byte
    > indata(6) = 0
    > i = 0
    >
    > DEBUG CLS, "starting...", CR
    >
    > 'Basic I/O loop
    > top:
    >
    > SERIN 1, baudmode, [noparse][[/noparse]STR indata\5\CR] 'get command either after
    > '5 characters or carraige
    > RETURN
    > SEROUT 1, baudmode,[noparse][[/noparse]CR] 'send carraige return
    > SEROUT 1, baudmode,[noparse][[/noparse]STR indata, ", index= ", DEC i, CR] 'send
    > response
    > i = i + 1
    > GOTO top
    >
    > ***********************
    >
    > Any suggestins?
    >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject
    > and Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.

    Yahoo! Groups Links







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.