Serial communication is a commonly used method with which to exchange data between computers and peripheral devices. Serial transmission between the sender and receiver are subject to strict protocols which provide security and reliability and have led to its longevity. Many devices from personal computers to mobile devices make use of serial communication. Let’s take a closer look at its fundamentals.
Serial communication makes use of a serial digital binary method of exchanging data. It employs a number of interfaces and serial communication protocols including RS232,RS485, SPI, and I2C among others.
COM Port Monitor
COM Port Monitor is a serial communication software that enables monitoring and analyzing data received by serial ports.
Binary pulses are used to transmit data in serial data transmission. The binary digit one is represented by five volts or a HIGH logic. Conversely, binary zero is denoted with a logic LOW or zero volts. In order to implement serial communication, a source and destination are required. They are also referred to as the sender and receiver. Various types of serial communication can be employed and are designated as Simplex, Half Duplex, and Full Duplex
The Simplex method implements one-way data transmission. In this scheme, only the source or destination is active at any given time. If the source is sending data, the receiver has no choice but to accept the transmission. Simplex mode is used when broadcasting television or radio signals.
Half Duplex mode permits the source and destination to both be active, but not simultaneously. Transmission only occurs in one direction at a time. A case in point can be seen when using the Internet. When you make a request from your computer for a webpage, the server processes the request. It then becomes the sender when returning the information to your computer, which is now the receiver.
Full Duplex mode is the world’s most widely used form of serial communication. Source and destination are both active and can send and receive data simultaneously. Your smartphone is a prime example of full duplex mode in action.
Another consideration when discussing serial communication is the protocol and endianness of the two host computers. Endianness refers to the method of using specific memory addresses to store data. It is the way of storing the data at a particular memory address. There are two classifications concerning data alignment endian.
The following example highlights the difference between Little Endian and Big Endian. It shows how a 32-bit hexadecimal data transmission of ABCD87E2 is stored using both endians.
What is the difference between Little endian and Big endian?
The difference between Little endian and Big endian is in endianness specifies wich byte (MSB or LSB) is stored at which of memory.
How ABCD87E2 is represented in memory?
In Little Endian format, LSB is stored at the lowest memory address, and MSB is stored at highest memory address.
Little endian and Big endian
There are two basic forms of data transfer. These are parallel and serial communication. Serial communication conducts the data transmission on a bit by bit basis. It essentially uses two wires, one for the sender and the other for the receiver.
When you are sending data, the endianness of the transmission matters. In an 8-bit binary data transmission of 11001110, which bit is sent first? It could be the Most Significant Bit – MSB (7th bit) or Least Significant Bit- LSB (0th Bit). The diagram below shows a Little Endian transmission where the LSB is moved first.
In this depiction, a single bit is sent by the transmitter to the receiver for each clock pulse.
Rather than moving data bit by bit, parallel communication can move 8,16, or 32 bits of data simultaneously. Examples of parallel communication are printers and copying machines which benefit from the faster rate of data transfer.
Serial communication sends data a single bit at a time. Consequently, fewer I/O (input-output) lines are needed to implement it than for parallel transmission. This results in less interference and a reduction in space requirements. It also reduces the cost of the embedded system and enables it to reliably transfer data over long distances. Data communication equipment (DCE) such as modems make use of serial data transfer.
More I/O lines are needed to implement parallel communication. When data is sent in a block of 8,16 or 32 bits, each bit needs its own physical I/O line. The speed of parallel transfer is faster than serial transmission but needs a larger number of I/O lines. Parallel data transfer is used in personal computers to exchange data with internal components such as the random access memory (RAM) or the CPU.
Note: Serial communication is the preferred method when dealing with circuits or processors with a limited number of I/O pins.
The pros and cons of serial and parallel communication are highlighted in this comparison chart.
Sends one data bit at each clock pulse
Transfers a block of data at a simultaneously
Better method for long distance communication
Mostly used for short distance communication
Slow transmission speed
Faster speed of communication
Requires a single wire for data transmission
Requires ‘n’ number of lines for transmitting ‘n’ bits
The serial interface is responsible for encoding the bits of a binary number. It performs this task by focusing on the bits’ "temporal" location on the wire rather than their "spatial" location inside a group of wires.
The clock index is the mechanism that enforces the efficient operation of serial devices. A faulty clock can lead to unexpected results, and each device has a different clock signal. Serial communication protocols are broadly defined as being either synchronous or asynchronous.
■ Synchronous serial interface
A synchronous serial interface uses a single CPU bus that shares the clock signal and data transmission. This makes synchronous data transfer faster than the alternative. There are no concerns over baud rates not matching and less I/O lines are needed to connect devices. Examples of synchronous interfaces are SPI and I2C.
■ Asynchronous serial interface
An asynchronous serial interface operates without an external clock signal. Its operation is controlled by these four parameters:
Baud rate control;
Data flow control;
Transmission and reception control.
When stability in communication is important, asynchronous protocols are preferred. They are also suitable for implementing long-distance data transmission. RS232, RS422, and RS485 are all examples of asynchronous protocols.
How does Serial communication works?
Serial communication is used by modern microcontrollers and microprocessors for internal and external data transfer. Let’s look at a simple, illustrative example of sending a file from your laptop to smartphone. You would probably send it using either the WiFi or Bluetooth protocol.
Establishing serial communication requires these steps:
Create a connection.
The laptop will conduct a search for nearby devices and provide a list of those it has discovered.
Select the device with which you wish to communicate.
Your smartphone must be paired to complete the connection. The software is operating with defaults, so you don’t need to manually configure parameters. There are four parameters that affect communication: baud rate, data bit selection (framing), start-stop bit, and parity.
Rules of Serial Communication
What is the Baud rate?
Baud rate refers to the transmission speed enacted between the sender and receiver. It is expressed in bits per second. Some commonly used baud rates are 1200, 2400, 4800, 9600, and 57600.
Both sender and receiver need to be set to the same baud rate. In this case, it’s your laptop and mobile device.
Note: A higher baud rate leads to faster data transmission.
You might consider using 115200 baud as a limit to minimize the possibility of the inability of the receiver to handle higher frequencies.
Framing indicates the number of data bits that will be sent from the host device. On most devices, 8 bits are the preferred number. Once the number of bits is agreed upon, the type of endianness used also needs to be specified.
Synchronization bits are used to identify the beginning and end of a data transfer. A Start bit and 1 or 2 Stop bits are added to the original data frame. This is how asynchronous data transfer is implemented.
Error control is critical to guard against data corruption that can occur due to noise impacting the receiver. Checking parity is required to assure that output is stable.
Parity can be set to odd or even. It is based on the number of 1s that are transferred. Parity is even and the parity bit set to one when an even number of 1s have been sent. The parity bit is set to zero when an odd number of 1s are transferred.
Serial Communication is a critical concept that is implemented in many areas of Electronics and Embedded Systems. A valid serial protocol must be selected for applications to ensure a proper exchange rate when two devices are sharing the same bus.