Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Posted by Yash on Sep 3, 2013 in Atmel AVR, Getting Started, Microcontrollers Search
| 33 comments
Microcontrollers
This post will cover the basics of serial communication and will be mostly a
theoretical topic. We will do some practical stu from next tutorial onwards.
Lets have a glance at the contents. Browse maxE by Categories
What is Communication?
26
Shares Why do we need Communication?
23
Serial Communication
Join our newsletter today for free. Enter your email address Subscribe Now
Subscribe to maxEmbedded
×
Parallel Communication
Serial vs Parallel Communication
Email Address
Major Factors Limiting Parallel Communication
Advantages of Serial over Parallel
How is Data sent Serially? Subscribe
Serial Transmission Modes
Asynchronous Data Transfer
Synchronous Data Transfer
Like maxE on Facebook
Serial Communication Terminologies
Importance of Baud Rate
The Catch in Serial Communication
UART and USART
Sponsored Links
Serial Communication Protocols
What is Communication?
Before we move on to serial communication, lets discuss a bit about
communication in general. In simple terms, communication is an exchange
of ideas between two individuals. Ideas can be anything and in any form –
they could be written/spoken words, in form of media like audio/video, or if
you like sci- , then it can also in form of telepathy! ;)
Lets take another example. This one’s a more common example. You have a
le in your mobile and you would like to share it with your friend who is
sitting next to you? How would you do it – Bluetooth, IR, NFC, LAN or email?
Mostly people would use Bluetooth. IR is obsolete, NFC is still in
developmental phase and isn’t available in most devices, LAN needs a
WiFi/LAN network whereas email requires an active Internet connection.
The same questions can be put forth here as well – how is it send, from
where is it sent and to where, what is being sent and how is it processed?!
26
Shares
Serial Communication
23
Join our newsletter today for free. Enter your email address Subscribe Now
×
Serial Transfer
Parallel Communication
Parallel Transfer
26 Serial vs Parallel
Shares
23
So these were theJoinbasic di erences
our newsletter between
today for free. Enter serial andaddress
your email parallel
communication. From the above di erences, one would obviously think that
Subscribe Now
×
parallel communication is far better than serial communication. But wait,
these are just the basic di erences. Before we proceed further, we need to
be acquainted with a few terminologies:
26
Serial Transmission Modes
Shares
23
Serial data can be Join
synchronous.
transferred
our newsletterin two
today modes
for free. – your
Enter asynchronous and
email address Subscribe Now
×
Lets take an analogy. Imagine you are playing a game with your friend
where you have to throw colored balls (let’s say we have only two colors –
red (R) and yellow (Y)). Lets assume you have unlimited number of balls. You
have to throw a combination of these colored balls to your friend. So you
start throwing the balls. You throw R, then R, then Y, then R again and so on.
So you start your sequence RRYR… and then you end your round and start
another round. How will your buddy on the other side know that you have
nished sending him rst round of balls and that you are already sending
him the second round of balls?? He/she will be completely lost! How nice it
would be if you both sit together and x a protocol that each round consists
of 8 balls! After every 8 balls, you will throw two R balls to ensure that your
friend has caught up with you, and then you again start your second round
of 8 balls. This is what we call asynchronous data transfer.
The rst bit is always the START bit (which signi es the start of
communication on the serial line), followed by DATA bits (usually 8-bits),
followed by a STOP bit (which signals the end of data packet). There may
be a Parity bit just before the STOP bit. The Parity bit was earlier used for
error checking, but is seldom used these days.
The START bit is always low (0) while the STOP bit is always high (1).
We will take the same analogy as before. You are still playing the throw-ball
game, but this time, you have set a timer in your watch such that it beeps
every minute. You will not throw a ball unless you hear a beep from your
watch. As soon as you hear a beep from your watch, you and your friend,
both know that you are going to throw a ball to her. Both of you can keep a
track of time using this; say you start a new round after every 8 beeps. Isn’t
it a much better approach? This approach is what we call synchronous data
transfer.
26
Shares
The concept
23 for synchronous data transfer is simple, and as follows:
Join our newsletter today for free. Enter your email address
The basic principle is that data bit sampling (or in other words, say,
Subscribe Now
×
‘recording’) is done with respect to clock pluses, as you can see in the
timing diagrams.
Since data is sampled depending upon clock pulses, and since the clock
sources are very reliable, so there is much less error in synchronous as
compared to asynchronous.
1. MSB/LSB: this stands for Most Signi cant Bit (or Least Signi cant Bit).
You can refer to Mayank’s this post for more information on MSB and LSB.
Since data is transferred bit-by-bit in serial communication, one needs to
know which bit is sent out rst: 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!
Types of Transmission
26
Shares
23
5. Baud Rate: according
Join our to Wikipedia,
newsletter baud
today for free. is Enter
synonymous
your emailto symbols
address Subscribe Now
×
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.
Di erent 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 xed values which you must use like 2400, 4800, etc. Please
note that the unit of baud rate is bps (bits per second).
1. Baud Rate: Unless the baud rate of both the transmitter and receiver
are the same, serial communication cannot work. The reason is speci ed
in the previous section.
2. Address: If you are trying to send multiple data together over the same
channel and/or you are sharing the same channel space with other users
sending their own data, then you need to take care to properly address
your data. We won’t discuss about it in this post, but we will surely discuss
about it in one of our upcoming posts.
If you take care of these two factors, your serial communication will be
established perfectly and your data will go through properly. These are the
two main reasons for unsuccessful serial link.
USB Pins
So that is it for now folks! We will be discussing about RS-232 and its basics
in the next post! Don’t forget to post your comments and questions
down below! And yes, subscribe to maxEmbedded and stay tuned! :)
Written By-
Yash Tambi
VIT University, Vellore
tambi@maxEmbedded.com
Like this:
Loading...
Related
The USART of the AVR Serial Communication - The SPI of the AVR
September 30, 2013 RS232 Basics November 26, 2013
September 21, 2013
In "Atmel AVR" In "Atmel AVR"
In "Atmel AVR"
26
Shares
23
Publish In Singapore Join our newsletter today for free.
& Affordable. Different Packages To Choose From. Free
Enter your email address Subscribe Now
×
ultation!
dgepublishing.com OPEN
33 Comments
REPLY
Hello Pradeep!
Thank you for the compliment! :)
Stay tuned for more on this! :D
REPLY
REPLY
REPLY
REPLY
Thanks for this wonderful post….i was waiting eagerly for AVR related
post….i am really thankful….great work….
REPLY
Hello Nirdosh!
Thanks a lot! :)
More coming up soon! :D
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
26
Shares
Max April
23 9, 2014
Join our newsletter today for free. Enter your email address Subscribe Now
×
Hello Sunil,
You’ll need to encode the data somehow. You can use only one
single transmitter to transmit data from six sources. So you’ll have
to gure out how you’re gonna go about that. You can transmit
only one byte of data at a time, so may be you can use
multiplexing. Or if something better strikes you, go with that!
You’ll need only one timer to control multiple servos. The idea is to
have a master timer and then wiggle the values of individual pins
in order to generate the PWM output. The CPU won’t do it for you,
you’ll have to do it manually. You might try using the Procyon AVR
library. It has a servo library which can control up to 8 RC servos. I
haven’t used it, may be you could let me know if it works out for
you or not! Keep me posted!
Procyon AVRlib
REPLY
Hello,
I wanted to send data serially from PC to two microcontrollers at the same
time. How can this be done. Can I get some idea.
Thank you.
REPLY
That should be simple. Simply split your RxD line into two and feed
one to each microcontroller. Make sure the settings of both the
microcontroller are the same. This is valid only if the data you
wanna send is same for both the microcontrollers. If the data is
di erent, then you’ll have to use two separate channels (like two
separate USB ports).
REPLY
Hello, Since the pc does not have M-bus interface it necessary to use a
converter RS232/M-Bus.
My question is: is that it is possible to encapsulate the M-Bus(RS485)
protocol in RS232 instead of using a converter?
26
Shares
23 REPLY
Join our newsletter today for free. Enter your email address Subscribe Now
×
I don’t think so. Both the protocols di er a lot. Read this for more
information.
REPLY
REPLY
Just wanted to say, great article, so well explained and made my revision
so much easier!
Thankyou
REPLY
Thanks Tom!
REPLY
REPLY
REPLY
Hi Sir,
Gr8 article.
Thank you
REPLY
Thanks Muskan!
REPLY
that’s mean that SPI and I2C are two di erent types of USART?!!
REPLY
Nope. USART, UART, SPI, I2C, USI, etc. are all DIFFERENT from each
other. They all follow the technique of serial data transfer but
follow di erent protocols.
REPLY
hello sir ,
i am b-tech 3rd year student would like to do a project on uart based
application could u suggest me one
26
Shares REPLY
23
Join our newsletter today for free. Enter your email address Subscribe Now
×
shubham pathak June 26, 2016
please explain me the rst component of USART and what do you mean by
bus,what are Tx,Rx pairs and what is DB9 connector
REPLY
REPLY
AMAZING!!! 😄😄😄
THANK YOU!!!
REPLY
Trackbacks/Pingbacks
Serial Communication – RS232 Basics | maxEmbedded - […] the previous post, we
discussed about the basics of serial communication. In this post, we will learn about
the…
The USART of the AVR | maxEmbedded - […] folks! Lets continue with our tutorials
on Serial Communication. Until now, we have seen a general introduction to serial…
Serial Peripheral Interface – SPI Basics | maxEmbedded - […] An introduction to
serial communication […]
Leave a Reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Home Copyright Privacy Policy Credits Sitemap Contact © Copyright 2011-2014 by maxEmbedded. Some rights reserved.
maxEmbedded is a free and open source platform to share knowledge and learn about the concepts of robotics, embedded systems and computer vision. People from
around the world who are enthusiastic about these topics and willing to support the open source community are invited to share their information, knowledge and
26
Shares
23