Serial Communication Basics

Hi guys today we will see the Basics of Serial Communication Basics Tutorial.

Serial Communication Basics Tutorial

Introduction

What is mean by communication?

Exchanging the data between two systems is termed as communication. Datas can be anything and in any form – they could be written/spoken words, in form of media like audio/video. But what does communication between two microcontrollers mean? Its simple! An exchange of data (bits)! There are many protocols for communication (which would be discussed later) but all of them are based on either serial communication or parallel communication.

Types of communication

Basically there are two types of communication

  • Parallel communication
  • Serial communication

Parallel communication

Ex.Printer

  • It will send one byte at a time (8-bits).
  • Fast, but distance cannot be great.
  • Expensive.

parallel-transfer-embetronicx Serial Communication Basics

Serial communication

 Ex.Telephone line

  • It sends one bit at a time.
  • Long distance
  • Cheaper

serial-transfer-embetronicx Serial Communication Basics

Types of Serial Communication

There are two methods of Serial Communication.

  1. Synchronous: Transfer block of data (characters) at a time.
  2. Asynchronous: Transfer a single byte at a time.

Serial Communication Terminologies

Now its time to learn about some new words. There are many terminologies, or ‘keywords’ associated with serial communication. We will discuss all of them one by one:

  1. MSB/LSB: This stands for Most Significant Bit/Least Significant Bit. Since data is transferred bit-by-bit in serial communication, one needs to know which bit is sent out first: MSB or LSB.
  2. Simplex Communication: In this mode of serial communication, data can only be transferred from transmitter to receiver and not vice versa.
  3. Half Duplex Communication: this means that data transmission can occur in only one direction at a time, i.e. either from master to slave, or slave to master, but not both.
  4. Full Duplex Communication: full duplex communication means that data can be transmitted from the master to the slave, and from slave to the master as the same time!

communications-embetronicx Serial Communication Basics

  1. Baud Rate: According to Wikipedia, baud is synonymous to symbols per second or pulses per second. It is the unit of symbol rate, also known as baud or modulation rate. However, though technically incorrect, in the case of modem manufacturers baud commonly refers to bits per second.

Importance of Baud Rate

For two microcontrollers to communicate serially they should have the same baud rate, else serial communication won’t work. This is because when you set a baud rate, you direct the microcontroller to transmit/receive the data at that particular rate. So if you set different baud rates, then the receiver might miss out the bits the transmitter is sending (because it is configured to receive data and process it with a different speed!).

If you don’t understand still i will tell you the small explanation that will help you. You and Me are playing game which is called catch and throw the ball. So my task is throw the ball. Your task to catch those balls which were thrown by me. Ok this is the game. Here my capacity is i can throw 10 balls per minute. Your capacity is you can catch 10 balls per minute. So i’m throwing the 10 balls. You can catch the all balls. Can’t you? So now i drink some energy drink or whatever. My strength got increased. So now i can throw 20 balls per minute. But your capacity is still 10 balls. Now tell me. Can you catch the all balls? You cant, right. So our strength should be same for catch all balls. I hope you got it now. So here strength is baudrate. Balls are datas.

Different baud rates are available for use. The most common ones are 2400, 4800, 9600, 19200, 38400 etc. You cannot choose any arbitrary baud rate, there are some fixed values which you must use like 2400, 4800, etc. Please note that the unit of baud rate is bps (bits per second).

Serial Transmission Modes

Serial data can be transferred in two modes – asynchronous and synchronous.

Asynchronous Communication

Data Transfer is called Asynchronous when data bits are not “synchronized” with a clock line, i.e. there is no clock line at all! Whenever we are using asynchronous mode that time baud rate is important. 

asynchronous-embetronicx Serial Communication Basics

Synchronous Communication

Synchronous data transfer is when the data bits are “synchronized” with a clock pulse. In synchronous transmission, the clock data is recovered separately from the data stream and no start/stop bits are used. This improves the efficiency of transmission on suitable channels since more of the bits sent are usable data and not character framing.

UART   – Universal Asynchronous Receiver and Transmitter 

USART – Universal Synchronous Asynchronous Receiver and Transmitter

The only difference between them is that UART supports only asynchronous mode, whereas USART supports both asynchronous and synchronous modes. Unlike Ethernet, Firewire etc., there is no specific port for UART/USART. They are commonly used in conjugation with protocols like RS-232, RS-434 etc. (we have specific ports for these two!).

Serial Communication Protocols

A variety of communication protocols have been developed based on serial communication in the past few decades. Some of them are:

  1. SPI – Serial Peripheral Interface: It is a three-wire based communication system. One wire each for Master to slave and Vice-versa, and one for clock pulses. There is an additional SS (Slave Select) line, which is mostly used when we want to send/receive data between multiple ICs.
  2. I2C – Inter-Integrated Circuit: Pronounced eye-two-see or eye-square-see, this is an advanced form of USART. The transmission speeds can be as high as a whopping 400KHz. The I2C bus has two wires – one for clock, and the other is the data line, which is bi-directional – this being the reason it is also sometimes (not always – there are a few conditions) called Two Wire Interface (TWI). It is a pretty new and revolutionary technology invented by Philips.
  3. FireWire – Developed by Apple, they are high-speed buses capable of audio/video transmission. The bus contains a number of wires depending upon the port, which can be either a 4-pin one, or a 6-pin one, or an 8-pin one.
  4. Ethernet: Used mostly in LAN connections, the bus consists of 8 lines, or 4 Tx/Rx pairs.
  5. Universal serial bus (USB): This is the most popular of all. Is used for virtually all type of connections. The bus has 4 lines: VCC, Ground, Data+, and Data-.
  6. RS-232 – Recommended Standard 232: The RS-232 is typically connected using a DB9 connector, which has 9 pins, out of which 5 are input, 3 are output, and one is Ground. You can still find this so-called “Serial” port in some old PCs. In our upcoming posts, we will discuss mainly about RS232 and USART of AVR microcontrollers.

RS232:

RS232 is set by Electronics Industries Association (EIA) in1960.

  1. 1963: RS232A

  2. 1965: RS232B

  3. 1969: RS232C

  4. RS232 is a serial I/O interfacing standard; however, since the standard was set long before the advent of the TTL logic family, its input and output voltage levels are not TTL compatible.

  5. TTL is Transistor-Transistor Logic family (Bipolar transistor) in 1968.

Line Driver: MAX232:

  1. RS232 is not compatible to TTL. For this reason, to connect any RS232 to a microcontroller system, we must use “Voltage Converters” such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa.

  2. MAX232 IC chips are referred to as “Line Driver”.

RS232 Connector: (DB-9):

db9-embetronicx Serial Communication Basics

Thanks for reading. If you have any doubts please ask us by commenting below.

 

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!