cancel
Showing results for 
Search instead for 
Did you mean: 

How to design UART to achieve a robust communication over longer distances

Rookie38
Associate III

How should a UART interface be designed so that a robust communication possible can be established between two MCUs. The following table is shown in a data sheet from Texas Instruments. You can see the error rate depending on the baud rate.

0693W000007DYU5QAO.pngAccording to my research a low baud rate below 57600 bit/s and 16x oversampling is suitable for a communication over a longer distance.

1) Are the error rates manufacturer dependent?

I can't find any application notes from ST for implementing a reliable UART.

2) Are there any recommendations on which communication protocols should be used? (Something like TCP/IP over UART).

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Paul1
Lead

As mentioned previously that table you posted is for baud rate error%, not for data bit errors.

  1. Distance?
  2. On board or between boards?
  3. Noisy or clean environment? (Nearby Radio/Radar, within a grounded metal or shielded box?
  4. Shielded or unshielded cable
  5. common ground between MCUs?
  6. Protocol
  7. more...

Example:

  • I have a custom shipboard network, which means varying power sources, noise from radios/radar/machinery and lots of nearby data communications, and possibly isolated power sources (no common ground between MCUs), more.
  • Developed a custom protocol for various reasons, but basic requirements is CRC on all packets (CRC-16 for my packets under 1000bytes), Using a "DLE stuffed" protocol to allow for variable length packets.
  • Using RS-485 with shielded cables. The RS-485 allows for varying ground return paths, and the balanced signals allow for ground differences (actual difference allowed depends on common mode of RS-485 driver IC = CMRR). Shielded cables blocks noise
  • Datarate currently 115200bps. May increase but I keep it as low as possible, no more than system needs. Lower datarate reduces emitted noise and power consumptions.
  • For connections to CPUs on isolated power supplies I use Isolation ICs (Optical or other as appropriate for the instance)

Not knowing much about your needs I'd suggest a very robust solutions as this appears to be a concern:

  • If going >3m/10ft = RS-422 for MCU-MCU, or RS485 for >2 nodes (if on same PCB under 1ft then anything OK (SPI/I2C/TTL_UART...).
  • Use a protocol with CRC (Choice may depend on quantity of data being transferred, and how efficient protocol needs to be)
  • Use shielded cables
  • Ensure both MCUs have a common ground (connect Grounds of their power supplies, but be careful of "ground loops"... study that term)

Beyond that - post detailed info.

Paul

View solution in original post

3 REPLIES 3
KnarfB
Principal III

[Edited]

For long transmission lines, RS232 transceiver chips are used transforming the logic levels to V.28 levels. There are also optical transceivers and others kinds of robust serial transmission. So, the real error rates depend heavily on your overall transmission line.

> I can't find any application notes from ST for implementing a reliable UART.

I would never assume that a serial transmission is fully reliable. Your code should handle all error flags properly and may implement some additional protocol layer to increase reliability.

> Are there any recommendations on which communication protocols should be used? (Something like TCP/IP over UART).

There are tradeoffs concerning throughput, latency, etc.. Many protocols have been developed: adding CRC, use HDLC framing, XMODEM family, PPTP, ...

Peter BENSCH
ST Employee

The error in this table is the deviation from the target baud rate. The baud rate must be derived from a clock, which is 150MHz in the example, which in turn is probably generated from an external crystal using a PLL. If you calculate the error in the table yourself by using e.g. the values for the row 56000:

(150MHz/(16*Divisor*TargetBaudRate))-1

you will get the value 0.002459..., which you have to multiply by 100 to get the percentage value 0.25 (rounded).

The transmission distance for communication via UART is instead limited by the electrical behavior of RS-232 (search for keywords like distance or signaling). Depending on your definition of "longer distances" you should consider one of the alternatives mentioned there, e.g. a differential line like RS-485, which would just need another PHY like e.g. the STR485.

The communication protocol has nothing to do with the physical layer as it is part of a higher level in the OSI model. It only depends on your system requirements whether and which one should be used.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Good luck!

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Paul1
Lead

As mentioned previously that table you posted is for baud rate error%, not for data bit errors.

  1. Distance?
  2. On board or between boards?
  3. Noisy or clean environment? (Nearby Radio/Radar, within a grounded metal or shielded box?
  4. Shielded or unshielded cable
  5. common ground between MCUs?
  6. Protocol
  7. more...

Example:

  • I have a custom shipboard network, which means varying power sources, noise from radios/radar/machinery and lots of nearby data communications, and possibly isolated power sources (no common ground between MCUs), more.
  • Developed a custom protocol for various reasons, but basic requirements is CRC on all packets (CRC-16 for my packets under 1000bytes), Using a "DLE stuffed" protocol to allow for variable length packets.
  • Using RS-485 with shielded cables. The RS-485 allows for varying ground return paths, and the balanced signals allow for ground differences (actual difference allowed depends on common mode of RS-485 driver IC = CMRR). Shielded cables blocks noise
  • Datarate currently 115200bps. May increase but I keep it as low as possible, no more than system needs. Lower datarate reduces emitted noise and power consumptions.
  • For connections to CPUs on isolated power supplies I use Isolation ICs (Optical or other as appropriate for the instance)

Not knowing much about your needs I'd suggest a very robust solutions as this appears to be a concern:

  • If going >3m/10ft = RS-422 for MCU-MCU, or RS485 for >2 nodes (if on same PCB under 1ft then anything OK (SPI/I2C/TTL_UART...).
  • Use a protocol with CRC (Choice may depend on quantity of data being transferred, and how efficient protocol needs to be)
  • Use shielded cables
  • Ensure both MCUs have a common ground (connect Grounds of their power supplies, but be careful of "ground loops"... study that term)

Beyond that - post detailed info.

Paul