You are on page 1of 41

EMBEDDED SYSTEM

KOE 062
Unit 2:
EMBEDDED NETWORKING

Mr. Sandeep Bhatia


Assistant Professor
ECE Department
RKGIT, Ghaziabad.
Syllabus

SANDEEP BHATIA
CONTENTS: EMBEDDED
NETWORKING
• Introduction to Embedded Networking
• I/O Device Ports and Buses
• Serial Bus Communication Protocols
• RS232 Standard
• RS422 Standard
• RS485 Standard
• CAN (Controller Area Network) Bus
• SPI (Serial Peripheral Interface)
• I2C (Inter Integrated Circuits)
• Need for Device Drivers

3 SANDEEP BHATIA
Introduction to Embedded
Networking
 A network is simply a group of two or more
Personal Computers linked together. Many types
of networks exist, but the most common types of
networks are Local-Area Networks (LANs), and
Wide-Area Networks (WANs).

 Adding connectivity to an embedded system is


now increasingly common, and networking
options are numerous. While networking platforms
include wireless (Bluetooth, ZigBee, 3G Cellular, Wi-
Fi, etc…) and wired (TCP/IP over Ethernet, CAN,
Modbus, Profinet, etc…), the networking technology
that has revolutionized communications is the
Internet Protocol (IP).
4 SANDEEP BHATIA
I/O Device Ports and Buses

5 SANDEEP BHATIA
What is a serial communication?
In telecommunication, the process of sending data
sequentially over a computer bus is called as serial
communication, which means the data will be
transmitted bit by bit. While in parallel communication
the data is transmitted in a byte (8 bit) or character on
several data lines or buses at a time. Serial
communication is slower than parallel communication
but used for long data transmission due to lower cost
and practical reasons. Parallel Communication:

Serial Communication:

6 SANDEEP BHATIA
Example to understand:
Serial communication – you are shooting a target using machine
guns, where bullets reach one by one to the target.
Parallel communication- you are shooting a target using a
shotgun, where many number of the bullets reach at the same time.

Characteristics of Serial Communication:


Baud rate is used to measure the speed of transmission. It is described as
the number of bits passing in one second. For example, if the baud rate is
200 then 200 bits per Sec passed. In telephone lines, the baud rates will
be 14400, 28800 and 33600.

Stop Bits are used for a single packet to stop the transmission which is
denoted as “T”. Some typical values are 1, 1.5 & 2 bits.

Parity Bit is the simplest form of checking the errors. There are of four kinds,
i.e., even odd, marked and spaced. For example, If 011 is a number the parity
bit=0, i.e., even parity and the parity=1, i.e., odd parity.

7 SANDEEP BHATIA
Communication Methods
Half Duplex
Half duplex means as follows: at an instant communication can only be one
way (input or output) on a bi-directional line.

An example of half-duplex mode─ telephone communication. On one


telephone line, the talk can only in the half duplex way mode.

Full Duplex
Full duplex means that at an instant, the communication can be both ways.

An example of the full duplex asynchronous mode of communication is the


communication between the modem and the computer though TxD and
RxD lines or communication using

8 SANDEEP BHATIA
Serial Communications

•Clock pulse is a signal used for synchronization of operation in


an electronic system.
SANDEEP BHATIA
9
RS ‐232

10 SANDEEP BHATIA
RS232
RS 232 is a standard developed by Electronics Industry
Association (EIA). The term RS232 stands for "Recommended
Standard 232" and it is a type of serial communication used for
transmission of data normally in medium distances.
RS232 is a standard protocol used for serial communication, it is
used for connecting computer and its peripheral devices to allow
serial data exchange between them. As it obtains the voltage for
the path used for the data exchange between the devices. It is
used in serial communication up to 50 feet with the rate of
1.492kbps. As EIA defines, the RS232 is used for connecting Data
Transmission Equipment (DTE) and Data Communication
Equipment (DCE).

11 SANDEEP BHATIA
RS232
Universal Asynchronous Data Receiver &Transmitter
(UART) used in connection with RS232 for transferring data
between printer and computer. The microcontrollers are not able to
handle such kind of voltage levels, connectors are connected
between RS232 signals. These connectors are known as the DB-9
Connector as a serial port and they are of two type’s Male
connector (DTE) & Female connector (DCE).
How RS232 Works?
RS232 works on the two-way communication that exchanges data to one
another. There are two devices connected to each other, (DTE) Data
Transmission Equipment& (DCE) Data Communication Equipment which
has the pins like TXD, RXD, and RTS& CTS. Now, from DTE source,
the RTS generates the request to send the data. Then from the other
side DCE, the CTS, clears the path for receiving the data. After clearing a
path, it will give a signal to RTS of the DTE source to send the signal. Then
the bits are transmitted from DTE to DCE. Now again from DCE source, the
request can be generated by RTS and CTS of DTE sources clears the path for
receiving the data and gives a signal to send the data. This is the whole
process through which data transmission takes place.
12 SANDEEP BHATIA
Asynchronous Serial (RS ‐232)
RS232 Pin Configuration

New RS232 has nine pins as mentioned earlier. These nine pins are
arranged in the port as shown in RS232 Connector Pinout. The DCE
and DTE ports are exactly similar except for the direction of data flow.
These nine pins are roughly divided in to three categories and we will
discuss each category below.

Pin Structure of DB-9 Connector:

13 SANDEEP BHATIA
Pin Number Pin Name Description
DATA pins (Data flow takes through these pins)
2 RXD Receive Data (Data is received though this pin)

3 TXD Transmit Data (Data is transmitted through this pin)


CONTROL pins (These pins are for establishing interface and to avoid data loss)
1 CD Carrier Detect(Set by MODEM)
4 DTR Data Terminal Ready(Set by PC to prepare MODEM)
6 DSR Data Set Ready (Set by MODEM to tell PC it is ready to
receive and send data)
7 RTS Request To Send(Set by PC to tell MODEM that MODEM can
begin sending data)
8 CTS Clear To send (Set by MODEM to tell PC that it is ready to
receive data)
9 RI Set by MODEM to tell PC a ringing condition has been
detected.
REFERENCE
5 GND Ground (Used as reference for all pin voltage pulses)

14 SANDEEP BHATIA
RS232 Features and Specifications
RS232 uses Asynchronous communication so no clock is shared
between PC and MODEM.

Logic ‘1’ on pin is stated by voltage of range ‘-15V to -3V’ and


Logic ‘0’ on pin is stated by voltage of range ‘+3V to +15V’. The
logic has wide voltage range giving convenience for user.

MAX232 IC can be installed easily to establish RS232 interface


with microcontrollers.

Full duplex interface of RS232 is very convenient.

A maximum data transfer speed of 19 Kbps(Kilobits per second) is


possible through RS232.

A maximum current of 500mA can be drawn from pins of RS232.

The interface can be established up to a distance of 50 feet.

15 SANDEEP BHATIA
For example: The signals set to logic 1, i.e., -12V. The data
transmission starts from next bit and to inform this, DTE sends start
bit to DCE. The start bit is always ‘0’, i.e., +12 V & next 5 to 9
characters is data bits. If we use parity bit, then 8 bits data can be
transmitted whereas if parity doesn’t use, then 9 bits are being
transmitted. The stop bits are sent by the transmitter whose values
are 1, 1.5 or 2 bits after the data transmission.

16 SANDEEP BHATIA
RS232 – Handshaking

17 SANDEEP BHATIA
Applications of RS232 Communication

•RS232 serial communication is used in old generation


PCs for connecting the peripheral devices like mouse,
printers, modem etc.

•Nowadays, RS232 is replaced by advanced USB.

•It is also used in PLC machines, CNC machines, and


servo controllers because it is far cheaper.

•It is still used by some microcontroller boards, receipt


printers, point of sale system.

18 SANDEEP BHATIA
UART

19 SANDEEP BHATIA
INTRODUCTION TO UART
COMMUNICATION

20 SANDEEP BHATIA
INTRODUCTION TO UART
COMMUNICATION
In UART communication, two UARTs communicate directly with each other.
The transmitting UART converts parallel data from a controlling device like
a CPU into serial form, transmits it in serial to the receiving UART, which
then converts the serial data back into parallel data for the receiving device.
Only two wires are needed to transmit data between two UARTs. Data flows
from the Tx pin of the transmitting UART to the Rx pin of the receiving
UART:

21 SANDEEP BHATIA
WHY USE A UART?
A UART may be used when:

High speed is not required.


An inexpensive communication link between
two devices is required.

UART communication is very cheap

Single wire for each direction (plus ground wire)


Asynchronous because no clock signal is transmitted.
2
Relatively simple hardware. 2

22 SANDEEP BHATIA
UART CHARACTER TRANSMISSION

• Below is a timing diagram for the transmission of a single byte


• Uses a single wire for transmission
• Each block represents a bit that can be a mark (logic ‘1) or space (logic
‘0’) 1 bit time

mark

space
Time

23 SANDEEP BHATIA
UART REGISTERS
1) Control Register- Contains settings for the UART.
Settings/features include: Number of data bits, number of
stop bits, parity control, UART TX/RX enable/disable,
baud rate setting, RX/TX interrupt enable, etc.

2) Status Register - From its name, this contains


information about the UART's condition or state.

3) Receive Register - This is the where received data is


temporarily stored.

3)Transmit Register - A buffer register/s for temporarily 19


storing data to be sent.

24 SANDEEP BHATIA
APPLICATIONS
 Communication between distant computers Serializes
data to be sent to modem
 De-serializes data received from modem

Seria
l
Phon Cabl
e e
Line

Phon
Seria Modem
e
l Line
Cabl
e

Modem

25 SANDEEP BHATIA
RS-485
RS232 is an interface to connect one DTE, data terminal equipment
to one DCE, data communication equipment at a maximum speed of
20 kbps with a maximum cable length of 50 feet.

This was sufficient in the old days where almost all computer
equipment were connected using modems, but soon after people
started to look for interfaces capable of one or more of the following:
•Connect DTE's directly without the need of modems
•Connect several DTE's in a network structure
•Ability to communicate over longer distances
•Ability to communicate at faster communication rates

RS485 is the most versatile communication standard in the standard


series defined by the EIA, as it performs well on all four points. That
is why RS485 is currently a widely used communication interface in
data acquisition and control applications where multiple nodes
communicate with each other.

26 SANDEEP BHATIA
Differential signals with RS485: Longer distances
and higher bit rates
•Main problems with RS232 is the lack of immunity for noise on the signal
lines.
•The transmitter and receiver compare the voltages of the data- and
handshake lines with one common zero line.
•Shifts in the ground level can have disastrous effects.
•Therefore the trigger level of the RS232 interface is set relatively high at ±3
Volt.
•Noise is easily picked up and limits both the maximum distance and
communication speed.
•With RS485 on the contrary there is no such thing as a common zero as a
signal reference.
•Several volts difference in the ground level of the RS485 transmitter
and receiver does not cause any problems.
•The RS485 signals are floating and each signal is transmitted over a Sig+
line and a Sig- line.
•The RS485 receiver compares the voltage difference between both lines,
instead of the absolute voltage level on a signal line.
•This works well and prevents the existence of ground loops, a common
source of communication problems.
•The best results are achieved if the Sig+ and Sig- lines are twisted.
27 SANDEEP BHATIA
RS 485 Advantages
•Twisted pairs in RS485 communication however adds immunity
which is a much better way to fight noise.

•The magnetic fields are allowed to pass, but do no harm.

•If high noise immunity is needed, often a combination of twisting


and shielding is used as for example in STP, shielded twisted pair
and FTP, foiled twisted pair networking cables.

•Differential signals and twisting allows RS485 to communicate


over much longer communication distances than achievable with
RS232. With RS485 communication distances of 1200 m are
possible.

•Differential signal lines also allow higher bit rates than possible
with non-differential connections. Therefore RS485 can overcome
the practical communication speed limit of RS232. Currently
RS485 drivers are produced that can achieve a bit rate of 35
mbps.
28 SANDEEP BHATIA
Characteristics of RS232, RS422, RS423
and RS485

29 SANDEEP BHATIA
CAN
A Controller Area Network (CAN) bus is a high -
integrity serial bus system for networking intelligent
devices. CAN busses and devices are common
components in automotive and industrial systems.

Automotive Applications

30 SANDEEP BHATIA
Benefits of CAN
•Lower cost from reduced wiring compared to two wire, point -to-
point wiring
•Highly robust protocol
–Built-in determinism
–Reliable—More than a decade of use in the automotive industry/

CAN Specifications
•CAN data (up to 8 bytes in a frame)
•Maximum 1 Mbaud/s
•40 Meters at 1 Mbaud/s
•6 km at 10 kbaud/s
•Theoretical maximum of 2,032 nodes per bus
–Practical limit is approximately 100 nodes due to transceiver
–Most buses use 3–10 nodes
•Data fields—Arbitration ID (11 bit or 29 bit)
– Indicates message priority

31 SANDEEP BHATIA
CAN Frame
•CAN devices send data across the CAN Network on
packets called frames.

•A typical CAN frame contains an arbitration ID, a data


field, a remote frame, an error frame, and an overload
frame.

32 SANDEEP BHATIA
CAN Arbitration

The arbitration ID determines the priority of the messages on the bus. If


multiple nodes try to transmit a message onto the CAN bus at the same
time, the node with the highest priority (lowest arbitration ID)
automatically gets bus access. Nodes with a lower priority must wait until
the bus becomes available before trying to transmit again. The waiting
devices wait until the end of the frame section is detected.

33 SANDEEP BHATIA
SPI (Serial Peripheral Interface)

34 SANDEEP BHATIA
SPI and the clock

35 SANDEEP BHATIA
SPI and the clock

36 SANDEEP BHATIA
I2C (Inter Integrated Circuits)

37 SANDEEP BHATIA
I2C Write a Single Byte

38 SANDEEP BHATIA
Other Features

39 SANDEEP BHATIA
Need for Device Drivers
The main purpose of device drivers is to provide abstraction by
acting as a translator between a hardware device and the
applications or operating systems that use it. Programmers can
write higher-level application code independently of whatever
specific hardware the end-user is using.

40 SANDEEP BHATIA
THANKS!!

SANDEEP BHATIA

You might also like