Detect Serial Baud Rate

edited 2008-12-12 16:31 in Microcontrollers
DetectRateSerial
My question concerns the different ways for the SX to detect serial baud rates and to automatically adjust the timing to recv. correctly.
Google brings this site:
www.iol.ie/~ecarroll/autobaud.html
In this scheme, a known ascii character - [noparse][[/noparse]Return] key - is sent to the micro which initially starts rec'ving at 9600. If the sending baud rate is different then the rec'ving 9600, the rec'vd data is 'corrupted' in a known fashion which the code in the micro can distinguish and adjust for, ending up with the correct timing.
Well, I don't have the luxury of sending out a known character to calibrate , so to speak, the rec'ing baud rate of the micro. I'm connecting to devices with unknown data streams at odd baud rates (8800, for example).
I'm thinking of measuring the period of bits first rec'vd , finding the shortest one and assuming that's the period for the correct baud rate. I need to figure out the proper baud rate after rec'ving one byte and respond correctly to continue the handshakes.
Is there any another algorithm for auto baud rate detection I could consider?
Thanks,
Kevin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!

Serial Baud Rate Speeds

Two devices, where the slave device is able to detect the baud rate of the master controller and self-adjust accordingly. This requires an automatic mechanism to determine the baud rate. The USART peripheral embedded in some STM32 devices offers many features, including. Automatic baud rate detection (ABR, autobaud) refers to the process by which a receiving device (such as a modem) determines the speed, code level, start bit, and stop bits of incoming data by examining the first character, usually a preselected sign-on character on a UART connection. ABR allows the receiving device to accept data from a variety of transmitting devices operating at different speeds without needing to establish data rates in advance.

Comments

  • edited 2008-11-29 17:13
    All of the methods for automatic Baud detection rely on some knowledge of the incoming character stream, usually that there are characters coming in with a little time between them so that the start bit can be detected. Usually the characters are odd in value so that the start bit (0) is always followed by a one bit and the width of the start bit is used to set the Baud.
    Your suggestion to measure the width of pulses received and assume that these represent received bits, finding the shortest one and using that for determining the Baud, is reasonable, but don't expect any reliability with arbitrary data streams. I don't think you'll find any better algorithm though. The problem is that the first character that comes along may have no single isolated bits and you'll end up with a Baud that's half or a third of the correct Baud. If there's any noise in the datastream, your Baud detection will be thrown off by that.
    Basically, you've got a bad situation. There is no good solution, but what you suggest will work some of the time. If you can put in a timeout where the whole system resets if synchronization fails and it starts over from the beginning, you at least will have some chance of achieving communications.
  • edited 2008-12-12 16:31
    Thanks, Mike for the reply.
    As an aside to dealing with non-standard baud rates, I've found a neat and free terminal program called RealTerm. Works great for diagnosing serial streams.
    realterm.sourceforge.net/
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Bad spellers of the world untie!

To change the baud rate setting for a PubSub+ appliance’s RS-232 serial console port, enter the following commands:

solace# configure
solace(configure)# console baud-rate <baud-rate>

Detect

Where:

baud-rate is the desired baud rate setting for the RS-232 serial console port in bits per second (bps). Valid values are 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, or 115200. The default value is 115200 on Solace PubSub+ 3260, 3530, and 3560.

To view the baud rate used for the RS-232 serial console port, enter the show console command. Note that this command does not apply to PubSub+ software event brokers.

The console has the following RS-232 configuration:

  • 8 data bits
  • 0 parity bits (turn Parity checking off)
  • 1 stop bit (RS232 allows 1, 1.5 and 2)
  • No flow control
  • Baud rate configurable

The baud rate setting of the RS-232 connection is affected by the length of the cable used between the appliance and the datacenter terminal server. The higher the baud rate, the shorter the cable length. The default 115,200 baud rate setting is designed for a shorter cable length to the ‘top of rack’ terminal server found in newer data centres. For data centres where larger terminal servers are deployed that serve a suite of racks, the default setting should be changed to allow longer cables and reliable communication. The value of 9,600 is a standard terminal server speed for such terminal server/console deployment style.

Note that both ends of the RS232 connection must have the same configuration.

Detect Serial Baud Rate

Detect Serial Baud Rate Code

For more information on baud rate and how it relates to bit rate, refer to this blog post.