EB 500 changing baud rate
Archiver
Posts: 46,084
Hi All,
I'm playing around with two EB500 units. I can get them to talk to each
other and send data. I can't seem to change the baud rate correctly. In the
code snip below, I check the modules address just to make sure I am
communicating at the default baud rate. Then I change the baudrate and query
the the address again to see if the baud rate has taken effect. At this
point the baud rate does not change, and I must continue to use the default
baudrate to communicate with the module. If I change to the new baud rate
(110), the SERIN commands in the second address read time out.
'{$STAMP BS2p}
'{$PBASIC 2.5}
szData VAR Byte(20)
SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
SERIN 0,240,[noparse][[/noparse]STR szData\17]
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
DEBUG "EB Address: ", STR szData\17,CR
DEBUG "Changing baud rate...",CR
SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
DEBUG "Baud rate set.",CR
SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
SERIN 0,240,[noparse][[/noparse]STR szData\17]
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
DEBUG "EB Address: ", STR szData\17,CR
END
Any ideas what is wrong here?
Thanks,
Jonathan
www.madlabs.info
I'm playing around with two EB500 units. I can get them to talk to each
other and send data. I can't seem to change the baud rate correctly. In the
code snip below, I check the modules address just to make sure I am
communicating at the default baud rate. Then I change the baudrate and query
the the address again to see if the baud rate has taken effect. At this
point the baud rate does not change, and I must continue to use the default
baudrate to communicate with the module. If I change to the new baud rate
(110), the SERIN commands in the second address read time out.
'{$STAMP BS2p}
'{$PBASIC 2.5}
szData VAR Byte(20)
SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
SERIN 0,240,[noparse][[/noparse]STR szData\17]
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
DEBUG "EB Address: ", STR szData\17,CR
DEBUG "Changing baud rate...",CR
SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
DEBUG "Baud rate set.",CR
SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
SERIN 0,240,[noparse][[/noparse]STR szData\17]
SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
DEBUG "EB Address: ", STR szData\17,CR
END
Any ideas what is wrong here?
Thanks,
Jonathan
www.madlabs.info
Comments
>Hi All,
>
>I'm playing around with two EB500 units. I can get them to talk to each
>other and send data. I can't seem to change the baud rate correctly. In the
>code snip below, I check the modules address just to make sure I am
>communicating at the default baud rate. Then I change the baudrate and query
>the the address again to see if the baud rate has taken effect. At this
>point the baud rate does not change, and I must continue to use the default
>baudrate to communicate with the module. If I change to the new baud rate
>(110), the SERIN commands in the second address read time out.
Change the Stamp's baud rate as well. Otherwise it may well time out at the wrong baud rate. Unless I'm missing something here.
>'{$STAMP BS2p}
>'{$PBASIC 2.5}
>
>szData VAR Byte(20)
>
>SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
>SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
>SERIN 0,240,[noparse][[/noparse]STR szData\17]
>SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
>DEBUG "EB Address: ", STR szData\17,CR
>
>DEBUG "Changing baud rate...",CR
>SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
>SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
>DEBUG "Baud rate set.",CR
>
>SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
>SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
>SERIN 0,240,[noparse][[/noparse]STR szData\17]
>SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
>DEBUG "EB Address: ", STR szData\17,CR
>
>END
>
>Any ideas what is wrong here?
>
>Thanks,
>
>Jonathan
>
>www.madlabs.info
>
>
>
>
>
>
>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
>
>
>
>
As I understand it, every serial command to the EB500 *after* I change the
baud rate should require the new baud rate. However, I find using the code
below that if I *do* change the baud of the serial command sent to the EB500
after the change, my SERINs time out. So:
This times out.
DEBUG "Changing baud rate...",CR
SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
SERIN 0,110,[noparse][[/noparse]WAIT("ACK",CR)]
DEBUG "Baud rate set.",CR
This passes, but all subsequent commands to the EB500 must be at 240, not
110.
DEBUG "Changing baud rate...",CR
SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
DEBUG "Baud rate set.",CR
I just tried the eb500 on a different MCU. I can get it to change the baud
rate. However, the first SERIN after the baud change is still at 240. All
other communications must be at the new baud rate, as one would imagine. I
suspect that is the way the unit is set up to operate.
Thanks,
Jonathan
Original Message
From: "Bruce Bates" <bvbates@u...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, May 19, 2004 12:05 PM
Subject: Re: [noparse][[/noparse]basicstamps] EB 500 changing baud rate
> At 11:41 AM 5/19/04 -0700, Jonathan Peakall wrote:
> >Hi All,
> >
> >I'm playing around with two EB500 units. I can get them to talk to each
> >other and send data. I can't seem to change the baud rate correctly. In
the
> >code snip below, I check the modules address just to make sure I am
> >communicating at the default baud rate. Then I change the baudrate and
query
> >the the address again to see if the baud rate has taken effect. At this
> >point the baud rate does not change, and I must continue to use the
default
> >baudrate to communicate with the module. If I change to the new baud rate
> >(110), the SERIN commands in the second address read time out.
>
> Change the Stamp's baud rate as well. Otherwise it may well time out at
the wrong baud rate. Unless I'm missing something here.
>
>
> >'{$STAMP BS2p}
> >'{$PBASIC 2.5}
> >
> >szData VAR Byte(20)
> >
> >SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
> >SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
> >SERIN 0,240,[noparse][[/noparse]STR szData\17]
> >SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
> >DEBUG "EB Address: ", STR szData\17,CR
> >
> >DEBUG "Changing baud rate...",CR
> >SEROUT 1,240,[noparse][[/noparse]"set baud 19200",CR]
> >SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
> >DEBUG "Baud rate set.",CR
> >
> >SEROUT 1,240,[noparse][[/noparse]"get addr",CR]
> >SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]
> >SERIN 0,240,[noparse][[/noparse]STR szData\17]
> >SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
> >DEBUG "EB Address: ", STR szData\17,CR
> >
> >END
> >
> >Any ideas what is wrong here?
> >
> >Thanks,
> >
> >Jonathan
> >
> >www.madlabs.info
> >
> >
> >
> >
> >
> >
> >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 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
>
>
>
>
>
>
>> I just tried the eb500 on a different MCU. I
>> can get it to change the baud rate. However,
>> the first SERIN after the baud change is
>> still at 240. All other communications must
>> be at the new baud rate, as one would imagine.
>> I suspect that is the way the unit is set up
>> to operate.
All commands to the EmbeddedBlue module return either and ACK or NCK
followed by a carriage return and eventually the '>' prompt
character when the command is complete. In the case of a baud rate
change, all of this happens before the baud is actually changed.
This means that if you are looking for errors you should look for
the ACK, <CR>, '>' sequence prior to changing to the new rate.
Strictly speaking checking the return value in this case is not
required if you are sure that your syntax is correct.
>> This passes, but all subsequent commands to
>> the EB500 must be at 240, not 110.
I am not sure why you do not see the baud rate change when sending
the command from a stamp. I do not have a BS2p module here for
testing, but with the exception of the rate change mentioned above
your code looks good. Is it possible that the module is resetting
due to low battery power when it shifts to the higher baud rate? If
you are plugged into the wall this is certainly not the case. When I
get a bit of time I will pick up a BS2p and see if I can reproduce
the problem.
If you want to avoid the problem all together you can easily persist
the new baud rate setting so that it powers on at the higher rate.
Simply execute the following command either on the micro that does
work or from a PC using an eb600 module.
set baud 19200 *
The asterisk causes the setting to be persisted. This will actually
work for all of the eb500 set commands and is a convenient way to
avoid a bunch of configuration code at the beginning of each
application.
Talk to you soon,
Bryan Hall
A7 Engineering
www.a7eng.com
> All commands to the EmbeddedBlue module return either and ACK or NCK
> followed by a carriage return and eventually the '>' prompt
> character when the command is complete. In the case of a baud rate
> change, all of this happens before the baud is actually changed.
> This means that if you are looking for errors you should look for
> the ACK, <CR>, '>' sequence prior to changing to the new rate.
> Strictly speaking checking the return value in this case is not
> required if you are sure that your syntax is correct
So, it sounds like it is working as it should on the other MCU.
> I am not sure why you do not see the baud rate change when sending
> the command from a stamp. I do not have a BS2p module here for
> testing, but with the exception of the rate change mentioned above
> your code looks good. Is it possible that the module is resetting
> due to low battery power when it shifts to the higher baud rate? If
> you are plugged into the wall this is certainly not the case. When I
> get a bit of time I will pick up a BS2p and see if I can reproduce
> the problem.
If the code is good, any other areas to check?
>
> If you want to avoid the problem all together you can easily persist
> the new baud rate setting so that it powers on at the higher rate.
> Simply execute the following command either on the micro that does
> work or from a PC using an eb600 module.
>
> set baud 19200 *
>
I did this, and of course it works. It is a pain though. I want to be able
to change the rate on the fly if need be, so I need to figure this out. I am
going to try some of the other commands, as so far I have only used the get
address and baud rate changes. I'll see if all the other commands work right
or what.
Thanks for the help,
Jonathan
www.madlabs.info