0% found this document useful (0 votes)
38 views51 pages

Unit 2

Uploaded by

Joke Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views51 pages

Unit 2

Uploaded by

Joke Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

IIMT COLLEGE OF ENGINEERING

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

EMBEDDED SYSTEM
KOE-062
UNIT-2 EMBEDDED NETWORKING
PRESENTED BY:
Dr. SEEMA NAYAK (PROF & HEAD ECE)

Dr. Seema Nayak


Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Dr. Seema Nayak
Serial Communication basics: Communication between electronic devices is like communication between
humans. Both sides need to speak the same language. In electronics, these languages are called
communication protocols.
SPI, I2C, and UART are quite a bit slower than protocols like USB, Ethernet, Bluetooth, and Wi-Fi, but they’re
a lot simpler and use less hardware and system resources.
SPI, I2C, and UART are ideal for communication between microcontrollers and between microcontrollers and
sensors where large amounts of high speed data don’t need to be transferred.

DATA COMMUNICATION TYPES:


(1) PARALLEL (2) SERIAL: (I) ASYNCHRONOUS (II) SYNCHRONOUS

Parallel Communication:
 In parallel communication, all the bits of data are transmitted simultaneously on separate
communication lines.
 Used for shorter distance.
 In order to transmit n bit, n wires or lines are used.
 More costly.
 Faster than serial transmission.
 Data can be transmitted in less time

Example: printers and hard disk

Dr. Seema Nayak


Serial Communication:
 In serial communication the data bits are transmitted serially one by one i.e. bit by bit on single
communication line
 It requires only one communication line rather than n lines to transmit data from sender to receiver.
 Thus all the bits of data are transmitted on single lines in serial fashion.
 Less costly.
 Long distance transmission. Example: Telephone. Serial communication uses two methods:
 Asynchronous, Synchronous.
Asynchronous:
 transfers single byte at a time
 No need of clock signal
Example: UART (universal asynchronous receiver transmitter)
The term asynchronous is usually used to describe communications in which data can be transmitted
intermittently rather than in a steady stream. For example, a telephone conversation is asynchronous because
both parties can talk whenever they like.

Synchronous:
 Transfers a block of data (characters) at a time.
 Requires clock signal
Example: SPI (serial peripheral interface), I2C (inter integrated circuit).
Synchronous data transfer In program-to-program communication, synchronous communication requires that
each end of an exchange of communication respond in turn without initiating a new communication. A typical
activity that might use a synchronous protocol would be a transmission of files from one point to another. As
Dr. Seema
each transmission is received, a response is returned Nayak
indicating success or the need to resend.
Data Transmission: In data transmission if the data can be transmitted and received, it is a duplex
transmission.
Simplex: Data is transmitted in only one direction i.e. from TX to RX only one TX and one RX only
Half duplex: Data is transmitted in two directions but only one way at a time i.e. two TX's, two RX’s and one
line
Full duplex: Data is transmitted both ways at the same time i.e. two TX's, two RX’s and two lines
A Protocol is a set of rules agreed by both the sender and receiver on
• How the data is packed
• How many bits constitute a character
• When the data begins and ends
Dr. Seema Nayak
Dr. Seema Nayak
Baud Rate Concepts: Data transfer rate in serial communication is measured in terms of bits per second
(bps). This is also called as Baud Rate. Baud Rate and bps can be used inter changeably with respect to
UART.
Ex: The total number of bits gets transferred during 10 pages of text, each with 100 × 25 characters with
8 bits per character and 1 start & stop bit is: For each character a total number of bits are 10. The total
number of bits is: 100 × 25 × 10 = 25,000 bits per page.
For 10 pages of data it is required to transmit 2, 50,000 bits. Generally baud rates of SCI are 1200, 2400,
4800, 9600, 19,200 etc.
To transfer 2, 50,000 bits at a baud rate of 9600, we need: 250000/9600 = 26.04 seconds (27 seconds).

Dr. Seema Nayak


Dr. Seema Nayak
Bus Communication for networking : Each specific I/O device may be connected to other using specific
interfaces, for example, with I/O device for example, LCD controller, keyboard controller and print controller.
Bus communication simplifies the number of connections and provides a common way (protocol) of
connecting different or same type of I/O devices

IO Bus : Any device that is compatible with a system's I/O bus can be added to the system (assuming an
appropriate device driver program is available), and a device that is compatible with a particular I/O bus can
be integrated into any system that uses that type of bus.

IO Bus : I/O devices communicate with the processor through an I/O bus, which is separate from the
memory bus that the processor uses to communicate with the memory system.

Embedded systems Networking : Embedded systems connected internally on same IC or systems at very
short, short and long distances can be networked using a type of the I/O buses- CAN, I 2C, USB, PCI, …

IO Bus for Networking vs. direct connections : Use of I/O bus, as opposed to direct connections between the
processor and each I/O device, very flexible, allowing a system to support many different I/O devices
depending on the needs of its users and allowing users to change the I/O devices that are attached to a
system as their needs change.

Dr. Seema Nayak


Main disadvantage of an I/O bus

• A bus has a fixed bandwidth that must be shared by all of the devices on the bus.
• Even worse, electrical constraints (wire length and transmission line effects) cause buses to have less
bandwidth than using the same number of wires to connect just two devices.
• Essentially, there is a trade-off between interface simplicity and bandwidth

A bus has bandwidth of 2 Mb/s (can be used to transfer 2 Mb data in one s. If 10 devices are connected,
the 2 Mb/s is shared between the networked systems

Serial Bus :
A serial bus has very few lines and the number of lines as per the protocol
• A wide range of I/O devices without having to implement a specific interface for each I/O device. When
the I/O devices in the distributed embedded systems are networked at long distances of 25 cm and
above, all can communicate through a common serial bus.

Parallel Bus : Using a parallel I/O bus allows a computer or controller or embedded system to interface
with number of internal systems at very short distances without having to implement a specific interface
for each I/O device.

Dr. Seema Nayak


RS-232

RS-232 (Recommended standard-232) is a standard interface approved by the Electronic Industries


Association (EIA) for connecting serial devices. In other words, RS-232 is a long established standard that
describes the physical interface and protocol for relatively low-speed serial data communication between
computers and related devices.
An industry trade group, the Electronic Industries Association (EIA), defined it originally for teletypewriter
Type equation here.
devices. In 1987, the EIA released a new version of the standard and changed the name to EIA-232-D. Many
people, however, still refer to the standard as RS-232C, or just RS232. RS-232 is the interface that your
computer uses to talk to and exchange data with your modem and other serial devices. The serial ports on
most computers use a subset of the RS232C standard.

Dr. Seema Nayak


RS232 on DB9 (9-pin D-type connector)

Dr. Seema Nayak


RS232 on DB25 (25-pin D-type connector) RS232 on RJ-45

Dr. Seema Nayak


DESCRIPTION OF PINS
TxD: - This pin carries data from the computer to the serial device
RXD: - This pin carries data from the serial device to the computer
DTR signals: - DTR is used by the computer to signal that it is ready to communicate with the serial device
like modem. In other words, DTR indicates to the Dataset (i.e., the modem or DSU/CSU) that the DTE
(computer) is ON.
DSR: - Similarly to DTR, Data set ready (DSR) is an indication from the Dataset that it is ON.
DCD: - Data Carrier Detect (DCD) indicates that carrier for the transmit data is ON.
RTS: - This pin is used to request clearance to send data to a modem
CTS: - This pin is used by the serial device to acknowledge the computer's RTS Signal. In most situations, RTS
and CTS are constantly on throughout the communication session.
Clock signals (TC, RC, and XTC): - The clock signals are only used for synchronous communications. The
modem or DSU extracts the clock from the data stream and provides a steady clock signal to the DTE. Note
that the transmit and receive clock signals do not have to be the same, or even at the same baud rate.
CD: - CD stands for Carrier Detect. Carrier Detect is used by a modem to signal that it has a made a
connection with another modem, or has detected a carrier tone. In other words, this is used by the modem
to signal that a carrier signal has been received from a remote modem
RI: - RI stands for Ring Indicator. A modem toggles(keystroke) the state of this line when an incoming call
rings your phone.
The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem.
Because most modems transmit status information to a PC when either a carrier signal is detected (i.e. when
a connection is made to another modem) or when the line is ringing, these two lines are rarely used.
Dr. Seema Nayak
Dr. Seema Nayak
Limitations of RS-232
RS-232 has some serious shortcomings as an electrical interface.

 Firstly, the interface presupposes a common ground between the DTE and DCE. This is a reasonable
assumption where a short cable connects a DTE and DCE in the same room, but with longer lines and
connections between devices that may be on different electrical busses, this may not be true.

 A signal on a single line is impossible to screen effectively for noise. By screening the entire cable one can
reduce the influence of outside noise, but internally generated noise remains a problem. As the baud
rate and line length increase, the effect of capacitance between the cables introduces serious crosstalk
until a point is reached where the data itself is unreadable.

Using low capacitance cable can reduce crosstalk. Also, as it is the higher frequencies that are the
problem, control of slew rate in the signal also decreases the crosstalk. The original specifications for RS-
232 had no specification for maximum slew rate.

Dr. Seema Nayak


RS422 and RS485
When communicating at high data rates, or over long distances in real world environments, single-ended
methods are often inadequate. Differential data transmission (balanced differential signal) offers superior
performance in most applications. EIA has recently released new serial interface, RS-422 and RS-485. These
standards were designed for highspeed communication.

 RS422
Serial Communication RS422 is a Standard interfaces approved by the Electronic Industries Association (EIA),
and designed for greater distances and higher Baud rates than RS232. In its simplest form, a pair of
converters from RS232 to RS422 (and back again) can be used to form an "RS232 extension cord." Data rates
of up to 100K bits / second and distances up to 4000 Ft. can be accommodated with RS422. RS422 is also
specified for multi-drop (party-line) applications where only one driver is connected to, and transmits on, a
"bus" of up to 10 receivers. RS422 devices cannot be used to construct a truly multi-point network. A true
multi-point network consists of multiple drivers and receivers connected on a single bus, where any node can
transmit or receive data.
Dr. Seema Nayak
RS485
Serial Communication RS485 is an Electronics Industry Association (EIA) standard for multipoint
communications. It supports several types of connectors, including DB-9 and DB-37. RS-485 is similar to
RS-422 but can support more nodes per line RS485 meets the requirements for a truly multi-point
communications network, and the standard specifies up to 32 drivers and 32 receivers on a single (2-wire)
bus.
With the introduction of "automatic" repeaters and high-impedance drivers / receivers this "limitation"
can be extended to hundreds (or even thousands) of nodes on a network. The RS-485 and RS-422
standards have much in common, and are often confused for that reason. RS-485, which specifies bi-
directional, half-duplex data transmission, is the only EIA/TIA standard that allows multiple receivers and
drivers in "bus" configurations. RS-422,
on the other hand, specifies a single, unidirectional driver with multiple receivers.

Dr. Seema Nayak


Dr. Seema Nayak
Introduction to Controller Area Network (CAN BUS)

Controller Area Network (CAN) is a serial network technology that was originally designed for the
automotive industry, especially for European cars, but has also become a popular bus in industrial
automation as well as other applications. The CAN bus is primarily used in embedded systems, and as its
name implies, is a network technology that provides fast communication among microcontrollers up to real-
time requirements, eliminating the need for the much more expensive and complex technology of a Dual-
Ported RAM.

CAN is a two-wire, half duplex, high-speed network system, that is far superior to conventional serial
technologies such as RS232 in regards to functionality and reliability and yet CAN implementations are more
cost effective.

Dr. Seema Nayak


Dr. Seema Nayak
Controller Area Network

 Is a serial networking technology for embedded solutions.


 Needs only two wires named CAN_H and CAN_L.
 Operates at data rates of up to 1 Megabit per second.
 Supports a maximum of 8 bytes per message frame.
 Does not support node IDs, only message IDs. One application can support multiple message IDs.
 Supports message priority, i.e. the lower the message ID the higher its priority.
 Supports two message ID lengths, 11-bit (standard) and 29-bit (extended).
 Does not experience message collisions (as they can occur under other serial technologies).
 Is not demanding in terms of cable requirements. Twisted-pair wiring is sufficient.

Dr. Seema Nayak


Advantages of CAN:

• It reduces wiring since it is a distributed control and this ensures enhancing the system performance.
• Many CAN chip manufactures provided the data link layer and the physical layer interfaced to the
chip and all the software developer needs to do only is to develop the application coding.
• It provides the ability to work in different electrical environments and ensures noise-free
transmission.
• Traffic congestion is eliminated as the messages are transmitted based on their priority and it allows
the entire network to meet the timing constraints.
• It provides for error-free transmission as each node can check for errors during the transmission of
the message and send the error frame.

Dr. Seema Nayak


The layered architecture consists of three layers
Application Layer: It interacts with the operating system or the application of the CAN device.
Data Link Layer: It connects the actual data to the protocol in terms of sending, receiving, and validating
data.
Physical Layer: It represents the actual hardware.

The standard CAN frame consists of the following bits:

Dr. Seema Nayak


SOF- Start of Frame. The message starts from this point.
Identifier: It decides the priority of the message. Lower the binary value, higher is the priority. It is 11 bit.
RTR– Remote Transmission Request. It is dominant when information is required from another node. Each
node receives the request, but only that node whose identifier matches that of the message is the required
node. Each node receives the response as well.z
IDE– Single Identification Extension. If it is dominant, it means a standard CAN identifier with no extension is
being transmitted.
R0– reserved bit.
DLC– Data Length Code. It defines the length of the data being sent. It is 4 bit
Data– Up to 64 bit of data can be transmitted.
CRC– Cyclic Redundancy Check. It contains the checksum (number of bits transmitted) of the preceding
application data for error detection.
ACK– Acknowledge. It is for 2 bit. It is dominant if an accurate message is received.
EOF– end of the frame. It marks the end of can frame and disables bit stuffing.
IFS– Inter Frame Space. It contains the time required by the controller to move a correctly received frame to
its proper position. Dr. Seema Nayak
Different message types are:
Data Frame: It consists of an arbitrary field, data field, CRC field and the acknowledge fields.
Remote Frame: It requests for transmission of data from another node. Here the RTR bit is recessive.
Error Frame: It is transmitted when an error is detected.
Overload Frame: It is used to provide a delay between messages. It is transmitted when the nodes become
too busy.
Valid Frame: A message is valid if the EOF field is recessive. Else the message is transmitted again.

Dr. Seema Nayak


Synchronous/Asynchronous Interfaces

In synchronous communication, data is transmission and receiving is a continuous stream at a constant


rate. Synchronous communication requires the clock of transmitting device and receiving device
synchronized. In most of the systems, like ADC, audio codes, potentiometers, transmission and reception of
data occurs with same frequency.
Examples of synchronous communication are: I2C, SPI etc.
In the case of asynchronous communication, the transmission of data requires no clock signal and data
transfer occurs intermittently rather than steady stream. Handshake signals between the transmitter and
receiver are important in asynchronous communications.
Examples of asynchronous communication are Universal Asynchronous Receiver Transmitter (UART),
USB, CAN etc.

Synchronous and asynchronous communication protocols are well-defined standards and can be
implemented in either hardware or software. In the early days of embedded systems, Software
implementation of I2C and SPI was common as well as a tedious work and used to take long programs
Dr. Seema Nayak
SPI COMMUNICATION PROTOCOL

SPI is a common communication protocol used by many different devices. For example, SD card modules,
RFID card reader modules, and 2.4 GHz wireless transmitter/receivers all use SPI to communicate with
microcontrollers.

One unique benefit of SPI is the fact that data can be transferred without interruption. Any number of bits
can be sent or received in a continuous stream.
With I2C and UART, data is sent in packets, limited to a specific number of bits. Start and stop conditions
define the beginning and end of each packet, so the data is interrupted during transmission.
Devices communicating via SPI are in a master-slave relationship. The master is the controlling device
(usually a microcontroller), while the slave (usually a sensor, display, or memory chip) takes instruction
from the master. The simplest configuration of SPI is a single master, single slave system, but one master
can control more than one slave

Dr. Seema Nayak


Dr. Seema Nayak
WORKING OF SPI

THE CLOCK The clock signal synchronizes the output of data bits from the master to the sampling of bits
by the slave. One bit of data is transferred the frequency of the clock signal. SPI communication is always
initiated by the master since the master configures and generates the clock Any communication protocol
where devices share a clock signal is known as synchronous communication protocol. There are also signal.
For example, on, in both sides timing of data transmission. The clock signal in SPI can These two properties
work together to define when the bits are output and when they are Clock polarity can be set by the master
to allow for bits to be output and sampled on either the or falling edge of the clock cycle. Clock phase can be
set for output and sampling to occur on either the first edge or second edge of the whether rising /falling

SLAVE SELECT

Dr. Seema Nayak


SPI can be set up to operate with a single master and a single slave, and it can be set up with multiple
slaves controlled by a single master. There are two ways to connect multiple slaves to the master. If the
master has multiple slave select pins
MOSI AND MISO The master sends data to the slave bit by bit, in serial through the MOSI line. The slave
receives the data sent from the master at the MOSI pin. Data sent from the master to the slave is usually
sent with the most significant bit first. The slave can also send data back to the master through the MISO
line in serial. The data sent from the slave back to the master is usually sent with the least significant bit
first.

STEPS OF SPI DATA TRANSMISSION

1. The master outputs the clock signal:

Dr. Seema Nayak


2. The master switches the SS/CS pin to a low voltage state, which activates the slave:

3. The master sends the data one bit at a time to the slave along the MOSI line. The slave reads bits as they
are received:

Dr. Seema Nayak


ADVANTAGES :
 No start and stop bits, so the data can be streamed continuously without interruption
 No complicated slave addressing system like I2C
 Higher data transfer rate than I2C (almost twice as fast)
 Separate MISO and MOSI lines, so data can be sent and received at the same time

DISADVANTAGES:
 Uses four wires (I2C and UARTs use two)
 No acknowledgement that the data has been successfully received (I2C has this)
 No form of error checking like the pa Only allows for a single master.

Dr. Seema Nayak


I2C COMMUNICATION PROTOCOL Inter IC (i2c)

(IIC) is important serial communication protocol in modern electronic systems.


Philips invented this protocol in 1986. The objective of reducing the cost of production of television remote
control motivated Philips to invent this protocol. IIC is a serial bus interface, can be implemented in software,
but most of the microcontrollers support IIC by incorporating it as hard IP (Intellectual Property). IIC can be
used to interface microcontroller with RTC, EEPROM and different variety of sensors. IIC is used to interface
chips on motherboard, generally between a processor chip and any peripheral which supports IIC. IIC is very
reliable wireline communication protocol for an on board or short distances. I2C is a serial protocol for two-
wire interface to connect low-speed devices like microcontrollers, EEPROMs, A/D and D/A converters, I/O
interfaces and other similar peripherals in embedded systems

Dr. Seema Nayak


I2C combines the best features of SPI and UARTs. With I2C, you can connect multiple slaves to a single
master (like SPI) and you can have multiple masters controlling single, or multiple slaves. This is really
useful when you want to have more than one microcontroller logging data to a single memory card or
displaying text to a single LCD. IIC protocol uses two wires for data transfer between devices: Serial Data
Line (SDA) and Serial Clock Line (SCL). The reduction in number of pins in comparison with parallel data
transfer is evident.
This reduces the cost of production, package size and power consumption. IIC is also best suited protocol
for battery operated devices. IIC is also referred as two wire serial interface (TWI).

Dr. Seema Nayak


SDA (Serial Data) – The line for the master and slave to send and receive data.
SCL (Serial Clock) – The line that carries the clock signal. I2C is a serial communication protocol, so data is
transferred bit by bit along a single wire (the SDA line).
Like SPI, I2C is synchronous, so the output of bits is synchronized to the sampling of bits by a clock signal
shared between the master and the slave. The clock signal is always controlled by the master.

Dr. Seema Nayak


WORKING OF I2C COMMUNICATION PROTOCOL

Dr. Seema Nayak


Dr. Seema Nayak
SINGLE MASTER WITH MULTIPLE SL Because I2C uses addressing, multiple slaves can be controlled from a
single master. With a 7 bit address, 128 (27 ) unique address are available. Using 10 bit addresses is
uncommon, but provides 1,024 (210) unique addresses. To connect multiple 4.7K/10K Ohm pull-up resistors
connecting the SDA and SCL lines to Vcc:

Dr. Seema Nayak


MULTIPLE MASTERS WITH MULTIPLE SLAVES

Dr. Seema Nayak


ADVANTAGES:
 Only uses two wires Supports multiple masters and multiple slaves
 ACK/NACK bit gives confirmation that each frame is transferred successfully
 Hardware is less complicated than with UARTs
 Well known and widely used protocol

DISADVANTAGES:
 Slower data transfer rate than SPI
 The size of the data frame is limited to 8 bits
 More complicated hardware needed to implement than SPI

Dr. Seema Nayak

You might also like