Shop OBEX P1 Docs P2 Docs Learn Events
How long does a BS2 take to send a number? - CLOSED — Parallax Forums

How long does a BS2 take to send a number? - CLOSED

davejamesdavejames Posts: 4,047
edited 2009-12-11 22:57 in BASIC Stamp
Hi All,

I'm bashing my way through understanding serial communication between a BS2 and VB2005; a question has popped up...

---> How long does it take a BS2 to send a number if the BS2 is set up for 9600 baud (baudmode 16468)?

I've read the SERIN/SEROUT chapters in the programming reference·and Nuts&Volts column #16 "Serin and Serout Demystified" - no help.· Values of time calculated from information in these writings make no sense.


Grateful for any insight,

DJ




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Post Edited (davejames) : 12/11/2009 9:34:12 PM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-12-11 20:51
    DJ,

    9600 bps translates to roughly 960 bytes per second with a single binary value (number) taking 10 bites to send...start, 8 data bits and stop bit. There is however the load time of the instruction and the setup time of formatting or parameters, so really the time it takes is variable depending on a number of factors. About all you can be sure on is once the first bit leaves, the others will be at the same bit rate making the actual transfer of the number take 1/960th of a second. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    Check out the new Savage Circuits TV!
    ·
  • davejamesdavejames Posts: 4,047
    edited 2009-12-11 21:07
    Mr. Savage,

    Thank you, yes it helps.

    Can you resolve for me a comment in the Nuts&Volts column #16 "Serin and Serout Demystified"? It's located between Tables 16.1 and 16.2 ("One frame of serial data", "SC2-IC baudmode dissected"). The comment reads:

    -->"The BS2's internal process for organizing and sending the bits apparently involves 20ms of overhead..."

    Is this overhead what you were referring to as "...the load time of the instruction...setup time of formatting..."?

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Instead of:

    "Those who can, do.· Those who can't, teach." (Shaw)
    I prefer:
    "Those who know, do.· Those who understand, teach." (Aristotle)
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-12-11 21:29
    DJ,

    20 mS seems like a long time...I don't think it takes that long, but there is loading the instruction from the EEPROM as well as setting up the parameters for the transmit. This can take more time than sending a single byte @ 9600 bps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    Check out the new Savage Circuits TV!
    ·
  • davejamesdavejames Posts: 4,047
    edited 2009-12-11 21:31
    ...ok, thanks.

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-12-11 21:36
    As a final note, if you have a scope, or even better, a logic analyzer, you can make a pin go high, set another pin high and then send data from another pin. By subtracting the time difference between setting the two pins high you can get an idea how much longer it takes to send the serial data. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    Check out the new Savage Circuits TV!
    ·
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-12-11 21:47
    Additional unoofficial information on the timing of the serial commands is available here: www.emesystems.com/BS2rs232.htm#sertime.

    For example in the following statement,
    SEROUT 14\15,$54,[noparse][[/noparse]dec x] ' 3500 microseconds setup, extra 180 us between bytes
    it takes a BS2 about 3.5 milliseconds from the time p15 allows flow until the first start bit of the data. Then, between each decimal digit, there is an extra 180 microseconds, which amounts to a total of 2.8 stop bits (including the usual 1). The setup time is about 500 microseconds longer if flow control is not used.

    The minimum setup time comes from statements like
    SEROUT 14\15,$54,[noparse][[/noparse]x] ' setup 480 us, or 920 us without flow control
    The process of formatting data (DEC, HEX) eats up processing time before the first bit is sent. The fastest intercharacter times come from the STR modifier for an array:
    SEROUT 14,$54,[noparse][[/noparse]STR x\6] ' setup 980 us, intercharacter ~2.5 stop bits total.

    If the statement is in a loop, there will be lots of time spent interpreting instruction code. Echoing what Chris said, the time it takes is variable depending on a number of factors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • davejamesdavejames Posts: 4,047
    edited 2009-12-11 22:57
    Mr. Savage & Mr. Allen,

    Thank you for follow up information. I'll copy this into my lab notes.


    Merry Christmas to you,

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.