Detect Serial Baud Rate

  1. Serial Baud Rates Table
  2. Detect Serial Baud Rate Calculator

The Web Serial API provides a way for websites to read from and write to a serial device with JavaScript. Serial devices are connected either through a serial port on the user's system or through removable USB and Bluetooth devices that emulate a serial port. In other words, the Web Serial API bridges the web and the physical world by allowing. Mar 29, 2012 Detects and sets the standard baud rates supported by the Arduino IDE serial monitor. Uses character 'U' as a test character I'm sure characters with multible zero bits in a row may fake out proper detection. If data is garbled in the serial monitor then the auto baud rate function failed. This is just a demo sketch to show concept.

Detect
edited 2008-12-12 16:31 in Microcontrollers

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. Automatically Detecting Serial Baud Rate As discussed on the prior page, the transmitter and receiver each needs to be within 2% of the agreed bps/baud rate to ensure accurate serial communication. Usually this means pre-programming or configuring the rate in both devices, and using either an individually compensated oscillator or a crystal.

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!

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!
-->

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Defines a list of commonly supported serial communication rates (baud rates). One baud signifies one pulse per second.

Serial Baud Rates Table

Namespace:System.IO.Ports
Assembly: Microsoft.SPOT.Hardware (in Microsoft.SPOT.Hardware.dll)

Syntax

Members

Member nameDescription
BaudrateNONEThe baud rate is unknown.
Baudrate7575 baud
Baudrate150150 baud
Baudrate300300 baud
Baudrate600600 baud
Baudrate12001,200 baud
Baudrate24002,400 baud
Baudrate48004,800 baud
Baudrate96009,600 baud
Baudrate1920019,200 baud
Baudrate3840038,400 baud
Baudrate5760057,600 baud
Baudrate115200115,200 baud
Baudrate230400230,400 baud

See Also

Detect Serial Baud Rate Calculator

Reference