You are on page 1of 62

Serial Bus

Communication
Protocols
Topics for discussion

● I2C Bus
● CAN Bus
● USB Bus
Serial bus communication protocols

● I2C Bus, CAN Bus and USB Bus are widely used serial
bus communication protocols for serial communication.
I2C Inter Integrated Circuit.
I2C Bus

● The I2C bus was designed by Philips in the early ‘80s to


allow easy communication between components which
reside on the same circuit board.
● I2C stands for Inter Integrated Circuit.
Originally intended for operation on one
single board / PCB
- Synchronous Serial Signal
- Multi-Master Multi-Slave protocol.
- “Byte sized data” oriented protocol with
acknowledgement.
I2C Bus

● I2C bus has two lines that carry the signals - one line is for
the clock and the other one is for bidirectional data.
● I2C protocol has specified fields.
● Each field has a specific number of bits and sequences
and time intervals between them.
I2C BUS signals:
Start Condition: The SDA line switches from a high voltage
level to a low voltage level before the SCL line switches
from high to low.

Stop Condition: The SDA line switches from a low voltage


level to a high voltage level after the SCL line switches from
low to high.
Read/Write Bit: A single bit specifying whether the master is
sending data to the slave (low voltage level) or requesting
data from it (high voltage level).

ACK/NACK Bit: Each frame in a message is followed by an


acknowledge/no-acknowledge bit. If an address frame or
data frame was successfully received, an ACK bit is
returned to the sender from the receiving device.
STEPS OF I2C DATA TRANSMISSION

START signal
7 bit address sending
ACK signal for address detection
Transmission of data
ACK signal for data detection
STOP condition
Data transfer speed

• (i)Slow (under 100 Kbps)


• (ii)Fast (400 Kbps)
• (iii)High-Speed (3.4 Mbps)
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
I2C Bus

● Any number of masters can be connected on the bus.


● However, at an instance, the master is one, which initiates
a data transfer on SDA (Serial Data) line and which
transmits the SCL (Serial Clock) pulses.
CAN Protocol (Controller Area
Network)
CAN Bus

● A Controller Area Network (CAN bus) is a robust vehicle


bus standard designed to allow microcontrollers and
devices to communicate with each other in applications
without a host computer.
What is CAN and what are some of its features?
CONVENTIONAL MULTI WIRE VS CAN BUS
• Serial communication
• Multi-Master Protocol
• Compact
– Twisted Pair Bus line
• 1 Megabit per second
What are some real world applications of CAN?

– Controller Area
Networks are used in
many different fields,
the bulk of which are
• Auto-motive industry
• Factory Automation
• Machine Control
• Medical Equipment
and devices
• And more….
Fig: Network of number of CAN controllers and devices on a CAN bus
‘Differential Signaling’
• Here two signal wires CAN_L & CAN_H (Low & High) are seen
• This is called ‘Differential Signaling’ in which the effective signal on
the bus is the difference of voltages in these two wires with respect
to ground
• When a common noise signal appears on the two wires, they are
subtracted off while taking the difference between the two bus signal
voltages
Physical Interface

• Dominant low
(voltage) line
• Recessive high line
• Bus must be
terminated
DIFFERENTIAL Signalling: BUS Topology

• Bit encoding:
• Voltage difference
“dominant” bit == logical 0

• “recessive” bit == logical 1


(No voltage difference)
Data Information – Frame Format
Start of 11- bit Remote 6-bit Cyclic 2-bit End of
Frame Identifier Transmission Control Data(0 to 8 bytes) Redundancy ACK Frame(
(SOF) Request(RTR) Check(CRC) EOF)

• SOF – Start of Frame begins with a dominant bit “0”


• Identifier – Tells the content of message and the message priority
• RTR – Remote Transmission Request, a node can tell another node to
transmit.
• Control Field– that indicates how many bytes of data follow in the data
field.
• Data- holds up to 8 bytes of data
• CRC – “Cyclic Redundant Check”, to check if the received data bit
sequence was corrupted or not.
• ACK – Acknowledge
• EOF – End of Frame, frame is terminated by seven bits as '0's indicating
the end of a frame
Message Transaction:
Example of Message Transaction
CASE 1 : Only One Node Sends Message to the
Network

• At this moment, only one node ‘broadcasts’ a message to


the network & every other node can access this message
• Depending on the ‘content of the message’, the nodes
can ‘accept’ or ‘ignore’
• A CAN message frame has a field called ‘Identifier’ which
indicates the ‘priority of a message’
Message Oriented Transmission Protocol
• Each node – receiver & transmitter
• A sender of information transmits to all devices on the bus
• All nodes read message, then decide if it is relevant to them
• All nodes acknowledge reception

CAN bus © 2005 Microchip Technology Incorporated. All Rights


Reserved.
CASE 2 : Many Nodes Send Messages to the
Network simultaneously

• When many nodes send messages simultaneously, only


one node is allowed to access the CAN bus for ‘message
broadcasting’
• In this situation, the transmitters of other nodes should
withdraw sending their messages & try again later
• Bus access is done through a special bus arbitration
scheme of CAN protocol
Bus Arbitration
• Arbitration – needed when multiple nodes try to transmit at the same
time
• Only one transmitter is allowed to transmit at a time.
• A node waits for bus to become idle
• Nodes with more important messages continue transmitting

© 2005 Microchip Technology Incorporated. All Rights


CAN bus Reserved.
Bus Arbitration
• Message importance is encoded in message ID.
Lower value = More important
• As a node transmits each bit, it verifies that it sees the same bit
value on the bus that it transmitted.
• A “0” on the bus wins over a “1” on the bus.
• Losing node stops transmitting, winner continues.
• The priority are specified during system design and cannot be
changed dynamically.
USB Universal Serial Bus
USB

● Universal Serial Bus (USB) is a bus between a host


system and a number of interconnected peripheral
devices.
● Maximum 127 devices can connect a host.
USB - Protocol standards

● USB 1.1 (low-speed data transfer of 1.5 Mbps & high-speed of 12


Mbps),

● USB 2.0 (low-speed data transfer rate of 1.5 Mbps & high-speed
480 Mbps),

● USB 3.0 (5 Gbit/s).


● Wireless USB (High speed data transfer rate of 480 Mbps
for 3 meters range)
Typical Application
USB System Member :HOST

• Host : only one


=>The smartest element in the USB system
=>Responsible to the complexity of the
protocol to make devices design simple
and low cost
=>Control the media access ( no one can
access the bus unless it get an approval
required from the host )
USB System Member :Hub

• Hub : one or more


=>Like the hubs used for computer network
=>Enables many devices to connect to a single USB
port
USB System Member :Devices

• Device : one or more


=>Everything in the USB system , which is
not a host , is a device
=>A device may provides one or more USB
functions.
USB CONNECTORS:Series A & Series B

A long flat rectangle for plugging into computers and Hub

A smaller square connector for plugging into devices like CD,


SCANNER etc.

USB A Connector USB B Connector


USB A & B Pinout's
Electrical specification

• USB cable contains 4 conductors.


• Two power conductors Vbus and GND.
• Two signal conductors D+ and D-
TYPE A

• The USB receptacle on your PC is a type A connector


and can be recognized by its rectangular shape.
• Type A receptacles can be found on upstream devices
such as a USB host, or a hub.
• Type A plugs can be found on cables, and smaller
peripherals such as a mouse and a flash drive.
TYPE B

• However, many larger USB peripherals such as printers


and scanners use a detachable cable, and use the Type
B receptacle, which has a square shape.
• To connect an instrument to your PC, you will need to use
a USB Type A to Type B cable.
BUS Topology STAR TOPOLOGY
BUS Topology :maximum 6 levels
USB transactions
Each transaction consists of :
1. A token packet
2. An optional data packet
3. A handshake packet
Token packet format
Sync PID(8) Address(7) End point(4) CRC(5) EOP
Data packet format

Sync PID(8) Data(0-1024) CRC(16) EOP


Handshake packet format

Sync PID(8) EOP


USB : Universal Serial Bus
Data Transfer through USB Packets:

SYNC -The clock for the data transfer is encoded & inserted in this field.

PID (Packet Identifier) - used to identify the type of packet that is being sent

Data - The data field may range from zero to 1024 bytes

CRC - For error detection

EOP - A USB packet end with an End of Packet Signal.


DIFFERENTIAL SIGNALLING with NRZI Encoding

• A problem with single-ended signaling is electromagnetic


interference. The interference adds noise to the voltage
on the data wire.
• For this reason, USB does not use the single-ended
method. Instead it uses “differential signaling”.
• The output signal is then the difference, S = D+ - D-.
• So by subtracting the two noisy wires, we cancel out the
noise.
NRZI Encoding
NRZI with Bit Stuffing:
• In addition to NRZI encoding, USB protocol specifies that
data sent on the bus must be bit stuffed.
• A “0” must be inserted into the bit sequence if there is a
sequence of six ones.
USB Bus Data Format and Transfers
● The data transfer is of four types:
(a) Controlled data transfer
(b) Bulk data transfer
(c) Interrupt-driven data transfer
(d) Iso-synchronous transfer.
– CONTROL
• Used for configuring the device, retrieving information and status about
the device, or sending commands to the device
– INTERRUPT
• Meant for USB devices that needs only a “periodic attention” form the
host.
• For USB keyboards and mouse
• Also used to control the device
• Not for large transfers
• Guaranteed reserved bandwidth
– BULK
• Transfer large amounts of data
• No data loss
• Not time guaranteed
• Used for printers, storage, and network devices
– ISOCHRONOUS means at regular intervals
• Transfer large amount of data
• For real-time data collections like audio video streamig.
• Unlike bulk endpoints, no guarantees (potential data loss)
• sending and receiving data is done in equal time
increments.

You might also like