Introduction
I have discovered something wonderful—we are stronger together. So is electronics! How do you improve communication between two parties that barely understand each other? Despair no more: we will explore some answers. It is all about interfacing! For electronics, at least...
Understanding interfacing techniques, including communication protocols, data transfer methods and device drivers, is essential for electronics makers to connect their devices to other systems. Without electronic interfacing, electronics could not communicate with each other, which would be terribly sad. Let’s see whether we can help them!
Data Transfer Methods
Transmission modes describe 3 methods by which modules can transmit data, receive data or do both simultaneously. The 3 types are simplex, half-duplex and full-duplex.
Simplex
Simplex involves 2 modules—a transmitter and a receiver; see Figure 1. One sends and the other receives. They cannot swap roles, so communication is one-way. Simplex = One Way Street!
Figure 1: Illustrates simplex transmission. As the arrow indicates, information travels from the transmitting module to the receiving module.
One advantage of simplex is that the transmitter can use the full capacity of the communication medium, such as radio signals and/or cables, to transmit data. Simplex can be seen between a computer and a keyboard or between a radio controller and a remote-controlled toy plane or racing car.
Half-Duplex
Half-duplex is when 2 modules can switch between transmitter and receiver roles; see Figure 2. Both can send and receive data because they can swap roles. However, each module cannot have both roles at the same time.
Figure 2: Illustrates half-duplex transmission. The arrows show that both modules can transmit and receive data, but each can only have one role at a time.
Like simplex, half-duplex can use the communication medium’s full capacity. For example, walkie-talkies use half-duplex data transmission. Roger. Over.
Full-Duplex
Full-duplex is when 2 modules can have both roles simultaneously—both can send and receive data at the same time; see Figure 3.
Full-duplex has a limitation concerning transmission-medium capacity. As we learned earlier, half-duplex and simplex can use the full capacity of the communication medium, whereas in full-duplex this data highway must be shared between the modules. Alternatively, each module needs its own transmission medium.
Figure 3: Illustrates full-duplex transmission. As the arrows show, both modules can transmit and receive data simultaneously.
Full-duplex is used, for example, in communication between telephones and in the Arduino UNO microcontroller.
Serial and Parallel Communication
Serial
Data moving between transmitting and receiving modules can be divided into serial and parallel communication. Data can be transmitted either serially or in parallel. Serial data means bits are transmitted over a connection one after another per clock cycle; see Figure 4.
(In electronics, a clock cycle is one period of the clock signal. An instruction may take several cycles, and some processors can handle several instructions per cycle.)
Figure 4: Illustrates serial communication between two modules. Here the transmitted data values enter the receiving module one after another.
The advantage of serial communication is that it is cheaper and simpler than parallel communication. It is also typically used over longer distances.
Parallel
Parallel transmission uses several cables, one for each bit to be transferred per clock cycle; see Figure 5.
Figure 5: Illustrates parallel communication. Each cable represents a bit transferred per clock cycle.
Parallel communication is often used over short distances. At the same transfer frequency, multiple parallel wires can carry more bits per cycle. This does not mean parallel interfaces are always faster than modern serial interfaces.
Communication Protocols
A communication protocol is a system of rules allowing two or more devices to transmit information through variations in a physical quantity. It is the system behind communication from one physical device to another. The protocol defines rules, syntax, semantics and synchronisation, as well as possible error-recovery methods.
Inter-System and Intra-System Protocols
To understand inter-system and intra-system protocols, we need to clarify what a protocol itself is. A protocol is a set of rules followed by two or more modules to understand what they communicate to each other. As an analogy, imagine two people who speak Danish and a third who speaks Hindi. If the Danish speakers cannot speak Hindi and the Hindi speaker cannot speak Danish, communication between them appears as a random collection of unfamiliar letters or unrecognisable sounds. They need an interpreter to communicate.
Inter-system and intra-system protocols are distinguished according to whether two modules communicate within one system, such as a circuit board, or beyond the system. Intra-system protocols communicate internally. In our analogy, this would be the Danish and Hindi speakers communicating without outside help and understanding each other’s language. Inter-system protocols communicate beyond a system.
The specific communication protocol determines how the data is transferred, whether inter- or intra-system. Examples include SPI, I2C and UART.
SPI
SPI uses the “MasterSlave” principle. SPI, Serial Peripheral Interface, uses synchronous transmission. It transmits serially and has no built-in error checking. Communication between master and slave (think of them as transmitter and receiver modules) is full-duplex—one bit is transmitted by both devices per clock cycle.
I2C
I2C, IIC, “I squared C” or “Inter-Integrated-Circuit”, is a bus protocol that transmits data serially and synchronously. It can have multiple masters and slaves in one system. The protocol needs 2 connections, SDA (Serial DAta) and SCL (Serial CLock). SCL carries the clock signal, which determines the data transmission speed.
I2C uses start and stop conditions to delimit transfers; see Figure 6. These do not by themselves guarantee error-free data.
Figure 6: The transfer begins with a START condition, followed by the address of the device the controller wants to communicate with and a read/write bit. ACK/NACK is the receiver’s acknowledgment or lack of acknowledgment after a byte; it is not a checksum guaranteeing error-free data. The figure shows 2x 8 data bits after the first ACK/NACK. Each byte is followed by ACK/NACK before the transfer ends with a STOP condition.
UART
UART converts between parallel internal data representation and serial transmission. Two UART devices can communicate point to point. Transmission is asynchronous: there is no shared clock wire, but both devices use their own timing and must be configured for the same baud rate and frame format. UART itself does not define master/slave roles.
UART data packets are structured as shown in Figure 7.
Figure 7: UART data packet
Device Driver
Now we know a little more about how electronics transmit and receive data. But where do we receive the transmitted data? For this, we use device drivers. What are they?
A device driver is a computer program that enables an operating system to communicate with different kinds of hardware, connecting many different modules. The idea is that the hardware manufacturer only needs to make one type of hardware (or as few as possible) and make it work with different operating systems. A driver therefore needs to account for many factors so it can support these different forms of communication between electronics as efficiently as possible!