Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

Instrumentation-II

-Er. Suresh Timilsina


Assistant Professor
IOE, Paschimanchal Campus
Serial Interfacing with Microprocessor Based System

-Data within a computer is transferred in parallel as it is fastest. But for a long distance transmission it requires to
many wire hence it is transmitted serially.
-One example of serial mode transmission is a connection established between a computer and a modem using the
RS-232 protocol. An RS-232 cable can accommodate 25 wires, but only two of these wires are for data
transmission; the rest are designated for overhead control signaling. The two data wires run using simple serial
transmission in either direction.
-An example of parallel mode transmission is a connection established between a computer and a printer. Most
printers are within 6 meters (about 20 feet) from the transmitting computer, and the slight cost for extra wires is
offset by the added speed gained through parallel transmission of data.
Basis for Comparison Serial Transmission Parallel Transmission

Definition Data flows in 2 directions, bit by bit Data flows in multiple directions, 8 bits (1 byte) at a time

Cost Economical Expensive


Number of bits transferred
1 bit 8 bits or 1 byte
per clock pulse
Speed Slow Fast
Applications Used for long distance communication Used for short distance communication
Example Computer to computer Computer to printer
Differences between Serial and Parallel Transmission

•Serial transmission requires a single line to send data. Parallel transmission requires multiple lines to send data.

•There are fewer errors and less noise in serial transmission, since the transmission is done one bit at a time. There
are more errors and noise in parallel transmission, since the transmission is done multiple bits at a time.

•Serial transmission is slower since data flows through a single line; conversely, parallel transmission is faster since
data flows through multiple lines.

•Serial transmission is full duplex since the sender can send and receive data at the same time. Parallel transmission
is half duplex since the data can be sent or received at any given time.

•The cables used in serial transmission are thinner, longer, and more economical compared to the cables used in
parallel transmission.

•Serial transmission is reliable and straightforward. Parallel transmission is unreliable and complicated.
Synchronous Transmission:
In Synchronous Transmission, data is sent in form of blocks or frames. This transmission is the full duplex type.
Between sender and receiver the synchronization is compulsory. In Synchronous transmission, There is no gap
present between data. It is more efficient and more reliable than asynchronous transmission to transfer the large
amount of data.

Asynchronous Transmission:
In Asynchronous Transmission, data is sent in form of byte or character. This transmission is the half duplex type
transmission. In this transmission start bits and stop bits are added with data. It does not require synchronization.
S.NO Synchronous Transmission Asynchronous Transmission
In Synchronous transmission, Data is sent in form of In asynchronous transmission, Data is sent in form of
1.
blocks or frames. byte or character.
2. Synchronous transmission is fast. Asynchronous transmission is slow.
3. Synchronous transmission is costly. Asynchronous transmission is economical.
In Synchronous transmission, time interval of In asynchronous transmission, time interval of
4.
transmission is constant. transmission is not constant, it is random.
In Synchronous transmission, There is no gap present In asynchronous transmission, There is present gap
5.
between data. between data.
Efficient use of transmission line is done in While in asynchronous transmission, transmission line
6.
synchronous transmission. remains empty during gap in character transmission.
Asynchronous transmission have no need of
Synchronous transmission needs precisely
7. synchronized clocks as parity bit is used in this
synchronized clocks for the information of new bytes.
transmission for information of new bytes.
Serial Synchronous Data Transfer-
• Synchronous data transmission is a data transfer method in which a continuous stream of data signals is accompanied by timing signals
(generated by an electronic clock) to ensure that the transmitter and the receiver are in step (synchronized) with one another. The data is
sent in blocks (called frames or packets) spaced by fixed time intervals.
• Synchronous transmission modes are used when large amounts of data must be transferred very quickly from one location to the other.
The speed of the synchronous connection is attained by transferring data in large blocks instead of individual characters.
• Synchronous transmission synchronizes transmission speeds at both the receiving and sending end of the transmission using clock
signals built into each component. A continual stream of data is then sent between the two nodes.
• The data blocks are grouped and spaced in regular intervals and are preceded by special characters called syn.

• After the syn characters are received by the remote device, they are decoded and used to synchronize the connection. After the
connection is correctly synchronized, data transmission may begin.
• Eg-large text document. Before the document is transferred across the synchronous line, it is first broken into blocks of sentences or
paragraphs. The blocks are then sent over the communication link to the remote site.
• The timing needed for synchronous connections is obtained from the devices located on the communication link. All devices on the
synchronous link must be set to the same clocking.
• The following is a list of characteristics specific to synchronous communication:
-There are no gaps between characters being transmitted.
-Timing is supplied by modems or other devices at each end of the connection.
-Special syn characters precede the data being transmitted.
-The syn characters are used between blocks of data for timing purposes.
Due to there being no start and stop bits the data transfer rate is quicker although more errors will occur, as the clocks will eventually get
out of sync, and the receiving device would have the wrong time that had been agreed in the protocol for sending/receiving data, so some
bytes could become corrupted (by losing bits).
Solution-Re-synchronization of the clocks and use of check digits to ensure the bytes is correctly interpreted and received.
Serial Asynchronous Data Transmission
• The term asynchronous is used to describe the process where transmitted data is encoded with start and stop bits, specifying the
beginning and end of each character.

• These additional bits provide the timing or synchronization for the connection by indicating when a complete character has been sent or received; thus,
timing for each character begins with the start bit and ends with the stop bit.
• When gaps appear between character transmissions, the asynchronous line is said to be in a mark state. A mark is a binary 1 (or negative voltage) that is
sent during periods of inactivity on the line as shown in figure.

• When the mark state is interrupted by a positive voltage (a binary 0), the receiving system knows that data characters are going to follow. It is for this
reason that the start bit, which precedes the data character, is always a space bit (binary 0) and that the stop bit, which signals the end of a character, is
always a mark bit (binary 1).
• The following is a list of characteristics specific to asynchronous communication:
-Each character is preceded by a start bit and followed by one or more stop bits.
-Gaps or spaces between characters may exist.
• With asynchronous transmission, a large text document is organized into long strings of letters (or characters) that make up the words within the
sentences and paragraphs. These characters are sent over the communication link one at a time and reassembled at the remote location.
• In asynchronous transmission, ASCII character would actually be transmitted using 10 bits. For example, "0100 0001" would become "1 0100 0001 0".
The extra one (or zero, depending on parity bit) at the start and end of the transmission tells the receiver first that a character is coming and secondly that
the character has ended. This method of transmission is used when data are sent intermittently as opposed to in a solid stream. In the previous example
the start and stop bits are in bold. The start and stop bits must be of opposite polarity. This allows the receiver to recognize when the second packet of
information is being sent. Asynchronous transmission is used commonly for communications over telephone lines.
Parameters for Serial Communication
What is the Baud rate?
Baud rate is the rate at which information is transferred from a sender to a receiver. Its unit is bits per
second. Some of the standard baud rates are 1200, 2400, 4800, 9600, 57600. The user has to set the
baud rate on both sides sender as well as a receiver.

Framing
Framing is a group of data bits that the user wants to send from a sender to a receiver. Mostly 8 bits
are preferred from the device.

Synchronization
There are 1 start bit and 1 or 2 stop bit in the framing from the transmitter ends. Start bit indicated
the start of the data transfer and Stop bit indicates the end of the data transfer to the receiver. This
process is also known as asynchronous data transfer.

Error Control
This is a function to find errors in the data and is selected from “even parity check (EVEN)”, “odd
parity check (ODD)”, or “no parity check (NONE)”.

Bit Rate
Is how many data bits are transmitted per sec.
Types of Transmission Modes
In serial communication, data is transferred in the form of binary pulses. The transmission modes are classified as a Simplex, Half
Duplex, and Full Duplex.
Simplex Method

This method is a unidirectional or one-way communication method. Only one of two devices on a link can transmit the data, the other can only
receive.
If a sender transmits, then the receiver can only receive the data. The typical examples of this type of communication method are Radio,
Television, etc.
Half Duplex Method

In the Half Duplex method, each of the sender and receiver can transmit the data but not at the same time. When one is sending the data then the
other can only receive and vice versa.
This method is popular among those devices in which there is no need for communication in both directions at the same time.
Walkie-Talkie is the best example of the half-duplex method. Another good example of the internet, if a client(laptop) sends a request for a web
page, the web server processes the application and sends back the information
Full Duplex Method

In the Full Duplex method, both the sender and receiver can transmit and receive the data simultaneously.
The Full Duplex method is used when communication in both directions is required all the time. The
capacity. Smartphone communication is an example of a full-duplex method.
Serial Data Unit (SDU)
• Serial Data unit is a block with 1 start bit, 8 data bits, 1 parity bit and 1 or 2 stop bits.
• Start bit always has a value ‘0’ and stop bits always have a value of 1.

Transmitting SDU
• The interfacing chip has a transmitter which transmit data. Before transmitting it fetches the data bytes from CPU.
• According to selected data, the SDU logic puts the start bit in front of data, it calculates the parity bit and add it along with
stop bits.
• Thus, formed SDU is transferred into transmitter shift register. And individual bits are provided at serial output
Receiving SDU

• Here start bits acts as trigger pulse and starts the receiving process.
• The serial data are loaded in receiver shift register according to baud rate provided.
• The receiver SDU logic then separates start, parity and stop bits from the receiver SDU bits.
• It also compares the parity.
• Afterwards the data is transferred to receiver buffer register from where CPU fetches the received data.
Types of Errors
There may be three types of errors:
•Single bit error

In a frame, there is only one bit, anywhere though, which is corrupt.


•Multiple bits error

Frame is received with more than one bits in corrupted state.


•Burst error

Frame contains more than1 consecutive bits corrupted.


Errors in Serial Data Transfer

• We know, that transmission and reception of any data must have same baud rate. Similarly, the data formats like
no of bits, start, parity and stop bits must also coincide otherwise the receiver may consider the received data
a different one then we had sent.
a) Framing Error- If there is change in no of bits in receiving and transmitting end then this type of error is known as
framing error Usually this occur when receiver and transmitter is not synchronized.

a) Break Error- If the receiver line is at logic zero for long duration then the SDU usually last, then the receiver assumes that
the connection to the transmitter has broken. Hence, no data is transferred.

a) Overrun Error-If data arriving at the receiver is much faster than it can be read from the receiver buffer the later received
byte overwrites the older data in the buffer.
b) Parity Error-If the calculated parity does not coincide with the set one then parity error occurs. Eg- even,odd etc
Q1. Explain in detail about the error checking mechanism
a) Parity check
b) Checksum
c) Cyclic redundancy check
Serial Data Transmission Standards
• Serial data transmission links used cables with a variety of different functions to enable data to be sent reliably between two
equipment's. Although a number of different wires were often used within a cable, they did not require nearly as many as the
systems that sent parallel data.

• The first of the RS standards was RS232, or more correctly RS-232. This was developed in 1962 when the need for forms of
transmitting data from modems attached telephone lines to remote communications equipment's became apparent.

• The 'RS' stands for Recommended Standard, although later these standards were formally adopted by the EIA / TIA in the
USA.

• The EIA is the Electrical Industries Association and the TIA is the Telecommunications Industries Association. Once RS-232
was established an equivalent standard was written for the ITU (International Telecommunications Union) to provide a more
international standard. This would enable the same standards to be used worldwide and also give manufacturers access to a
global market using just one product. This standard was known as V.24 and is totally compatible with RS-232.

• With RS232 well established and the need for faster communications and over longer distances, further standards beyond
RS232 were introduced. Although a number of standards were introduced, the most widely used are RS-422 and RS485.
What is RS232 Protocol?

• In RS232, ‘RS’ stands for Recommended Standard. It defines the serial communication using DTE and DCE
signals.
• Here, DTE refers to Data Terminal Equipment and DCE refers to the Data Communication Equipment. Example
of DTE device is a computer and DCE is a modem. Formally, it is specified as the interface between DTE
equipment and DCE equipment using serial binary data exchange.

• The DTE (computer) transmits the information serially to the other end equipment DCE (modem). In this case,
DTE sends binary data “11011101” to DCE and DCE sends binary data “11010101” to the DTE device.

• RS232 describes the common voltage levels, electrical standards, operation mode and number of bits to be
transferred from DTE to DCE. This standard is used for transmission of information exchange over the telephone
lines.
RS232 Features and Specifications

1.RS232 uses Asynchronous communication so no clock is shared between PC and MODEM.

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

3. MAX232 IC can be installed easily to establish RS232 interface with microcontrollers.

4. Full duplex interface of RS232 is very convenient.

5. Two pin simplex RS232 interface can also be established easily if required.

6. A maximum data transfer speed of 19 Kbps(Kilobits per second) is possible through RS232.

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

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


RS-232 signals used in handshaking

9 25
Acronym Full name Description
pin # pin#
Transmits bytes out of
3 2 TxD Transmit Data
computer or device
Receives bytes into
2 3 RxD Receive Data
computer or device
7 4 RTS Request To Send RTS/CTS flow control
8 5 CTS Clear To Send RTS/CTS flow control
This device is ready to
6 6 DSR Data Set Ready
communicate
This device is ready to
4 20 DTR Data Terminal Ready
communicate
Modem connected to
1 8 DCD Data Carrier Detect
another
9 22 RI Ring Indicator Ringing on telephone line
5 7 SG Signal Ground
The TTL signals output by a USART, however, are not suitable for transmission over long distances, so these signals are
converted to some other form to be transmitted. In this section we discuss device used to send serial data signals over long
distances.
•RS232 is the most widely used serial I/O interfacing standard.
•However the I/O voltage levels are not TTL compatible. In the RS232, a 1 is represented by –3 to –25 V, while 0 bit is +3 to +25
V, making –3 to +3 undefined.
•For this reason, voltage converter such as MC1488 and MC1489 are used to convert the TTL logic levels to the RS232 voltage
levels and vice versa.

Fig: RS232 connection

RS-232 stands for Recommend Standard number 232 and C is the latest revision of the standard. The serial ports on most
computers use a subset of the RS-232C standard. The full RS-232C standard specifies a 25-pin "D" connector of which 22 pins
are used. Most of these pins are not needed for normal PC communications, and indeed, most new PCs are equipped with male D
type connectors having only 9 pins.
How RS-232 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.

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.
Digital Data Transmission Using Modem and standard Phone Lines

Standard telephone system can be used for sending serial data over long distances. However, telephone lines are
designed to handle voice, bandwidth of telephone lines ranges from 300 HZ to 3400 HZ. Digital signal requires a
bandwidth of several megahertz. Therefore, data bits should be converted into audio tones, this is accomplished
through modems.
Null (Zero) Modem Connection
A zero modem serves for data exchange between DTEs. Since both the computers are configured as DTEs, directly connecting
them by means of the conventional serial interface cable is impossible; not even the plug fits into the jack of the second
terminal. Also the TxD meets TxD and RxD meets RxD, DTR meets DTR and DSR meets DSR etc. This means that outputs
are connected to outputs and inputs are connected to inputs. With this convention, no data transfer is possible.

For the transmission of data, it is required to twist the TxD and RxD lines. In this way, the transmitted data of one terminal
(PC) becomes received data of other and vice versa. As shown in figure, activation of RTS to begin a data transfer gives rise to
an activation of CTS on same DTE and to an activation of DCD on other DTE. Further, an activation of DTR leads to rise of
DSR and RI on other DTE. Hence for every DTE, it is simulated that a DCE is on the end of line, although a connection
between two DTEs is actually present. Zero modem can be operated with
standard BIOS and DOS functions.
COMMON RS SERIES SERIAL DATA TRANSMISSION STANDARDS

PARAMETER RS232 RS422


Cabling Single ended Differential
Number of devices One transmit and one receive Five transmitters and ten receivers
Communication mode Full duplex Full duplex / half duplex
Maximum distance 50 feet at 19.2 kbps 4000 feet at 100 kbps
Maximum data rate 19.2 kbps at 50 feet 10 Mbps at 50 feet
Signalling mode Unbalanced Balanced
Mark (1) -5 to -15 V 2 V to 6 V max. (B>A)
Space (0) +5 to +15 V 2 V to 6 V max. (A>B)
Output current capability 500 mA 150 mA
Assignment- Explain in detail about RS-423A and RS-422A standards along with necessary figures?
USB and Its Features
• Nowadays, Universal Serial Bus (also known as USB) is considered a very simple and flexible way of connection between
personal computer (PC) and numerous of peripherals.
• With USB booting supported by your computer motherboard's BIOS devices such as mouse, printer, digital camera, webcam,
speaker, modem, network connection…etc, it can now be connected to your computer at ease through USB port (i.e. USB
hub).
• This feature, when being compared with serial or parallel port connection, is critically advantageous since it offers much more
convenience in terms of speed, mobility and flexibility.

USB Main Features


•A maximum of 127 peripherals can be connected to a single USB host controller.
•USB device has a maximum speed up to 480 Mbps (for USB 2.0).
•Length of individual USB cable can reach up to 5 meters without a hub and 40 meters with hub.
•USB acts as "plug and play" device.
•USB can draw power by its own supply or from a computer. USB devices use power up to 5 voltages and deliver
up to up to 500 mA.
•If a computer turns into power-saving mode, some USB devices will automatically convert themselves into
"sleep" mode.
How USB Works

When a computer is powered up and USB devices are connected to a hub, the system will query and request from
them the information on how much bandwidth is needed. Enumeration process will then occur where each device is
assigned with a unique address. After that, the system will determine what kind of data the USB devices wish to
transfer. There will be 4 different modes of transfers:

•Interrupt: used for devices which transfer little amount of data but need fast response (E.g. mouse, keyboard)
•Bulk: used for devices which receive big packet of data (E.g. printer)
•Isochronous: used for devices which requires streaming process (E.g. speaker, webcam)
•Control: short, simple commands to the device, and a status response.

After all connected devices are enumerated, the computer system will take care of the overall bandwidth and allocate
it to different devices according to their transfer mode. Most of the bandwidth will be used for interrupt and
isochronous transfer to ensure their requests are guaranteed. Once 90% of bandwidth is taken, the computer will
refuse any other transfer from these two modes. Bulk or control transfer (if available) will then take up the remaining
bandwidth amount, which is up to 10%.
•USB1.1: This was the original version of the USB, Universal Serial Bus and was released in September 1998 after a few problems with
the USB 1.0 specification released in January 1996 were resolved.. It provided a Master / Slave interface and a tiered star topology which
was capable of supporting up to 127 devices and a maximum of six tiers or hubs. The master or "Host" device was normally a PC with the
slaves or "Devices" linked via the cable.
One of the aims of the USB standard was to minimise the complexity within the device by enabling the Host to perform the processing.
This meant that devices would be cheap and readily accessible.
The data transfer rates of USB 1.1 are defined as:
•Low speed: 1.5 Mbps
•Full speed: 12 Mbps
The data encoding method for this version of USB is Unicode.
The cable length for USB 1.1 is limited to 5 metres, and the power consumption specification allows
each device to take up to 500mA, although this is limited to 100mA during start-up.
USB 1.1 does not allow extension cables or the inclusion of pass-through monitors
(due to timing and power limitations).

USB 2.0: The USB 2.0 standard is a development of USB 1.1 which was released in April 2000. The main difference when compared to
USB 1.1 was the data transfer speed increase up to a "High Speed" rate of 480 Mbps. However it should be noted that even though
devices are labelled USB 2.0, they may not be able to meet the full transfer speed.
The data encoding method for this version of USB is Unicode.
Series of USB 2 Type A sockets on a PCB
In addition to the improvements in data capability USB 2 also saw an increase in the power provision to 1.8A. This enabled USB to
provide charge for smartphones that were increasingly charging faster and also for more power hungry peripherals such as external drives,
etc. When compared to USB 1, this provided a much needed improvement in current capability.
USB 3.0: The USB3 standard was first demonstrated at the Intel Developer Forum in September 2007. The major
feature is what is termed the SuperSpeed bus, which provides a fourth transfer mode which gives data transfer rates of
4.8 Gbit/s. Although the USB3 raw throughput is 4 Gbit/s, data transfer rates of 3.2 Gbit/s, i.e.0.4 GByte/s more after
protocol overhead are deemed acceptable within the standard. The standard is also backwards compatible with USB
2.0.
•The move to USB 3 saw a change in the data encoding from Unicode to 8b/10b encoding.
•Often USB ports on computers, etc. may have the USB symbol with 'SS' added, i.e. SS USB. SS
USB denotes USB 3, i.e. Super Speed USB.

•USB 3.1: USB 3.1 is also known as SuperSpeed+. The use of USB 3.1 doubles the speed of data transfer when compared to
USB 3.0. It provides raw data transfer of 10 Gbit/s, and it also reducing line encoding overhead to just 3%. It does this by
changing the encoding scheme to 128b/132b.
•USB 3.1 also increases the charging capability to 20V, 5A, with the capability to reduce it to 5V as appropriate. This enables
users to charge much larger devices including laptop computers, etc. All these advances mean that when compared to previous
releases, USB 3.1 provides a significant increase in speed and functionality.

•USB 3.2: The next USB iteration is USB 3.2. This was released in September 2017. It retains the existing USB 3.1 SuperSpeed
and SuperSpeed+ data modes but introduces two new SuperSpeed+ transfer modes over the USB-C connector with data rates of
10 and 20 Gbit/s (1.25 and 2.5 GB/s). The increase in bandwidth is a result of multi-lane operation over existing wires that were
intended for flip-flop capabilities of the USB-C connector.
•Another key aspect of USB 3.2 was that the USB-IF introduced a new naming scheme for the different variants with the aim of
simplifying the marketing, although whether this has brought ore confusion is a matter of debate. The USB-IF recommended
branding the three variants as 5, 10, and 20 Gbit/s transfer modes as SuperSpeed USB 5Gbps (often called USB 3.2 Gen 1),
SuperSpeed USB 10Gbps (USB 3.2 Gen 2), and SuperSpeed USB 20Gbps (USB 3.2 Gen 2x2), respectively. The USB-IF
decided on "2x2" notation for the highest speed version because the new standard doubles the number of data lanes within a
USB-C cable to achieve the 20Gbps transfer speed.

•USB 4: To keep ahead of the market, the USB-IF introduced the USB4 specification on 29 August 2019. The new standard
provides more flexibility and functionality. It is based around the Thunderbolt 3 protocol specification and as such it supports
data throughput up to 40 Gbps. It is compatible with Thunderbolt 3, and also backwards compatible with USB 3.2 and USB 2.0.
•USB 4 will use the USB-C type connector as this is able to accommodate the speed and mode of operation of USB 4. This
means that anyone who currently has USB 3 with a USB C connector will be able to use the USB 4 ports, although to utilize the
full speed, it is necessary to have USB 4 ports and devices all the way.
•Wireless USB The concept for wireless USB is that, as the name suggests, it provides a wire-less
connection over which data can be transferred. This USB standard has not been as widely adopted
even though the standard was released in September 2010. Sometimes the abbreviation WUSB is
used, although the USB-IF does not encourage the use of this abbreviation.
•Wireless USB uses frequencies in the band 3.1 - 10.6 GHz and provides a data bandwidth of 53 -
480 Mbps over a distance up to 3 to ten metres. Modulation used is MB-OFDM.

With the ever increasing requirements for faster and larger levels of data transfer as well as increased levels of convenience and
capability, the concept for USB has evolved. The levels of functionality that are available today are enormous when compared to
the first standard release in the late 1990s. Since then a number of new versions of the USB standard have been introduced, each
providing a greater level of performance.
Basic Terminologies in USB network

•Host: The host is the computer or item that acts as the main element or controller for the USB system. The host has a hub
contained within it and this is called the Root Hub.
•Hub: The hub is a device that effectively expands the number of ports available - it will have one connection to the upstream
connection, and several downstream. It is possible to plug one hub into another to expand the capability and connectivity
further.
•Port: This is the socket through which access to the USB network is gained. It can be on a host, or a hub.
•Function: These are the peripherals or items to which the USB link is connected. Mouse, keyboards, Flash memories, etc.
•Device: This term is collectively used for hubs and functions.

The physical layout of a USB 'network' may consist of the host with two
(for example) ports and each of these may have a hub attached, to which
further devices or 'functions' are attached.

The actual physical layout of the USB system will vary according to the
actual situation, but the operation is always basically the same.

In terms of the data flow, the signals travel along the bus so that it is
accessibly by all the functions, but only the destination function accepts it.
USB Data Pipes
• The communication within USB is based around the concept of using data pipes. These can be considered as being logical
channels within the data flow on the bus.

• In reality, a USB data pipe is a connection from the host controller to a logical entity within a device, i.e. the endpoint. Because
pipes correspond to endpoints, the terms are sometimes used interchangeably.
The host then uses the concept of a data pipe to ensure the data to and from
a device is correctly directed or the source is known. The data pipe uses a
combination of the address, endpoint and also the direction to define it.
To communicate with the zero endpoints a special form of data pipe is
needed because it needs to be used to establish the initial communication. It
is called the Default Control Pipe and it can be used when the initial
physical connection is made.
There are two types of USB pipe:
•Message Pipe : This type is a bi-directional USB pipe and it is used for
control data. Message pipes are typically used for short, simple commands
to the device, and for status responses from the device. They can be used by
the bus control pipe number 0.

•Stream Pipe: This form of USB pipe is uni-directional and it is connected


to a uni-directional endpoint that transfers data using an isochronous,
interrupt, or bulk transfers.
There are four basic types of data transaction that can be made within USB.
•Control: This type of data transaction within the overall USB protocol is used by the host to send commands or query
parameters. The packet lengths are defined within the protocol as 8 bytes for Low speed, 8-64 bytes for Full, and 64 bytes
for High Speed devices.

•Interrupt: The USB protocol defines an interrupt message. This is often used by devices sending small amounts of data,
e.g. mice or keyboards. It is a polled message from the host which has to request specific data of the remote device.

•Bulk: This USB protocol message is used by devices like printers for which much larger amounts of data are required.
In this form of data transfer, variable length blocks of data are sent or requested by the Host. The maximum length is 64-
byte for full speed Devices or 512 bytes for high speed ones. The data integrity is verified using cyclic redundancy
checking, CRC and an acknowledgement is sent. This USB data transfer mechanism is not used by time critical
peripherals because it utilizes bandwidth not used by the other mechanisms.

•Isochronous: This form of data transfer is used to stream real time data and is used for applications like live audio
channels, etc. It does not use and data checking, as there is not time to resend any data packets with errors - lost data can
be accommodated better than the delays incurred by resending data. Packet sizes can be up to 1024 bytes.
The data transfer methodology and protocol for USB provides an effective method of transferring the data across the
interface in an effective and reliable manner.
USB data packets

Within the USB system, there are four different types of data packets each used for different types of data transfer.
•Token Packets: Essentially a Token USB data packet indicates the type of transaction is to follow.

•Data Packets: The USB data packets carry the payload data, carrying the data as required.

•Handshake Packets: The handshake packets are used acknowledging data packets received or for reporting errors, etc.

•Start of Frame Packets: The Start of Frame packets used to indicate the start of a new frame of data.

USB Data Packet Fields

• The USB data packet fields are what make up a USB packet, consisting of individual bits.

• USB data packet fields include a Sync field, a Packet ID (PID) field, ADDR (Address) field, ENDP (Endpoint) field, CRC
(cyclical redundancy check) field, and EOP (end of packet) field.

• The SYNC field is used to synchronize the clocks from both the receiver and transmitter.

• The PID field provides information on what type of data is being sent. The below table presents the PID Type, the PID Name,
and what its purpose is the packet.
Table 1: USB Packet Types
PID Type PID Description
Name •The ADDR (Address) field includes the address
Token OUT Host to device transfer of the device the packet is being sent to.
IN Device to Host transfer
SOF Start of Frame marker •The ENDP (Endpoint) field specifies the
SETUP Host to device control transfer Endpoint number.
Data DATA0 Data packet
DATA1 Data packet •The CRC field is used to check the data in the
DATA2 High-Speed Data packet packet for errors.
MDATA Split/High-Speed Data packet
Handshake ACK The data packet was received error free •THE EOP field indicates the end of the packet
NAK Receiver cannot accept data or the transmitter could not
send data
STALL Endpoint halted or control pipe request is not supported
NYET No response yet
Special PRE Preamble to full-speed hub for low-speed traffic
ERR Error handshake for Split Transaction
SPLIT Preamble to high-speed hub for low/full-speed traffic
PING High-speed flow control token
EXT Protocol extension token
USB Data Packets
These fields are used to form data packets, which define the various transactions. There are four USB packet types
including:
Token Packet, which is initiated by the host and determines if the host will send or receive data.

Data Packet, where the Data is sent by the transmitter, and a device can return a NAK or Stall packet to indicate if they
are not able to respond.

Handshake Packet, used for acknowledging data or reporting errors.

Start-of-Frame Packet, splits the USB bus into time segments and schedules the data transfers.
These packets are formed into frames and sent through a USB transaction. The length and frequency of the transaction
depends upon the transfer type being used for an endpoint.
• The diagram above illustrates USB data flow on three logical levels: client
USB data Flow software to function, USB driver to device, and the USB physical level,
where actual transmission occurs. On the highest logical level, USB is the
data transport agent for data transfers moving between client software and
function endpoints envisioned as a bundle of logical data flow "pipes."
There is one logical endpoint for each client software-function pipe. USB
supports isochronous, bulk, interrupt and control data transfer types.
• Devices are managed by USB system software. "Endpoint 0" is required of
every device for control transfers which define USB function
configuration. Control transfers allow the host to access different parts of a
device and communicate between client software and its function using
configuration/command/status control type information. Data content
includes standard, class and vendor type requests. Communication occurs
via bi-directional pipes, with a full-speed payload of 64 bytes and a low-
speed payload of 8 bytes. Since the control transfer is a host-based token,
bus access is guaranteed. Endpoint 0 must support control transfers.
• Other endpoints are optionally determined by implementation requirements, with a total of 16 endpoints available to each device.
Under the host-based token policy of the Universal Serial Bus, the USB host handles most protocol complexity, generates the data transfer
tokens, initiates data transfers at full-speed (12 Mb/sec.) or low-speed (1.5 Mb/sec.) and manages the logical connection from the host to
function. Isochrony is guaranteed and managed by the host. This fundamental design asymmetry allows the design of extremely simple and
low-cost USB-compliant peripherals.
• The USB physical layer (bus interfaces, ports and USB cable) is source terminated, provides limited power distribution and also allows hot
insertion and removal. Intel fourth-generation PCIsets, the 8x930Ax peripheral controller (Data Sheet DS8X930AX.PDF) and the 8x930Hx
peripheral controller (Data Sheet DS8X930HX.PDF) family represent an end-to-end solution that makes USB hardware design implementation
simple, fast and cost-effective.
The physical USB network is implemented as a tiered star network with one host (master) and several devices
(slaves).
The USB Host provides one attachment port. If more peripherals are required, connect a hub to the root port to
provide additional connection ports. The USB network can support up to 127 external nodes. Due to timing
constraints for signal propagation, the maximum number of tiers allowed is seven:
•One tier for the host (bus master).
•Six tiers for hubs and devices.

Tier Network
USB devices are divided into device classes:
•Hubs provide additional attachment points and simplify USB connectivity from the user perspective. Each hub
converts a single attachment point into multiple attachment points referred to as ports.
•Functions provide capabilities to the system for transmitting or receiving data and control information. Each function
contains configuration information describing the device capabilities and resource requirements.
•Compound Devices are physical packages that implement multiple functions and include an embedded hub. A
compound device appears to the host as a hub with one or more non-removable USB devices.
•Composite Devices support more than one class and thus, provide more than one function to the host.
Examples of functions:

•A human interface device such as a mouse, keyboard, tablet, or game controller.


•An imaging device such as a scanner, printer, or camera.
•A mass storage device such as a CD-ROM drive, floppy drive, or DVD drive.

The logical USB network appears as a star network to the developer with the host at the centre. Hubs do not introduce any
programming complexity and are transparent as far as the programmer is concerned. An USB device will work the same
way whether connected directly to a root-hub or whether connected via intermediate hubs. All USB devices are available as
addressable nodes in this master/slave network. Only the host can initiate a data transfer in the network.

• Only one host exists in any USB system.


• Only functions can be enabled in tier seven.
• Compound devices occupy two tiers.
USB On-the-Go
• USB drives are convenient, but you can't use one with your phone. Well, unless you have an Android phone and know what
USB OTG is.
• USB On-The-Go (OTG) is a standardized specification that allows a device to read data from a USB device without
requiring a PC. The device basically becomes a USB host, which isn't an ability every gadget has. You will need an OTG
cable or OTG connector.
• You can do a lot with this, For example, you might connect a USB flash drive to your phone, or use a video game
controller with an Android device
• USB OTG is not an Android-specific feature. But since that's its most popular use, we'll focus on using it with Android.
• The release of the On-The-Go (OTG) supplement to the USB 2.0 specification changed the USB world. For the first time,
spec-compliant USB devices can talk to each other without requiring the services of a host computer. Cellphones and PDAs
can exchange contact lists, phones can attach to printers and print faxes, and MP3 players can swap tunes.
• To accomplish OTG functionality, a USB device must be able to function as a host, a role previously served exclusively by
desktop or laptop personal computers. However, adding host capability to a USB device is only part of the requirements to
operate as an OTG device. The OTG specification introduces new cables, connectors, and two new protocols - Session
Request Protocol (SRP) and Host Negotiation Protocol (HNP).
• Additionally, the OTG specification defines a new type of USB device with both host and peripheral capabilities called a
“dualrole device”. This application note covers the electrical and protocol aspects of OTG, providing information that
should make it easier to read and understand the formal OTG Specification.
Cables

• Two new cables and two adapters are defined in the OTG specification. Figure 1 shows the traditional A and B connectors,
and the standard A-to-B cable that connects USB peripherals to PC hosts. Following the Figure 1 model, the OTG
specification refers to hosts as “A” devices and peripherals as “B” devices.
• In October 2000, the mini-B receptacle and plug were incorporated as standard USB components to allow portable equipment
such as digital cameras and MP3 players to use a smaller connector than the relatively large “B” receptacle (see Figure 2).

OTG introduces a new receptacle, the mini-AB, which accepts either the standard USB mini-B plug or a new OTG plug, the
mini-A (see Figure 3). Fortunately, OTG was anticipated when the mini-B receptacle and plug were defined. Therefore, a mini-
B plug mates with the new mini-AB receptacle. As Figure 3 illustrates, a camera with the new OTG mini-AB receptacle is a
direct substitute for the camera with the mini-B connector in Figure 2.
• As its name implies, the mini-AB receptacle accepts either the standard mini-B plug, or a new OTG plug, the mini-A. Two
new OTG cables are defined, the mini-A to B, and the mini-A to mini-B (see Figure 4).

• The top cable allows a new OTG device to talk as a host to a traditional USB peripheral. The bottom cable allows two OTG
devices to talk to each other.

• In the Figure 4 camera-to-camera connection, both dual-role cameras provide mini-AB receptacles. Therefore, each must
function either as host or peripheral. This raises the obvious question of which is the host and which is the peripheral at
connection. The OTG spec resolves this question in a very simple manner: the cable decides. OTG receptacles and plugs
contain a fifth pin, added to the standard four USB pins (VBUS, GND, D+, and D–).
• This is a fifth pin in the connector, not a fifth wire in the cable. The mini-A plug has the fifth pin tied to its ground pin, and the
mini-B plug leaves the fifth pin unconnected. A dual-role device requires circuitry to read the state of this fifth pin (with, for
example, the aid of a pull-up resistor) to determine which end of the cable is inserted. The dual-role device receiving the mini-A
plug is the default host. To understand why the word “default” is important, see the following figure.
• In Figure 5, two dual-role devices are connected with a mini-A to mini-B cable. The camera contains a printer
driver. However, the mini-A end of the cable is connected to the printer, making it the default host. This will
be backwards - the camera must be the host in order to print. The OTG architects put a lot of thought into the
user experience.
• Realizing that the Figure 5 connection is possible, they invented the HNP to allow two connected dual-role
devices to exchange roles. Using HNP, the camera in Figure 5 can assume the host role, even though the initial
cable connection established the printer as the default host (A-Device).
• This saves (a) informing the user of a non-workable connection, and (b) making the user remove the cable and
plug it in “the other way”. For an orderly startup, one of the devices must be the “initial” (default) host, a
role established by the cable. After connection, the devices can use HNP to exchange roles.
• Note: Dual-role devices must operate at full speed (high-speed optional) as a peripheral. Dual-role devices
must operate at full speed (low- and high-speed optional) as a host.
Chapter-4 Interfacing A/D and D/A Converters

• Introduction
• General Terms Involved in A/D and D/A Converters
• Examples of A/D and D/A Interfacing
• Selection of A/D and D/A Converters Based on Design Requirements
What is ADC (Analog To Digital Converter)?
Answer- ADC stands for analog to digital converter. It is an electronic device used for converting an analog signal into
a digital signal.
Why ADC?
Answer- In the real world, every real quantity such as voice, temperature, weight etc exists in the analog state. And it cannot be
processed by any digital device such as a computer or a cell phone.

Block Diagram of ADC

The analog signal is first applied to the ‘sample‘ block where it is sampled at a specific sampling frequency. The sample
amplitude value is maintained and held in the ‘hold‘ block. It is an analog value. The hold sample is quantized into discrete value
by the ‘quantize‘ block. At last, the encoder converts the discrete amplitude into a binary number.

Analog To Digital Conversion Steps


The conversion from analog signal to a digital signal in an analog to digital converter is explained below using the block diagram
given above.
Sample
The sample block function is to sample the input analog signal at a specific time interval. The samples are taken in continuous
amplitude & possess real value but they are discrete with respect to time.
The sampling frequency plays important role in the conversion. So it is maintained at a specific rate. The sampling rate is set
according to the requirement of the system.
Hold
The second block used in ADC is the ‘Hold’ block. It has no function. It only holds the sample amplitude until the next sample is
taken. The hold value remains unchanged till the next sample.
Quantize
This block is used for quantization. It converts the analog or continuous amplitude into discrete amplitude.
The on hold continuous amplitude value in hold block goes through ‘quantize’ block & becomes discrete in amplitude. The
signal is now in digital form as it has discrete time & discrete amplitude.
Encoder
The encoder block converts the digital signal into binary form i.e. into bits.
As we know that the digital devices operate on binary signals so it is necessary to convert the digital signal into the binary form
using the Encoder. This is the whole process of converting an Analog signal into digital form using an Analog to Digital
Converter. This whole conversion occurs in a microsecond.
Factors Of ADC
Resolution:
Resolution of an ADC is the number of bits that represents the digital signal’s amplitude.
The analog signal has continuous amplitude. It can have infinite values i.e. real, floating basically any value one can imagine. On
the other hand, the digital signal has a discrete and finite number of values. These discrete values are represented using binary
numbers (bits).
Formula for to calculate resolution is : 2^n.
10 bit adc has resolu1 of 2^10=1024.
Sampling Rate
An analog signal is continuous in time and it is necessary to convert this to a flow of digital values. Sampling rate is the rate at
which new digital data are sampled or extracted from the analog signal. The accuracy of reproducing these sampled data are
limited by quantization error. However, this faithful reproduction is only possible if the sampling rate is higher than twice the
highest frequency of the signal.

The Nyquist–Shannon sampling theorem (Nyquist principle) states that perfect reconstruction of a signal is possible when the
sampling frequency is greater than twice the maximum frequency of the signal being sampled. For example, if an audio signal has
an upper limit of 20,000 Hz (the approximate upper limit of human hearing), a sampling frequency greater than 40,000 Hz (40
kHz) will avoid aliasing and allow theoretically perfect reconstruction.

Aliasing
If the digital data/signal produced by ADC are converted back to analog
values by a DAC then it is desired to have an output which is exactly equal
to the input signal. If the input signal is changing much faster than the sample
rate then this is not possible and this false is called aliases. For eg- A 2kHz
sine wave being sampled at 1.5KHz would be reconstructed at 500Hz sine wave.
This problem is called aliasing. To avoid aliasing the i/p to an ADC must be low
pass filtered to remove frequencies above half the sampling rate. This filter is
called antialiasing filter.
Dither- In ADC, the performance can usually be improved by using dither which is small amount of noise added to Input before
conversion. After conversion if the data is varying then suitable filter can be used in order to obtained desired output.
Quantization is representing the sampled values of the amplitude by a finite set of levels, which means converting a continuous-
amplitude sample into a discrete-time signal. The following figure shows how an analog signal gets quantized. The blue line
represents analog signal while the brown one represents the quantized signal.

Both sampling and quantization result in the loss of information. The quality of a
Quantize output depends upon the number of quantization levels used. The discrete
amplitudes of the quantized output are called as representation
levels or reconstruction levels. The spacing between the two adjacent
representation levels is called a quantum or step-size.

The following figure shows the resultant quantized signal which is the digital form
for the given analog signal.
DAC block diagram

Binary data are entered which are stored in the register which are converted to analog equivalent with the help of convert signal.
After converting separate bit, these are stored in separate voltage switch and compared with the reference voltage. All these
separate voltage are summed up and are amplified to provide analog output.
For example, a microphone turns incoming sounds into an analog electrical signal representing those sounds; room speakers
convert an analog electrical signal back into the original sound (or as close as possible).
Parameters (Characteristics) of DAC/ ADC
1. Resolution
It is determined by the number of bits in the input binary word. A 12-bit converter has a resolution of 1 part in 212 .

2. Full scale output voltage


The maximum output voltage of a converter (when all input are 1) will always have a value 1 LSB less than the
named value.

3. Accuracy
The actual output voltage of a DAC is different from the ideal value; the factors that contribute to the lack of linearity
also contribute to the lack of accuracy. The accuracy of a DAC is the measure of difference between actual output
voltage and the expected output voltage. For an example, a DAC with ±0.2% accuracy and full scale (maximum)
output voltage of 10V will produce a maximum error for an output voltage is of 20 mV.
[0.2/100 * 10V = 0.002*10 V = 20mV]

4. Linearity
An ideal DAC should be linear i.e. the output voltage should be a linear function of the input code. All DAC depart
somewhat from the ideal linearity. Typical factors responsible for introducing non-linearity are non-exact value of
resistors and non-ideal electronic switches that introduce extra resistance to the circuit. The non-linearity (linearity
error) is the amount by which the actual output differs from the ideal straight line output.
5. Settling time
When the output of DAC changes from one value to another, it typically overshoots the new value and may oscillate
briefly around that new value before it settles to a constant value. It is the time interval between the instant when the
analog input passes a specified value and the time instant when the analog output enters for the last time a specified
error band about its final value.

6. Monotonicity
A converter is said to be monotonic if its output voltage value continuous to increase with a continuously increasing
input value.

7. Temperature Coefficient
It is defined as the degree of inaccuracy that the temperature change can cause in any of the parameter of the DAC.

8. Glitches
It is a delay occurred during the input of digital bits. i.e the time delay caused while inputting successive bits.,

9. Conversion Time
It is the time interval between two successive conversion.
Errors in DAC and ADC

Offset error - difference between an ideal and actual DAC output when zero digital
code applied to the input.

Gain error - the difference between an ideal and actual output when full scale digital
code applied to the input. Strongly depends on VREF stability.

Reference Voltage Variations: Since the analog output of a DAC is proportional to the
reference voltage Vref, any variations in the voltage supply will directly appear.

Code Ambiguity: In many digital codes (e.g., in the straight binary code), incrementing a
number by an LSB will involve more than one bit switching. If the speed of switching
from 0–1 is different from that for 1–0, and if switching pulses are not applied to the
switching circuit simultaneously, the switching of the bits will not take place
simultaneously. For example, in a 4-bit DAC, incrementing from decimal 2 to decimal 4
will involve changing the digital word from 0011–0100. This requires two bit-switching
from 1–0 and one bit switching from 0–1. If 1–0 switching is faster than the 0–1
switching, then an intermediate value given by 0000 (decimal zero) will be generated,
with a corresponding analog output. Hence, there will be a momentary code ambiguity
and associated error in the DAC signal.
Quantization errors in digital filters can be classified as:
•Round-off errors derived from internal signals that are quantized before
or after more down additions;
•Deviations in the filter response due to finite word length representation
of multiplier coefficients; and
•Errors due to representation of the input signal with a set of discrete
levels.

Missing Codes-
Sometime some digital data are missed while converting which may lead to
drastic or great change in the signal. This type of error is occurred by
manual itself.
Input Noise- Sometime while converting one form of signal to other form some input noise nay be imposed
Such imposed error may lead the conversion or output to be deviated i.e for changed then the real one.

Offset Error
Offset error, often called 'zero-scale' error, indicates how well the actual transfer function matches the ideal transfer
function at a single point. For an ideal data converter, the first transition occurs at 0.5LSB above zero. For an ADC, the
zero-scale voltage is applied to the analog input and is increased until the first transition occurs. For a DAC, offset
error is the analog output response to an input code of all zeros.
Slew Rate
Slew rate is the maximum rate at which a DAC output can change, or the maximum rate at which an ADC's input can change
without causing an error in the digitized output. For a DAC with output amplifier, the specified slew rate is typically that of the
amplifier.
When one class of data is the underrepresented minority class in the data sample, over sampling techniques maybe used to
duplicate these results for a more balanced amount of positive results in training. Over sampling is used when the amount of data
collected is insufficient. A popular over sampling technique is SMOTE (Synthetic Minority Over-sampling Technique), which
creates synthetic samples by randomly sampling the characteristics from occurrences in the minority class.

Conversely, if a class of data is the overrepresented majority class, under sampling may be used to balance it with the minority
class. Under sampling is used when the amount of collected data is sufficient. Common methods of under sampling include
cluster centroids and Tomek links, both of which target potential overlapping characteristics within the collected data sets to
reduce the amount of majority data.

In both over sampling and under sampling, simple data duplication is rarely suggested. Generally, over sampling is preferable as
under sampling can result in the loss of important data. Under sampling is suggested when the amount of data collected is larger
than ideal and can help data mining tools to stay within the limits of what they can effectively process.
Assignments
1. Types of DAC-
i) WRN
ii) R-2R ladder
2. Types of ADC
i) Successive approximation
ii) counter type ADC
iii) Flash type ADC
iv) Ramp ADC
v) Integrator ADC

You might also like