Unit Ii

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 29

UNIT- II

EMBEDDED NETWORKING

I/O Devices:

Input and output devices are used in parallel with other embedded system components
such as the processing element, such as a CPU, and memory. Together, they allow the
system to collect certain data to execute a specific task and also allows users to easily
control and interact with the embedded system.

Ports:

An embedded system's communication port is a physical or virtual interface that it uses


to communicate with networks or other external devices. It functions as a gateway for
data exchange, enabling the embedded system to communicate with sensors, actuators
and other systems.

In embedded systems, I/O (Input/Output) ports are essential components that allow the
microcontroller or microprocessor to interact with the external world, including sensors,
actuators, and other devices.

Bus:

A bus is a subsystem that is used to connect computer components and transfer data
between them. For example, an internal bus connects computer internals to the
motherboard. A “bus topology” or design can also be used in other ways to describe
digital connections. A bus may be parallel or serial.

The system bus carries address, data and control information. It is comprised of three
types of buses to do this function, the Address Bus, the Data Bus, and Control Bus.

There are three types of bus lines: Data bus, Address bus, and Control bus.
Communication over each bus line is performed in cooperation with another. The data
bus is a signal line for exchanging the data between the CPU and the memory, and
between the CPU and I/O and handles the data stored in the specified location.
Serial communication Protocols:

Serial communication is a communication method that uses one (or) two transmission
lines to send and receive data, and that data is continuously sent and received one bit at
a time. The transmission mode can be classified into simplex, half-duplex, and full-
duplex. Each transmission mode contains the source, also known as sender or
transmitter, and destination, also known as the receiver.

There are two broad types of serial communication: synchronous and asynchronous.
There are a very large number of different standards and protocols for serial
communication, ranging from the very simple to the seriously complicated. It is
important to match the right protocol with the right application.

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.
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.

Modes of Data Transfer in Serial Communication:

 Asynchronous Data Transfer – The mode in which the bits of data are not
synchronized by a clock pulse. Clock pulse is a signal used for synchronization of
operation in an electronic system.
 Synchronous Data Transfer – The mode in which the bits of data are
synchronized by a clock pulse.

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.
RS 232 Standard:

RS232 is a standard communication protocol that defines the electrical and physical
characteristics of a serial communication system. It is used for data transfer between
two devices and is typically used for short-distance communications.

RS-232 defines that asynchronous serial communication is used to exchange data


between devices, meaning that information is transmitted one bit at a time without a
dedicated clock signal that synchronizes exchange between the communication partners.

RS232C “Recommended Standard 232C” is the recent version of Standard 25 pin


whereas, RS232D which is of 22 pins. In new PC’s male D-type which is of 9 pins.

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).
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).

Electrical Specifications
Let us discuss the electrical specifications of RS232 given below:

 Voltage Levels: RS232 also used as ground & 5V level. Binary 0 works with
voltages up to +5V to +15Vdc. It is called as ‘ON’ or spacing (high voltage level)
whereas Binary 1 works with voltages up to -5V to -15Vdc. It is called as ‘OFF’ or
marking (low voltage level).

 Received signal voltage level: Binary 0 works on the received signal voltages
up to +3V to +13 Vdc & Binary 1 works with voltages up to -3V to -13 Vdc.

 Line Impedances: The impedance of wires is up to 3 ohms to 7 ohms & the


maximum cable length are 15 meters, but new maximum length in terms of
capacitance per unit length.

 Operation Voltage: The operation voltage will be 250v AC max.

 Current Rating: The current rating will be 3 Amps max.

 Dielectric withstanding voltage: 1000 VAC min.

 Slew Rate: The rate of change of signal levels is termed as Slew Rate. With its
slew rate is up to 30 V/microsecond and the maximum bitrate will be 20 kbps.

The ratings and specification changes with the change in equipment model.

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.

TXD TRANSMITTER

RXD RECEIVER

RTS REQUEST TO SEND


CTS CLEAR TO SEND

GND GROUND

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.

Mechanical Specification
For mechanical specifications, we have to study about two types of connectors that
is DB-25 and DB-9. In DB-25, there are 25 pins available which are used for many of
the applications, but some of the applications didn’t use the whole 25 pins. So, the 9 pin
connector is made for the convenience of the devices and equipments.

Now, here we are discussing the DB-9 pin connector which is used for connection
between microcontrollers and connector. These are of two types: Male Connector
(DTE) & Female Connector (DCE). There are 5 pins on the top row and 4 pins in the
bottom row. It is often called DE-9 or D-type connector.

Pin Structure of DB-9 Connector:


Pin Description DB-9 Connector:

PIN No. Pin Name Pin Description

1 CD (Carrier Detect) Incoming signal from DCE

2 RD (Receive Data) Receives incoming data from DTE

3 TD (Transmit Data) Send outgoing data to DCE

4 DTR (Data Terminal Ready) Outgoing handshaking signal

5 GND (Signal ground) Common reference voltage

6 DSR (Data Set Ready) Incoming handshaking signal

7 RTS (Request to Send) Outgoing signal for controlling flow

8 CTS (Clear to Send) Incoming signal for controlling flow

9 RI (Ring Indicator) Incoming signal from DCE

What is Handshaking?
How can a transmitter, transmits and the receiver receives data successfully. So, the
Handshaking defines, for this reason.

Handshaking is the process which is used to transfer the signal from DTE to DCE to make
the connection before the actual transfer of data. The messaging between transmitter &
receiver can be done by handshaking.

There are 3 types of handshaking processes named as: -

No Handshaking:
If there is no handshaking, then DCE reads the already received data while DTE
transmits the next data. All the received data stored in a memory location known as
receiver’s buffer. This buffer can only store one bit so receiver must read the memory
buffer before the next bit arrives. If the receiver is not able to read the stored bit in the
buffer and next bit arrives then the stored bit will be lost.

As shown in below diagram, a receiver was unable to read the 4 th bit till the 5th bit arrival
and this result overriding of 4th bit by 5th bit and 4th bit is lost.

Hardware Handshaking:

 It uses specific serial ports, i.e., RTS & CTS to control data flow.

 In this process, transmitter asks the receiver that it is ready to receive data then
receiver checks the buffer that it is empty, if it is empty then it will give signal to
the transmitter that I am ready to receive data.

 The receiver gives the signal to transmitter not to send any data while already
received data cannot be read.

 Its working process is same as above described in handshaking.

Software Handshaking:

 In this process, there are two forms, i.e., X-ON & X-OFF. Here, ‘X’ is the
transmitter.

 X-ON is the part in which it resumes the data transmission.


 X-OFF is the part in which it pauses the data transmission.

 It is used to control the data flow and prevent loss during transmission.

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 (PoS), etc.

 RS-485
 In industrial environments, RS-485 is very popular because of its ability to
communicate over long distances, its multidrop capability, and its immunity to
noise. Multidrop means there can be multiple controlling devices with multiple
receivers on a single bus. With RS-485, there can be at least 32 receivers (and up
to 256 depending on the unit load) on one bus.
 Like RS-232, there are many USB to RS-485 adapters available today, but the
pinouts do vary from manufacturer to manufacturer. This is because there is no
specified pinout by the standard, so it is important to check the pinouts of each
device to ensure compatibility.
 RS-485 is typically two-wire and half-duplex, but it can also be a four-wire with
full-duplex. Mensor’s transducers are offered in four-wire with full-duplex. There
are benefits and drawbacks to both configurations. Half-duplex is easier to setup
because it has only two wires compared to four. On the other hand, half-duplex is
more difficult to program. This is because only one device can communicate at
once, so timing can become an issue. If two devices attempt to communicate at
the same time, a data collision will occur.

 Another benefit of full-duplex is it allows the controller to continue sending
commands to the transducer if the transducer is in a continuous output mode.
With a half-duplex setup, continuous output would clog the transmission lines,
and not allow the controller to send commands reliably.

 A four-wire device can be converted into a two-wire device, but this will void the
full-duplex features. This can be done by connecting RX+ with TX+ (A with Y),
and RX- with TX- (B with Z). This flexibility gives the user control over using
either configuration.
 RS-422
 RS-422 is the predecessor to RS-485, and the two are often a source of
confusion.
 RS-422 is similar to RS-485 because they both use differential signalling,
communicate over long distances, and allow for multidrop. However, RS-422
multidrop allows for only one driver and a maximum of 10 receivers.
 RS-422 is usually four-wire and full duplex. Because of this, it is common for RS-
422 ports to be used to communicate with full-duplex RS-485 devices.
 RS-485 has more or less replaced RS-422 as the serial multidrop standard in the
industry.
 Below is a table summarizing the key features of the three protocols:

Controlled Area Network:

CAN stands for Controller Area Network protocol. It is a protocol that was developed by
Robert Bosch in around 1986. The CAN protocol is a standard designed to allow the
microcontroller and other devices to communicate with each other without any host
computer.

The Controller area network or CAN protocol is a method of communication between


electronic devices embedded in a vehicle, such as the engine-management systems,
active suspension, central locking, air conditioning, airbags, etc. The idea was initiated
by Robert Bosch GmbH in 1983 to improve the quality and safety of automobiles,
enhancing automobile reliability and fuel efficiency.

Bosch’s CAN protocol, first released in 1986, also provided advancements in


communication. This was significant because developments in the electronics and
semiconductor industries at the time led to new technologies but also challenges for
engineers in the auto industry. For example, electronics offered more features and
complexities, including the ability to “communicate” between devices. Auto engineers
were often given the task of incorporating such devices, ensuring they worked without
errors.

CAN simplified the process, whereby different electronic modules could communicate
with each other by using a common cable.

The need for CAN

A vehicle contains a network of electronic devices that share data and information with
one another. A spark-ignition engine, for instance, requires a spark to initiate the
combustion chamber. Timing is important here. To ensure this occurs accurately, it
“communicates” with the vehicle’s engine control unit, which chooses the ideal time for
the ignition to provide the power and fuel efficiency.

Another example of communication between devices includes that of an automobile’s


transmission-control unit. It automatically changes a vehicle’s gear in relation to its
speed by using data from the engine control unit and various sensors in the system.
Every electronic device has an ECU/MCU (electronic/microcontroller control unit) with its
own set of rules to share and transfer information.

However, for two or more devices to interact, they must be equipped with hardware and
software to properly communicate. Before CAN was used in vehicles, each electronic
device was connected to another via wires (or, more specifically, point-to-point wiring).
This worked effectively enough when the functions were basic. But one of the major
problems for automotive engineers as electronics advanced was linking the ECUs of
different devices so that real-time information could be exchanged. The CAN protocol
was designed to address this problem.

The protocol set


rules by which electronic devices can exchange information with one another over a
common serial bus. It reduced the wiring connections and the overall complexity of the
system.

An algorithmic diagram that shows the connectivity between devices using the CAN protocol.

The standard technology of the time — asynchronous transmitter/receiver — was unable


to support multi-domain communication. A domain is a group of electronic devices that
have similar requirements to work properly in the system. For example, a CD/DVD
player, GPS, and monitors and displays form a single domain. Similarly, the dashboard,
air-conditioning system (or climate control), wipers, lights, and door locks form another
domain.

The electronic devices in a vehicle can be classified under different domains and CAN
facilitates multi-domain communication, which is a great help to auto engineers.
A vehicle’s multi-domain communication, supported by the CAN protocol.

How is the CAN protocol implemented?

The CAN protocol is a set of rules for transmitting and receiving messages in a network
of electronic devices. It defines how data is transferred from one device to another in a
network.

Interestingly, CAN was developed with a specific focus on the auto industry but its
architecture and advantages have led several other industries (such as the railway,
aircraft, and medical sectors) to adopt the protocol as well.

A simplified version of the CAN protocol.


Every electronic device (or node) that communicates via the CAN protocol is connected
with one another through a common serial bus, which allows for the transfer of
messages. For this data exchange to occur, the nodes first require the necessary
hardware and the software.

Various nodes present in a CAN network.


As shown in the above figure, a typical CAN network consists of several nodes. Each
device has a host controller (ECU/MCU), which is responsible for the function of a specific
node, and the CAN controller and transceiver.

The CAN controller converts messages from the nodes per the CAN protocols, which are
then transmitted via the CAN transceiver over the serial bus — and vice versa. The
controller is a chip that’s embedded inside the host controller of the node or added
separately.

The CAN protocol does not follow the master-slave architecture, which means every
nodes has access to read and write data on the CAN bus. When the node is ready to
send data, it checks the availability of the bus and writes a CAN frame onto the network.
A frame is a structure that carries a meaningful sequence of bit or bytes of data within
the network.

There are two types of protocols: address or message-based.

 In an address-based protocol, the data packets contain the address of


the device for which a message is intended.
 In a message-based protocol, every message is identified by a pre-
defined ID rather than an address.

The CAN transmitted frame is typically a message-based protocol. A message is a packet


of data that carries information. A CAN message is made up of 10 bytes of data, which
are organized in a specific structure (called a frame). The data carried in each byte is
defined in the CAN protocol.

All nodes using the CAN protocol receive a frame and depending on the node’s ID, the
CAN “decides” whether or not to accept it. If multiple nodes send the message at the
same time, the node with the highest priority (so, the lowest arbitration ID) receives the
bus access. Lower priority nodes must wait until the bus is available.

Benefits
 Low cost: Since a CAN serial bus uses two wires (with high-volume and
low-cost production), it offers a good price-to-performance ratio.
 Reliable: CAN offers excellent error-detection and error-handling
mechanisms, which provides highly reliable transmission. It’s also largely
immune to electromagnetic interference.
 Flexible: CAN nodes are not limited by the protocol and can be easily
connected or disconnected.
 Fast: CAN supports a data rate of 1 MBit/s @ 40m bus length.
 Multi-master communication: Any node can access the bus
 Fault confinement: Faulty nodes do not disturb the communication.
 Broadcast capabilities: Messages can be sent to one /many/all nodes.
 Standardized: ISO has standardized the CAN protocol via ISO-DIS 11898
(for high-speed applications) and ISO-DIS 11519-2 (for low-speed
applications). The CAN protocol is also standardized by industry
organizations, such as the SAE-Society of Automotive Engineers.

CAN architecture

The CAN protocol uses the existing OSI reference model to transfer data between
the nodes connected in a network. The OSI reference model represents a set of
seven layers where data passes through during communication between
connected devices. The seven-layered structure of the OSI model is reliable and
widely used in several communication protocols.

The CAN architecture.


Each layer has its specific function that supports the layer above and below as
described under-
· Application layer
It serves as a window for users and application processes to access network services.
The common functions of the layers are resource sharing, remote file access,
network management, electronic messages and so on.

· Presentation layer
The most important function of this layer is defining data formats such as ASCII text,
EBCDIC text BINARY, BCD and JPEG. It acts as a translator for data into a format
used by the application layer at the receiving end of the station.

· Session layer
It allows to establishing, communicating and terminating sessions between processes
running on two different devices performing security, name recognition and logging.

· Transport layer
The transport layer ensures that messages are delivered error-free, in sequence, and
without loss or duplication. It relieves the higher layer from any concern with the
transfer of data between them and their peers.

· Network layer
It provides end to end logical addressing system so that a packet of data can be
routed across several layers and establishes, connects and terminates network
connections.

· Data link layer


It packages raw data into frames transferred from physical layer. This layer is
responsible for transferring frames from one device to another without errors. After
sending the frame it waits for the acknowledgement from receiving device. Data link
layer has two sub layers:

{C1. MAC (Medium Access Control) layer: It performs frame coding, error
detection, signaling, serialization and de-serialization.
LLC (Logical Link Control) layer: The LLC sub layer
provides multiplexing mechanisms that make it possible for several network
protocols (IP, Decnet and Appletalk) to coexist within a multipoint network and to
be transported over the same network medium. It performs the function of
multiplexing protocols transmitted by MAC layer while transmitting and decoding
when receiving and providing node-to-node flow and error control.
· Physical layer
The physical layer transmits bit from one device to another and regulates the
transmission of bit streams. It defines the specific voltage and the type of cable to be
used for transmission protocols. It provides the hardware means of sending and
receiving data on a carrier defining cables, cards and physical aspects.

CAN protocol uses lower two layers of OSI i.e. physical layer and data link layer. The
remaining five layers that are communication layers are left out by BOSCH CAN
specification for system designers to optimize and adapt according to their needs.
Fig. 7: Block Diagram Showing Various Layers of a Nework Using CAN Protocol

Function of each part is shown with the figure below.

Fig. 8: Block Diagram Showing Functions of Various Parts of A CAN Network

The concept of the CAN protocol can be understood using the figure above.
Every node has a Host controller also known as micro-controller which is a small
and low-cost computer .Host controller implements application layer of OSI
model. Micro-controller gathers information from other electronic control units
like braking, steering, power windows etc. to communicate with other nodes and
transfers it to CAN controller. CAN controller incorporate logical link control and
MAC medium access control of data link layer. LLC allows filtering of messages by
using unique ID on each message then MAC sub layer frames the message.
Once, framing is done it is followed by arbitration, error detection and
acknowledgement that all comes under MAC sub layer of data link. The frame is
transferred to CAN trans-receiver, for encoding and decoding. Finally CAN trans-
receiver synchronizes with the CAN bus to send the message to anther node.
Terms associated with CAN protocol.
BUS VALUES
Binary values in CAN protocol are termed as dominant and recessive bits.

· CAN define the logic “0” as dominant bit.


· CAN define the logic “1” as recessive bit.
In the CAN system dominant bit always overwrites the recessive bit.
Message based communication

A Message is packet of data that carries the information to be exchanged


between the nodes. Each message in CAN has a unique identification number. The
identification number is specified according to the content of the message and stored in
message identifier. This identification number is also unique within the network so when
the transmitting node places the data on the network for access to all nodes it checks
unique ID number to allow the message to pass through the filter and rest are ignored.
This is done to save the time spent on sorting. With message based protocol other nodes
can be added without re-programming since the units connected to the bus have no
identifying information like node addressing. So there is no change needed in the
software and hardware of any of the units connected on the bus.

Fig. 9: Diagram Showing Message Based Communication in A CAN Protocol Using


Network

Message Framing

Messages in CAN are sent in a format called frames. A frame is defined structure,
carrying meaningful sequence of bit or bytes of data within the
network. Framing of message is done by MAC sub layer of Data Link Layer .There are
two type of frames standard or extended .These frames can be differentiated on the
basis of identifier fields. A CAN frame with 11 bit identifier fields called Standard
CAN and with 29 bit identifier field is called extended frame.

Standard frame

Fig. 10: Figure Showing How Message Is Framed in A Standard CAN Frame

Various fields in standard CAN are as follows-

{C· SOF – Start of Frame bit. It indicates start of message and used to
synchronize the nodes on a bus. A dominant bit in the field marks the start of
frame.
· IDENTIFIER – It serves dual purpose one, to determine which node has access
to the bus and second to identify the type of message.
· RTR – Remote Transmission Request. It identifies whether it’s a data frame or a
remote frame .RTR is dominant when it is a data frame and recessive when it is a
remote frame.
{C}{· IDE – Identifier Extension. It is used to specify the frame format.
Dominant bit is for standard frame and recessive for extended frame.
{C}· R0 – Reversed bit. Not used currently and kept for future use.
{C· DLC – Data Length Code. It is 4 bit data length code that contains the
number of bytes being transmitted.
{· DATA– Used to store up to 64 data bits of application data to be transmitted.
{C}· CRC– Cyclic Redundancy Check. The 16-bit (15 bits plus delimiter) cyclic
redundancy check (CRC) contains the checksum of the preceding application data
for error detection.
{· ACK – Acknowledge (ACK) field. It compromises of the ACK slot and the ACK
delimiter. When the data is received correctly the recessive bit in ACK slot is
overwritten as dominant bit by the receiver.
{C}· EOF– End of Frame (EOF). The 7-bit field marks the end of a CAN frame
(message) and disables
Bit – stuffing, indicating a stuffing error when dominant.
{C}· IFS – Inter Frame Space that specifies minimum number of bits separating
consecutive messages. It provides the intermission between two frames
and consists of three recessive bits known as intermission bits. This time allows
nodes for internal processing before the start of next frame.
EXTENDED CAN

Fig. 11: Extended CAN Network Parts and Their Functionalities

It is same as 11-bit identifier with some added fields

{C· SRR- Substitute Reverse Request. The SRR bit is always transmitted as a
recessive bit to ensure that, in the case of arbitration between a Standard Data
Frame and an Extended Data Frame, the Standard Data Frame will always have
priority if both messages have the same base (11 bit) identifier.
{· R1- It is another bit not used currently and kept for future use.
Message frame

There are four different frames which can be used on the bus.
Data frames– These are most commonly used frame and used when a node transmits
information to any or all other nodes in the system. Data Frames consist of fields that
provide additional information about the message as defined by the CAN specification.
Embedded in the Data Frames are Arbitration Fields, Control Fields, Data Fields, CRC
Fields, a 2-bit Acknowledge Field and an End of Frame.
Fig. 12: Data Frames Used In A CAN Network

· Remote frames – The purpose of the remote frame is to seek permission


for the transmission of data from another node. This is similar to data frame
without data field and RTR bit is recessive. For example, the microprocessor
controlling the central locking on your car may need to know the state of the
transmission gear selector from the power train controller.
· Error frames – If transmitting or receiving node detects an error, it will
immediately abort transmission and send error frame consisting of an error flag
made up of six dominant bits and error flag delimiter made up of eight recessive bits.
The CAN controller ensures that a node cannot tie up a bus by repeatedly
transmitting error frame.

Fig. 13: Error Frames Used In A CAN Network

· Overload frame-It is similar to error frame but used for providing extra
delay between the messages. An Overload frame is generated by a node when it
becomes too busy and is not ready to receive.
Fig. 14: Overload Frame Present in A CAN Network

Arbitration

It is a mechanism which resolves the conflict when two or more nodes try to
send the message at the same time. In this technique whenever the bus is free any
unit can transmit a message. If two or more units starts transmitting at the same time
access to the bus is conflicted, but this problem can be solved by arbitration using
identifier. During arbitration every transmitter compares the value of transmitted bit with
bit value on the bus. If the bit value is same, the node continues to send the bits. But at
any time if transmitted bit value is different from bus value the dominant bit overwrites
the recessive bits. The arbitration field of the CAN message consists of an 11- or 29-bit
identifier and a remote transmission (RTR) bit. The identifier having lowest numerical
value has the highest priority. RTR simply distinguishes between remote frame for which
RTR is recessive and data frame for which RTR is dominant. If both data frame and
remote frame with the same identifier is initiated at the same time data frame will
prevail over remote frame. With the concept of arbitration neither information nor time is
lost.

CAN as a CSMA protocol

CSMA is a carrier sense, multiple-access protocol in which node verifies the


absence of traffic before transmitting on a shared medium such as electrical
bus. In CSMA each node on a bus waits for a specific time before sending the message.
Once this wait period is over every node has equal opportunity to send the message.
Based on pre-programmed priority of each message in identifier field i.e. highest priority
identifier wins the bus access. It is implemented on the physical layer of OSI model. Let
us understand CSMA with an example. In a discussion every person gets an equal
opportunity to voice their thoughts however when a person is talking others keep quiet
and listens and waits for their chance to speak (carrier sense). But if two or more people
start speaking at the same time then they detect the fact and quit speaking (collision
detection).
Error Control

Error Checking and Fault Confinement

This is one of the attributes of CAN that makes it robust. CAN protocol has five methods
of error checking, out of which three are at message level while other two are at bit
level. Every frame is simultaneously accepted or rejected by every node in the network.
If a node detects an error it transmits an error flag to every node and destroys the
transmitted frame and the transmitting node resends the frame

Message level

CRC check

In this stage a 15-bit cyclic redundancy check value is calculated by transmitting node
and is transmitted in the CRC field. This value is received by all nodes. Then all the
nodes calculate CRC value and matches the results with the transmitted value. If values
differ than an Error Frame is generated. Since one of the nodes did not receive the
message properly it is resent.

ACK slots

When transmitting node sends a message, a recessive bit is sent in acknowledgement


slot. After message is received acknowledge slot is replaced by dominant bit which would
acknowledge that at least one node correctly received the message. If this bit is
recessive, then none of the node has received the message properly.

Form Error

End of frame, Inter-frame space, Acknowledge Delimiter are fields that are always
recessive, if any node detects dominant bit in one of these fields than CAN protocol calls
it a violation and a Form Frame is generated and original message is resent after certain
period.

Bit level

Stuff error

Bit stuffing – It is a very common technique used in telecommunication and data


transmission to insert non -informative bits to have same bit rates or to fill the
frames .These extra bits are removed by data link layer to retrieve the original message.
This same technique is used in bit error.CAN bus is never idle because it uses NRZ
method. After five consecutive bits of the same value, a bit with a complement or
opposite value is stuffed into the bit stream. If six bits of the same value are detected
between SOF and CRC delimiter, error frame is generated. Upon detection of errors, the
transmission is aborted and frame is repeated. If errors continue, then the station or
node may switch itself off to prevent the bus from being tied up.

Bit error

A node that is sending the bit always monitors the bus. If the bit sent by transmitter
differs from the bit value on the bus then error frame is generated. But there is an
exception in case of arbitration field or Acknowledge slot where a recessive bit is sent
and a dominant bit is received. Then no Bit Error is occurs when dominant bit is
monitored.
Conclusion

CAN protocol initially developed for in-vehicle networking of automobiles has expanded
its applications in various other industries. The application started for luxurious cars is
now being used in heavy duty vehicles like trucks, buses, trains and rail vehicles. The
unique feature of CAN that allows various electronic units to communicate with each
other made it important in healthcare domain. For example intensive care units and
operating rooms where time and communication is of utmost importance. Entertainment
industry also used CAN protocols to improve features in studios to control lights and door
system and to control stage of theatres, event halls etc. Gambling machines and toys
are other examples in entertainment field. In the field of science the high energy
experiments and astronomical telescope use CAN in embedded network.

Inter-Integrated Circuit:
I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol
incorporated into devices for serial communication. It was originally designed by Philips
Semiconductor in 1982. Recently, it is a widely used protocol for short-distance
communication. It is also known as Two Wired Interface(TWI).
Working of I2C Communication Protocol :
It uses only 2 bi-directional open-drain lines for data communication called SDA and
SCL. Both these lines are pulled high.
Serial Data (SDA) – Transfer of data takes place through this pin.
Serial Clock (SCL) – It carries the clock signal.
I2C operates in 2 modes –

 Master mode
 Slave mode
Each data bit transferred on SDA line is synchronized by a high to the low pulse of each
clock on the SCL line.
According to I2C protocols, the data line can not change when the clock line is high, it
can change only when the clock line is low. The 2 lines are open drain, hence a pull-up
resistor is required so that the lines are high since the devices on the I2C bus are
active low. The data is transmitted in the form of packets which comprises 9 bits. The
sequence of these bits are –

1. Start Condition – 1 bit


2. Slave Address – 8 bit
3. Acknowledge – 1 bit

Start and Stop Conditions :


START and STOP can be generated by keeping the SCL line high and changing the level
of SDA. To generate START condition the SDA is changed from high to low while
keeping the SCL high. To generate STOP condition SDA goes from low to high while
keeping the SCL high, as shown in the figure below.

Start and Stop Condition

Repeated Start Condition :


Between each start and stop condition pair, the bus is considered as busy and no
master can take control of the bus. If the master tries to initiate a new transfer and
does not want to release the bus before starting the new transfer, it issues a new
START condition. It is called a REPEATED START condition.

Read/Write Bit :
A high Read/Write bit indicates that the master is sending the data to the slave,
whereas a low Read/Write bit indicates that the master is receiving data from the
slave.

ACK/NACK Bit :
After every data frame, follows an ACK/NACK bit. If the data frame is received
successfully then ACK bit is sent to the sender by the receiver.

Addressing :
The address frame is the first frame after the start bit. The address of the slave with
which the master wants to communicate is sent by the master to every slave
connected with it. The slave then compares its own address with this address and
sends ACK.

I2C Packet Format :


In the I2C communication protocol, the data is transmitted in the form of packets.
These packets are 9 bits long, out of which the first 8 bits are put in SDA line and the
9th bit is reserved for ACK/NACK i.e. Acknowledge or Not Acknowledge by the
receiver.

START condition plus address packet plus one more data packet plus STOP
condition collectively form a complete Data transfer.

Features of I2C Communication Protocol :


 Half-duplex Communication Protocol –
Bi-directional communication is possible but not simultaneously.
 Synchronous Communication –
The data is transferred in the form of frames or blocks.
 Can be configured in a multi-master configuration.
 Clock Stretching –
The clock is stretched when the slave device is not ready to accept more
data by holding the SCL line low, hence disabling the master to raise the
clock line. Master will not be able to raise the clock line because the wires
are AND wired and wait until the slave releases the SCL line to show it is
ready to transfer next bit.
 Arbitration –
I2C protocol supports multi-master bus system but more than one bus can
not be used simultaneously. The SDA and SCL are monitored by the masters.
If the SDA is found high when it was supposed to be low it will be inferred
that another master is active and hence it stops the transfer of data.
 Serial transmission
I2C uses serial transmission for transmission of data.
 Used for low-speed communication.

Advantages :
 Can be configured in multi-master mode.
 Complexity is reduced because it uses only 2 bi-directional lines (unlike SPI
Communication).
 Cost-efficient.
 It uses ACK/NACK feature due to which it has improved error handling
capabilities.

Limitations :
 Slower speed.
 Half-duplex communication is used in the I2C communication protocol.
Comparison between I2C and SPI Communication Protocols

I2C Communication SPI Communication


Features
Protocol Protocol

4 (MOSI, MISO, SCK, and


Number of wires 2 (SDA and SCL)
SS)

Communication type Half-duplex Full-duplex

Maximum number of Limited by addressing Limited by number of chip


devices scheme select (SS) lines

Data transfer speed Slower Faster

Improved due to
Error handling Not as robust
ACK/NACK feature

Cost-efficient due to More expensive due to


Cost
fewer wires additional wires

Simpler due to fewer More complex due to


Complexity
wires additional wires

Multi-master
Yes Yes
configuration

Synchronous
Yes Yes
communication

Clock stretching Yes No

Arbitration Yes No
The Local Interconnect Network (LIN):

LIN Protocol is a low-cost embedded serial networking standard for connecting


intelligent devices and is most popular in the automotive industry, where it enables
communication between vehicle components.

What is LIN bus?


LIN bus is a supplement to CAN bus.

It offers lower performance and reliability - but also drastically lower costs. Below we
provide a quick overview of LIN bus and a comparison of LIN bus vs. CAN bus.

 Low cost option (if speed/fault tolerance are not critical)


 Often used in vehicles for windows, wipers, air condition etc..
 LIN clusters consist of 1 master and up to 16 slave nodes
 Single wire (+ground) with 1-20 kbit/s at max 40 m bus length
 Time triggered scheduling with guaranteed latency time
 Variable data length (2, 4, 8 bytes)
 LIN supports error detection, checksums & configuration
 Operating voltage of 12V
 Physical layer based on ISO 9141 (K-line)
 Sleep mode & wakeup support
 Most newer vehicles have 10+ LIN nodes
LIN bus vs CAN bus

 LIN is lower cost (less harness, no license fee, cheap nodes)


 CAN uses twisted shielded dual wires 5V vs LIN single wire 12V
 A LIN master typically serves as gateway to the CAN bus
 LIN is deterministic, not event driven (i.e. no bus arbitration)
 LIN clusters have a single master - CAN can have multiple
 CAN uses 11 or 29 bit identifiers vs 6 bit identifiers in LIN
 CAN offers up to 1 Mbit/s vs. LIN at max 20 kbit/s

LIN bus history


Below we briefly recap the history of the LIN protocol:

 1999: LIN 1.0 released by the LIN Consortium (BMW, VW, Audi, Volvo, Mercedes-
Benz, Volcano Automotive & Motorola)
 2000: The LIN protocol was updated (LIN 1.1, LIN 1.2)
 2002: LIN 1.3 released, mainly changing the physical layer
 2003: LIN 2.0 released, adding major changes (widely used)
 2006: LIN 2.1 specification released
 2010: LIN 2.2A released, now widely implemented versions
 2010-12: SAE standardized LIN as SAE J2602, based on LIN 2.0
 2016: CAN in Automation standardized LIN (ISO 17987:2016)

LIN bus future


The LIN protocol serves an increasingly important role in providing low cost feature
expansion in modern vehicles.

As such, LIN bus has exploded in popularity in the last decade with >700 million nodes
expected in automotives by 2020 vs ~200 million in 2010.

LIN bus applications


Today, LIN bus is a de facto standard in practically all modern vehicles - with examples
of automotive use cases below:
 Steering wheel: Cruise control, wiper, climate control, radio
 Comfort: Sensors for temperature, sun roof, light, humidity
 Powertrain: Sensors for position, speed, pressure
 Engine: Small motors, cooling fan motors
 Air condition: Motors, control panel (AC is often complex)
 Door: Side mirrors, windows, seat control, locks
 Seats: Position motors, pressure sensors
 Other: Window wipers, rain sensors, headlights, airflow

Further, LIN bus is also being used in other industries:

 Home appliances: Washing machines, refrigerators, stoves


 Automation: Manufacturing equipment, metal working

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy