Are you a beginner looking for some insight on serial communication? If yes, then you’ve landed on the right page. This article will walk you through a detailed introduction of serial communication, its types and how you can implement it using Arduino.
What Is Serial Communication?
Serial communication is a two-way transfer of data between a transmitter and a receiver, using a single communication channel. In simple words, it is the transfer of bits between two parties, over a single wire. The special part about serial communication is that the bits are transferred one after the other which means that a single bit is transmitted in one time slot.
There are certain parameters that need to be understood before we move towards knowing how serial communication works. Here is a brief explanation of these parameters:
Baud rate is a measure of the number of bits transmitted in one second. It allows us to measure the speed of transmission i.e. a higher baud rate means that the transmission is faster because more number of bits are travelling from the sender to the receiver.
There are four types of parity bits – odd, even, spaced and marked. They are used for error detection and correction in serial communication.
Stop bits indicates the end of a packet. Since the transmission of bits is continuous, these bits act as markers between successive packets of information.
How Does Serial Communication Work?
Serial communication requires two serial devices – a sender and a receiver. Both devices must have a TX (transmitter) and an RX (receiver) pin and the TX pin of the sender must be connected to the RX pin of the receiving device.
Serial communication can be configured in three different ways namely simplex, half-duplex and full-duplex. These configurations have the same elements (transmitter, receiver and communication channel) yet they differ from one another. How? Let’s find out.
Simplex involves one-way communication i.e. the sender can only send signals to the receiver and not receive anything. A classic example of simplex is the radio where only the radio station transmits signals and the listeners receive it. The listeners cannot respond back to the radio station.
This mode of transmission is a partial two-way communication where a device can send and receive signals but not at the same time. When the sender transmits a signal to the receiver, the receiver cannot respond back at the same time. An example of a half-duplex is a walkie talkie, formally known as a two-way radio where only one person at a time can talk, the other person has to wait until the first one finishes talking.
Full-duplex is a two-way communication between a sender and a receiver where both the parties can send and receive signals at the same time. Mobile phone calls are the best example of a full-duplex configuration
Serial vs. Parallel Communication
Now that you know what serial communication is, let’s talk about parallel communication. Sending information one bit at a time is called serial communication and sending them side by side, at the same time is termed as parallel communication. Using parallel communication, you can send more number of bits at the same time which means you can achieve a greater baud rate.
Since parallel communication allows multiple bits to be transmitted at the same time, it requires more number of wires hence is expensive as compared to serial communication. An example of serial communication is transmission of data between two computers whereas communication between a computer and printer is parallel communication.
So, which one’s better? Parallel communication might sound like a better option because of its high speed but practically, serial communication is the wiser choice because it supports full duplex communication and that has better applications in microcontroller based projects.
Hardware Implementation of Serial Communication
Now, let’s come to the real part. How can you implement serial communication through hardware? There are two very common serial communication hardware – RS232 and TTL which we will discuss in the next section.
RS232 vs. TTL
What is RS232?
RS232 is a very popular serial communication protocol used in many devices. It is also used by the serial ports in your computer. It connects a DTE (Data Transmission Equipment) to a DCE (Data Communication Equipment), for example, when connecting a computer to a modem, DTE is the computer and DCE is the modem.
RS232 signals in PCs swing between +13V and -13V where the high logic evel (1) is represented by the negative voltage and the low logic level (0) is represented by the positive voltage.
RS232 connects equipment via these five pins – TXD (transmitter), RXD (receiver), RTS (request to send), CTS (clear to send) and GND (ground). It offers a simplex mode of transmission by connecting a maximum of two devices across a maximum cable length of 15m. The maximum speed of data transfer that can be achieved is 20 kbps.
The advantage of using RS232 for serial communication is that it is low cost because of simple wiring and it is widely used all around the world. The disadvantage of using this protocol is its speed of 20 kbps, which is very low and it does not work for devices placed more than 15 feet apart.
To use with Arduino, the RS232 device available is called Grove RS232. It is a serial communication module which needs no jumper wires or soldering. All you need to do is plug the device in and start sending signals through serial communication.
What is TTL?
Transistor-Transistor Logic (TTL) is another serial communication used in many microcontrollers these days. It is specifically used by UART (Universally Asynchronous Receiver/Transmitter), a transmission system used in a number of microcontrollers including Arduino.
TTL can be understood as a transmission of 1s and 0s. 1 being the high level (5 Volts or 3.3 Volts) and 0 being the low level (0 Volts). The signals swings between these two levels only. This implies that we can work on low voltages via TTL and it is highly used in microcontrollers these days. Moreover, it is a low cost and easy to use transmission system.
TTL is a bit noisy as compared to RS232 and it has a limited frequency. At higher frequencies, it requires more power to function.
Which One Is Better?
We can compare RS232 with TTL based on the following features:
· Logic level – the logic levels are inverted between the two protocols. RS232 considers a positive voltage to be a low level whereas TTL considers a negative voltage/0V to be a low logic level.
· Noise – RS232 signals swing between +13V and -13V which means they can travel further than the low voltage signals in TTL. Hence, RS232 signals are more resistive to noise and external interference.
· Voltage Range – RS232 signals operate at a greater voltage (+13V to -13V) as compared to TTL signals which swing between 0 Volts to 3.3 Volts or 5 Volts.
· Using with a microcontroller – It is pretty obvious that TTL is much more compatible with a microcontroller such as Arduino because the voltage range of Arduino is between 0 Volts to 3.3/5 Volts.
If you are working with microcontrollers, then TTL is a much better choice for serial communication. Otherwise, you can choose between the two as per your requirements.
How to Convert Between RS232 and TTL?
Since RS232 and TTL cater to two completely different signals, one having a high voltage range and the other one having a low voltage range. Plus, the RS232 signals are inverted as compared to TTL signals. So, how can you convert between the two signals?
The best solution for this problem is the easy to use MAX3232 converter which sells for around $3. It easily converts between RS232 and TTL, without the need of any external circuitry. All that you need to do is connect its RX and TX pins to the sender and receiver devices, respectively and connect the Vcc and GND pins of the module. You will notice the LED indicator light up and that’s when you are good to go.
You can also build your own circuit using transistors to invert the signals between the two devices and some capacitors to pump up the voltages for TTL to RS232 conversion. You can find a schematic for this circuit through a simple Google search.
Arduino is compatible with TTL because of its voltage levels (0 or 3.3/5 Volts). If you are connecting your Arduino to your computer for serial communication then you need a converter such as Grove RS232 as mentioned above. It has a serial connector at one end and a TTL connector at the other end. These converters are essential if you are working on a project that requires monitoring values on the computer using its serial port.
Generally, TTL is a better option for serial communication because of its low voltages, it is easy to implement and is compatible with many microcontrollers but, if your project requires you to use RS232 then you must use a convertor module when working with Arduino boards.
Now that you know everything about serial communication, we wish you all the best for working on your upcoming serial communication projects!