Communication Protocols

From Idea Shop Wiki
Revision as of 23:01, 14 April 2020 by Dchraca (talk | contribs)

This page will give the reader a fundamental foundation of different widely used digital communication protocols. There is are many difference with analog and digital signals, but fundamentally are the same. The introduction talks about both types through the analogy given so understanding they are the same in this context will be very helpful.

Introduction

Transmitting information has been around longer than humankind can recall. Transmitting information can be done in an infinite number of ways. But with any kind of transmission of information, there are some fundamental building blocks. These building blocks can be seen in the diagram.

communication1.jpg

This is extremely basic and more systems can have more complex designs in the communication process. Furthermore, in the case of two Indian speaking humans communicating verbally, this diagram stands. When one individual wants to speak, the data needs to be converted. This way of conversion matters on two factors, the data median and the common language. The communication data must first be converted in the common language (Hindi) and then transmitted (verbally). The data median is air so this is why it must be verbally transmitted. Then the receiver must receive the data then decode it, then interpret what the data means. Now then data being transmitted verbally is in an analog pattern. This analog pattern is extremely complex and this is why large amounts of data can be transmitted human to human in just a single word. The picture below shows the pressure wave of a human saying a word. communication2.png

In digital, the signal is either on or off. Or in vocal communication, it is either the person is yelling at the top of their lungs, or they are not. The communication graph would look like this.

[[File:communication3.png]

From all of these on and off states, a system can begin decoding the data. A common encoding and decoding protocol to use is the ASCII protocol. This protocol represents english letters as a 7 digit string of 1s and 0s. This can be the same as just writing a regular number but with binary, it must be as 1s(on) and 0s(off). These ones and zeros are called bits. The letter ‘B’ would be represented as 1000001. Once this concept is fully understood, learning any communication protocol will be much easier.

communication4.png

USART ( universal synchronous and asynchronous receiver):

A common way for this type of signal to be transmitted would involve a clock, some kind of pulse that would tell the receiver to write down the state of the signal (1 or 0). The picture below shows the type of connection between the microcontroller and another microcontroller, neglecting the slave signal. USART doesn’t need to be both microcontrollers, it can honestly be any device with this supported transmission type.

communication5.jpg

The TX stands for transmission (data that is being sent from the device), RX stands for receive (data being sent to the device), and a common clock. This clock is going to basically put both devices on the same talking speed (baud rate or equivalently bits per second). First, a start bit is sent, this will tell the receiver it is sending. The diagram below shows a data packet (or frame) below the receiver to know that data is being sent.

communication6.png

The next 8 bits will be the actual data, once all the data bits are sent, a parity bit and a stop bit will be sent. The parity bit is to tell if the data was corrupted or not. The stop bit is to tell when the signal is finished being sent. The parity and stop bit are both there to see if the data has been corrupted or not. This is just one variation of USART, USART can be customized in many different ways. For instance, the amount of data packets being sent in one packet can be changed from 5 to 9 bits. There can also be 2 stop bits to make sure that the whole frame was sent properly. Say one device wants to send “Hello” in ascii format; then, the controller would have to send individual letters in each packet: that sounds like it would take a long time; however, in actuality, the microcontrollers are doing this in insanes speeds. A common baud rate is 9600b/s (bits per second), so say the packet was the one in the picture. The amount of bits per packet is 11 and we have 5 letters to send which would be 5 packets. This would take 55 bits of data to send “Hello”. To send this, it would take 55b / 9600(b/s) = 5.7ms. Furthermore, these speeds can be increased even higher but this is dependent on the speeds of both devices. USART can also operate without a clock, this method works the same way but the signals must be both programmed at a set baud rate beforehand. The pro of this approach is that there is only a need of two wires, but the con is that the baud rates are a lot lower than with the clock. Using without the clock is also commonly called UART.

Examples with using UART with the arduino to arduino: https://iot-guider.com/arduino/serial-communication-between-two-arduino-boards/