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

Serial Communication

ArchiverArchiver Posts: 46,084
edited 2004-06-29 02:40 in General Discussion
I need some kind of program or advice on how to write some kind of
program that will allow me to send characters or character strings
through the serial port. Anything to do with C++ or visual basic i
can understand. I was thinking about using the C++ bios.h file and
its functions to go about doing this. Is this a good idea?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-03-29 13:38
    Have a look at http://www.al-williams.com/stampcom.zip. Examples there
    with C++ or Visual Basic.

    I think www.rentron.com has some serial examples. Plenty of serial
    advice at www.lvr.com also.

    I would not use bios.h unless I was under DOS. In Windows you may have
    lots of serial ports the bios doesn't know about (the machine I am using
    right now has 10 com ports...)

    Al Williams
    AWC
    * Floating point math for the Stamp, PIC, SX, or any microcontroller
    http://www.al-williams.com/awce/pak1.htm



    >
    Original Message
    > From: compsci2522003 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=3aNn95od-1EF6fSyBUX37lBIJXY1gbNCzsZ59B6DTWuH5s7TAr1eQhQ4c1yYLX-wtHwRm_fBWDDZzPdmcEWPQQ]waseemthedream@h...[/url
    > Sent: Monday, March 25, 2002 9:21 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Serial Communication
    >
    >
    > I need some kind of program or advice on how to write some kind of
    > program that will allow me to send characters or character strings
    > through the serial port. Anything to do with C++ or visual basic i
    > can understand. I was thinking about using the C++ bios.h file and
    > its functions to go about doing this. Is this a good idea?
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 07:40
    Good morning Stampers,

    I have a question concerning serial communication. I am working on a project
    involving a CMU-cam that sends serial data to the stamp. The lowest baudrate
    the CMU can handle is the highest that the stamp can handle. I got it
    working somehow but very often the data are corrupted like parts of it
    missing or sometimes even nothing appears.
    Is there any chance to put a BAUD-SLOWER between the stamp and the cmu?
    (isn't that a nice word? :-)
    I am not depending on speed in that project. so 2400b would be perfectly ok
    for me.

    Thanks for any suggestions,

    Uli


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 07:51
    At 08:40 AM 11/21/02 +0100, you wrote:
    >Good morning Stampers,
    >
    >I have a question concerning serial communication. I am working on a project
    >involving a CMU-cam that sends serial data to the stamp. The lowest baudrate
    >the CMU can handle is the highest that the stamp can handle. I got it
    >working somehow but very often the data are corrupted like parts of it
    >missing or sometimes even nothing appears.
    >Is there any chance to put a BAUD-SLOWER between the stamp and the cmu?
    >(isn't that a nice word? :-)
    >I am not depending on speed in that project. so 2400b would be perfectly ok
    >for me.
    >
    >Thanks for any suggestions,
    >
    >Uli
    >
    >Uli-

    What is the baud rate of the CMU-cam ?

    Regards,

    Bruce Bates
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 08:05
    which stamp do you use? you may try a BS2sx or BS2p which are faster
    and thus can better handle the high baud rates.

    second you probably should look at the electrical characteristics of
    your circuitry: shielding, grounding layout, cable lengths, etc.

    maybe a memory buffer between the cam and the stamp may help. The
    buffer should be big enough to hold one full image at least.
    In the early times such buffers were popular for printers.

    regards
    adrian
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 12:11
    According to my CMU Cam manual the baud rates are 115,200 baud or 38,400
    baud for serial communication (default is 115,200). Perhaps that is your
    problem if your using 9600 baud.


    Original Message
    From: ulibasic [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=tm6TKdQwfGItoI8GEmxZRDQ0MlChDAjROrelvO9tHyfVhO_P0WLj1k8r0tnVN6fhhv3OHfGjZQqajl6ilnusLY1Nbv1PBIX4]ulibasic@r...[/url
    Sent: Thursday, November 21, 2002 3:26 AM
    To: basicstamps@yahoogroups.com
    Subject: AW: [noparse][[/noparse]basicstamps] serial communication




    What is the baud rate of the CMU-cam ?

    Hi Bruce, it is 9600 baud

    Regards,

    Bruce Bates



    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.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




    [noparse][[/noparse]Non-text portions of this message have been removed]


    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.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-12 08:10
    Trying to make BS2 to talk to PC via serial
    communication by using a visual basic 6 window
    program. Need to know if there is any existing
    program that I can use, rather than reinventing the
    wheel. Thank you for any help that I can get.

    George

    __________________________________
    Do you Yahoo!?
    Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
    http://calendar.yahoo.com
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-12 17:48
    Yes. GOTO our web site and look in the Nuts & Volts downloads section. The
    latest [noparse][[/noparse]best information] is column #89: Data Exchange With Visual Basic.

    -- Jon Williams
    -- Parallax


    In a message dated 6/12/2003 2:11:13 AM Central Standard Time,
    gyan48@y... writes:

    > Trying to make BS2 to talk to PC via serial
    > communication by using a visual basic 6 window
    > program. Need to know if there is any existing
    > program that I can use, rather than reinventing the
    > wheel. Thank you for any help that I can get.
    >
    > George



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-23 19:44
    On 18.Juni I asked for a Hint for a:

    9600, Odd, 1, 8 Communication Parameters for the Basic-Stamp II.

    Didn´t expected to ask such a difficult Question.

    Can ANYBODY help me???

    I Need a solution between Basic-Stamp II and a Converter for the ODD
    Parity Problem.

    The Max 232 Only Handles the 5V-TTL to 12V-IEE433 Problem.

    I need something like a Buffer for 8 Bits In-Buffer and out 9 Bits
    with ODD Parity. Software-Control ist about too risky for me (but if
    it´s working..), I think more about a Hardware-Solution.

    thanks in common
    Alex
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-23 20:09
    The built-in 'software UART' 'bit-bang' SERIN/SEROUT
    modes don't support ODD parity. They only support
    8-bit No, and 7-bit Even.

    You may have to go to a true UART chip. I'd recommend
    the Maxim 3110 chip. It is a 28-pin narrow DIP, with
    an SPI interface to the Stamp. You need a 3.6864 MHz
    crystal to go with it, with two tiny 10 pF caps.
    With this package, you get a true send/receive UART,
    and no-extra-capacitor RS232 2 drivers/2 recievers.

    Having just looked at the data sheet, there
    is a problem. If you want ODD parity, you'll have
    to calculate the parity bit yourself. The 3110 will
    support SENDING the parity bit, but it won't
    automatically calculate the parity bit. You could
    use a long 'lookup' command to find the ODD parity
    bit for a given byte.

    It does have an 8-bit buffer, so your BS2 can do
    other things besides just taking data.

    --- In basicstamps@yahoogroups.com, "harveyhase68" <yahoo@p...> wrote:
    > On 18.Juni I asked for a Hint for a:
    >
    > 9600, Odd, 1, 8 Communication Parameters for the Basic-Stamp II.
    >
    > Didn´t expected to ask such a difficult Question.
    >
    > Can ANYBODY help me???
    >
    > I Need a solution between Basic-Stamp II and a Converter for the
    ODD
    > Parity Problem.
    >
    > The Max 232 Only Handles the 5V-TTL to 12V-IEE433 Problem.
    >
    > I need something like a Buffer for 8 Bits In-Buffer and out 9 Bits
    > with ODD Parity. Software-Control ist about too risky for me (but
    if
    > it´s working..), I think more about a Hardware-Solution.
    >
    > thanks in common
    > Alex
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-24 14:23
    Alex-

    If you get to choose what will be transmitted, your Stamp can do
    this, in effect. Essentially, you must only transmit bytes with even
    parity over the 8 bits of the byte itself. The stop bit generated
    by the Stamp, when interpreted by your receiving device as a parity
    bit, will then create an odd parity over the perceived data+parity
    bits, and the follow-on idle line will serve as a stop bit. Use the
    PACE argument if needed to ensure adequate idle time following the
    "real" stop bit.

    Otherwise you're probably looking at a custom, external solution.

    Regards,

    Steve

    On 23 Jun 03 at 18:44, harveyhase68 wrote:

    > On 18.Juni I asked for a Hint for a:
    >
    > 9600, Odd, 1, 8 Communication Parameters for the Basic-Stamp II.
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 04:22
    I have an Infocus LP280 projector that I use in a multimedia
    presentation at our museum (Shreveport LA)and trying to turn it on
    and off using a BS2. I tried wiring directly into the remote
    control and with the help of simple reed relay but it is not very
    reliable.

    The LP280 has an RS232 port but the command structure is very
    confusing. According to their manual:

    +++++++++++++++++
    The message sent to the projector is divided into a header(7 bytes)
    and a body part(6 bytes)
    The message has the following structure:
    Magic Number Body Size CRC
    0xBE 0xEF 0x80 0xo6 0x00 CRC_Lo CRC_Hi

    The Body has the following structure
    Operation Type Function Value
    OpTypeLo 0x00 funcNum_Io Opval_lo Opval_hi

    And, according to the manual again, the command to turn power on
    should be:
    0xBE 0xEF 0x80 0x06 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x00
    +++++++++++++++++++++++

    My main question is what the heck is the "0x" preceeding each byte.
    The second question, how would I send this long command, should I
    just enclose it in hyphens and send it?

    Any help deciphering this would be most appreciated

    Al
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 05:26
    Hello,

    0x indicates that the commands are in HEX numerical code. You cannot
    enclose them in Quotes like "". Quotes indicates to the Stamp to send its
    data out as readable ASCII text that a person can read.

    If this group cannot help you or you cannot seem to get it together, my I
    sugges calling Louisiana Tech in Ruston. I went there. The Engineering
    Dept. may be able to get a student to help you.

    Brian
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 08:32
    From: "brownstamp" <brownstamp@y...>

    > the command to turn power on should be:
    > 0xBE 0xEF 0x80 0x06 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x00
    > +++++++++++++++++++++++
    >
    > My main question is what the heck is the "0x" preceeding each byte.
    > The second question, how would I send this long command, should I
    > just enclose it in hyphens and send it?
    >
    Put it in EEPROM with a data directive, and then read and send it one byte
    at a time. The data directive and a loop to read the values from EEPROM
    would look like this:

    PowerOnCmd DATA $BE, $EF, $80, $06, $00, $00, $00, $01, $00, $01, $00, $01,
    $00
    ThisCmdByte VAR Byte
    Pos VAR Nib

    '
    [noparse][[/noparse] Main
    Code ]
    Main:

    FOR pos=0 TO 12
    READ PowerOnCmd+Pos, ThisCmdByte
    DEBUG HEX2(ThisCmdByte)," "
    NEXT
    END

    This just displays the value, and note that the HEX2() function is changing
    those hexadecimal values in EEPROM into characters we expect to see. The raw
    values would look like command bytes to the debug terminal and would not
    display properly. You don't want that with your SEROUT command. Just send
    the bits as they are in the variable ThisCmdByte. Of course you can change
    all those labels to be anything you like. (I'm too lazy to work out the
    details of the SEROUT command, which I haven't gotten around to needing yet,
    but take away the HEX2 when you do that yourself.)

    The dollar sign is PBASIC's way of indicating that the characters that
    follow are to be interpreted as a hexadecimal value. The 0x is another
    convention for the same purpose.

    Gary
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 13:00
    Many thanks for your comprehensive reply. I will try this tonight.

    --- In basicstamps@yahoogroups.com, "Gary W. Sims" <simsgw@c...>
    wrote:
    > From: "brownstamp" <brownstamp@y...>
    >
    > > the command to turn power on should be:
    > > 0xBE 0xEF 0x80 0x06 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x00
    > > +++++++++++++++++++++++
    > >
    > > My main question is what the heck is the "0x" preceeding each
    byte.
    > > The second question, how would I send this long command, should I
    > > just enclose it in hyphens and send it?
    > >
    > Put it in EEPROM with a data directive, and then read and send it
    one byte
    > at a time. The data directive and a loop to read the values from
    EEPROM
    > would look like this:
    >
    > PowerOnCmd DATA $BE, $EF, $80, $06, $00, $00, $00, $01, $00, $01,
    $00, $01,
    > $00
    > ThisCmdByte VAR Byte
    > Pos VAR Nib
    >
    > '
    [noparse][[/noparse] Main
    > Code ]
    > Main:
    >
    > FOR pos=0 TO 12
    > READ PowerOnCmd+Pos, ThisCmdByte
    > DEBUG HEX2(ThisCmdByte)," "
    > NEXT
    > END
    >
    > This just displays the value, and note that the HEX2() function is
    changing
    > those hexadecimal values in EEPROM into characters we expect to
    see. The raw
    > values would look like command bytes to the debug terminal and
    would not
    > display properly. You don't want that with your SEROUT command.
    Just send
    > the bits as they are in the variable ThisCmdByte. Of course you
    can change
    > all those labels to be anything you like. (I'm too lazy to work
    out the
    > details of the SEROUT command, which I haven't gotten around to
    needing yet,
    > but take away the HEX2 when you do that yourself.)
    >
    > The dollar sign is PBASIC's way of indicating that the characters
    that
    > follow are to be interpreted as a hexadecimal value. The 0x is
    another
    > convention for the same purpose.
    >
    > Gary
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 14:06
    The 0x prefix indicates hex -- change that to $ for the BASIC Stamp. If
    you know the baud parameters you can send it out with SEROUT:

    Projector_On:
    SEROUT Spin, Baud, [noparse][[/noparse]$BE, $EF, $80, $06, $00, $00, $00, $01, $00, $01,
    $00, $01, $00]

    Please consult the BASIC Stamp help file or manual for specifics on
    using SEROUT and setting the baud rate.

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


    Original Message
    From: brownstamp [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=NMsl01UgWeVyEnoNKF5yRLq7QyliBM0_n3txP9jzhRfle90ZzYAQMXafhHngGh59ZE_p2nJiHvqL5DWCsFiP]brownstamp@y...[/url
    Sent: Monday, November 03, 2003 10:23 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Serial communication


    I have an Infocus LP280 projector that I use in a multimedia
    presentation at our museum (Shreveport LA)and trying to turn it on
    and off using a BS2. I tried wiring directly into the remote
    control and with the help of simple reed relay but it is not very
    reliable.

    The LP280 has an RS232 port but the command structure is very
    confusing. According to their manual:

    +++++++++++++++++
    The message sent to the projector is divided into a header(7 bytes)
    and a body part(6 bytes)
    The message has the following structure:
    Magic Number Body Size CRC
    0xBE 0xEF 0x80 0xo6 0x00 CRC_Lo CRC_Hi

    The Body has the following structure
    Operation Type Function Value
    OpTypeLo 0x00 funcNum_Io Opval_lo Opval_hi

    And, according to the manual again, the command to turn power on
    should be:
    0xBE 0xEF 0x80 0x06 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x00
    +++++++++++++++++++++++

    My main question is what the heck is the "0x" preceeding each byte.
    The second question, how would I send this long command, should I
    just enclose it in hyphens and send it?

    Any help deciphering this would be most appreciated

    Al



    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.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-04 14:52
    Right, HEX as opposed to decimal. for example 0xAB = decimal
    171. You can use the calulator that comes with windows to
    convert it if needed..

    In most forms of basic, you would use the command chr(171)
    to send send it out. In PBasic use 'dec 171' in the serout
    or debug command. See the documentation for this.
    --
    Regards

    Dave Evartt
    American Hovercraft
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-29 01:31
    Hey everybody,
    I'm new to basic stamps and was wondering if anyone can answer a
    short question for me. Can a basic stamp2 communicate serially
    using I2c of SPI?

    Thanks in advance for any responses I get.

    David
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-29 02:19
    You can do SPI (master only -- the BASIC Stamp always provides the
    clock) with any BS2-family module using the SHIFTOUT and SHIFTIN
    instructions. The BS2p and BS2pe modules have built-in commands for I2C
    (I2COUT and I2CIN) and again, the BASIC Stamp is the master. You can do
    I2C with non-BS2p/pe BASIC Stamp modules, but it requires a bit of code.
    It's not tough, though, I've done it and have made my library of I2C
    routines available for anybody who wants them.

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


    Original Message
    From: David Dupont [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7ksK1Iomg7El8AFAd0LoG0IEMFrYhnHTXniIqwg5sBEnXNN2hmXVXe4rfoLNvByNYGl5VF6SF8CKDbv4wg]dldupont@Q...[/url
    Sent: Monday, June 28, 2004 7:32 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Serial communication


    Hey everybody,
    I'm new to basic stamps and was wondering if anyone can answer a
    short question for me. Can a basic stamp2 communicate serially
    using I2c of SPI?

    Thanks in advance for any responses I get.

    David
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-29 02:40
    The BS2 can act as an SPI 'master' with the
    SHIFTIN and SHIFTOUT commands.

    I believe only the BS2p variants can use I2C
    directly, but I think there are way to use
    a BS2 with I2c in the Nut&Volts section.

    --- In basicstamps@yahoogroups.com, "David Dupont" <dldupont@Q...>
    wrote:
    > Hey everybody,
    > I'm new to basic stamps and was wondering if anyone can answer a
    > short question for me. Can a basic stamp2 communicate serially
    > using I2c of SPI?
    >
    > Thanks in advance for any responses I get.
    >
    > David
Sign In or Register to comment.