Shop OBEX P1 Docs P2 Docs Learn Events
Serial Communication during Runtime -- Multiple Stamps — Parallax Forums

Serial Communication during Runtime -- Multiple Stamps

ArchiverArchiver Posts: 46,084
edited 2000-09-21 14:38 in General Discussion
Hello:

I will be using 8 BS 2 stamps, each doing relatively simple tasks
(switching on and off leds) under the control of my computer. My
intention is that the computer will communicate during runtime with
the stamps via the serial connection. I would like to connect all the
stamps to the same serial port (basically in parallel) and the send
information to all of them and have each one listen out for its own
"name". Following the name will be a code describing what it needs to
do (i.e. switch on led ). For example I might send something like:

B,5

which means Stamp No. B, switch on LED 5.

Will this work the way I hope it will? I know there was a problem
with
doing this on the BS 1, because there was the danger of shorting the
serial connection to ground, but it seems it should be okay for the
BS2 since it has separate serial pins. Also, I don't need the stamps
to communicate back to the computer. Are there any precautions I
should take, or should it all work just the way I think it will (ha!
as if it ever does....)

Thanks for any advice

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-09-20 07:13
    Good day,

    I just wonder, if all you are doing is switching leds, perhaps
    eight stamps would be overkill in terms of money and energy. If you use
    any kind of serial latch, you require but one stamp. You would not have
    the problem you are trying to solve.
    Unless you are doing this just to figure out how; then please
    disregard the latter comments...

    Have nice evening,
    Paul

    On Wed, 20 Sep 2000, Chundle Chundle wrote:

    > Hello:
    >
    > I will be using 8 BS 2 stamps, each doing relatively simple tasks
    > (switching on and off leds) under the control of my computer. My
    > intention is that the computer will communicate during runtime with
    > the stamps via the serial connection. I would like to connect all the
    > stamps to the same serial port (basically in parallel) and the send
    > information to all of them and have each one listen out for its own
    > "name". Following the name will be a code describing what it needs to
    > do (i.e. switch on led ). For example I might send something like:
    >
    > B,5
    >
    > which means Stamp No. B, switch on LED 5.
    >
    > Will this work the way I hope it will? I know there was a problem
    > with
    > doing this on the BS 1, because there was the danger of shorting the
    > serial connection to ground, but it seems it should be okay for the
    > BS2 since it has separate serial pins. Also, I don't need the stamps
    > to communicate back to the computer. Are there any precautions I
    > should take, or should it all work just the way I think it will (ha!
    > as if it ever does....)
    >
    > Thanks for any advice
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-20 17:14
    Paul,

    If serial data exchange between multiple stamps is required, your going
    to have to build a 'simple serial network' that all the stamps can attach
    to. Research RS-485 for your simple net. Each stamp, once attached to the
    net, will have to constantly watch all messages, filtering for messages sent
    specifically to it, and then act on the message. This is a bit complex, but
    well documented if you search some. Start with ( and maybe end with! It's
    that good! ) Jan Axelsons' Serial Port Complete book (
    http://www.lvr.com/spc.htm ). She has provided a project ( including
    examples for Stamps ) to do just this. Good Luck!

    Bill Mrozinski - DCS

    "Paul J. Csonka" wrote:

    > Good day,
    >
    > I just wonder, if all you are doing is switching leds, perhaps
    > eight stamps would be overkill in terms of money and energy. If you use
    > any kind of serial latch, you require but one stamp. You would not have
    > the problem you are trying to solve.
    > Unless you are doing this just to figure out how; then please
    > disregard the latter comments...
    >
    > Have nice evening,
    > Paul
    >
    > On Wed, 20 Sep 2000, Chundle Chundle wrote:
    >
    > > Hello:
    > >
    > > I will be using 8 BS 2 stamps, each doing relatively simple tasks
    > > (switching on and off leds) under the control of my computer. My
    > > intention is that the computer will communicate during runtime with
    > > the stamps via the serial connection. I would like to connect all the
    > > stamps to the same serial port (basically in parallel) and the send
    > > information to all of them and have each one listen out for its own
    > > "name". Following the name will be a code describing what it needs to
    > > do (i.e. switch on led ). For example I might send something like:
    > >
    > > B,5
    > >
    > > which means Stamp No. B, switch on LED 5.
    > >
    > > Will this work the way I hope it will? I know there was a problem
    > > with
    > > doing this on the BS 1, because there was the danger of shorting the
    > > serial connection to ground, but it seems it should be okay for the
    > > BS2 since it has separate serial pins. Also, I don't need the stamps
    > > to communicate back to the computer. Are there any precautions I
    > > should take, or should it all work just the way I think it will (ha!
    > > as if it ever does....)
    > >
    > > Thanks for any advice
    > >
    > >
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-20 17:56
    Fantastic! This is very similar to the program I was intending to
    use.... A few questions, however:

    1. what is the "inverted mode", and is this different from normal
    serial communication? I was under the impression that serial
    communication is generally "inverted".
    2. the resistor you mention -- does this need to be in series to the
    input pin, and will all 8 need the resistor or will it be enough to
    put it at the serial cable connector before branching out to the 8?
    If
    you have a moment perhaps you could explain what exactly it's there
    for!

    Thanks so much for your help!

    Chundle


    > HI,
    > YES, its possible and simple to transmit to some different BS2-IC ,
    all
    > connected to PCs TXD-line in "inverted mode". (Take care for the
    needed
    > resist 22 kOhm in BS2-IC serial input pin).To adress one of the the
    > BS2-IC you should use the WAIT modifiers in SERIN-statement for
    > recognicing the aligned message.
    >
    > Try this program
    >
    > recstr var byte(3)
    > loop: serin 12,16468,[noparse][[/noparse]WAIT ("B"),DEC recstr]
    >
    > if recstr = 51 then LED5ON
    > if recstr = 50 then LED5OFF
    >
    > if recstr = 41 then LED4ON
    > if recstr = 40 then LED4OFF
    >
    > 'if recstr (any actions aligned to received recstr)
    > 'if ...
    > goto loop
    >
    >
    > LED5ON: high 5 'LED 5 ON (LED + resist from pin to GND)
    > goto loop
    >
    > LED5OFF: low 5 'LED 5 OFF
    > goto loop
    >
    > LED4ON: high 4 'LED 4 ON
    > goto loop
    >
    > LED4OFF: low 4 'LED 4 OFF
    > goto loop
    >
    > '.....: ........
    > '.....: actions You want
    > 'goto loop
    > end
    >
    > With your PC-RS232-Monitor You can switch the called pins of
    BS2-IC,
    > adressed with
    > presetted char.
    > For example, with keying "B51" + (ENTER or any nonnum.key):
    > BASIC Stamp 2 , adressed with "B" , LED on pin 5 will lights on.
    > Today tested,- works fine ! Klau
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-20 18:41
    In a message dated 9/20/00 11:25:00 AM Central Daylight Time,
    kzahnert@d... writes:

    > Try this program
    >
    > recstr var byte(3)
    > loop: serin 12,16468,[noparse][[/noparse]WAIT ("B"),DEC recstr]
    >
    > if recstr = 51 then LED5ON
    > if recstr = 50 then LED5OFF
    >
    > if recstr = 41 then LED4ON
    > if recstr = 40 then LED4OFF
    >
    > 'if recstr (any actions aligned to received recstr)
    > 'if ...
    > goto loop
    >
    >
    > LED5ON: high 5 'LED 5 ON (LED + resist from pin to GND)
    > goto loop
    >
    > LED5OFF: low 5 'LED 5 OFF
    > goto loop
    >
    > LED4ON: high 4 'LED 4 ON
    > goto loop
    >
    > LED4OFF: low 4 'LED 4 OFF
    > goto loop
    >
    > '.....: ........
    > '.....: actions You want
    > 'goto loop
    > end
    >

    You can simplify the program a bit and save a lot of typing by taking
    advantage of the Stamp's method of treating its memory as an array. Like
    this:

    LEDs VAR Out0 ' LED outputs (index as bit)

    LEDcmd VAR Byte ' serial command string
    theLED VAR Nib ' selected LED
    state VAR LEDcmd.Bit0 ' on if Bit0 set

    Init:
    DirL = %11111111 ' make them outputs

    Loop:
    ' SERIN 12,16468,[noparse][[/noparse]WAIT ("B"),DEC LEDcmd]

    ' test with DEBUG terminal
    '
    DEBUG CR,"Enter an LED command: "
    SERIN 16,84,[noparse][[/noparse]WAIT ("B"),DEC LEDcmd]

    theLED = LEDcmd / 10
    IF theLED > 7 THEN Loop
    LEDs(theLED) = state

    GOTO Loop



    -- Jon Williams
    -- Dallas, TX
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-20 19:31
    At 05:09 20.09.2000 -0000, you wrote:
    >Hello:
    >
    >I will be using 8 BS 2 stamps, each doing relatively simple tasks
    >(switching on and off leds) under the control of my computer. My
    >intention is that the computer will communicate during runtime with
    >the stamps via the serial connection. I would like to connect all the
    >stamps to the same serial port (basically in parallel) and the send
    >information to all of them and have each one listen out for its own
    >"name". Following the name will be a code describing what it needs to
    >do (i.e. switch on led ). For example I might send something like:
    >
    >B,5
    >
    >which means Stamp No. B, switch on LED 5.
    >
    >Will this work the way I hope it will? I know there was a problem
    >with
    >doing this on the BS 1, because there was the danger of shorting the
    >serial connection to ground, but it seems it should be okay for the
    >BS2 since it has separate serial pins. Also, I don't need the stamps
    >to communicate back to the computer. Are there any precautions I
    >should take, or should it all work just the way I think it will (ha!
    >as if it ever does....)
    >
    >Thanks for any advice
    >

    HI,
    YES, its possible and simple to transmit to some different BS2-IC , all
    connected to PCs TXD-line in "inverted mode". (Take care for the needed
    resist 22 kOhm in BS2-IC serial input pin).To adress one of the the
    BS2-IC you should use the WAIT modifiers in SERIN-statement for
    recognicing the aligned message.

    Try this program

    recstr var byte(3)
    loop: serin 12,16468,[noparse][[/noparse]WAIT ("B"),DEC recstr]

    if recstr = 51 then LED5ON
    if recstr = 50 then LED5OFF

    if recstr = 41 then LED4ON
    if recstr = 40 then LED4OFF

    'if recstr (any actions aligned to received recstr)
    'if ...
    goto loop


    LED5ON: high 5 'LED 5 ON (LED + resist from pin to GND)
    goto loop

    LED5OFF: low 5 'LED 5 OFF
    goto loop

    LED4ON: high 4 'LED 4 ON
    goto loop

    LED4OFF: low 4 'LED 4 OFF
    goto loop

    '.....: ........
    '.....: actions You want
    'goto loop
    end

    With your PC-RS232-Monitor You can switch the called pins of BS2-IC,
    adressed with
    presetted char.
    For example, with keying "B51" + (ENTER or any nonnum.key):
    BASIC Stamp 2 , adressed with "B" , LED on pin 5 will lights on.
    Today tested,- works fine ! Klaus Zahnert
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-21 00:29
    At 16:56 20.09.2000 -0000, you wrote:
    >Fantastic! This is very similar to the program I was intending to
    >use.... A few questions, however:
    >
    >1. what is the "inverted mode", and is this different from normal
    >serial communication? I was under the impression that serial
    >communication is generally "inverted".
    >2. the resistor you mention -- does this need to be in series to the
    >input pin, and will all 8 need the resistor or will it be enough to
    >put it at the serial cable connector before branching out to the 8?
    >If
    >you have a moment perhaps you could explain what exactly it's there
    >for!
    >
    >Thanks so much for your help!
    >
    >Chundle
    >
    >
    >> HI,
    >> YES, its possible and simple to transmit to some different BS2-IC ,
    >all
    >> connected to PCs TXD-line in "inverted mode". (Take care for the
    >needed
    >> resist 22 kOhm in BS2-IC serial input pin).To adress one of the the
    >> BS2-IC you should use the WAIT modifiers in SERIN-statement for
    >> recognicing the aligned message.
    >>
    >> Try this program
    >>
    >> recstr var byte(3)
    >> loop: serin 12,16468,[noparse][[/noparse]WAIT ("B"),DEC recstr]
    >>
    >> if recstr = 51 then LED5ON
    >> if recstr = 50 then LED5OFF
    >>
    >> if recstr = 41 then LED4ON
    >> if recstr = 40 then LED4OFF
    >>
    >> 'if recstr (any actions aligned to received recstr)
    >> 'if ...
    >> goto loop
    >>
    >>
    >> LED5ON: high 5 'LED 5 ON (LED + resist from pin to GND)
    >> goto loop
    >>
    >> LED5OFF: low 5 'LED 5 OFF
    >> goto loop
    >>
    >> LED4ON: high 4 'LED 4 ON
    >> goto loop
    >>
    >> LED4OFF: low 4 'LED 4 OFF
    >> goto loop
    >>
    >> '.....: ........
    >> '.....: actions You want
    >> 'goto loop
    >> end
    >>
    >> With your PC-RS232-Monitor You can switch the called pins of
    >BS2-IC,
    >> adressed with
    >> presetted char.
    >> For example, with keying "B51" + (ENTER or any nonnum.key):
    >> BASIC Stamp 2 , adressed with "B" , LED on pin 5 will lights on.
    >> Today tested,- works fine ! Klau
    >
    >
    >

    HI Chundle,
    the wanted answers for the two points of questions above in shortnes:

    1. RS232 "inverted" mode, used in BASIC Stamps SERIN.../SEROUT
    statements,also
    known as "direct connection" is a solution to avoid the "normaly" used
    TTL <==> RS232 level converter, like the classic MAX 232 - IC.
    With RS232-specification you see
    TTL HIGH <==> RS232 about -10V
    TTL LOW <==> RS232 about +10V

    For easy/cheapy connecting (without inserting such level converter
    ) two things
    are to do:
    1.1 invert the signal in BASIC Stamp itself
    (gives the name "inverted" ) with setting the
    parameter
    for this, included in baudmode.
    1.2 For driving a TTL -Input (clamped with inner
    diodes
    to about > -0.6 Volt and < 5.5Volt) you need a
    simple
    resist only to limit the current for clamping.
    Calculate for HIGH : (10V-5.5V)/22kOhm = 0.2mA.
    Because the RS232 - switching level is some
    positive,
    near zero, CMOS TTL-Output switches the RS232-input
    with a simple wire.-


    2. 2.1 With point 1.2. you see "in series",
    connecting RS232 OUT to TTL IN.
    2.2 It should be (!) possible to use one resist
    for "some",
    perhaps "all", connected BASIC Stamps, for the
    used
    pins all as inputs, of course.
    You should calculate the current with single
    resists
    for each BASIC Stamp in relation to PC's RS232
    inner
    resist. But I think You don't use a lot of BASIC Stamps
    in your little network...

    Chundle, hope again this helps for you. See also to:

    1. BASIC STAMP MANUAL V1.9 page 307... , 309....
    2. "BASIC Stamp Second Edition" ,Kuehnel.C/Zahnert.K, ISBN 0-7506-7245-5,
    year 2000
    Detailed items and hints for RS232 connection PC <==> BASIC Stamp:
    Chapter 7.1.1

    Regards Klaus Zahnert
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-21 03:28
    Hello Klaus:

    Thanks so much for taking the time to explain this to me. However I'm
    still confused -- if the stamp (I'm using Stamp II) already has its
    own dedicated serial pins (serial in being rpin 16 according to the
    manual) why do I need to do any conversion, inversion or adding
    resistor? In fact, I used your programme directly and just changed
    the
    statement to "serin 16" and it worked fine. Does what you write below
    only apply to Stamp I which I understand doesn't have dedicated
    serial
    pins?

    Thanks again so much for your patience! Also, thanks to Jon Williams
    for the alternate code!

    Chundle

    --- In basicstamps@egroups.com, Klaus Zahnert <kzahnert@d...> wrote:
    > HI Chundle,
    > the wanted answers for the two points of questions above in
    shortnes:
    >
    > 1. RS232 "inverted" mode, used in BASIC Stamps SERIN.../SEROUT
    > statements,also
    > known as "direct connection" is a solution to avoid the "normaly"
    used
    > TTL <==> RS232 level converter, like the classic MAX 232
    -
    IC.
    > With RS232-specification you see
    > TTL HIGH <==> RS232 about -10V
    > TTL LOW <==> RS232 about +10V
    >
    > For easy/cheapy connecting (without inserting such level
    converter
    > ) two things
    > are to do:
    > 1.1 invert the signal in BASIC Stamp itself
    > (gives the name "inverted" ) with
    setting the
    > parameter
    > for this, included in baudmode.
    > 1.2 For driving a TTL -Input (clamped with
    inner
    > diodes
    > to about > -0.6 Volt and < 5.5Volt)
    you
    need a
    > simple
    > resist only to limit the current for clamping.
    > Calculate for HIGH : (10V-5.5V)/22kOhm
    =
    0.2mA.
    > Because the RS232 - switching level is
    some
    > positive,
    > near zero, CMOS TTL-Output switches the RS232-input
    > with a simple wire.-
    >
    >
    > 2. 2.1 With point 1.2. you see "in series",
    > connecting RS232 OUT to TTL IN.
    > 2.2 It should be (!) possible to use one
    resist
    > for "some",
    > perhaps "all", connected BASIC Stamps,
    for the
    > used
    > pins all as inputs, of course.
    > You should calculate the current with
    single
    > resists
    > for each BASIC Stamp in relation to
    PC's
    RS232
    > inner
    > resist. But I think You don't use a lot of BASIC Stamps
    > in your little network...
    >
    > Chundle, hope again this helps for you. See also to:
    >
    > 1. BASIC STAMP MANUAL V1.9 page 307... , 309....
    > 2. "BASIC Stamp Second Edition" ,Kuehnel.C/Zahnert.K, ISBN
    0-7506-7245-5,
    > year 2000
    > Detailed items and hints for RS232 connection PC <==> BASIC
    Stamp:
    > Chapter 7.1.1
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-21 03:30
    Just for reference, to avoid future confusion in the archives etc., I
    believe this message is directed towards the poster "Chundle Chundle"[noparse]:)[/noparse]

    Paul

    On Wed, 20 Sep 2000, William E. Mrozinski wrote:

    > Paul,
    >
    > If serial data exchange between multiple stamps is required, your going
    > to have to build a 'simple serial network' that all the stamps can attach
    > to. Research RS-485 for your simple net. Each stamp, once attached to the
    > net, will have to constantly watch all messages, filtering for messages sent
    > specifically to it, and then act on the message. This is a bit complex, but
    > well documented if you search some. Start with ( and maybe end with! It's
    > that good! ) Jan Axelsons' Serial Port Complete book (
    > http://www.lvr.com/spc.htm ). She has provided a project ( including
    > examples for Stamps ) to do just this. Good Luck!
    >
    > Bill Mrozinski - DCS
    >
    > "Paul J. Csonka" wrote:
    >
    > > Good day,
    > >
    > > I just wonder, if all you are doing is switching leds, perhaps
    > > eight stamps would be overkill in terms of money and energy. If you use
    > > any kind of serial latch, you require but one stamp. You would not have
    > > the problem you are trying to solve.
    > > Unless you are doing this just to figure out how; then please
    > > disregard the latter comments...
    > >
    > > Have nice evening,
    > > Paul
    > >
    > > On Wed, 20 Sep 2000, Chundle Chundle wrote:
    > >
    > > > Hello:
    > > >
    > > > I will be using 8 BS 2 stamps, each doing relatively simple tasks
    > > > (switching on and off leds) under the control of my computer. My
    > > > intention is that the computer will communicate during runtime with
    > > > the stamps via the serial connection. I would like to connect all the
    > > > stamps to the same serial port (basically in parallel) and the send
    > > > information to all of them and have each one listen out for its own
    > > > "name". Following the name will be a code describing what it needs to
    > > > do (i.e. switch on led ). For example I might send something like:
    > > >
    > > > B,5
    > > >
    > > > which means Stamp No. B, switch on LED 5.
    > > >
    > > > Will this work the way I hope it will? I know there was a problem
    > > > with
    > > > doing this on the BS 1, because there was the danger of shorting the
    > > > serial connection to ground, but it seems it should be okay for the
    > > > BS2 since it has separate serial pins. Also, I don't need the stamps
    > > > to communicate back to the computer. Are there any precautions I
    > > > should take, or should it all work just the way I think it will (ha!
    > > > as if it ever does....)
    > > >
    > > > Thanks for any advice
    > > >
    > > >
    > > >
    > > >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-21 14:38
    At 02:28 21.09.2000 -0000, you wrote: (snipped the appended past messages )
    >Hello Klaus:
    >
    >Thanks so much for taking the time to explain this to me. However I'm
    >still confused -- if the stamp (I'm using Stamp II) already has its
    >own dedicated serial pins (serial in being rpin 16 according to the
    >manual) why do I need to do any conversion, inversion or adding
    >resistor? In fact, I used your programme directly and just changed
    >the
    >statement to "serin 16" and it worked fine. Does what you write below
    >only apply to Stamp I which I understand doesn't have dedicated
    >serial
    >pins?
    >
    >Thanks again so much for your patience! Also, thanks to Jon Williams
    >for the alternate code!
    >
    >Chundle
    >

    HI Chundle,

    BS2-IC Pins 0...15:
    Comes with CMOS-TTL-features for common use input/output.
    For this you have to provide the hardware conditions (like level, direction)
    to use the input/output-statements of PBASIC-language. Two of this are
    SERIN.., SEROUT. You have to handle these as described in my message before.

    BS2-IC rpin 16:
    is a logical name (there is no "rpin16" on board). As you see from scheme,
    there are the TX/RX/ATN-lines to get the dialog with PC while downloading
    or debugging.But while running the program you can use TX/RX also for SERIN
    16,...;
    SEROUT 16, ...without any additional components. ("cable is enough") .

    See to message from Jon Willims:
    >SERIN 16,84,[noparse][[/noparse]WAIT ("B"),DEC LEDcmd]
    In his contribution he use the pin-number 16.
    Take attention for baudrate 84 instead of 16468 because there are hardware
    inverted signals for this (!) pin-number (with transistors on BS2-IC).

    Regards Klaus Zahnert
Sign In or Register to comment.