In an embedded world, communication protocols are vital as they provide a gateway to exchange information among various devices with excellent reliability. Any secure and efficient communication must agree between sender and receiver on a specific set of rules called a protocol. So, a protocol is a collection of rules that governs data communications.
A protocol allows various network-connected devices to communicate together irrespective of their design, structure, and internal processes. Both hardware and software operate during protocol implementation. Sensors share automation system data to the controllers, and the actuators receive the controlled signal. A communication protocol enables such an exchange of data or information. This article discusses some critical protocols in use in the embedded world.
Figure 1: Communication protocol
Types of Communication protocols
The communication protocols have different categories.
Figure 2: Types of communication protocols
The intersystem protocol helps to establish communication between two devices. A good example is a computer and a development board via inter bus system.
Types of Inter System Protocols
Intersystem protocols are of three categories:
USB Communication protocol
UART Communication protocol
USART Communication protocol
USB Communication protocol
Universal Serial Bus or USB provides asynchronous serial transmission of data between a host and up to a total of 127 devices. The host consists of two components: the root hub and the host controller. The host controller is a hardware chipset with a software driver layer responsible for the following tasks:
Detecting attachment and removal of USB devices
Managing data flow among host and devices
Provide and control power to the attached devices
Monitor activities on the bus
Data is sent serially in packets form consisting of 8 bits. The USB interface uses a non-return-to-zero inverted (NRZI) differential transmission, and a bit stuffing across the twisted pair encodes the NRZI. USB communication occurs through many different signaling states on the D+ and D- lines. The hardware in USB devices manages all the encoding and bit stuffing upon receiving any data and before transmitting any data. The reason for using the differential D+ and D- signal is to reject common-mode noise. The following are the different types of USB connectors available in the market:
(i) USB-A: It is the most popular connector. They are present in flash drives and at the end of hard-wired cables to USB devices like keyboards and mouse.
(ii) USB-B: These are square-shaped and widely used in printers, scanners, portable optical drives, and other external storage devices.
(iii) USB-C: They are small and thin, with an oval appearance and asymmetrical shape. USB C has 24 pin cable that can relay videos and data as quickly as 10 Gbps and power up to 100 watts. USB type C finds wide use in smartwatches, modern cellphones, new generation embedded development boards, etc.
(iv) Micro-USB: The first generation smartphones had Micro-USB. These had an On-the-Go (OTG) function that allowed them to have an adapter connecting other USB connector types. Tablets, game controllers, smartphones, and similar devices have Micro-USB inside them.
Figure 3: Types of USB connectors
The current USB specification defines four speeds for a USB system: Low-Speed, Full-Speed, Hi-Speed, and SuperSpeed. A High-Speed Host can communicate with a Low-Speed device, but a Full-Speed Host cannot communicate with a High-Speed device.
keyboards, mice, and game peripherals
phones, audio devices, and compressed video
video, imaging, and storage devices
application media requiring fast and high-capacity transfers
Table: USB transfer speed
Advantages of USB
Widely acceptable standard among various device manufacturers
Easy to configure and comes with plug and play functionality
USB connections are all hot-swappable
Disadvantages of USB
Speed supported is lower compared to gigabit Ethernet and Firewire interfaces
Cable length is limited to five meters
Communication of messages is possible only between host and peripherals as broadcasting is impossible in USB
UART Communication Protocol
A Universal Asynchronous Receiver/Transmitter (UART) receives serial data and stores it as parallel data, usually one byte. It also takes serial data and transmits it as parallel data. Such serial communication is beneficial when it is necessary to communicate bytes of data between devices separated by long distances or have few I/O pins.
Figure 4: Serial transmission using UART
UART is two-wired, i.e., the Tx (Transmitter) and Rx (Receiver) pins manage the serial data. Two serially connected UARTs must agree on the transmission protocol used to communicate. The UART transmission protocol determines the rate at which bits are sent and received. This rate is called the baud rate. The standard baud rates are 2400, 4800, 9600, and 19.2 k. The protocol also specifies the number of bits of data and the type of parity sent during each transmission. Finally, the protocol defines the minimum number of bits that separates two consecutive data transmissions.
Figure 5: Transmission protocols used by two UART
UART protocol finds use during the interface of PC and FPGA evaluation boards, RFID-based applications, Bluetooth Modules, GSM and GPRS Modems, Wireless Communications, GPS Receivers, etc.
Advantages of UART protocol
Simple, single-wire transmission and single wire reception of data with error checking
Easy interface for interconnecting embedded devices and desktop computers etc.
Can be directly interfaced to popular RS-232 physical interfaces
Disadvantages of UART protocol
The typical maximum data rate is low compared to SPI
Since it is asynchronous, the clock on both devices must be accurate, particularly at higher baud rates
Settings need to be known in advance, including baud rate, data size, and parity checking type
USART Communication Protocol
Universal Synchronous Asynchronous Receiver and Transmitter (USART) is a mode of communication between serial devices, i.e., data units. For example, a byte transmits one bit at a time. The USART is unlike parallel modes of transmission where the entire data unit, like a byte, transmits at once. These are fit to change the parallel information in the sequential structure.
A USART is a standard device that can transmit a binary number as a square waveform to a receiver and receive a square waveform. It converts the information to a binary number. It uses asynchronous communications in which a master clock signal transmits to the receiver to coordinate data bit sampling through time. The two endpoints each manage their clock in asynchronous mode. USART transmits and receives the signal in full-duplex mode and uses it to signal when a send and/or receive is complete.
Figure 6: USART to convert Parallel data into serial data
USART protocols are popular in industrial and control applications. They operate in multi-drop networks where a master USART can communicate with a particular slave USART. They are also for Infrared (IR), Bluetooth communications, and USART modules used with other RF communication purposes – AM, FM, QPSK, PSK, FSK, Wi-Fi, etc.
Advantages of USART protocol
The speed of USART is more than the speed of UART
Uses both data signals and clock for its functioning
Data is transmitted in the form of blocks
Disadvantages of USART protocol
Data is transmitted at a definite rate
USART is more complex than UART in terms of complexity
Intra system Protocol
The Intra system protocol establishes communication between components within the circuit board. In embedded systems, intra-system protocol increases the population of components connected to the controllers. An increase in components led to circuit complexity and increased power consumption. Intra system protocol promises secure access to data from the peripherals.
Types of Intra System Protocols
The categories of Intersystem protocols are:
I2C Communication protocol
SPI Communication protocol
CAN Communication protocol
I2C Communication protocol
Philips invented the Inter-Integrated Circuits protocol (IIC or I2C) in 1982. The I2C protocol connects multiple slaves to a single master or various slaves to multiple masters. The I2C protocol operates when two microcontrollers send data to the same memory or send identical data to the LCD with many other applications. The I2C serial communication protocol has two signals: Serial Data (SDA) and Serial Clock (SCL). The master and slave receive data through the SDA line, and SCL is the clock signal line. The I2C protocol supports, depending upon the modes of operation, different data speeds ranging from 100kbit/s in standard mode to 3.4 Mbps in full speed mode.
Figure 7: Single master and slave in the I2C protocol
I2C protocols use data from hardware sensors, communicate with multiple microcontrollers, display control of cellphones, change color settings of the monitor color, assess ADCs and DACs, circuits, and read specific memory ICs. They also operate in control applications like controlling and transmitting user-directed actions and switching on/off the power supply of the internal components.
Advantages of I2C protocol
Simple and effective
It occupies less space as it directly connects the components and reduces the cost of interconnection
It supports multi-mastering, i.e., any device that can send or receive data can be a master
The ACK/NACK feature supports a robust error handling mechanism
Disadvantages of I2C protocol
Hardware, especially software implementation, is more complicated than the SPI Half-duplex
Not scalable for a large number of devices
It takes up much more real estate on a PCB as it uses pull-up resistors
SPI Communication protocol
Serial Peripheral Interface (SPI) is a four-wire serial data bus. A single node, called the master, manages activity on the bus. Other nodes called slaves respond to the master. The four wires on the bus perform the following functions:
The Slave Select (SS) signal notifies a slave that a master is interacting with it
The Serial Clock (SCLK) sequences data transfer on the bus, one bit per cycle
The Master Input Slave Output (MISO) line transfers data from the slave to the master
The Master Output Slave Input (MOSI) line transfers data from the master to the slave
SPI can simultaneously transfer data in both the directions on the MISO and MOSI lines, making it a full-duplex communication standard. One master can control multiple slaves, but additional SS pins are required. SPI protocol can support transfer data up to 50Mbps over short distances.
Figure 8: Architecture of SPI
The SPI communicates with different peripherals like sensors, analog to digital converter, digital to analog converter, etc. They interface LCDs, LEDs, MMC or SD cards, including SDIO variants, and communicate with FLASH and EEPROM memories.
Advantages of SPI protocol
No start and stop bit required
No complicated slave communicating system
Higher data transfer rate than I2C protocol (almost double)
Separate MOSI and MISO pins to simultaneously transmit and receive data
Disadvantages of SPI protocol
It uses four wires, whereas I2C and UART use two wires only
No acknowledgment from the receiver after the reception of data
It allows only a single master
CAN communication protocol
Robert Bosch developed the Controller Area Network (CAN) protocol in the 1980s. A CAN bus system in a vehicle makes it possible to network electronic modules such as control units or intelligent sensors. The CAN bus is independent of the vehicle's electronics systems and functions as a data line to swap information among control units.
The system's design and construction enable it to work with a high degree of intrinsic safety. If faults still occur, they are mainly stored in the fault memory of the related control unit and are accessible by the Diagnostic Testing and Information System.
The basic system consists of several control units. Transceivers connect them parallel to the bus line, which implies that identical conditions apply to all stations. In simple words, the management of all control units is equal, and none are preferred. In this context, this is called multi-master architecture. There is a serial exchange of information.
Figure 9: A CAN bus in automobile
The CAN bus system divides into three unique systems due to the different requirements regarding signal repetition rate and the large data volume:
Drive train CAN bus (high-speed) at 500 kbps with almost real-time requirements
Convenience CAN bus (low-speed) at 100 kbps with low time requirements
Infotainment CAN bus (low-speed) at 100 kbps with low time requirement
The CAN data bus uses twisted-pair wiring with differential data transfer to achieve top-notch security during data transfer. CAN high and CAN low are the wire names.
Both wires have the same default setting regarding the signal level in the rest state. For example, this setting of the drivetrain CAN data bus is about. 2.5V. The recessive state is also known as rest state setting. This is because as any control unit connected in the network can change it. The voltage increases in dominant state to match the CAN high wire. This is a predetermined value (on the drivetrain CAN data bus, this is at least 1V). The CAN low wire voltage drops by the same increment (a minimum of 1V on the drivetrain CAN data bus). The voltage thus rises by a minimum 3.5V ((2.5V + 1V = 3.5V) inactive state on the CAN high wire from the drivetrain CAN data bus. The voltage in the CAN low wire then drops to a maximum of 1.5V (2.5V - 1V = 1.5V). Therefore, the voltage difference between CAN high and CAN low in a recessive state is 0V, and in a dominant state, at least 2V.
Figure 10: Differential data transfer on CAN data bus
CAN protocol finds use for networking of components in automobiles. Besides automotive, CAN also finds applications in aircraft for in-flight analysis and networking of components such as fuel systems, pumps, and more. CANopen is popular in embedded control applications like industrial automation.
Advantages of CAN protocol
It is a low-cost solution as the number of wires used reduces compared to old communication models in automotive and thus reduces vehicle weight
It is a fast way of communicating between different control modules and sensors as it supports a data transfer rate of 1 Mbit/s at a bus length of 40m
It provides highly reliable transmission by offering an excellent error-detection and error-handling mechanism. It is also immune to electromagnetic interference.
It can auto retransmit the same message if any device does not receive a notification
Disadvantages of CAN protocol
It lacks encryption and authentication mechanisms
It is limited to a maximum of 64 nodes or devices
The cost of development and maintenance of software is high