How to Guarantee Signal Integrity in Your PCB Design for Serial Communication Protocols
During my school days, I was addicted to the popular FIFA PC games series. I could spend hours scoring against the best virtual soccer teams. I was so engrossed in playing the game that I become oblivious to my mom’s voice when she called me to run an errand. It goes without saying that I received a healthy dose of scolding from my mom and was slapped with a 3 months ban on PC gaming. This is a good example of external sources can cause us to miss or misread important communication sent to us. In the world of embedded systems, miscommunication is also a big issue. This is particularly the case when the signal integrity of your microcontroller (MCU) is compromised. Missed data packets, or incorrectly delivered packets can land you with a punishment far worse than 3 months without FIFA. Let’s explore how to ensure that information is transmitted and received properly between embedded systems on a serial communication interface.
The Usage Of Serial Communication Protocol In Embedded Systems
Communication is important in the embedded systems. As you may well know, serial communication is one of the most popular means for data transfer in embedded systems. It involves transmitting packets bit by bit in a sequential manner between MCUs. Let’s look at the two different types of serial communication.
Serial communication can be divided into synchronous and asynchronous. Synchronous serial communication, like Serial Peripheral Interface (SPI) and the Inter-Integrated Circuit (I2C) protocol, use a clocking signal to synchronize the data transmission. Memory chips like Static Random Access Memory (SRAM), Flash and Electrically Erasable Programmable Read-only Memory (EEPROM) are common components that use synchronous communication.
On the other hand, asynchronous serial communication, like RS232 and RS485, do not have a clocking signal. Instead they rely on unique Start and Stop bits to separate data packets. These are commonly used to communicate between different embedded systems or between embedded system and a data collecting computer. Standards like RS232 and RS485 do not have a defined upper layer of protocol, error handling and recovery. These are normally specified by the system developers.
Asynchronous serial communication is quite common in applications like parking payment machines, data monitoring systems, and security systems that rely on conventional wired communication technology. Vital information such as payment transactions, periodic parameter variables, alarms and fault events are transferred to a data collecting PC for audit purposes and backup.
Why Signal Integrity In Communication Is Important And How It Can Be Compromised
It is important that data packets are transferred from embedded systems to data collecting terminals accurately. When this fails to occur, there can be financial repercussions. For example, in a payment systems, if valid payment transactions are occasionally lost in transmission then there is no record of them. This can cause serious issues when the money collected does not tally with the logged transactions.
Besides data packets that went missing in transmission, signal integrity can also affect the content of a data packet. Although serial communication is a digital process, the nature of the voltage level that makes every byte is still analog. Theoretically, digital communications involve logics of 1 and 0, and are represented by different voltage levels. In real life, these voltages are not smooth and straight lines, since they occasionally suffer distortion from electrical interference.This is especially so in communication cables that are thousands of feet long. Compared to packet losses, it is harder to locate data that has been miscaptured. For example, a transaction with corrupted date information may still appear somewhere in the database.
Besides the inevitable electrical interference from external factors in locations where the embedded systems are installed, corruption in the transacted data packet may be caused by PCB designs that do not adhere to best design practices. Proper error checking handling and recovery systems may also be missing from embedded systems that encountered issues from corrupted or lost packets. This can be a result of inexperienced programmers or simply because the programmer failed to consider the importance of a proper error checking system.
When your data packets are lost and recovery is not possible.
How To Design With Signal Integrity For Proprietary Serial Communication Protocol In Mind
A well-designed embedded system will be able to mitigate issues that can affect your SPI signal integrity by preventing them in the first place and/or by having backup recovery measures. Here are some approaches that I have personally used in my embedded system designs.
1. Implementing Checksum In The Data Packet
Having a Cyclic Redundancy Check (CRC) checksum, instead of simplistic performing bitwise operations (ADD or XOR), on all the bytes in the packet enables the receiver to accurately detect if a packet has been corrupted. The receiver can compare between the checksum in the transmitted packet and the manual calculation. Then it can discard the data packet if both of the checksums do not match.
2. Handshaking And Acknowledgement
Unless it is a broadcast message, each transmission data packet must be replied by the receiver with a (positive) acknowledgement (ACK) or negative acknowledgment (NACK). This allows the sender to know if the transmission has been successful or if they need to retransmit the same packet.
3. Decreasing The Speed Of Transmission
In serial protocol like RS485, the speed of transmission is often expressed in baud rate, which is the number of bits transmitted per second. Theoretically, RS485 supports a transmission rate of 100 kbps at a maximum length of 4000 feet but in actual applications, these values can be greatly reduced due to the quality of cables, electrical noises and the ability of the MCU to process the messages while managing other tasks. In applications where devices are separated from each other by thousands of feet, data packets can become corrupted at a higher baud rate. In that case, it’s wise to switch to a lower transmission speed.
Sometimes, lowering your speed in serial communication is the best option.
4. Incorporate Best Design Practice In Your PCB
Your firmware’s ability to deal with data corruption may be limited to the fundamental design of your PCB. Always adhere to the best design practices, like maintaining reasonable clearance between communication signals and using proper grounding to ensure digital signal stability. Users can implement this technology and many other PCB design techniques with the world-class PCB design and layout features in Altium Designer®. Users can take advantage of a single integrated design platform with circuit design and PCB layout features for creating manufacturable circuit boards. When you’ve finished your design, and you want to release files to your manufacturer, the Altium 365™ platform makes it easy to collaborate and share your projects.
We have only scratched the surface of what’s possible with Altium Designer on Altium 365. Start your free trial of Altium Designer + Altium 365 today.