Have you ever wondered how do instruments communicate with microcontrollers?
Communication between electronic components is similar to that between humans. Both the components need to speak in the same language in order to understand each other. For electronic components, these languages are known as communication protocols. Communication protocols are rules required to exchange information between computers and instruments. Serial Peripheral Interface (SPI), Inter- Integrated Circuit (I2C), Universal Asynchronous Receiver / Transmitter (UART), Controller Area Network (CAN) and Universal Serial Bus (USB) are ideal communication protocols which people use for communication between microcontrollers.
- Serial Peripheral Interface (SPI)
SPI is a common communication protocol used in various devices like SD card modules, RFID card reader modules, etc. When designing an embedded system, it is important to consider how the speed of the system is. The speed will largely impact user experience. Thus the communication protocol should allow rapid data transfer. SPI has higher data transfer rate. In SPI, devices communicate in a master-slave relationship. The master is the controlling device which usually is a microcontroller, while the slave usually a sensor, display, or memory chip takes instruction from the master. In SPI, since there are no start and stop bits, data can be streamed continuously and thus data can be transferred without interruption.
- Inter- Integrated Circuit (I2C)
It is a half-duplex bi-directional two-wire bus system for transmitting and receiving data between masters and slaves. In I2C only two signals are used regardless of the number of devices on the bus. Signals used are clock and data. Both these signals are pulled up to a positive power supply voltage. In I2C, every device interfaces to the data and clock signal through open-drain output drivers. Each slave here has a 7-bit address and the master must know these addresses so that it can communicate with a particular slave. The master can write data to one or even more than one slaves. It can also request data from any slave. Thus, all transmissions are initiated and terminated by a master.
- Universal Asynchronous Receiver / Transmitter (UART)
UART (Universal asynchronous receiver transmitter), as the name indicates, is an asynchronous communication protocol which does not use any clock source for synchronizing the data, so there are more chances of losing the data over UART protocol. UART has two wires for its transmitting and receiving ends. The main purpose of a transmitter and receiver line is to transmit and receive serial data which is intended for serial communication. The transmitting UART is connected to a controlling data bus which sends data in a parallel form. Then, the data is transmitted on the transmission line serially i.e. bit by bit, to the receiving UART. Then the receiving UART converts the serial data into parallel data for the receiving device.
- Controller Area Network (CAN)
CAN is a serial communications bus. It was initially developed for the automotive industry so as to replace the complex wiring harness with a two-wire bus. The specification of CAN has high immunity to electrical interference and the ability to self-diagnose and repair data errors. These features have led to CAN’s popularity in a variety of industries which includes automation, medical, and manufacturing to name a few. The CAN bus is a broadcast type of bus. This means that all nodes can hear all the transmissions. There is no facility to send a particular message to a specific node. All nodes will pick up all the traffic. The CAN hardware provides local filtering so that each node may react only on the interesting messages. CAN uses short messages. The maximum utility load is 94 bits. There is no explicit address in the messages; instead, the messages can be said to be contents-addressed, that is, their contents implicitly determines their address.
- Universal Serial Bus (USB)
USB hosts also known as master devices, initiate all the communication that occurs over the USB bus. Typically, a computer or other controllers are considered to be the master, only responding to other devices if requesting certain information. The host and slave devices are connected. The slave device is programmed in such a way that it provides the host device with the information it needs to operate. Typically, slave devices include USB flash drives, keyboards, and other such devices. It is important for host and slave devices to be able to effectively communicate with each other. If either one is not able to perform its job function, the communication between the two devices would be interrupted.