Serial Timing issue
I have set up a network of BS2s and a PC through RS485. I also created a
communication protocol which first sends a flag and then an address,
communicating at 2400bps. The problem that I am experiencing is that some
data can be lost if the stamp does any calculations between receiving bytes
in a frame. For instance, if the basic code checks the first byte to verify
that it is a flag, and it is, the BS misses the second byte. It can receive
both if I set the stamp up to wait for both and then check for the flag,
but I run into other frame sync problems with this type of a setup. Right
now I am having the PC wait an interval between the flag and the next byte
(address). Is there any way to prevent the BS2 from missing data?
Technically the chip is fast enough to receive the first byte, do the
calculation, and then receive the second byte. What's going on here????
-Nick
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
communication protocol which first sends a flag and then an address,
communicating at 2400bps. The problem that I am experiencing is that some
data can be lost if the stamp does any calculations between receiving bytes
in a frame. For instance, if the basic code checks the first byte to verify
that it is a flag, and it is, the BS misses the second byte. It can receive
both if I set the stamp up to wait for both and then check for the flag,
but I run into other frame sync problems with this type of a setup. Right
now I am having the PC wait an interval between the flag and the next byte
(address). Is there any way to prevent the BS2 from missing data?
Technically the chip is fast enough to receive the first byte, do the
calculation, and then receive the second byte. What's going on here????
-Nick
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Comments
The BS can always miss data if it is doing something else while receiving
data.
A scheme that I used is an acknowledge scheme, assuming you have control
over
what the pc sends and receives:
STAMP PC
Send 'I am ready to receive data' ---->
<---- dataframe or NAK if no data
Send NAK if transmission error
Send ACK if data ok and want more ---->
Send TBE if data ok and pause
This way the BS is in control. The BS can send data to the PC at any time.
(btw, TBE stands for Transmission Block End)
If you have no control over what the pc sends it is best to read in an
entire
Frame, like you said, and do calculations after receiving the frame.
I am sure you can rearrange some of your code so that it doesn't conflict
with other parts of your code.
Hope that helps.
Regards peter
Oorspronkelijk bericht
Van: Nick H [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XirEEHyyEHIxKM-GHaNw97TDifVSMhZdMuNiCyGl9IWSZ3Ab6wHBRoXqhlVGQsywwtXz2_2BczQ57sc]lightclb@y...[/url
Verzonden: vrijdag 21 december 2001 22:06
Aan: basicstamps@yahoogroups.com
Onderwerp: [noparse][[/noparse]basicstamps] Serial Timing issue
I have set up a network of BS2s and a PC through RS485. I also created a
communication protocol which first sends a flag and then an address,
communicating at 2400bps. The problem that I am experiencing is that some
data can be lost if the stamp does any calculations between receiving bytes
in a frame. For instance, if the basic code checks the first byte to verify
that it is a flag, and it is, the BS misses the second byte. It can receive
both if I set the stamp up to wait for both and then check for the flag,
but I run into other frame sync problems with this type of a setup. Right
now I am having the PC wait an interval between the flag and the next byte
(address). Is there any way to prevent the BS2 from missing data?
Technically the chip is fast enough to receive the first byte, do the
calculation, and then receive the second byte. What's going on here????
-Nick
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
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/
an industrial setting. I don't want to make each receive the entire frame
because of framing and transmission errors, i.e. if one misses a start byte,
it will forever be out-of-sync with the rest.
-Nick
Original Message
From: "peter verkaik" <peterverkaik@b...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 22, 2001 9:56 AM
Subject: RE: [noparse][[/noparse]basicstamps] Serial Timing issue
> Hi,
>
> The BS can always miss data if it is doing something else while receiving
> data.
> A scheme that I used is an acknowledge scheme, assuming you have control
> over
> what the pc sends and receives:
>
> STAMP PC
>
> Send 'I am ready to receive data' ---->
>
> <---- dataframe or NAK if no data
>
> Send NAK if transmission error
> Send ACK if data ok and want more ---->
> Send TBE if data ok and pause
>
> This way the BS is in control. The BS can send data to the PC at any time.
> (btw, TBE stands for Transmission Block End)
>
> If you have no control over what the pc sends it is best to read in an
> entire
> Frame, like you said, and do calculations after receiving the frame.
> I am sure you can rearrange some of your code so that it doesn't conflict
> with other parts of your code.
>
>
> Hope that helps.
>
> Regards peter
>
>
>
>
Oorspronkelijk bericht
> Van: Nick H [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=o1FeQ5sO8hgoj98rnZlMmif2sYQeEKOnhNb4loNhaRTsRuniJ5y8ZK1ZfDuY7H9f1g4nyy5WSEIPiFT0]lightclb@y...[/url
> Verzonden: vrijdag 21 december 2001 22:06
> Aan: basicstamps@yahoogroups.com
> Onderwerp: [noparse][[/noparse]basicstamps] Serial Timing issue
>
> I have set up a network of BS2s and a PC through RS485. I also created a
> communication protocol which first sends a flag and then an address,
> communicating at 2400bps. The problem that I am experiencing is that some
> data can be lost if the stamp does any calculations between receiving
bytes
> in a frame. For instance, if the basic code checks the first byte to
verify
> that it is a flag, and it is, the BS misses the second byte. It can
receive
> both if I set the stamp up to wait for both and then check for the flag,
> but I run into other frame sync problems with this type of a setup. Right
> now I am having the PC wait an interval between the flag and the next byte
> (address). Is there any way to prevent the BS2 from missing data?
> Technically the chip is fast enough to receive the first byte, do the
> calculation, and then receive the second byte. What's going on here????
> -Nick
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> 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/
>
>
>
> 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/
>
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
>The actual problem is that I will have a large network of maybe 100 BS2s in
>an industrial setting. I don't want to make each receive the entire frame
>because of framing and transmission errors, i.e. if one misses a start byte,
>it will forever be out-of-sync with the rest.
>
>-Nick
Hi Nick -
You may want to take a look at the SNAP Protocol here:
http://www.hth.com/snap/
It has been used successfully with Stamps, and in industrial settings.
Regards,
Bruce Bates
I had a dialogue with Jon Williams of Parallax on this list a week or two
ago with a similar problem. The most elegant & the classic way of solving
this is by using interrupt-driven serial input/output with buffering.
The Basic Stamps do not support this facility on board, currently you have
to add this functionality outside the chip - eg external devices.
Jon can probably amplify on this at length - he also said there was a future
project to address this. I suspect this mught be on different architechture
such as a java-based stamp.
However you might be able to do *something* to solve the problem in the
short term. It requires asserting another pin and handshaking (otherwise
known as flow control).
It does however mean that the sending device hangs around waiting for the
receiver to say that it is ready to receive.
I have snipped Jon's reply to me last week below. Handshaking as Jon
described does not always solve the problem - sometimes the sending device
is not built for flow control.
Regards,
Tony Wells
From Jon Williams:
>Have you considered using flow control with SERIN? My January >article for
>Nuts & Volts magazine shows how to implement a working "co->processor" with
t>he BASIC Stamp. It uses SERIN with flow control and a timeout >parameter.
>If no command comes fromt he master, jumps out to a little task >manager
that
>lets it do a piece of work before checking for the master command >again.
>This strategy is simple and will work in many applications.
Original Message
From: "Nick H" <lightclb@y...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 22, 2001 6:05 AM
Subject: [noparse][[/noparse]basicstamps] Serial Timing issue
Original Message
From: "Nick H" <lightclb@y...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 22, 2001 5:57 PM
Subject: Re: [noparse][[/noparse]basicstamps] Serial Timing issue
> The actual problem is that I will have a large network of maybe 100 BS2s
in
> an industrial setting. I don't want to make each receive the entire frame
> because of framing and transmission errors, i.e. if one misses a start
byte,
> it will forever be out-of-sync with the rest.
>
> -Nick
>
Original Message
> From: "peter verkaik" <peterverkaik@b...>
> To: <basicstamps@yahoogroups.com>
> Sent: Saturday, December 22, 2001 9:56 AM
> Subject: RE: [noparse][[/noparse]basicstamps] Serial Timing issue
>
>
> > Hi,
> >
> > The BS can always miss data if it is doing something else while
receiving
> > data.
> > A scheme that I used is an acknowledge scheme, assuming you have control
> > over
> > what the pc sends and receives:
> >
> > STAMP PC
> >
> > Send 'I am ready to receive data' ---->
> >
> > <---- dataframe or NAK if no data
> >
> > Send NAK if transmission error
> > Send ACK if data ok and want more ---->
> > Send TBE if data ok and pause
> >
> > This way the BS is in control. The BS can send data to the PC at any
time.
> > (btw, TBE stands for Transmission Block End)
> >
> > If you have no control over what the pc sends it is best to read in an
> > entire
> > Frame, like you said, and do calculations after receiving the frame.
> > I am sure you can rearrange some of your code so that it doesn't
conflict
> > with other parts of your code.
> >
> >
> > Hope that helps.
> >
> > Regards peter
> >
> >
> >
> >
Oorspronkelijk bericht
> > Van: Nick H [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=NZE6yDhUdk3h3SyQfuULROV2VPPeM0VoFgVEUsDtiGHMcllwS8Bb6tHCXvZmV3bnZqlq_nMwMZrR]lightclb@y...[/url
> > Verzonden: vrijdag 21 december 2001 22:06
> > Aan: basicstamps@yahoogroups.com
> > Onderwerp: [noparse][[/noparse]basicstamps] Serial Timing issue
> >
> > I have set up a network of BS2s and a PC through RS485. I also created a
> > communication protocol which first sends a flag and then an address,
> > communicating at 2400bps. The problem that I am experiencing is that
some
> > data can be lost if the stamp does any calculations between receiving
> bytes
> > in a frame. For instance, if the basic code checks the first byte to
> verify
> > that it is a flag, and it is, the BS misses the second byte. It can
> receive
> > both if I set the stamp up to wait for both and then check for the
flag,
> > but I run into other frame sync problems with this type of a setup.
Right
> > now I am having the PC wait an interval between the flag and the next
byte
> > (address). Is there any way to prevent the BS2 from missing data?
> > Technically the chip is fast enough to receive the first byte, do the
> > calculation, and then receive the second byte. What's going on here????
> > -Nick
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > 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/
> >
> >
> >
> > 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/
> >
> >
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> 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/
>
>
>
Perhaps you already know this, but take a look at
http://www.hth.com/snap/
Here you will find an open network implementation
with lots of BS examples. You may find what you need
there or other useful solutions.
Regards peter
Oorspronkelijk bericht
Van: Nick H [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IWq1AqLURqkFKSlV2Y64r2_2n07amIx5PpFYut5TiMoE3zHWCTgS7NpKPMmVfAc-CjlgJizd4mcdAdJVxQ]lightclb@y...[/url
Verzonden: zaterdag 22 december 2001 9:58
Aan: basicstamps@yahoogroups.com
Onderwerp: Re: [noparse][[/noparse]basicstamps] Serial Timing issue
The actual problem is that I will have a large network of maybe 100 BS2s in
an industrial setting. I don't want to make each receive the entire frame
because of framing and transmission errors, i.e. if one misses a start byte,
it will forever be out-of-sync with the rest.
-Nick
Original Message
From: "peter verkaik" <peterverkaik@b...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 22, 2001 9:56 AM
Subject: RE: [noparse][[/noparse]basicstamps] Serial Timing issue
> Hi,
>
> The BS can always miss data if it is doing something else while receiving
> data.
> A scheme that I used is an acknowledge scheme, assuming you have control
> over
> what the pc sends and receives:
>
> STAMP PC
>
> Send 'I am ready to receive data' ---->
>
> <---- dataframe or NAK if no data
>
> Send NAK if transmission error
> Send ACK if data ok and want more ---->
> Send TBE if data ok and pause
>
> This way the BS is in control. The BS can send data to the PC at any time.
> (btw, TBE stands for Transmission Block End)
>
> If you have no control over what the pc sends it is best to read in an
> entire
> Frame, like you said, and do calculations after receiving the frame.
> I am sure you can rearrange some of your code so that it doesn't conflict
> with other parts of your code.
>
>
> Hope that helps.
>
> Regards peter
>
>
>
>
Oorspronkelijk bericht
> Van: Nick H [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IWq1AqLURqkFKSlV2Y64r2_2n07amIx5PpFYut5TiMoE3zHWCTgS7NpKPMmVfAc-CjlgJizd4mcdAdJVxQ]lightclb@y...[/url
> Verzonden: vrijdag 21 december 2001 22:06
> Aan: basicstamps@yahoogroups.com
> Onderwerp: [noparse][[/noparse]basicstamps] Serial Timing issue
>
> I have set up a network of BS2s and a PC through RS485. I also created a
> communication protocol which first sends a flag and then an address,
> communicating at 2400bps. The problem that I am experiencing is that some
> data can be lost if the stamp does any calculations between receiving
bytes
> in a frame. For instance, if the basic code checks the first byte to
verify
> that it is a flag, and it is, the BS misses the second byte. It can
receive
> both if I set the stamp up to wait for both and then check for the flag,
> but I run into other frame sync problems with this type of a setup. Right
> now I am having the PC wait an interval between the flag and the next byte
> (address). Is there any way to prevent the BS2 from missing data?
> Technically the chip is fast enough to receive the first byte, do the
> calculation, and then receive the second byte. What's going on here????
> -Nick
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> 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/
>
>
>
> 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/
>
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
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/