Strange serial problems
Archiver
Posts: 46,084
Hi there,
I have a BS2 set up to send and recieve serial data from a microcontroller.
The BS2 sends a single byte to the device, then listens for a single byte
reply. For instance if i send $FF to the device it should return $FF. For
the moment i am displaying the recived data via the debug output. Comms are
running at 19200bps, and both devices are talking TTL levels with the
Stamp's I/O lines directly connected to the serial port of the target
device's microcontroller.
Pin 0 is connected to the target's RX
Pin 5 is connected to the target's TX
Here is my code:
Byte VAR BYTE
Byte = 0
DEBUG "Sending Data", CR
SEROUT 0, 110, [noparse][[/noparse]$FF]
SERIN 5, 110, [noparse][[/noparse]Byte]
DEBUG "Recieved Data", CR
DEBUG Byte, CR
I am using a PC to sniff both serial lines between the target device and
Stamp so i can see in real time what is happening. When the program is
started running it sends $FF to the device as expected, and the device
replies with $FF - however the stamp seems not to have noticed this and sits
waiting for a serial input.
If i use my PC to "inject" an $FF into the line connecting to Pin 5 while
the Stamp is waiting for input, the stamp correctly recieves the byte,
displays it via the debug output and the program stops.
This makes me think that the Stamp isn't quick enough to catch the data on
Pin 5 after it has processed the SEROUT command and misses the data from the
target device? Can anyone throw any light on what i might be doing wrong, or
how to get round the problem? Perhaps i need a faster Stamp?
Many thanks,
Mark.
I have a BS2 set up to send and recieve serial data from a microcontroller.
The BS2 sends a single byte to the device, then listens for a single byte
reply. For instance if i send $FF to the device it should return $FF. For
the moment i am displaying the recived data via the debug output. Comms are
running at 19200bps, and both devices are talking TTL levels with the
Stamp's I/O lines directly connected to the serial port of the target
device's microcontroller.
Pin 0 is connected to the target's RX
Pin 5 is connected to the target's TX
Here is my code:
Byte VAR BYTE
Byte = 0
DEBUG "Sending Data", CR
SEROUT 0, 110, [noparse][[/noparse]$FF]
SERIN 5, 110, [noparse][[/noparse]Byte]
DEBUG "Recieved Data", CR
DEBUG Byte, CR
I am using a PC to sniff both serial lines between the target device and
Stamp so i can see in real time what is happening. When the program is
started running it sends $FF to the device as expected, and the device
replies with $FF - however the stamp seems not to have noticed this and sits
waiting for a serial input.
If i use my PC to "inject" an $FF into the line connecting to Pin 5 while
the Stamp is waiting for input, the stamp correctly recieves the byte,
displays it via the debug output and the program stops.
This makes me think that the Stamp isn't quick enough to catch the data on
Pin 5 after it has processed the SEROUT command and misses the data from the
target device? Can anyone throw any light on what i might be doing wrong, or
how to get round the problem? Perhaps i need a faster Stamp?
Many thanks,
Mark.
Comments
found! Try 2400 or 4800, It if it works try 9600. I have not been able to
get about the 9600 mark reliably...
Good Luck,
Phillip Kocmoud
Original Message
From: Mark Lamond [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=dp3wBziWT_1kvffLloNzXci2pGRhkEM85nK3-5F1Lsvs4YLlSgjeskLS68nU-UswVT_EKHlTvZ_sUFOgSglQ0w]lists@m...[/url
Sent: Saturday, March 15, 2003 11:23 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Strange serial problems
Hi there,
I have a BS2 set up to send and recieve serial data from a microcontroller.
The BS2 sends a single byte to the device, then listens for a single byte
reply. For instance if i send $FF to the device it should return $FF. For
the moment i am displaying the recived data via the debug output. Comms are
running at 19200bps, and both devices are talking TTL levels with the
Stamp's I/O lines directly connected to the serial port of the target
device's microcontroller.
Pin 0 is connected to the target's RX
Pin 5 is connected to the target's TX
Here is my code:
Byte VAR BYTE
Byte = 0
DEBUG "Sending Data", CR
SEROUT 0, 110, [noparse][[/noparse]$FF]
SERIN 5, 110, [noparse][[/noparse]Byte]
DEBUG "Recieved Data", CR
DEBUG Byte, CR
I am using a PC to sniff both serial lines between the target device and
Stamp so i can see in real time what is happening. When the program is
started running it sends $FF to the device as expected, and the device
replies with $FF - however the stamp seems not to have noticed this and sits
waiting for a serial input.
If i use my PC to "inject" an $FF into the line connecting to Pin 5 while
the Stamp is waiting for input, the stamp correctly recieves the byte,
displays it via the debug output and the program stops.
This makes me think that the Stamp isn't quick enough to catch the data on
Pin 5 after it has processed the SEROUT command and misses the data from the
target device? Can anyone throw any light on what i might be doing wrong, or
how to get round the problem? Perhaps i need a faster Stamp?
Many thanks,
Mark.
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/
The problem is that i am stuck with the one baud rate, i can't change it [noparse]:([/noparse]
The only way i can think round it is to have a routine seperate from the
main program constantly monitoring for serial data on my input pin and if it
sees data it stores it in a variable. However i'm not aware of any way to do
this on the Stamp (i have a BS2SX).
Has anyone got any ideas (i am a bit of a Stamp newbie)?
>
> I have had similar problems and reducing the speed was the only solution I
> found! Try 2400 or 4800, It if it works try 9600. I have not been able to
> get about the 9600 mark reliably...
>
> Good Luck,
> Phillip Kocmoud
>
>
Original Message
> From: Mark Lamond [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=NTKfd_7wMc62ohe0d_XOk9Yzeai960yW7-jEEMBHIdXEHmkJaNPDBG1NUp7GLOsUVKcqHVRE6LZsFLzugw]lists@m...[/url
> Sent: Saturday, March 15, 2003 11:23 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Strange serial problems
>
>
>
> Hi there,
>
> I have a BS2 set up to send and recieve serial data from a
> microcontroller.
> The BS2 sends a single byte to the device, then listens for a single byte
> reply. For instance if i send $FF to the device it should return $FF. For
> the moment i am displaying the recived data via the debug output.
> Comms are
> running at 19200bps, and both devices are talking TTL levels with the
> Stamp's I/O lines directly connected to the serial port of the target
> device's microcontroller.
>
> Pin 0 is connected to the target's RX
> Pin 5 is connected to the target's TX
>
> Here is my code:
>
> Byte VAR BYTE
> Byte = 0
>
> DEBUG "Sending Data", CR
> SEROUT 0, 110, [noparse][[/noparse]$FF]
> SERIN 5, 110, [noparse][[/noparse]Byte]
> DEBUG "Recieved Data", CR
> DEBUG Byte, CR
>
> I am using a PC to sniff both serial lines between the target device and
> Stamp so i can see in real time what is happening. When the program is
> started running it sends $FF to the device as expected, and the device
> replies with $FF - however the stamp seems not to have noticed
> this and sits
> waiting for a serial input.
>
> If i use my PC to "inject" an $FF into the line connecting to Pin 5 while
> the Stamp is waiting for input, the stamp correctly recieves the byte,
> displays it via the debug output and the program stops.
>
> This makes me think that the Stamp isn't quick enough to catch the data on
> Pin 5 after it has processed the SEROUT command and misses the
> data from the
> target device? Can anyone throw any light on what i might be
> doing wrong, or
> how to get round the problem? Perhaps i need a faster Stamp?
>
1. Have your slave device wait 1mSec before replying.
(Preferred software only fix)
2. Use the 'Flow' pin in your SERIN cmd. This means
your Sender should monitor the Flow pin from the
receiver until it goes high -- THEN send the byte.
(DO put a 220 ohm resistor in the Flow line to
protect it from the 'two driver' problem)
Device 1) SEROUT DPin\FPin, SerBaud, [noparse][[/noparse]MyChar]
Device 2) SERIN DPin\FPin, SerBaud, [noparse][[/noparse]MyChar]
3. Use a hardware UART -- MAXIM 3100 is 14-pin DIP,
with SPI interface (MUST add 3.8464 MHz crystal + 2 caps)
4. Use some other Stamp compatible device.
The BasicAtom (www.basicmicro.com) is pin compatible,
and has an on-chip hardware UART (HSERIN, HSEROUT) for
this purpose.
--- In basicstamps@yahoogroups.com, "Mark Lamond" <lists@m...> wrote:
>
> Hi, thanks for the info Phillip
>
> The problem is that i am stuck with the one baud rate, i can't
change it [noparse]:([/noparse]
>
> The only way i can think round it is to have a routine seperate
from the
> main program constantly monitoring for serial data on my input pin
and if it
> sees data it stores it in a variable. However i'm not aware of any
way to do
> this on the Stamp (i have a BS2SX).
>
> Has anyone got any ideas (i am a bit of a Stamp newbie)?
>
> >
> > I have had similar problems and reducing the speed was the only
solution I
> > found! Try 2400 or 4800, It if it works try 9600. I have not been
able to
> > get about the 9600 mark reliably...
> >
> > Good Luck,
> > Phillip Kocmoud
> >
> >
Original Message
> > From: Mark Lamond [noparse][[/noparse]mailto:lists@m...]
> > Sent: Saturday, March 15, 2003 11:23 AM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] Strange serial problems
> >
> >
> >
> > Hi there,
> >
> > I have a BS2 set up to send and recieve serial data from a
> > microcontroller.
> > The BS2 sends a single byte to the device, then listens for a
single byte
> > reply. For instance if i send $FF to the device it should return
$FF. For
> > the moment i am displaying the recived data via the debug output.
> > Comms are
> > running at 19200bps, and both devices are talking TTL levels with
the
> > Stamp's I/O lines directly connected to the serial port of the
target
> > device's microcontroller.
> >
> > Pin 0 is connected to the target's RX
> > Pin 5 is connected to the target's TX
> >
> > Here is my code:
> >
> > Byte VAR BYTE
> > Byte = 0
> >
> > DEBUG "Sending Data", CR
> > SEROUT 0, 110, [noparse][[/noparse]$FF]
> > SERIN 5, 110, [noparse][[/noparse]Byte]
> > DEBUG "Recieved Data", CR
> > DEBUG Byte, CR
> >
> > I am using a PC to sniff both serial lines between the target
device and
> > Stamp so i can see in real time what is happening. When the
program is
> > started running it sends $FF to the device as expected, and the
device
> > replies with $FF - however the stamp seems not to have noticed
> > this and sits
> > waiting for a serial input.
> >
> > If i use my PC to "inject" an $FF into the line connecting to Pin
5 while
> > the Stamp is waiting for input, the stamp correctly recieves the
byte,
> > displays it via the debug output and the program stops.
> >
> > This makes me think that the Stamp isn't quick enough to catch
the data on
> > Pin 5 after it has processed the SEROUT command and misses the
> > data from the
> > target device? Can anyone throw any light on what i might be
> > doing wrong, or
> > how to get round the problem? Perhaps i need a faster Stamp?
> >
I am a few months in front of you with various serial problems. Two
great sources of info have been
www.phanderson.com/stamp/tutorial 10.html
www.emesystems.com/BS2rs232.htm
http://www.wd5gnr.com/suart.htm
The second link has a lot of info concerning wait timing between
tx of a command and when the stamp is ready to receive (rx).
The third is a note about a serial buffer. I can only buffer about 8
bits at a time which is too few for my application.
The upshot is the stamp won't be able to receive a command after a tx
command for over 1/2 a second!!
One helpful command only available to the faster chips (I am using
a 2p24 stamp) is the SPSER command. It is an unpublished command that
takes a serin command and places the data in the scratch pad memory
area.
Email me offline and I can give you some of my code and an email from
Jon Williams, who helped me greatly, if you would like.
What I am ending up doing is strapping two stamps together to send a
tx command from one chip and have the other stamp in rx mode waiting
for the reply. It is a bit of a pain. I am just getting into it.
One of the other tricks is keeping the baud rates down. I am stuck
because my external devices are only 9600.
If you need any ttl to rs232 level converters Al Williams one is
fairly cheap, works well and goes directly into proto board.
http://www.al-williams.com/rs1.htm
I am using 4 of them.
--- In basicstamps@yahoogroups.com, "Mark Lamond" <lists@m...> wrote:
>
> Hi, thanks for the info Phillip
>
> The problem is that i am stuck with the one baud rate, i can't
change it [noparse]:([/noparse]
>
> The only way i can think round it is to have a routine seperate
from the
> main program constantly monitoring for serial data on my input pin
and if it
> sees data it stores it in a variable. However i'm not aware of any
way to do
> this on the Stamp (i have a BS2SX).
>
> Has anyone got any ideas (i am a bit of a Stamp newbie)?
>
> >
> > I have had similar problems and reducing the speed was the only
solution I
> > found! Try 2400 or 4800, It if it works try 9600. I have not been
able to
> > get about the 9600 mark reliably...
> >
> > Good Luck,
> > Phillip Kocmoud
> >
> >
Original Message
> > From: Mark Lamond [noparse][[/noparse]mailto:lists@m...]
> > Sent: Saturday, March 15, 2003 11:23 AM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] Strange serial problems
> >
> >
> >
> > Hi there,
> >
> > I have a BS2 set up to send and recieve serial data from a
> > microcontroller.
> > The BS2 sends a single byte to the device, then listens for a
single byte
> > reply. For instance if i send $FF to the device it should return
$FF. For
> > the moment i am displaying the recived data via the debug output.
> > Comms are
> > running at 19200bps, and both devices are talking TTL levels with
the
> > Stamp's I/O lines directly connected to the serial port of the
target
> > device's microcontroller.
> >
> > Pin 0 is connected to the target's RX
> > Pin 5 is connected to the target's TX
> >
> > Here is my code:
> >
> > Byte VAR BYTE
> > Byte = 0
> >
> > DEBUG "Sending Data", CR
> > SEROUT 0, 110, [noparse][[/noparse]$FF]
> > SERIN 5, 110, [noparse][[/noparse]Byte]
> > DEBUG "Recieved Data", CR
> > DEBUG Byte, CR
> >
> > I am using a PC to sniff both serial lines between the target
device and
> > Stamp so i can see in real time what is happening. When the
program is
> > started running it sends $FF to the device as expected, and the
device
> > replies with $FF - however the stamp seems not to have noticed
> > this and sits
> > waiting for a serial input.
> >
> > If i use my PC to "inject" an $FF into the line connecting to Pin
5 while
> > the Stamp is waiting for input, the stamp correctly recieves the
byte,
> > displays it via the debug output and the program stops.
> >
> > This makes me think that the Stamp isn't quick enough to catch
the data on
> > Pin 5 after it has processed the SEROUT command and misses the
> > data from the
> > target device? Can anyone throw any light on what i might be
> > doing wrong, or
> > how to get round the problem? Perhaps i need a faster Stamp?
> >