Sensors, interfaces and bus systems (SENIN, BUSSY)

Hardware interfaces and buses (wiki)

last updated: 2021-11-09

Quick links


Song of this chapter: Interface > Angels in Disguise > Angels in Disguise

The word "interface" can refer to many things. One definition in the dictionary is:
The place at which independent and often unrelated systems meet and act on or communicate with each other.

We will look here at hardware interfaces mostly used by microcontrollers (or computers) to interact with internal or external devices, buses or networks. So we use here more the electrical and physical definition of interface. In the real world the word "port" is used interchangeably for interface (e.g. USB interface or port). If we look from the networking side it is better to distinguish both. A port resides at layer 1 of the OSI model (physical layer) and the interface resides more at layer 2 of the OSI model (data link layer).

Most interfaces need beside the physical definitions a communication protocol to be able to transmit data. A protocol (e.g. TCP or SMTP) is a set of rules and procedures needed for the communication and can be implemented in hardware or software. Protocols need to be standardised, so that devices from different manufacturers can communicate.

An interface is an endpoint, and endpoints are connected together via a bus. The bus carries the signals (data).

Electrical connectors are often a part of the physical interface and they often help to identify the interface.

Characteristics of interfaces

Interfaces can be categorised using the following characteristics:

The continuously improvements of electronic components (e.g. accuracy, speed) and data processing leaded in the past decades to digital and serial interfaces.

Analog interfaces are seldom used today. Parallel interfaces are used when very high speed is needed (internal buses in microcontroller or computer) but also seldom as external interface.

Serial means that the data is sent spread over time (time-division multiplex), most often one single bit after another.

The mechanical properties are important and can determine if an interface will be accepted an spread. As an example for USB, the standard connectors were designed to be more robust than many past connectors. USB would not be so successful if the connectors would be less robust.

Digital and serial (wiki)

The benefit of digital signals is that they can be processed and transmitted without introducing significant additional noise or distortion. Degradation can even be detected and corrected.

In a serial transmission the data is transferred bit by bit from the sender Tx to the receiver Rx over one data line. With the help of shift register (see MICSY) the parallel data is converted to a serial stream. The data clock is normally generated by the sender. The receiver will re-transform the serial data stream to the parallel data, also with the help of a shift register.

serial block diagram

The clock generated by the sender will define the bit rate (number of bits send per unit of time) in bit/s (bits per second). Normal rates begin at 9600 bit/s to Gbit/s (normally here the metric prefixes are used so G for one billion bits/s).

The big benefit of serial interfaces is the low wire respectively pin counts (cheaper and better handling). Serial communications can be performed with just two wires or one I/O pin. Serial communication can reach long distances, and we get less crosstalk and no clock skew (for asynchronous communication)).

Some examples of digital serial hardware interfaces:

USB, Firewire, TIA-232 (formerly RS-232, EIA-232 oder V24), TIA-485 (formerly RS‑485, EIA-485), I2C, SPI, S-ATA, PCI-Express, HDMI, DisplayPort, IrDA, Bluetooth, CAN (automotive), S0 (ISDN), MIDI, S/P-DIF, , Ethernet, WLAN, A2DP via Bluetooth, AC'97, ADAT Lightpipe, AES3, AES47, I²S (Inter-IC sound), MADI (Multichannel Audio Digital Interface)

In serial communication the receiver must sample the signal at the same time intervals used by the transmitter. This can be achieved asynchronously or synchronously, so we distinguish the asynchronous and the synchronous serial communication:

Asynchronous or synchronous

In asynchronous serial communication the sender and receiver are not continuously synchronized by a common timing clock signal. So the synchronization information has to be contained in the data stream. This is done normally with start information (e.g. start bit) at the beginning and stop information (e.g. stop bit) at the end of the stream.

serial asynchronous start stop

A good example of asynchronous serial communication is the keyboard of a PC. Data is only sent if the user hits a key.

Asynchronous synchronisation will only work when sender and receiver use the same signalling parameters like the number of bits per character (including parity info), the number of stop bits, the bit rate ....

In synchronous serial communication, often a second wire is used to add a clock signal (sometimes named strobe) that helps the receiver to stay synchronised with the sender (same bit rate) and so sample the signal at the same time intervals used by the sender.

The synchronisation can also be maintained with the help of extra information in the data stream used to synchronize both clocks. This can be a predefined sequence of bits or bytes at the beginning of a block or a coded data stream containing clock information. In synchronous synchronisation it is possible to adapt the bit rate. Normally a buffer is needed because a certain amount of data is used to built a block.

The advantages of asynchronous communication are that it is simple, cheap (simple hardware) and optimal for a communication that pauses a lot. The disadvantage over synchronous communication is the overhead (e.g 10 bit for 8 bit pf data) which makes the communication slightly less fast.

Duplex (wiki) and multiplex (wiki)

In simplex communication is only in one direction: one device transmits and the others listen (e.g. radio and television broadcast).

In point to point duplex communication two connected devices can communicate with one another in both directions. We distinguish full-duplex (FDX) and half-duplex (HDX). In full-duplex both devices can communicate with each other simultaneously (e.g. telephone). In a half-duplex both devices can communicate with each other only alternately in time (e.g. push-to-talk walkie-talky).

simplex duplex

In point-to-multipoint networks (e.g. cellular networks (UMTS, DECT, VDSL)) the forward and reverse communication channels have to be divided on the same physical communications medium. Time-division duplexing (TDD) and frequency-division duplexing (FDD), also named time-division multiplexing (TDM) and frequency-division multiplexing (DDM) can be used.

In TDM synchronized switches at each end of the channel make appear each signal a fraction of time in an alternating pattern (e.g. used in digital telephony). In FDM the total bandwidth of the channel is divided into non-overlapping frequency bands which are used to carry separate signals (e.g. used in radio and television broadcasting).

Peer, bus and master/slave

If two interfaces are connected directly together we call them point-to-point or peer interfaces. In a peer relation there are no masters or slaves. Peer interfaces are most often asynchronous (e.g. TIA-232).

If more interfaces share the same medium, we call this a bus. The time in communication must be shared. This is normally done by a master. The other devices are called slaves. Each device has an individual address. Master/slave buses (e.g. I2C-Bus, SPI) are often synchronous and it is the the master that supplies the timing clock signal.

There exist also multi-master buses. An arbitration scheme must take care of conflicts (two masters need the bus at the same time).

Wire or wireless

For reliability and security reasons data communication over wire is always preferable to wireless communication. This is why enterprises stay resolutely wired.

We will look at the wireless protocols in a later chapter.

Other criteria

Other criteria could be:

An interesting article about this criteria can be found here.

"Just do it" Interfaces 1:

Microcontroller interfaces

In IoT devices microcontroller communicate with sensors or other devices. Often in IoT projects the microcontroller is chosen depending on the disposable interfaces. Interfaces integrated in hardware are always preferable to software only solutions (.e.g. Softserial). They are more stable and use less of the microcontroller resources. Here some of the most important hardware interfaces used by sensors and microcontroller:

wiring 232 i2c spi

TIA-232 (wiki)

This interface formerly known as RS-232 is one of the oldest interfaces (1960!!) in use and its importance doesn't diminish even with its limited speed. In the contrary its simplicity assured the continued existence.

TIA-232 uses today normally only two wires Tx and Rx (duplex, three including GND) and is used for communications between just two devices. In special cases supplementary handshaking wires are used for control of data flow. In modern microcontroller one to six UART or USART (hardware device for serial communication) are implemented for serial communication.

The communication is asynchronous, full duplex and typical speeds range from 9600 bit/s to 115200 bit/s. TIA-232 is often used for long (tens of meters), inter-equipment links with a voltage of ± 12V. For this it needs a level converter like the MAX232.

I²C (wiki)

I²C (Inter-Integrated-Circuit) was developed by Philipps (now NXP) intended for communication between IC's in Audio and Video devices. It is a synchronous, half-duplex interface on a (multi)master/slave bus. Many special IC's can be used directly on this bus. The IC's have an own selectable address. More than one master can be used on the bus (multi-master). I2C is a superset of the Intel's SMBus.

We get two open drain lines: serial clock (SCL) and serial data (SDA) (3 wires including GND). Standard bit rate is 100 kbit/s, but today often the faster 400 kbit/s are used. Higher speeds (1 Mbit/s, 3.4100 Mbit/s) are possible but reduce the length of the connecting wires.

On AVR controller the interface is called TWI (two-wire-interface).

SPI (wiki)

SPI (Serial Peripheral Interface) was developed by Motorola for communication between microcontroller. So high speed (> 10 Mbit/s) with short connections is possible. It is a synchronous, full-duplex interface on a master/slave bus.

Three lines are needed for the communication: serial clock (SCLK/SCK/SCL), serial data in (SDI/MISO master in slave out) and serial data out (SDO/MOSI: master out slave in). SPI has no device addressing, so in addition to the communication lines one or more selection lines (one for each slave) named slave select (SS) are needed. This makes min. 5 lines including ground, with one slave.

TIA-485, 1-wire, CAN bus, USB, Ethernet, WiFi, BLE

Other wireless protocols like Z-Wave, LoRa or XBEE will be covered in a later chapter.

Comparison table

Here is a rough comparison table for the 5 interfaces. If you want to choose an interface for a project it is important to look at the details!

wires (no ground/Vcc) 2 (Rx, Tx) 2 (SCL, SDA) min. 4 (MISO, MOSI, SCL, SS) 2 (D+, D-) 2 (CAN H+, CAN H-)
synchronisation asynchronous synchronous synchronous synchronous synchronous
duplex full half full full full
bus point to point (multi)master/slave master/slave master/slave (multi)master/slave
bit rate [Mbit/s] slow (0.1152) limited (0.4) fast (10) real fast (480) limited (1)
distance* 20 m (1200 m with TIA-485 ) 1 m less than 1 m 1 m-3 m 100 m
security low simple simple complex high
costs lowest cost low cost low cost low cost expensive
complexity (development) simple simple simple complex complex

* the distance heavily depends on the used cables and speed, so the values are only roughly approximate.