Shop OBEX P1 Docs P2 Docs Learn Events
Trouble getting reliable serial input — Parallax Forums

Trouble getting reliable serial input

ArchiverArchiver Posts: 46,084
edited 2003-12-23 17:46 in General Discussion
Hi,

I am using a BS2SX to communicate with a motion controller via RS-
232. The controller does not use flow control, but I am only
grabbing one byte from it at a time, so that shouldn't be too much of
a problem. So it works like this: I send a SEROUT command to the
controller from the Stamp asking for status. Then I execute a SERIN
command on the Stamp to grab the one byte result coming back from the
controller. This works most of the time, but occasionally, I beleive
the byte is coming back into the Stamp before the SERIN is ready, and
thus being ignored. Is there some way to make this more reliable, or
speed up the SERIN setup time?

Thanks,
/John

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-23 16:53
    If you are using formatters in your SERIN statement you may want to
    remove them and deal with the data yourself -- but I'm surprise that
    your program works sometimes and not others. Perhaps your issue is a
    signaling thing between the devices. Is the output from your motion
    controller driven or and "open" type output that can be bussed to
    multiple receivers? If the latter, perhaps a stiff pull-up on that
    serial line will cure your ills.

    Happy Holidays.

    -- Jon Williams
    -- Parallax


    Original Message
    From: John Schwab [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Q7zz39BN9i8UgTE2ZCkV_3l4isicxKJpJcjY-n3kTf_ITfPqriUvBkVUo0pEZGiLwMb-2xfZmjHPa9iV4VE]johnschwab5678@y...[/url
    Sent: Tuesday, December 23, 2003 10:23 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Trouble getting reliable serial input


    Hi,

    I am using a BS2SX to communicate with a motion controller via RS- 232.
    The controller does not use flow control, but I am only
    grabbing one byte from it at a time, so that shouldn't be too much of
    a problem. So it works like this: I send a SEROUT command to the
    controller from the Stamp asking for status. Then I execute a SERIN
    command on the Stamp to grab the one byte result coming back from the
    controller. This works most of the time, but occasionally, I beleive
    the byte is coming back into the Stamp before the SERIN is ready, and
    thus being ignored. Is there some way to make this more reliable, or
    speed up the SERIN setup time?

    Thanks,
    /John


    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

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    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-12-23 17:00
    The motion controller has its own processes that are busy to varying
    degrees at different times, so it may sometimes respond faster than
    other times. The serial output is just a plain vanilla RS-232.
    Anyway, when I hook the controller up to a PC serial port, I can read
    from it 100% of the time, and I beleive it is because the serial port
    on the PC is buffered, and can already be listening when I send the
    command out to the controller. Do you know how long it takes for a
    SERIN command to become active/

    /John

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > If you are using formatters in your SERIN statement you may want to
    > remove them and deal with the data yourself -- but I'm surprise that
    > your program works sometimes and not others. Perhaps your issue is
    a
    > signaling thing between the devices. Is the output from your motion
    > controller driven or and "open" type output that can be bussed to
    > multiple receivers? If the latter, perhaps a stiff pull-up on that
    > serial line will cure your ills.
    >
    > Happy Holidays.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: John Schwab [noparse][[/noparse]mailto:johnschwab5678@y...]
    > Sent: Tuesday, December 23, 2003 10:23 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Trouble getting reliable serial input
    >
    >
    > Hi,
    >
    > I am using a BS2SX to communicate with a motion controller via RS-
    232.
    > The controller does not use flow control, but I am only
    > grabbing one byte from it at a time, so that shouldn't be too much
    of
    > a problem. So it works like this: I send a SEROUT command to the
    > controller from the Stamp asking for status. Then I execute a
    SERIN
    > command on the Stamp to grab the one byte result coming back from
    the
    > controller. This works most of the time, but occasionally, I
    beleive
    > the byte is coming back into the Stamp before the SERIN is ready,
    and
    > thus being ignored. Is there some way to make this more reliable,
    or
    > speed up the SERIN setup time?
    >
    > Thanks,
    > /John
    >
    >
    > 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
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > 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-12-23 17:10
    The setup time will depend on the complexity of your SERIN statement,
    and it's tough to measure emperically since it's asynchonous and
    affected by an outside device. That said, I would guess anywhere
    between 250 and 1500 microseconds based on Tracy Allen's measurements of
    Stamp execution speeds.

    FWIW, our Javelin Stamp allows you to create buffers for serial data
    streams. If you're comfortable with C or already know Java it may be
    something to consider.

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



    Original Message
    From: John Schwab [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rUmue4UB4veEuqki_HCo_DvaBC1wMjavgWKnZ_gRo0nXOEplGYYoFfgP5s9VnzIQ5vodkRliqmMzHKMItUDIeQ]johnschwab5678@y...[/url
    Sent: Tuesday, December 23, 2003 11:00 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: Trouble getting reliable serial input


    The motion controller has its own processes that are busy to varying
    degrees at different times, so it may sometimes respond faster than
    other times. The serial output is just a plain vanilla RS-232.
    Anyway, when I hook the controller up to a PC serial port, I can read
    from it 100% of the time, and I beleive it is because the serial port
    on the PC is buffered, and can already be listening when I send the
    command out to the controller. Do you know how long it takes for a
    SERIN command to become active/

    /John

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > If you are using formatters in your SERIN statement you may want to
    > remove them and deal with the data yourself -- but I'm surprise that
    > your program works sometimes and not others. Perhaps your issue is
    a
    > signaling thing between the devices. Is the output from your motion
    > controller driven or and "open" type output that can be bussed to
    > multiple receivers? If the latter, perhaps a stiff pull-up on that
    > serial line will cure your ills.
    >
    > Happy Holidays.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: John Schwab [noparse][[/noparse]mailto:johnschwab5678@y...]
    > Sent: Tuesday, December 23, 2003 10:23 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Trouble getting reliable serial input
    >
    >
    > Hi,
    >
    > I am using a BS2SX to communicate with a motion controller via RS-
    232.
    > The controller does not use flow control, but I am only
    > grabbing one byte from it at a time, so that shouldn't be too much
    of
    > a problem. So it works like this: I send a SEROUT command to the
    > controller from the Stamp asking for status. Then I execute a
    SERIN
    > command on the Stamp to grab the one byte result coming back from
    the
    > controller. This works most of the time, but occasionally, I
    beleive
    > the byte is coming back into the Stamp before the SERIN is ready,
    and
    > thus being ignored. Is there some way to make this more reliable,
    or
    > speed up the SERIN setup time?
    >
    > Thanks,
    > /John
    >
    >
    > 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
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > 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...


    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

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    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-12-23 17:46
    Hi John,

    Some of the serial timings that Jon mentioned are posted at this URL:

    http://www.emesystems.com/BS2rs232.htm#sertime
    http://www.emesystems.com/BS2speed.htm

    The BS2sx is faster than the BS2, and I had noted 190 microseconds as
    the wait before ready on the following command:
    x var byte
    serin 15,$54,2,comNotReady,[noparse][[/noparse]x] ' (without flow)
    ' 480 microseconds for BS2
    ' 190 microseconds for BS2SX
    It would be somewhat faster without the timeout parameters.

    -- Tracy




    >The setup time will depend on the complexity of your SERIN statement,
    >and it's tough to measure emperically since it's asynchonous and
    >affected by an outside device. That said, I would guess anywhere
    >between 250 and 1500 microseconds based on Tracy Allen's measurements of
    >Stamp execution speeds.
    >
    >FWIW, our Javelin Stamp allows you to create buffers for serial data
    >streams. If you're comfortable with C or already know Java it may be
    >something to consider.
    >
    >-- Jon Williams
    >-- Applications Engineer, Parallax
    >-- Dallas Office
    >
    >
    >
    >
    Original Message
    >From: John Schwab [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=wGZaTuaXLSZz2y1PZRpI1_ia9ECWV-eJ8wGzUXAXiQ_BJrtkRFyIW70NuSd17HtcwZs9e6-ohk7jFgT1sseOpfwINQ]johnschwab5678@y...[/url
    >Sent: Tuesday, December 23, 2003 11:00 AM
    >To: basicstamps@yahoogroups.com
    >Subject: [noparse][[/noparse]basicstamps] Re: Trouble getting reliable serial input
    >
    >
    >The motion controller has its own processes that are busy to varying
    >degrees at different times, so it may sometimes respond faster than
    >other times. The serial output is just a plain vanilla RS-232.
    >Anyway, when I hook the controller up to a PC serial port, I can read
    >from it 100% of the time, and I beleive it is because the serial port
    >on the PC is buffered, and can already be listening when I send the
    >command out to the controller. Do you know how long it takes for a
    >SERIN command to become active/
    >
    >/John
    >
    >--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    >wrote:
    >> If you are using formatters in your SERIN statement you may want to
    >> remove them and deal with the data yourself -- but I'm surprise that
    >> your program works sometimes and not others. Perhaps your issue is
    >a
    >> signaling thing between the devices. Is the output from your motion
    >> controller driven or and "open" type output that can be bussed to
    >> multiple receivers? If the latter, perhaps a stiff pull-up on that
    >> serial line will cure your ills.
    >>
    >> Happy Holidays.
    >>
    >> -- Jon Williams
    >> -- Parallax
    >>
    >>
    >>
    Original Message
    >> From: John Schwab [noparse][[/noparse]mailto:johnschwab5678@y...]
    >> Sent: Tuesday, December 23, 2003 10:23 AM
    >> To: basicstamps@yahoogroups.com
    >> Subject: [noparse][[/noparse]basicstamps] Trouble getting reliable serial input
    >>
    >>
    >> Hi,
    >>
    >> I am using a BS2SX to communicate with a motion controller via RS-
    >232.
    >> The controller does not use flow control, but I am only
    >> grabbing one byte from it at a time, so that shouldn't be too much
    >of
    >> a problem. So it works like this: I send a SEROUT command to the
    >> controller from the Stamp asking for status. Then I execute a
    >SERIN
    >> command on the Stamp to grab the one byte result coming back from
    >the
    >> controller. This works most of the time, but occasionally, I
    >beleive
    >> the byte is coming back into the Stamp before the SERIN is ready,
    >and
    >> thus being ignored. Is there some way to make this more reliable,
    >or
    >> speed up the SERIN setup time?
    >>
    >> Thanks,
    >> /John
    >>
    >>
    >> 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
    >>
    >> To visit your group on the web, go to:
    >> http://groups.yahoo.com/group/basicstamps/
    >>
    >> To unsubscribe from this group, send an email to:
    >> basicstamps-unsubscribe@yahoogroups.com
    >>
    >> 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...
    >
    >
    >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
    >
    >To visit your group on the web, go to:
    >http://groups.yahoo.com/group/basicstamps/
    >
    >To unsubscribe from this group, send an email to:
    >basicstamps-unsubscribe@yahoogroups.com
    >
    >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....
    >
    >
    >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
    >
    >To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    >To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    >Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
Sign In or Register to comment.