2.4.1.1. Overview
UART (Universal Asynchronous Receiver-Transmitter) asynchronous serial data transmission, this is one of the most used device-to-device communication protocols.
UART communication is widely used in applications to communicate with modules such as: Wifi, Bluetooth, Xbee, RFID card reader module with Raspberry Pi, Arduino or another microcontroller. This is also a common and popular communication standard in the industry.
2.4.1.2. Data transmission method
In UART communication, two UARTs communicate directly with each other. The transmission UART converts parallel data from a control device such as a CPU into serial form, transmits it serially to the receiving UART, and then converts the serial data back into parallel data for the receiving device.
Fig 2.5. Data transmission method of UART
(Source: https://www.analog.com/en/analog-dialogue/articles/uart-a-hardware-communication-protocol)
19 UART transmits data asynchronously, which implies there is no clock signal to synchronize the transmitting UART's output of bits with the receiving UART's sampling of bits. Instead of a clock signal, the UART adds start and stop bits to the data packet to be transferred. These bits define the start and end points of the data packet so that the UART knows when to start reading the bits. Both UARTs must also be configured to transmit and receive the same data packet structure.
One chip's Tx (transmit) pin connects directly to the Rx (receive) pin of the other chip, and vice versa. Typically, the transmission will take place at 3.3V or 5V. When sending on the Tx pin, the UART converts the parallel data to serial and sends it to the receiving device. The second UART receives this data on its Rx pin and converts it back into parallel to communicate with its control device.
2.4.1.3. Pros and Cons
⮚ Pros:
● Use only two wires.
● No clock signal required.
● There is a parity bit to enable error checking.
● The structure of the data packet can be changed as long as both sides are set up for it.
● The method is well-documented and widely used.
⮚ Cons:
● The size of the data frame is limited to a maximum of 9 bits.
● Does not support multiple slave systems or multiple master systems.
● The baud rate of each UART must be within 10% of the other.
2.4.2. I2C protocol 2.4.2.1. Overview
Philips Semiconductors invented the I2C communication protocol, also known as the inter-integrated communication protocol, in 1982.This allows data to be transferred between a central CPU and several ICs on the same circuit board using only two common wires, and it is extensively used for short-distance synchronous serial communication between microcontrollers, sensor arrays, displays, IoT devices, EEPROMs, and other devices. The I2C multi-master bus has two active wires (Serial Data/SDA and Serial Clock/SCL), and data is carried bit by bit via a single wire.
20 2.4.2.2. Data transmission method
Because I2C is synchronous, the bit output is synchronized to the bit sampling by a clock signal shared by the master and slave. The master is always in charge of the clock signal.
Fig 2.6. Data transmission of I2C
(Source: https://www.circuitbasics.com/basics-of-the-i2c-communication-protocol)
The data that needs to be transferred is sent to the Serial Data Line (SDA) wire and is synchronized with the clock signal from Serial Clock Line (SCL). The devices on the I2C network are connected to the above lines as shown in the above Fig.
The two I2C bus lines are operated as open-drain drivers. This means that any device on the I2C network can drive SDA and SCL low but not high. Therefore, a pull-up resistor is used for each bus line, to keep them positive(high) by default. By using an open drain system, the chances of shorting will be reduced.
The devices which are connected to the I2C bus are called masters or slaves. At any given time, only one master is active on the I2C bus. The master device controls the SCL clock line and the SDA lines, as well as communicating with the slave devices.
When transferring data to or from a slave device, the master specifies a 7-bit address on the SDA line that is assigned to the slave device, and then the data transfer begins. As a result, communication between the master and slave devices is efficient.
21 2.4.2.3. Pros and Cons
⮚ Pros:
● Use only two wires.
● Supports multi-master and multi-slave modes.
● Confirmation that each frame is transferred successfully with ACK/NACK bit.
● Widely used protocol.
● Good error handling functionality.
⮚ Cons:
● Slower data transfer rate.
● Limited size of the data frame (8 bits).
● I2C is a half-duplex protocol which is complex when compared to other protocols.
● Complex hardware and firmware when compared other protocols.
2.4.3. USB protocol 2.4.3.1. Overview
The USB protocol, also known as Universal Serial Bus, was first created, and introduced in 1996 as a way to institutionalize a more widespread, uniform cable and connector that could be used across a multitude of different devices. With the proliferation of technological devices at this time, having a universal cable would help reduce the confusion and inconvenience of having a collection of cables required for each individual device.
2.4.3.2. Data transmission method
Allows expansion of 127 devices connected to the same computer through a single USB port. With the high-speed USB 2.0 standard, the maximum transmission speed is up to -480 Mbps. USB cable consists of two power wires (+5V and GND common wire) as well as a pair of two twisted wires to carry data. On the power cord, the computer can supply up to 500mA at 5V direct current (DC).
Devices that consume low power (e.g., mouse, keyboard, low-power computer speakers...) are powered directly from the USB ports without the need for a separate power supply. For devices that need to use a large power source (such as printers, or scanners) that do not use USB line power as their main source, now it seems that the power transmission only works as a power level generator. signal body.
USB devices have a heat-sensitive property, which means that devices can be connected (plugged in) or disconnected at any time when the user is available without having to reboot the system. Many USB devices can be put into a suspended state when the computer enters power-saving mode.
22 2.4.3.3. Pros and Cons
⮚ Pros
● The universal serial bus is easy to use and low cost
● It has variety of connector types and size available.
● Daisy chain up to 127 USB components / peripherals at the same time to one PC.
● Fits almost all devices that have a USB port.
⮚ Cons
● It has limited capability and overall performance.
● Universal Serial Bus does not provide the broadcasting feature, only individual messages can be communicated between host and peripheral.
● The data transfer not as fast as some other systems.
2.4.4. Modbus protocol 2.4.4.1. Overview
Modicon, Incorporated created the Modbus protocol in 1979 for industrial automation systems and Modicon programmable controllers. It has become an industry-standard method; for transferring discrete/analog I/O information and data registers between industrial monitoring and control devices. Modbus is now a widely accepted, public domain protocol; requires a license, but does not require royalties to be paid to its owner.
2.4.4.2. Data transmission method
Modbus is transmitted over serial lines between devices. The simplest setup would be a single serial cable connecting the serial ports on two devices, Master and Slave.
The data is encoded in binary, and only one communication byte is required for one data byte. This is the ideal communication protocol for RS232 or RS485, a rate from 1200 to 115000 baud. The most common rate is between 9600 and 19200 baud.
MODBUS RTU is the most widely used industrial communication protocol.
The RS485 module is a communication function device to combine with a PLC to implement RS485 communication protocol with other devices. For transmission frames, frames are transmitted according to standard Modbus RTU frames. In programming for PLCs, function modules are used for connection and data transmission. We only need to conFig and set variables to connect and transfer data to the field device. Before entering the programming part, we need to conFig the CM1241 module (Module RS485) to be connected to the PLC.
23 2.4.4.3. Pros and Cons
⮚ Pros
● Development with industrial applications
● Easy to deploy and maintain.
● It is a public protocol, free to download and copyright-free.
● Enables fast and efficient communication between devices in the network.
● Connect a monitoring system to remote terminals in a monitoring control and data acquisition system.
⮚ Cons
● The biggest drawbacks of Modbus tcp / ip network is that Modbus has no form of object but only space reserved for addresses.
● It uses only two types of data (Boolean and 16bit unsigned integer).
● It is limited to Ethernet / IP, ProfiNet IO, etc.
● It has a relatively low data rate (Kbit/s).