Instrumentation II PDF
Instrumentation II PDF
Chapter – 1
Microprocessor Based Instrumentation System
Microprocessor: A Microprocessor is a multipurpose programmable, clock driven,
register based electronic device fabricated using signal integrations from SSI to VLSI that
reads binary instructions from a storage device called memory, accepts binary data as
input, processes data according to those instructions and provide result s as output.
Why microprocessor?
Can be used in any system.
Can be used in specific applications and specific design.
Logical and computational power of microprocessor has been used to develop
more accurate and efficient system.
Pressure (Analog
Signal) RAM Panel
ADC Panel
Memory Interface
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 2
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
DAC
To Heater
Control System
Port RAM
Panel
port Panel
Interface
ADC
Temperature of
Oven
Fig: Block diagram of automatic temperature control system – Closed loop
control
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 3
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Process / Multiplexer
Analog
Plant / (to sequentially feeds
Transducer
System the outputs one at atime)
Signal Conditioner
And
Magnetic Disk Print Out ADC
Computer Digital
Data Logger
Produces O/P Computer Software
Data
Communica-
tion
Remote Indicator
Fig: A typical digital computer based instrumentation system
Advantages:
Suitably programmed to automatically carry out the mundane tasks of drift
correction, noise reduction, gain adjustments, automatic calibration etc.
These instruments have signal conditioning and display which are
compact, rugged and reliable and are suited for performing in wide
conditions like industrial, consumer, military, automobile etc.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 4
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Disadvantages:
They cannot replace the program themselves.
Software update
Prone to virus problem, so may become in-operational.
3) USB ports
Universal serial bus used for connecting number of peripheral
devices such as printer, scanner, digital cameras, and pen drives
etc. It is faster compared to traditional parallel and serial ports.
registers are arranged in a sequence and identified by binary numbers called memory
address.
To communicate with memory, the MPU should be able to:
- Select the chip
- Identify the register
- Read from or write into the register
The address decoding circuit enables MPU to select an address within memory chip or
I/O chip and then read or write into it through the available data bus and thus avoid
contention or data collision within the data bus.
Microprocessor is connected with memory and I/O devices via common address and data
bus. Only one device can send data at a time and other devices can only receive that data.
If more than one device sends data at the same time, the data gets garbled. In order to
avoid this situation, ensuring that the proper device gets addressed at proper time, the
technique called address decoding is used.
In address decoding method, all devices like memory blocks, I/O units etc. are assigned
with a specific address. The address of the device is determined from the way in which
the address lines are used to derive a special device selection signal known as chip select
( ). If the microprocessor has to write or to read from a device, the signal to that
block should be enabled and the address decoding circuit must ensure that signal to
other devices are not activated.
Depending upon the no. of address lines used to generate chip select signal for the device,
the address decoding is classified as:
Depending on the address that are allocated to the device the address decoding are
categorized in the following two groups.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 6
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
If A0 is high and A1- A7 are low and if becomes low, the latch gets enabled.
The data to the LED can be transferred in only one case and hence the device has unique
address of 01H.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 7
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Example: Design an address decoding circuit for two RAM chips each of 4K X 8 at address
2050H.
Step 1: Calculate the number of address pins
Here both memory devices are of 4K X 8 memory which is 4KB. That means 2 n = 4KB (4X1KB
= 22X210 = 212). Therefore, 4KB memory requires 12 address lines.
n = log (memory capacity in bytes) / log (2)
n = log (4X1024) / log (2) = 12
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 8
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Memory Address A A A A A A A A A A A A A A A A
Block 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0
5 4 3 2 1 0
RAM Start:2050H 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0
End:304FH 0 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1
ROM Start:3050H 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0
End:404FH 0 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1
Here RAM1 requires 12 address lines that is 111111111111 (FFFH). The starting address of
RAM1 is 2050H; we can calculate the end address of RAM1 by adding RAM1 addresses with its
base address that is 2050H + FFFH = 304FH.
Similarly RAM2 requires 12 address lines that is 111111111111 (FFFH). The next address of the
RAM1’s end address is the starting address of RAM2 that is 304FH + 01H = 3050H. Now we
can calculate the end address of RAM2 by adding RAM2 addresses with its starting address that
is 3050H + FFFH = 404FH.
Step 3: Decide decoder pins
Here, bit A12 in address lines for RAM1 and RAM2 referring to start address are different, so
we require a 1X2 decoder. If we refer the end address, bits A12, A13 and A14 are different; in
this case we should use 3X8 decoder. Address lines A0 through A11 are used by RAM1 and
RAM2 as both having 12 address pins. Rest of the address lines (A15 if 3X8 decoder and A13,
A14 and A15 if 1X2 decoder) will be decoded to generate chip enable signals for decoder.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 9
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 10
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
1.5.4 Programmed I/O, Interrupt Driven I/O and Direct Memory Access
(DMA)
Programmed I/O or Polling:
The microprocessor is kept in a loop (programmed) to check whether data are
available. For example to read a data from an input keyboard in a single board
microcomputer, the microprocessor can keep polling the port until a key is
pressed.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 11
Instrumentation II Chapter 1: Microprocessor Based Instrumentation System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Fowler | 12
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Chapter – 2
Parallel Interfacing with Microprocessor Based System
The device which can handle data at higher speed cannot support with serial interface. N bits of
data are handled simultaneously by the bus and the links to the device directly. Achieves faster
communication but becomes expensive due to need of multiple wires.
2.1 Methods of Parallel Data Transfer: Simple Input and Output, Strobe I/O, Single
Handshake I/O, & Double Handshake I/O
Parallel transmission of data is used for short distance where the speed of information transfer is
critical. This form of data communication is found in newer type of computer peripheral
equipment with transfer speed of to one million characters per second. The equipment includes
printers, disk drives and various other forms of peripheral components.
The information exchanged between a microprocessor and an I/O interface circuit consists of
input or output data and control information. The status information enable the microprocessor
monitor the device and when it is ready then send or receive data. Control information is the
command by microprocessor to cause I/O device to take some action. If the device operates at
different speeds, then microprocessor can be used to select a particular speed of operation of the
device. The techniques used to transfer data between different speed devices and computer is
called synchronizing. There are various ways of synchronization techniques which are involved
in parallel data transfer such as simple input and output, simple strobe I/O, single handshaking
and double handshaking.
Simple I/O
To get digital data from a simple switch into a microprocessor; switch is connected on input port
line from which port can be read. The data is always present and ready so that it can be read at
any time. Similarly to output data to a simple display device like LED, the input of LED buffer
is connected on an output port pin. And output the logic level required turning on the light. The
LED is always there and ready so that data can be sent at any time.
This timing waveform illustrates the simple I/O where cross lines represent the time at which a
new data byte becomes valid on the output lines of the port. Absences of other waveforms
indicate that this output operation is not directly dependent on any other signals.
Simple Strobe I/O
In many applications, valid data is present on an external device only at a certain time and must
be read in at that time. Here a strobe pulse is supplied to indicate the time at which data is being
transmitted. For an example, we can discuss the ASCII encoded keyboard. When a key is
pressed, circuitry on keyboard sends out ASCII code for pressed key on eight parallel data lines
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 1
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
and then sends out a strobe signal on another line to indicate that valid data is present on eight
data lines
The sending device outputs parallel data on the data lines, and then outputs STB’ signal to
represent the valid data is present.
In this technique, microprocessors need to wait until the device is ready for the operation and
also known as simple wait I/O. Consider a simple keyboard consisting of 8 switches connected to
a microprocessor through a parallel interface circuit (Tri-state buffer). The switch is of dip
switches. In order to use this keyboard as an input device the microprocessor should be able to
detect that a key has been activated. This can be done by observing that all the bits are in
required order. The processor should repeatedly read the state of input port until it finds the right
order of bits i.e. at least 1 bit of 8 bits should be 0.
Used to convert analog to digital data which can be read by I/O unit of microprocessor.
When SOC appears 1, I/O unit should ready for reading binary data/digital data.
When EOC’s status is 1, then I/O unit should stop to read data.
Strobe signal indicates the time at which data is being activated to transmit.
Single Handshaking
Handshaking is the method of synchronizing the actions of slow peripheral devices with that of
high speed microprocessor. It can have two transfer schemes.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 2
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
The peripheral outputs some data and send signal to microprocessor to tell “Here is
the data for you”.
Microprocessor detects asserted signal, reads the data and sends an acknowledge
signal (ACK) to indicate data has been read and peripheral can send next data, “I got that
one, send me another”.
Microprocessor sends or receives data when peripheral is ready.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 3
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
The peripheral asserts its line low to ask microprocessor “Are you ready?”
The microprocessor raises its ACK line high to say “I am ready”.
Peripheral then sends data and raises its line low to say “Here is some valid data for
you.”
Microprocessor then reads the data and drops its ACK line to say, “I have the data, thank
you, and I await your request to send the next byte of data.”
2.2 8255 as General Purpose Programmable I/O Device and its interfacing examples
The Intel 8255 A is a general purpose programmable I/O device designed for use with Intel
microprocessors. It has 24 I/O pins that can be grouped primarily in two 8-bit parallel ports: A
and B, with the remaining bits as port C. The 8-bits of port C can be used as individual bits or be
grouped in two 4-bits ports: C upper (Cu) and C lower (Cl). The functions of these ports are
defined by writing a control word in the control register.
Bit Set/Reset mode: The BSR mode is used to set or reset the bits in port C.
I/O mode: The I/O mode is further divided into three modes: mode 0, mode 1 and mode
2. In mode 0, all ports function as simple I/O ports. Mode 1 is a handshake mode
whereby ports A and/or B use bits from port C as handshake signals. In the handshake
mode, two types of I/O data transfer can be implemented: status check and interrupt. In
mode 2, port A can be set up for bidirectional data transfer using handshake signals from
port C and port B can be set up either in mode 0 or mode 1.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 4
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
The pin diagram and block diagram of 8255 is given above. It has the following main blocks.
The 3-state bidirectional 8-bit buffer is used to interface the 8255A to the system data bus.
Data is transmitted or received by the buffer upon execution of input or output instructions
by the CPU. Control words and status information are also transferred through the data bus
buffer.
The function of the block is to manage all of the internal and external transfers of both data
and control or status words. It accepts inputs from the CPU address and control buses and in
turn, issues commands to both of the control groups.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 5
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Chip Select (CS’): A “low” on this pin enables the communications between the
8255A and the CPU.
Read (RD’): A “low” on this input enables the 8255A to send the data or status
information to the CPU on the data bus. In essence, it allows the CPU to read from
the 8255A.
Write (WR’): A “low” on this input pin enables the CPU to write data or control
words into the 8255A.
Reset (RESET): A “high” to this pin clears the control register and sets all ports (A, B
and C) in the input mode.
A0 and A1: These input signals controls the selection of one of the three ports or the
control word register. They are connected to the least significant bits of the address
bus.
The CS’ signal is the master chip select, and A0 and A1 specify one of the I/O ports or the
control register as given below.
CS’ A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control Register
1 X X 8255A is not
selected
Functional configuration of each port is programmed by the system software. In essence, the
CPU outputs a control word to the 8255A. The control word contains information such as
“mode”, “bit set’, “bit reset”, etc. that initialize the functional configuration of the 8255A.
Each of the control blocks (Group A and Group B) accepts “commands” from the
Read/Write control logic, receives control word from the internal data bus and issues the
proper commands to its associated ports.
Control Word
When A0 and A1 pins have value 1, the mapped address addresses the control register which is
the 8-bit register to write the specific content according to the port conditions although it cannot
be read. The content of this register is called control word which specifies an I/O function for
each port.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 6
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
The MSB (D7) of the control word tells which control word we are sending it that is it specifies
either the I/O function or the Bit Set/Reset function. If bit D7=1, bits D6-D0 determine I/O
functions in various modes as shown in figure. If bit D7=0, port C operates in the Bit Set/Reset
(BSR) mode. The BSR control word does not affect the functions of ports A and B.
To communicate with peripherals through 8255, following are the steps are necessary.
Determine the Port addresses of Ports A, B and C and of the control register according to
Chip Select logic and address lines A1 and A0.
Write a control word in control register.
Write I/O instructions to communicate with peripherals through Ports A, B and C.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 7
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Q. Determine the Control word for the following configuration of ports of Intel 8255A
PPI chip.
a. Port A output, mode of port A mode 1, port B output, mode of port B mode 0, port C lower
pins as output and remaining pins of port C upper as output.
D7 D6 D5 D4 D3 D2 D1 D0 = A0H
1 0 1 0 0 0 0 0
b. Port A output, mode 0, port B output, mode 0, port C lower output and port C upper input.
D7 D6 D5 D4 D3 D2 D1 D0 = 88H
1 0 0 0 1 0 0 0
c. Port A input, mode 1, port B output, mode 1, and remaining pins of port C upper input.
d. Port A input mode 1, port B output mode 0, port C lower input and port C upper output.
D7 D6 D5 D4 D3 D2 D1 D0 = B1H
1 0 1 1 0 0 0 1
e. Port A bidirectional (Mode 2), port B input mode 0, port C lower output.
Operating Modes
This functional configuration provides simple input and output operation for each of the three
ports. No ‘handshaking” is required; data is simply written to or read from a specified port.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 8
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
BSR mode is concerned only with eight bits of port C, which can be set or reset by writing an
appropriate control word in the control register. A control word with bit D7=0 is recognized as a
control word and it does not alter any previously transmitted control word with bit D7=1; thus the
I/O operations of ports A and B are not affected by a BSR control word. In the BSR mode
individual bits of port C can be used for applications such as On/Off switch.
BSR Control Word: This control word, when written in control register, sets or resets one
bit at a time, as specified in figure.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 9
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Q. Determine the BSR Control word for the following Port C configurations.
a. Set PC7
To set PC7
b. Reset PC3
The functional configuration provides a means for transferring I/O data to or from a specified
port in conjunction with strobes or handshaking signals. In mode 1, port A and port B use the
lines of port C to generate or accept these handshaking signals.
The functional configuration provides a means for communicating with a peripheral device or a
structure on a single 8-bit bus for both transmitting and receiving data (bidirectional bus I/O).
“Handshaking Signals” are provided to maintain proper bus flow discipline in a similar manner
to Mode 1. Interrupt generation and enable/disable functions are also available.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 10
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
The 5-bit control port (Port C) is used for control and status for the 8-bit,
bidirectional bus port (Port A)
A high on the RESET pin causes all 24 lines of the three 8-bit ports to be in the input mode. All
flip-flops are cleared and the interrupts are reset. This condition is maintained even after the
RESET goes low. The ports of the 8255 can then be programmed for any other mode by sending
out a single output instruction to the control register. Also, the current mode of operation can be
changed by writing a single mode word onto the control register, when required.
Modes for Group A and Group B can be separately defined with Port C taking on responsibilities
as dictated by the mode definitions or Ports A and B. If Group A is programmed for Mode 0, and
Group B is programmed for Mode 1, Port A and PC4–PC7 can be programmed for either input or
output, while Port B can be programmed for input or output with PC0–PC2 used for handshaking.
The mode definition format and bit set-reset format are discussed in above topics. The control
words for both mode definition and Bit Set-Reset are loaded into the same control register, with
bit D7 used for specifying whether the word loaded into the control register is a mode definition
word or Bit Set-Reset word. If D7 is high, the word is taken as a mode definition word, and if it is
low, it is taken as a Bit Set-Reset word. The appropriate bits are set of reset depending on the
type of operation desired, and loaded into the control register (which is accessed when A1 and A0
both are '1'; WR and CS both are '0'. It is to be noted that Group B does not have provision for
operation in Mode 2.
The eight possible combinations of the states of bits D1 -D3 (B2 B1 B0) in the Bit Set-Reset
format (henceforth referred to as BSR) determine the particular bit in PC0-PC7 being set or reset
as per the status of bit D0. A BSR word is to be written for each bit that is to be set or reset. For
example, if bit PC2 is to be set and bit PC7 is to be reset, the appropriate BSR words that will
have to be loaded into the control register will be, 0XXX001 and 0XXX1110, respectively,
where X can be either '0' or '1'.
The BSR, word can also be used for enabling or disabling interrupt signals generated by Port C
when the 8255 is programmed for Mode 1 or Mode 2 operation. This is done by setting or
resetting the associated bits of the interrupts.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 11
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Example 1
a) Identify the port addresses in given figure.
b) Identify the Mode 0 control word to configure port A as an input port and port B as an
output port.
c) Write a program to read the Dip switches and display the reading from port A at port B.
Solution
a) This is I/O mapped I/O; when A15 A14 A13 is 011, then chip select of 8255 is enabled. We
also know that during the execution of IN and OUT instruction, A15-A8 and AD7-AD0 carry
the same signals. Keeping this in mind, port addresses will be derived. Firstly, port A’s port
address will be calculated as under:
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 1 1 X X X X X = X X X X X X 0 0
To have equality, 0’s and 1’s on one side of the equation must appear on other sides. This means
that AD7 AD6 AD5 must equal 011 and A9 and A8 must equal 00 (port A) to get
0 1 1 X X X 00 = 0 1 1 X X X 00
Since the remaining don’t cares can be 0’s and 1’s, there are many solutions. For instance, if all
the don’t cares are equal to zero; address of port A becomes 1110 0000 (60H). The port
addresses of the given figure are determined as under:
Port A = 60H
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 12
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Port B = 61H
Port C = 62H
Control Register = 63H
b) The Mode 0 control word to configure port A input and port B output is calculated as under:
D7 D6 D5 D4 D3 D2 D1 D0 = 90H
1 0 0 1 X 0 0 X
c) Program subroutine to read DIP switches and display the reading from port A at port B is as
under:
MVI A, 90H; Load ACC with the control word
OUT 63H; Write the control word in control register and initialize the ports
IN 60H; Reads switches at port A
OUT 61H; Display the reading at port B
RET
Example 2
Write a BSR control word to set PC7, PC6, PC5, PC4, PC3, PC2, PC1, and PC0 and reset each after
1 second.
Solution
Let us assume Port addresses same as example 1. The control word is calculated with Port C
output in this case so it is 10000 0000 (80H). BSR control word for each case is given as under:
Program Subroutine
MVI A, 80H
LOOP: OUT 63H
MVI A, 0FH
OUT 63H
CALL DELAY
DCR A
ANI 0FH
JMP LOOP
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 14
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
LOOP2: DCR E
JNZ LOOP2
DCR D
JNZ LOOP1
DCR C
JNZ LOOP
RET
Mode 1 Input
Below figure shows Port A as input port (when it operates in Mode 1) along with the control
word and control signals (for handshaking with a peripheral). When the control word is loaded
into control register, Group A is configured in Mode 1 with Port A as an input port, Port A can
accept parallel data from a peripheral (like a keyboard) and this data can be read by the CPU.
The peripheral first loads data into Port A by making the STBA input low. This latches the data
placed by the peripheral on the common data bus into Port A. Port A acknowledges reception of
data by making IBFA (Input Buffer Full) high. IBFA is set when the STBA input is made low.
INTRA is an active output signal which can be used to interrupt the CPU so that the CPU can
suspend its current operation and read the data written into Port A by the peripheral. INTR A can
be enabled or disabled by the INTEA flip-flop which is controlled by BIT Set-Reset operation of
PC4. INTRA is set (if enabled by setting the INTEA flip-flop) after the STBA has gone high again,
and if IBFA is high.
On receipt of the interrupt, the CPU can be made to read Port A. The falling edge of the RD input
resets IBFA and it goes low. This can be used to indicate to the peripheral that the input buffer is
empty and that data can again be loaded into it.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 15
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 16
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Fig: Timing Waveforms for Strobed Input (With Handshake) – 8255 Mode 1
Above figure shows Port B as an input port (when in Mode 1). The timing diagram and operation
of Port B is similar to that of Port A except that it uses different bits of Port C for control. INTEB
is controlled by Bit Set/Reset of PC2.
If the CPU is busy with other system operations, it can read data from the input port when it is
interrupted. This is often called Interrupt Controlled I/O. However, if the CPU is otherwise not
busy with other jobs, it can continuously poll (read) the status word to check for an IBF A. This is
often called Program Controlled I/O. The status word is accessed by reading Port C (A1 A0 must
be 10, RD and CS must be low). The status word format as assumed by the bits of Port C when
Ports A and B are input ports in Mode 1, is shown in above figure.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 17
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Mode 1 Output
Figure below shows Port A configured as an output port (when in Mode 1) along with the control
word and control signals (for handshaking with a peripheral). When the control word is loaded
into the control register, Group A is configured in Mode 1 with Port A as an output port. The
CPU can send out data to a peripheral (like a display device) through Port A of the 8255.
The OBFA output (Output Buffer Full) goes low on the rising edge of the WR signal (when the
CPU writes data into the 8255). The OBFA output from 8255 can be used as a strobe input to the
peripheral to latch the contents of Port A. The peripheral responds to the receipt of data by
making the ACKA input of the 8255 low, thus acknowledging that it has received the data sent out
by the CPU through Port A. The ACKA low resets the OBFA signal, which can be polled by the
CPU through OBFA of the status word to load the next data when it is high again.
INTRA is an active high output of the 8255 which is made high (if the associated INTE flip-flop
is set) when ACKA is made high again by the peripheral, and when OBFA goes high again (see
timing diagram in Figure below). It can be used to interrupt the CPU whenever the output buffer
is empty. It is reset by the falling edge of WR when the CPU writes data onto Port A. It can be
enabled or disabled by writing a '1' or a '0' respectively to PC6 in the BSR mode.
Figure below shows Port B as an output port when in Mode 1. The operation of Port B is similar
to that of Port A. INTEB is controlled by writing a '1' or '0' to PC2 in the BSR mode.
The status word is accessed by issuing a Read to Port C. The format of the status word as
assumed by the bits of Port C when Ports A and B are Output ports in Mode 1 is shown in Figure
below.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 18
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 19
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Fig: Timing Waveform for Strobed (With Handshake) Output - 8255 Mode 1
Example 3
Below mentioned figure shows an interfacing circuit using the 8255A in Mode 1. Port A is
designated as the input port for a keyboard with interrupt I/O and port B is designated as the
output port for a printer with status check I/O.
a) Find port addresses by analyzing the decode logic.
b) Determine the control word to set up port A as input and port B as output in Mode 1.
c) Determine the BSR word to enable INTEA.
d) Determine the masking byte to verify the OBF’ line in status check I/O.
e) Write subroutine to accept character from keyboard and send character to printer.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 20
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Solution
a) The 8255A is connected as I/O mapped I/O. When the address lines A7-A2 are all 1, the
output of NAND gate goes low and selects 8255A. The port addresses are calculated as
1111 11XX:
Port A = 1111 1100 (FCH)
Port B = 1111 1101 (FDH)
Port C = 1111 1110 (FEH)
Control Register = 1111 1111 (FFH)
b) Control word to set up port A as input and port B as output Mode 1 is:
D7 D6 D5 D4 D3 D2 D1 D0 = B4H
1 0 1 1 X 1 0 X
c) BSR word to set INTEA
D7 D6 D5 D4 D3 D2 D1 D0 = 09H
0 0 0 0 1 0 0 1
d) Status word to check OBFB’
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 21
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 22
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 23
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Assignment 1:
Interfacing keyboard and seven segment display
Interfacing a microprocessor to a tape reader and lathe
Interfacing to parallel printer
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 24
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 25
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 26
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Fig: The 16-bit ISA bus. (a) Both 8- and 16-bit connectors and (b) the pinout of the 16-bit
connector.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 27
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 28
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 29
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Tutorials:
1. Assume that your group has decided to make a PC based control system for a wine company.
After studying the system, your group found out that the following to be implemented for
controlling purpose:
Pressure measurement (6 points)
Temperature measurement (5 points)
Weight measurement (1 point)
Volume measurement for filling (5 points)
Your group also decided to use 8255A PPI card at base address 0550H.
a) List out collected documents and components
b) List out different signals you need to derive and or can be directly connected to your
interfacing circuit.
c) Draw minimum mapping circuit for above system
d) What are the address captured by card
e) Generate necessary control word
f) Write a program module for measuring the pressure of all the points and control if the
pressure is not in a range, Assume suitable data if necessary.
Solution:
a) Components: 8255A card, ADC, MUX, Memory, Processor, connecting wires, power
supplies (+5V, GND), gates etc.
Documents: Data sheets and technical documentation of above components
b) Signals needed to be derived on directly connected to circuit
A1, A2, Chip Select ( CS ) for Port selection of of 8255A, RESET signal
Read ( RD ) and Write ( WR ) signals
Start Conversion (SC) and End of Conversion (EOC)
c) The minimum mapping circuit is as given below:
D7 PA7 D7
To 8085 PA0 D0
D0 8 Bit Vin
A15 ADC
. PC7 EOC
. CS PC0 SC
.
A2 8255A
A1 PPI
A0
Select Line
RD PB4 32X1
WR PB0 MUX
……
RESET OUT Analog
Input
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 30
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
d) The base address of card is 0550H, following are address captured by card.
Port Address A A A A A A A A A A A A A A A A
1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0
5 4 3 2 1 0
A 0550H 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0
B 0551H 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1
C 0552H 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0
CR 0553H 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1
The total numbers of monitoring points are 17. If we use 1 ADC for all of them, we need
to select any one at given time. So, we can use 32X1 MUX which would then have 25=32
i.e. 5 selection lines (B0 to B4). These lines can have defined for any of the 17 lines.
In the above circuit,
Port A Input port to read data from ADC in mode 0
Port B Output port to select any one of 17 lines from MUX in mode 0
Port C Output port (PC0 as SC) and Input port (PC7 as EOC)
D7 D6 D5 D4 D3 D2 D1 D0 = 98H
1 0 0 1 1 0 0 0
D7 D6 D5 D4 D3 D2 D1 D0 = 01H
0 0 0 0 0 0 0 1
D7 D6 D5 D4 D3 D2 D1 D0 = 00H
0 0 0 0 0 0 0 0
Assuming that ADC starts the conversion process only when it receives SC signal and
after conversion indicates via EOC line i.e. it has finished conversion and so ADC port
data in its data lines which can be now be read through port A.
f) Program Module:
LXI H, MEMORY
MVI A, 98H
STA 0553H; write control word in CR
MVI C, 06H; set counter to read 6 pressure points
MVI B, 00H; selection of points for MUX
NEXT: MOV A, B
STA 0551H; select first pressure point
MVI A, 01H; load A with BSR word to set PC0
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 31
Instrumentation II Chapter 2 : Parallel Interfacing With Microprocessor Based System
Load temperature from temperature sensor LM135 and control fan and heater.
If temperature > 35o Fan ON
If temperature < 10o Heater ON
(Refer Gaonkar 15.1.4 pages 468-472)
6. You are required to monitor the operation of pump as well as status of upper and lower tank
in the household. Apart from that you need to control 3 lights that are to turn ON in the
evening and turn OFF in the morning time. Additionally, you also need to check the status of
smoke sensors in Room1, Room2 & Room3, and heat sensor in kitchen and ring alarm when
necessary.
Your group also decided to use 8255 PPI card at base address 3000H in memory mapped I/O
for controlling purpose. Make complete circuitry including relays and relay driving
transistor.
Write a program module to read status of heat sensor and generate alarm when the limit
exceeds.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Brey | 32
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Chapter -3
Within a microcomputer data is transferred in parallel, because that is the fastest way to do it.
For transferring data over long distances, however, parallel data transmission requires too many
wires. Therefore, data to be sent long distances is usually converted from parallel form to serial
form so that it can be sent on a single wire or pair of wires. Serial data received from a distant
source is converted to parallel form so that it can easily be transferred on the microcomputer
buses.
But in serial mode of transfer, only one bit of a word is transferred at a time so that data
transfer rate is very slow; it is the one of the demerit over parallel data transfer.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 1
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
In case of serial transmission data is sent in a serial form i.e. bit by bit on a single line. Also, the
cost of communication hardware is considerable reduced since only a single wire or channel is
require for the serial bit transmission. Serial data transmission is slow as compared to parallel
transmission. Serial data can be sent synchronously or asynchronously.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 2
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Synchronous transmission has the advantage that the timing information is accurately aligned to
the received data, allowing operation at much higher data rates. It also has the advantage that the
receiver tracks any clock drift which may arise (for instance due to temperature variation). The
penalty is however a more complex interfaces design, and potentially a more difficult interface to
configure (since there are many more interface options).
Data transmission takes place without any gap between two adjacent characters. However data is
send block by block. A block is a continuous steam of characters or data bit pattern coming at a
fixed speed. You will find a SYNC bit pattern between any two blocks of data and hence the data
transmission is synchronized. Synchronous communication is used generally when two
computers are communicating to each other at a high speed or a buffered terminal is
communicating to the computer.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 3
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 4
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Parity Check
This is the simplest method of error checking which checks the characters by counting the
number of 1s. In this method, D7 of each ASCII code is used to transmit parity check
information. Parity may be the even parity (having even number of 1s in a character) or the odd
parity (having odd number of 1s in a character).
In an even parity system, when a character has an odd number of 1s, the bit D7 is set to 1 and an
even number of 1s is transmitted. On the other hand, in an odd parity system, when a character
has an even number of 1s, the bit D7 is set to 1 and an odd number of 1s is transmitted.
For an example, character to be sent is ‘A’ whose ASCII code is 41H (0100 0001) with two 1s. If
the character is transmitted in an odd parity system, the bit D7 is set to 1 and if it is transmitted in
an even parity system, the bit D7 is set to 0. Most of microprocessors are designed to detect
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 6
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
parity using the parity flag. However, the parity check cannot detect multiple errors in any given
character.
Checksum
The checksum technique is used when blocks of data are transmitted. It involves adding all the
bytes in a block without carriers. Then, the 2’s complement of the sum (negative of the sum) is
transmitted as the last byte. The receiver adds all the bytes, including the 2’s complement of the
sum; thus, the result should be zero if there is no error in the block.
A baud rate is the number of times a signal in a communications channel changes state or varies.
For example, a 2400 baud rate means that the channel can change states up to 2400 times per
second. The term “change state” means that it can change from 0 to 1 or from 1 to 0 up to X (in
this case, 2400) times per second. It also refers to the actual state of the connection, such as
voltage, frequency, or phase level).
The main difference between the two is that one change of state can transmit one bit, or slightly
more or less than one bit, that depends on the modulation technique used. So the bit rate (bps)
and baud rate (baud per second) have this connection:
Note:
If 1 frame of data is coded with 1 bit then band rate and bit rate are same. Sometimes frame of
data are coded with two or more bits then baud rate and bit rate are not same.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 7
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
System A System B
Transmitter/Rec Transmitter/Rec
OR
eiver eiver
Fig:Half Duplex mode
Transmitter/Rec Transmitter/Rec
eiver OR/AND eiver
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 8
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
RS-232C
Serial transmission of data is used as an efficient means for transmitting digital information
across long distances, the existing communication lines usually the telephone lines can be used
to transfer information which saves a lot of hardware. RS-232C is an interface developed to
standardize the interface between data terminal equipment (DTE) and data communication
equipment (DCE) employing serial binary data exchange. Modem and other devices used to send
serial data are called data communication equipment (DCE). The computers or terminals that are
sending or receiving the data are called data terminal equipment (DTE).
RS- 232C is the interface standard developed by electronic industries Association (EIA) in
response to the need for the signal and handshake standards between the DTE and DCE. RS-
232C has following standardize features.
- It uses 25 pins (DB – 25P) or 9 Pins (DE – 9P) standard where 9 pins standard does not
use all signals i.e. data, control, timing and ground.
- It describes the voltage levels, impendence levels, rise and fall times, maximum bit rate
and maximum capacitance for all signal lines.
- It specifies that DTE connector should be male and DCE connector should be female.
- It can send 20kBd for a distance of 50 ft.
- The voltage level for RS-232 are:
o A logic high or 1 or mark, -3V to -15V
o A logic low or 0 or space, +3v to +15v
- Normally ±12V voltage levels are used
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 9
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 10
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 11
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Simplex, Half Duplex and Full Duplex Operation Using RS-232 port
signal is also enabled all the time on most modems but on some DCEs, DSR may be active only
if preparations for calling destination device are completed. The signal is normally activated by
DCE only if it has detected a carrier signal from the destination device. Also, in this connection,
DTR signal acts as a main switch and RI indicates that an external device wants to establish a
connection with DTE via DCE.
A full duplex connection is very comfortable, as we need not pay attention to the roles of
receiver and transmitter i.e. we may keep RTS signal active all time ignoring CTS and DSR
signals.
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.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 13
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Connection to Printers
As a printer is not DCE, various control and status lines have to be connected or interchanged to
emulate behavior of a DCE. TxD data of PC becomes received data of printer. DCD and RI
signals on PC are meaningless. On PC, RTS and CTS are connected to each other so that a
transmission request from PC immediately enables the transmission. Since, printer as DTE refers
to print anything as long as no active signal is present at inputs CTS, DSR and DCD. This
problem is solved by connecting RTS with CTS and DTR with DCD and DSR. Thus, activating
RTS gives rise to an activation of CTS and that of DTR to an activation of DCD and DSD.
Overrun error arises in serial interface as PC can transmit data much faster than printer can print
it so internal printer buffer gets full. On parallel interface, this problem is solved as printer
activates BUSY signal informing PC that it cannot accept data temporarily. In serial interface,
pin 19 of printer is used to output a <<Buffer Full Signal>>. On DTE, DSR provide an input for
this signal. If printer buffer is full, printer simply disables handshake signal at pin 19 and DTE
knows that temporarily no additional data can be transferred. If enough room is available in
buffer again, printer enables signal once more; PC may transfer data to printer. Not all printers
with serial interface provide such a buffer full signal at pin 19.
RS-423A
A major problem with RS-232C is that it can only transmit data reliably for about 50 ft at its
maximum rate of 20Kbd. If longer lines are used the transmission rate has to be drastically
reduced due to open signal lines with a common signal ground. Another EIA standard which is
improvement over RS-232C is RS-423A. The standardize features of RS-423 are:
- This standard specifies a low impendence single ended signal which can be sent over 50
coaxial cable and partially terminated at the receiving end to prevent reflection.
- Voltage levels
o Logic High 4V - 6V negative
o Logic Low 4V - 6V positive
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 14
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
- It allows a maximum data rate of 100 Kbd over 40 ft line or a maximum baud rate of 1
Kbd over 4000 ft line.
RS-422A
It is a newer standard for serial data transfer. It specifies that each signal will be sent
differentially over two adjacent wires in a ribbon cable or a twisted pair of wires uses differential
amplifier to reject noise. The term differential in this standard means that the signal voltage is
developed between two signal lines rather than between signal line and ground as in RS-232C
and RS-423A. Any electrical noise induced in one signal line will be induced equally in the other
signal line. A differential line receiver MC3486 responds only to the voltage difference between
its two inputs so any noise voltage that is induced equally on two inputs will not have any effect
on the output of the differential receiver.
Features of USB
Single connector type: USB replaces all the different legacy connectors with one well-
defined, standardized USB connector for all USB peripheral devices, eliminating the need
for different cables and connectors and thus simplifying the design of the USB devices.
So all USB devices can be connected directly to a standard USB port on a computer.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 16
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Hot-swappable: USB devices can be safely plugged and unplugged as needed while the
computer is running. So there is no need to reboot.
Plug and Play: Operating system software automatically identifies, configures, and loads
the appropriate device driver when a user connects a USB device.
High performance: USB offers low speed (1.5 Mbit/s), full speed (12 Mbit/s) and high
speed (up to 480 Mbit/s) transfer rates that can support a variety of USB peripherals.
USB 3.0 (SuperSpeed USB) achieves the throughput up to 5.0 Gbit/s.
Expandability: Up to 127 different peripheral devices may theoretically be connected to a
single bus at one time.
Power supplied from the bus: USB distributes the power to all connected devices
eliminating the need for external power source for low-power devices. High-power
devices can still require their own local power supply. USB also supports power saving
suspend/resume modes.
Easy to use for end user: A single standard connector type for all USB devices simplifies
the end user's task at figuring out which plugs go into which sockets. The operating
system automatically recognizes the USB device attachment and loads appropriate device
drivers.
Low-cost implementation: Most of the complexity of the USB protocol is handled by the
host, which along with low-cost connection for peripherals makes the design simple and
low cost.
• Wide range of workloads and applications:
– Suitable for device bandwidths ranging from a few kb/s to several Mb/s
– Supports isochronous as well as asynchronous transfer types over the same set of
wires
– Supports concurrent operation of many devices (multiple connections)
– Supports up to 127 physical devices
– Supports transfer of multiple data and message streams between the host and
devices
– Allows compound devices (i.e., peripherals composed of many functions)
– Lower protocol overhead, resulting in high bus utilization
• Isochronous bandwidth
– Guaranteed bandwidth and low latencies appropriate for telephony, audio, etc.
– Isochronous workload may use entire bus bandwidth
• Robustness
– Error handling/fault recovery mechanism is built into the protocol
– Dynamic insertion and removal of devices is identified in user-perceived real-time
– Supports identification of faulty devices
USB Standards
USB 1.0
USB 1.0: Released in January 15, 1996.
Specified data rates of 1.5 Mbit/s (Low-Bandwidth) and 12 Mbit/s (Full-Bandwidth).
Does not allow for extension cables or pass-through monitors (due to timing and power
limitations). Few such devices actually made it to market.
USB 1.1: Released in September 23, 1998.
Introduced the improved specification and was the first widely used version of USB.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 17
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Fixed problems identified in 1.0, mostly relating to hubs. Earliest revision to be widely
adopted.
USB 2.0
The USB 2.0 specification was released in April 27, 2000 and was ratified by the USB
Implementers Forum (USB-IF) at the end of 2001.
The major feature of revision 2.0 was the addition of a high-speed transfer rate of 480
Mbit/s. USB 2.0 supports three speeds namely High Speed - 480Mbits/s, Full Speed -
12Mbits/s and Low Speed - 1.5Mbits/s with one host per bus (at a time).
USB 3.0
The USB 3.0 specification was published on 12 November 2008.
Brings significant performance enhancements to the USB standard while offering
backward compatibility with the peripheral devices currently in use. Legacy USB 1.1/2.0
devices continue to work while plugged into new USB 3.0 host and new USB 3.0 devices
work at USB 2.0 speed while plugged into USB 2.0 host.
Delivering data transfer rates up to ten times faster (the raw throughput is up to 5.0
Gbit/s) than Hi-Speed USB (USB 2.0), SuperSpeed USB is the next step in the continued
evolution of USB technology.
Its main goals were to increase the data transfer rate (up to 5 Gbit/s), to decrease power
consumption, to increase power output, and to be backwards-compatible with USB 2.0.
USB 3.0 includes a new, higher speed bus called SuperSpeed in parallel with the USB 2.0
bus. For The first USB 3.0 equipped devices were presented in January 2010
Transfer of 25 GB file in approx 70 seconds
Extensible – Designed to scale > 25Gbps
Optimized power efficiency
o No device polling (asynchronous notifications)
o Lower active and idle power requirements
Backward compatible with USB 2.0
o USB 2.0 device will work with USB 3.0 host
o USB 3.0 device will work with USB 2.0 host
Wireless USB
Released in May 12, 2005 which uses UWB (Ultra Wide Band) as the radio technology.
480 M bits/sec up to 3m
110 m bits/sec up to 10m
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 18
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
• USB Schedule: The USB provides a shared interconnect. Access to the interconnect is
scheduled in order to support isochronous data transfers and to eliminate arbitration
overhead.
Signals
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 19
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Reset
When the host wants to start communicating with a device it will start by applying a 'Reset'
condition which sets the device to its default unconfigured state.
The Reset condition involves the host pulling down both data lines to low levels (SE0) for at
least 10 ms. The device may recognize the reset condition after 2.5 us.
This 'Reset' should not be confused with a micro-controller power-on type reset. It is a USB
protocol reset to ensure that the device USB signaling starts from a known state.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 20
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
EOP signal
The End of Packet (EOP) is an SE0 state for 2 bit times, followed by a J state for 1 bit time.
Suspend
One of the features of USB which is an essential part of today's emphasis of 'green' products is
its ability to power down an unused device. It does this by suspending the device, which is
achieved by not sending anything to the device for 3 ms.
Normally a SOF packet (at full speed) or a Keep Alive signal (at low speed) is sent by the host
every 1 ms, and this is what keeps the device awake.
A suspended device may draw no more than 0.5 mA from Vbus.
A suspended device must recognise the resume signal, and also the reset signal.
Resume
When the host wants to wake the device up after a suspend, it does so by reversing the polarity of
the signal on the data lines for at least 20ms. The signal is completed with a low speed end of
packet signal.
It is also possible for a device with its remote wakeup feature set, to initiate a resume itself. It
must have been in the idle state for at least 5ms, and must apply the wakeup K condition for
between 1 and 15 ms. The host takes over the driving of the resume signal within 1 ms.
Throughput
• Throughput is the actual output of any device, USB’s actual throughput is a function of
many variables:
– Target device’s ability to source or sink data
– Bandwidth consumption by other devices in the bus
– Efficiency of host’s USB ports
– Types of data
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 21
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
Speed
A USB device must indicate its speed by pulling either the D+ or D- line high to 3.3 volts. A full
speed device, pictured below will use a pull up resistor attached to D+ to specify itself as a full
speed device. These pull up resistors at the device end will also be used by the host or hub to
detect the presence of a device connected to its port. Without a pull up resistor, USB assumes
there is nothing connected to the bus.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 22
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
USB Protocols
Unlike RS-232 and similar serial interfaces where the format of data being sent is not defined,
USB is made up of several layers of protocols. While this sounds complicated, don’t give up
now. Once you understand what is going on, you really only have to worry about the higher level
layers. In fact most USB controller I.C.s will take care of the lower layer, thus making it almost
invisible to the end designer.
Each USB transaction consists of a
Token Packet (Header defining what it expects to follow), an
Optional Data Packet, (Containing the payload) and a
Status Packet (Used to acknowledge transactions and to provide a means of error
correction)
As we have already discussed, USB is a host centric bus. The host initiates all transactions. The
first packet, also called a token is generated by the host to describe what is to follow and whether
the data transaction will be a read or write and what the device’s address and designated endpoint
is. The next packet is generally a data packet carrying the payload and is followed by an
handshaking packet, reporting if the data or token was received successfully, or if the endpoint is
stalled or not available to accept data.
• ADDR: The address field specifies which device the packet is designated for. Being 7
bits in length allows for 127 devices to be supported. Address 0 is not valid, as any
device which is not yet assigned an address must respond to packets sent to address zero.
• ENDP: The endpoint field is made up of 4 bits, allowing 16 possible endpoints. Low
speed devices, however can only have 2 additional endpoints on top of the default pipe.
(4 endpoints max)
• CRC: Cyclic Redundancy Checks are performed on the data within the packet payload.
All token packets have a 5 bit CRC while data packets have a 16 bit CRC.
• EOP: End of packet. Signalled by a Single Ended Zero (SE0) for approximately 2 bit
times followed by a J for 1 bit time.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 23
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
• Data Packets: There are two types of data packets each capable of transmitting up to
1024 bytes of data.
o Data0
o Data1
High Speed mode defines another two data PIDs, DATA2 and MDATA.
Data packets have the following format,
Sync PID Data CRC16 EOP
o Maximum data payload size for low-speed devices is 8 bytes.
o Maximum data payload size for full-speed devices is 1023 bytes.
o Maximum data payload size for high-speed devices is 1024 bytes.
o Data must be sent in multiples of bytes.
• Status / Handshake Packets: There are three type of handshake packets which consist
simply of the PID
o ACK - Acknowledgment that the packet has been successfully received.
o NAK - Reports that the device temporary cannot send or received data. Also used
during interrupt transactions to inform the host there is no data to send.
o STALL - The device finds its in a state that it requires intervention from the host.
Handshake Packets have the following format,
Sync PID EOP
Transfer Model
Endpoints
Endpoints can be described as sources or sinks of data. As the bus is host centric, endpoints
occur at the end of the communications channel at the USB function. At the software layer, your
device driver may send a packet to your devices EP1 for example. As the data is flowing out
from the host, it will end up in the EP1 OUT buffer. Your firmware will then at its leisure read
this data. If it wants to return data, the function cannot simply write to the bus as the bus is
controlled by the host. Therefore it writes data to EP1 IN which sits in the buffer until such time
when the host sends a IN packet to that endpoint requesting the data. Endpoints can also be seen
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 24
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
as the interface between the hardware of the function device and the firmware running on the
function device.
All devices must support endpoint zero. This is the endpoint which receives all of the devices
control and status requests during enumeration and throughout the duration while the device is
operational on the bus.
Pipes
While the device sends and receives data on a series of endpoints, the client software transfers
data through pipes. A pipe is a logical connection between the host and endpoint(s). Pipes will
also have a set of parameters associated with them such as how much bandwidth is allocated to
it, what transfer type (Control, Bulk, Iso or Interrupt) it uses, a direction of data flow and
maximum packet/buffer sizes. For example the default pipe is a bi-directional pipe made up of
endpoint zero in and endpoint zero out with a control transfer type.
USB defines two types of pipes
Stream Pipes have no defined USB format, that is you can send any type of data down a
stream pipe and can retrieve the data out the other end. Data flows sequentially and has a
pre-defined direction, either in or out. Stream pipes will support bulk, isochronous and
interrupt transfer types. Stream pipes can either be controlled by the host or device.
Message Pipes have a defined USB format. They are host controlled, which are initiated
by a request sent from the host. Data is then transferred in the desired direction, dictated
by the request. Therefore message pipes allow data to flow in both directions but will
only support control transfers.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 25
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
integrated within the PC, which allows a number of attachment points (often loosely
referred to as ports). A further hub may be plugged into each of these attachment points,
and so on. However there are limitations on this expansion.
A device can be plugged into a hub, and that hub can be plugged into another hub and so
on. However the maximum number of tiers permitted is six.
All devices have an upstream connection to the host and all hosts have a downstream
connection to the device.
The length of any cable is limited to 5 metres. This limitation is expressed in the
specification in terms of cable delays etc, but 5 metres can be taken as the practical
consequence of the specification. This means that a device cannot be further than 30
metres from the PC, and even to achieve that will involve 5 external hubs, of which at
least 2 will need to be self-powered.
So the USB is intended as a bus for devices near to the PC. For applications requiring
distance from the PC, another form of connection is needed, such as Ethernet.
Un-powered Hub
• Un-powered hubs can be used with any number of high-power devices such as printers
and scanners that have their own power supply, thus not requiring power from the bus.
• Safe to use with low-power devices (mice, cameras, joysticks, etc.) as long as too many
aren’t connected as once.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 26
Instrumentation II Chapter 3: Serial Interfacing With Microprocessor Based System
• Endpoint is where data enters or leaves the USB system. An IN endpoint is data creator
and OUT endpoint is data consumer. For reliable data delivery scheme, need multiple IN
and OUT endpoints.
• The collection of endpoints is called an interface and is directly related to the real world
connection.
• An operating system will have a driver that corresponds to each interface.
• Some devices may have multiple interfaces such as a telephone has a keypad interface
and audio interface. Operating system will manage two separate device drivers.
• A collection of interface is called a configuration, and only one configuration can be
active at a time.
• A configuration defines the attribute and features of a specific model.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: Gaonkar, Hall & Hyde | 28
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
CHAPTER 4
INTERFACING A/D AND D/A CONVERTERS
4.1 Introduction
4.2 General terms involved in D/A and A/D converter
4.3 Examples of D/A and A/D Interfacing
4.4 Selection of A/D and D/A converter based on Design Requirements
4.1 Introduction
Even though an analog signal may represent a real physical parameter like temperature, pressure
etc, it is difficult to process or store the analog signal for later use without introducing a
considerable error. Therefore, in microprocessor based industrial products, it is necessary to
translate an analog signal into digital signal. The electronic circuit that translates an analog signal
into digital signal is called ADC (Analog to Digital Converter). Similarly a digital signal needs to
be translated into an analog signal to represent a physical quantity; this translator is called DAC
(Digital to Analog Converter).
Fig. 4.1.a shows a block diagram of a 3-bit A/D converter, it has one input line for an analog
signal and three output lines for digital signals. Fig. 4.1.b shows the graph of the analog input
voltage (0-1 V) and the corresponding digital output signal. It shows 8 (23) discrete output states
from 000 to 111 each state being 1/8V apart. This is defined as the resolution of the converter.
D0
A/D
Analog D1
Input Converter
D2
(a)
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 1
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
(b)
Fig. 4.1: a) A 3-bit ADC block diagram b) Analog input versus digital output
Types of ADC
1. Successive Approximation A/D Converter
It is one of the most used ADC.
Conversion time is faster than Dual slope but slower than Flash.
It has fixed conversion time for any value of analog input.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 2
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Successive approximation register generates a series of bit and DAC convert it into analog value
which is compared with output. For 4-bit ADC, 1000 is generated and the analog value of 1000
is compared with the output. If it is greater, 1 is flipped to 0 otherwise retained. Then in next
clock cycle the second bit is changed to 1 and the whole cycle continues till every bit is flipped
and checked.
Comparator
VIN +
Analog Input Start
Control Status
_ Data
Ready
CLK
VO Successive
4-Bit D/A
Approximation
Converter
Register
Analog Output
Reference Register
D3 D2 D1 D0
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 3
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Comparator
V+ + AND Gate
Analog Input
8-Bit Counter
V- _ Q7Q6Q5Q4Q3Q2Q1Q0
Digital
Clock Output
DAC Output
D7D6D5D4D3D2D1D0
Fig. 4.4 shows a circuit for 2-bit ADC using parallel comparators. A voltage divider sets
reference voltage on the inverting input’s of each of the comparator. The voltage at the top of the
divider chain represents the full scale value for the converter. The voltage to be converted is
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 4
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
applied to the non-inverting inputs of all the comparators in parallel. If the input voltage on a
comparator is greater than the reference voltage on the inverting input, the output of the
comparator will go high. The outputs of the comparators then give us a digital representation of
the voltage level of the input signal.
VIN A3 A2 A1 D1 D2
0 ≤ VIN ≤ 1 0 0 0 0 0
1 ≤ VIN ≤ 2 0 0 1 0 1
2 ≤ VIN ≤ 3 0 1 1 1 0
3 ≤ VIN ≤ 4 1 1 1 1 1
For an example, with an input voltage of 2.6 V, the output of comparators A1 and A2 will be
high. A priority encoder produces a binary output corresponding to the input having the highest
priority. In this case, the one representing the largest voltage level equal to or less than analog
input. Thus, the binary output closely represents the analog input voltage. Although it is
expensive, the conversion time is fast.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 5
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
5. Integrator ADC
control logic). Inputs to the controller include a clock (used to measure time) and the output of a
comparator used to detect when the integrator's output reaches zero.
The conversion takes place in two phases: the run-up phase, where the input to the integrator is
the voltage to be measured, and the run-down phase, where the input to the integrator is a known
reference voltage. During the run-up phase, the switch selects the measured voltage as the input
to the integrator. The integrator is allowed to ramp for a fixed period of time to allow a charge to
build on the integrator capacitor. During the run-down phase, the switch selects the reference
voltage as the input to the integrator. The time that it takes for the integrator's output to return to
zero is measured during this phase.
Q. Calculate the maximum conversion time of a successive approximation ADC and an 8-bit
staircase ramp ADC, if the clock rate is 2MHz.
For a 8-bit successive approximation ADC, the conversion time is constant and equal to
n 8
Tc 4 106 s 4s
f 2 106
For a 8-bit staircase ramp ADC, the maximum number of count is
nc = 28 = 256
Therefore, the maximum conversion time is
n 256
Tc c 128 106 s 128s
f 2 10 6
It can be noted that the conversion speed of successive approximation ADC is much
faster than the staircase ramp type.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 7
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Above figure shows a schematic of interfacing a typical ADC using status check.
ADC has one input line for analog signal and eight output lines for converted digital
signals.
Typically, analog signal can range from 0 to 10V or ±5V.
When an active low pulse is sent to the START pin, the DR goes high and the output
lines go into high impedance state.
The START pulse initiates conversion.
When the conversion is complete, the DR goes low and data are made available on the
output lines that can be read by the microprocessor.
To interface A/D converter, we need one output port to and a START pulse and two
input ports one to check the status of DR line and the other to read the output of the
converter.
The subroutine instructions to initiate the conversion and to read output data, and the
flowchart are shown below.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 8
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 9
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
However, the full-scale output can be restricted to the lower range of inputs by using pin
9 (Vref/2). For example, if we connect a 0.5V DC source at pin 9, we can obtain full
scale output FFH for a 1V input signal.
Service Routine:
LDA 8000H; Read data
MOV M, A ; store data in memory
INX H; Next memory location
DCR B; Next count
STA 8000H; start next conversion
EI; Enable interrupt again
RNZ; Go back to main if counter not equal to zero
HLT
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 10
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
When the conversion is needed the switch is opened, isolating the capacitor from the
input
The capacitor will hold the voltage when switch is opened
The capacitor will not discharge due to the high impedance of the voltage follower
Quantization
It is the process of converting an input function having continuous values to an output having
only discrete values.
Binary Coding
It is the method of assigning a binary equivalent number to each discrete level.
Sampling Rate:
The Analog Signal is continuous in time and it is necessary to convert this to a flow of digital
values. It is therefore required to define the rate at which new digital values are sampled from the
analog signal. The rate of new values is called the Sampling Rate or Sampling Frequency of the
converter. A continuously varying band limited signal can be sampled and then the original
signal can be exactly reproduced from the discrete-time values by an interpolation formula. The
accuracy is 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. This is essentially what
is embodied in the Shannon-Nyquist Sampling Theorem.
Since a practical ADC cannot make an instantaneous conversion, the input value must
necessarily be held constant during the time that the converter performs a conversion (called the
Conversion Time). An input circuit called a Sample and Hold performs this task in most cases by
using a capacitor to store the analog voltage at the input, and using an electronic switch or gate to
disconnect the capacitor from the input. Many ADC integrated circuits include the sample and
hold subsystem internally.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 11
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Aliasing:
If the digital values produced by the ADC are converted back to analog values by a DAC, it is
desirable that the output of the DAC be an exact replica of the original signal. If the input signal
is changing much faster than the sample rate, then this will not be the case, and spurious signals
(false) called aliases will be produced at the output of the DAC. For example, a 2 kHz sine wave
being sampled at 1.5 kHz would be reconstructed as a 500 Hz sine wave. This problem is called
aliasing. To avoid aliasing, the input to an ADC must be low-pass filtered to remove frequencies
above half the sampling rate. This filter is called an Anti-aliasing Filter, and is essential for a
practical ADC system that is applied to analog signals with higher frequency content.
Dither:
In ADC, performance can usually be improved using dither. This is a very small amount of
random noise (white noise), which is added to the input before conversion. The result is an
accurate representation of the signal over time. A suitable filter at the output of the system can
thus recover this small signal variation. An audio signal of very low level (with respect to the bit
depth of the ADC) sampled without dither sounds extremely distorted and unpleasant. Without
dither the low level may cause the least significant bit to "stick" at 0 or 1. With dithering, the true
level of the audio may be calculated by averaging the actual quantized sample with a series of
other samples (the dither) that are recorded over time.
In other way; a continuous time signal may be completely represented in its samples and
recovered back if the sampling frequency fs ≥ 2fm. Here, fs is the sampling frequency and fm is
the maximum frequency present in the signal.
A signal or function is band limited if it contains no energy at frequencies higher than some band
limit or bandwidth B. A signal that is band limited is constrained in how rapidly it changes in
time, and therefore how much detail it can convey in an interval of time. The sampling theorem
asserts that the uniformly spaced discrete samples are a complete representation of the signal if
this bandwidth is less than half the sampling rate. To formalize these concepts, let x(t) represent
a continuous-time signal and X(f) be the continuous Fourier transform of that signal:
The signal x(t) is said to be band limited to a one-sided baseband bandwidth, B, if:
for all
or, equivalently, supp(X)[2] [−B, B]. Then the sufficient condition for exact
reconstructability from samples at a uniform sampling rate fs(in samples per unit time) is:
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 12
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
or equivalently:
2B is called the Nyquist rate and is a property of the band limited signal, while fs / 2 is
called the Nyquist frequency and is a property of this sampling system.
The time interval between successive samples is referred to as the sampling interval:
The sampling theorem leads to a procedure for reconstructing the original x(t) from the samples
and states sufficient conditions for such a reconstruction to be exact.
What happens if we sample the signal at a frequency that is lower that the Nyquist rate? When
the signal is converted back into a continuous time signal, it will exhibit a phenomenon
called aliasing. Aliasing is the presence of unwanted components in the reconstructed signal.
These components were not present when the original signal was sampled. In addition, some of
the frequencies in the original signal may be lost in the reconstructed signal. Aliasing occurs
because signal frequencies can overlap if the sampling frequency is too low. Frequencies "fold"
around half the sampling frequency - which is why this frequency is often referred to as the
folding frequency.
Sometimes the highest frequency components of a signal are simply noise, or do not contain
useful information. To prevent aliasing of these frequencies, we can filter out these components
before sampling the signal. Because we are filtering out high frequency components and letting
lower frequency components through, this is known as low-pass filtering.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 13
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
MSB
Digital D2 D/A Analog
Input D1 Converter Output
D0
LSB
(a)
FS
A 7/8
n
a 3/4
l
o 5/8
g LSB
1/2
O
u 3/8
t
p 1/4
u
t 1/8
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 14
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
For the maximum input signal (111)2, the output signal is equal to the value of the full
scale input signal minus the value of 1 LSB input signal. Here, maximum input signal
(111)2 represents (1 – 1 / 8) = 7 / 8 V.
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]
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.
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.
Monotonicity
A converter is said to be monotonic if its output voltage value continuous to increase with
a continuously increasing input value.
Temperature Coefficient
It is defined as the degree of inaccuracy that the temperature change can cause in any of
the parameter of the DAC.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 15
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Types of DAC:
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 16
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 17
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
This includes an 8-input NAND gate and a NOR gate as the address decoding logic, the
74LS373 as a latch, and a 1408 DAC. Address lines (A7-A0) are decoded using the 8-input
NAND gate and its output is combined with the control signal IOW . When the microprocessor
sends the address FFH, the output of the negative AND gate enables the latch, and the data bits
are placed on the input lines of the converter for conversion.
The total reference current source is determined by the resistor R14 and the voltage VRef. The
resistor R15 is generally equal to R14 to match the input impedance of the reference source. The
output IO is calculated as:
Output voltage,
VO = IO * RF
= 2mA (255/256) * 5K
= 9.961V
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 18
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
This program outputs 00 to FF continuously to the DAC. Analog output of DAC starts at 0 and
increases approximately up to 10V as ramp. Slope of the ramp can be varied by changing the
delay.
Q. Explain the operation of the 1408 which is calibrated for a bipolar range ±5V. Calculate
output voltage VO if the input is 100000002.
The 1408 is calibrated for the bipolar range from -5V to +5V by adding the resistor RB (5.0K)
between the reference voltage VRef and the output pin 4. RB supplies 1mA (VRef/RB) current to
the output in the opposite direction of the current generated by input signal.
Here, IO’ = IO – VRef/RB
When input signal is zero,
VO = IO’ RF
= (IO – VRef/RB) RF
= (0 – 5V/5K) 5K
= -5V
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 19
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Fig: Block Diagram of Analog Device along with latch and output Op-Amp internal to the Chip
To interface a device with the microprocessor, two signals are required: Chip Select ( CS ) and
Chip Enable ( CE ). In the figure shown above, the address line A7 through inverter is used for
Chip Select, which assigns port address 80H (assuming all other address lines 0) to the DAC
port.
Figure above shows the timing of latching data in relation to the control signals. When both
signals CS and CE are at logic 0, the latch is transparent, meaning the input is transferred to the
DAC. When either CS or CE goes logic 1, input is latched in the register and held until both
control signals go to logic 0.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 21
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 22
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
B. Delay Time
It is the time interval between the instant when the digital input changes and the instant when
the analog output passes a specified value that is close to its initial value.
C. 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 output passes a specified value and
the instant when the analog output enters for a last time a specified error band about its final
value.
A
n
a
l Error band (± ½ LSB)
o
g
O
u
t
p
u
t
Digital Input
Settling Time (TS)
Time that digital Time of last entry
input changes into error band
Fig: Settling Time
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 23
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
2. Static Errors
A. Differential Linearity
It is a measure of the separation between adjacent levels. Differential linearity measures the
bit-to-bit deviations from ideal output steps rather than entire output range. If VS is the ideal
change and VCX is the actual change, then the differential linearity can be expressed as:
[(VCX-VS)/VS]*100%
Actual Output
FS Ideal Output
A 7/8
n
a 3/4
l
o 5/8
g
1/2
O
u 3/8
t
p 1/4
u
t 1/8
B. Monotonicity
In a D/A converter; means that as the digital input to the converter increases over its full scale
range, the analog output never exhibit a decrease between one conversion step and next.
A FS Ideal Output
n
a 7/8
l Actual Output
o
3/4
g
5/8
O
u 1/2
t
p 3/8
u
t
1/4
1/8
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 24
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
C. Integral Linearity
It is the maximum deviation of the output of a D/A for any given input code from a straight line
drawn from its ideal minimum to its ideal maximum.
A FS
n Actual Output
a 7/8
l
o Expected Output
3/4 Integral
g
Linearity Error
5/8
O
u 1/2
t
p 3/8
u
t
1/4
1/8
I. Absolute Linearity
It is measured by assuming that the output of a D/A will begin at zero and end at full scale.
The actual outputs are compared with a line drawn through these two points.
a. Zero Error
It is the difference between the actual output and zero when the digital word for a zero
output is applied.
b. Full Scale Error
It is the difference between the actual and the ideal voltage when the digital word for a
full scale output is applied.
i. Gain Error (Scale Factor Non-Linearity)
It is the difference between the gains of the actual static and ideal input output
characteristics.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 25
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
A FS Expected Output
n
a 7/8
l Actual Output
o
3/4
g
5/8
O
u 1/2
t
p 3/8
u
t
1/4
1/8
1/8
Offset Error
000 001 010 011 100 101 110 111
Digital Input
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 26
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
A
n
a
l u t } Gain Error
o Outp
d
g
ju ste
Ad ut
utp
O a lO
u Ide
t
p
u
t
Offset Error
Digital Input
A
n
a
l
ut
o utp
g lO
tua
Ac
O
u
t
p
u
t
Digital Input
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 27
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Static Dynamic
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 28
Instrumentation II Chapter 4: Interfacing A/D and D/A Converters
Designing the embedded system with ADC, MUX, S/H circuit for transmitting data in long
distance.
Gain Adjustment
Temperature
Humidity EOC
Pressure Display
OP Micro 8255
…………..
A typical system that converts signals from analog to digital and back to analog includes:
A transducer that converts non-electrical signals into electrical signals
An A/D converter that converts analog signals into digital signals
A digital processor that processes digital data (signals)
A D/A converter that converts digital signals into equivalent analog signals
A transducer that converts electrical signals into real life non-electrical signals
(sound, pressure, and video)
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 29
Instrumentation II Chapter 5: Data Acquisition and Transmission
Chapter – 5
Data Acquisition and Transmission
5.1 Analog and Digital Transmission
Analog Transmission
• Analog signal transmitted without regard to content
• May be analog or digital data
• Attenuated over distance
• Use amplifiers to boost signal
• Also amplifies noise
Digital Transmission
• Concerned with content
• Integrity endangered by noise, attenuation etc.
• Repeaters used
• Repeater receives signal
• Extracts bit pattern
• Retransmits
• Attenuation is overcome
• Noise is not amplified
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 1
Instrumentation II Chapter 5: Data Acquisition and Transmission
Presently, all the AM, FM radio transmission and TV transmission is analog communication.
The analog communication needs lower bandwidth compared to digital communication. But the
effect of noise interference is more in case of analog communication.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 2
Instrumentation II Chapter 5: Data Acquisition and Transmission
• Estimate what was send, aiming at the minimum possible probability of making mistakes
Design Factors
• Bandwidth
o Higher bandwidth gives higher data rate
• Transmission impairments
o Attenuation
• Interference
• Number of receivers
o In guided media
o More receivers (multi-point) introduce more attenuation (need more amplifies or
repeaters)
• Optical Fiber is a cylindrical waveguide system through which the optical wave can
propagate.
• An Optical Fiber consists of three main parts: Core, Cladding and Jacket (See Figure )
• An optical fiber is a dielectric (nonconductor of electricity) waveguide made of glass or
plastic. As shown in Figure below, it consists of three distinct regions: a core, the
cladding, and a sheath or jacket. The sheath or jacket protects the fiber but does not
govern the transmission capability of the fiber.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 3
Instrumentation II Chapter 5: Data Acquisition and Transmission
2. Multi-mode fibers:
It is used to transmit many signals per fiber (used in computer networks). They have larger
cores (62.5 microns in diameter) and transmit infra-red light from LED.
The multimode fiber has larger core diameter than single mode fiber. The core diameter is
about 40 um and that of cladding is 70 um. The relative refractive difference is also larger
than single mode fiber. They are not suitable for long distance communication due to large
dispersion and attenuation of the signal. The fabrication of multi fiber is less difficult and so
the fiber is not costly.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 5
Instrumentation II Chapter 5: Data Acquisition and Transmission
• Military Applications – Optical Fiber are lighter in transportation and more reliable in
terms of secrecy as compared to conventional systems.
• Entertainment – A coherent Optical Fiber bundle offers better enlargement of the image
displayed on a TV or screen.
5.2.2 Satellite
• A Satellite communication system consists of ground stations for transmitting and
receiving signals and a communication satellite in the space.
• A satellite is simply a repeater
• It consists of several transponders each of which listens to some portion of the spectrum,
amplifies the incoming signal and then rebroadcasts it at another frequency to avoid
interference with the incoming signal.
• The range of frequencies used for transmission of signals from ground station to the
satellite is uplink frequency and those used for transmission of signals from satellites to
ground station is downlink frequency. Uplink and downlink frequencies are different to
avoid interference.
• The downlink beam can be broad, covering a substantial fraction of the earth’s surface
(used in broadcasting) or narrow beam covering only a hundreds of km in diameter.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 6
Instrumentation II Chapter 5: Data Acquisition and Transmission
Types of Satellite
1. Low Earth Orbit (LEO)
• LEO satellites are much closer to the earth than GEO satellites, ranging from 500 to
1,500 km above the surface.
• LEO satellites don’t stay in fixed position relative to the surface, and are only visible for
15 to 20 minutes each pass.
• A network of LEO satellites is necessary for LEO satellites to be useful.
Advantages
o A LEO satellite’s proximity to earth compared to a GEO satellite gives it a better
signal strength and less of a time delay, which makes it better for point to point
communication.
o A LEO satellite’s smaller area of coverage is less of a waste of bandwidth.
Disadvantages
o A network of LEO satellites is needed, which can be costly
o LEO satellites have to compensate for Doppler shifts cause by their relative
movement.
o Atmospheric drag affects LEO satellites, causing gradual orbital deterioration.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 7
Instrumentation II Chapter 5: Data Acquisition and Transmission
Advantages of Satellites
• The coverage area of a satellite greatly exceeds that of a terrestrial system.
• Multiple signals can be superimposed at a time so capacity increased
• Transmission cost of a satellite is independent of the distance from the center of the
coverage area.
• Satellite to Satellite communication is very precise.
• Higher Bandwidths are available for use.
Disadvantages of satellite
• Bandwidth is decreased due to gradually becoming used up
• Launching satellites into orbit is costly.
• There is a larger propagation delay in satellite communication than in terrestrial
communication.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 8
Instrumentation II Chapter 5: Data Acquisition and Transmission
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 9
Instrumentation II Chapter 5: Data Acquisition and Transmission
Bluetooth Connection
Bluetooth uses the concept of Master/Slave mode of data communication which is packet based.
1. Passive State
2. Inquiry; Search of devices
3. Paging; Synchronization
4. Access Point Service Discovery; Wireless link
5. Channel Creation
6. Pairing; Optional (require pin code)
Bluetooth Characteristics
Bluetooth characteristics:
Operates in the 2.4 GHz Industrial-Scientific-Medical (ISM) band.
Uses Frequency Hop (FH) spread spectrum, which divides the frequency band into a
number of hop channels. During a connection, radio transceivers hop from one channel
to another in a pseudo-random fashion.
Supports up to 8 devices in a piconet (two or more Bluetooth units sharing a channel).
Built-in security.
Non line-of-sight transmission through walls and briefcases.
Omni-directional.
Supports both isochronous and asynchronous services; easy integration of TCP/IP for
networking.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 10
Instrumentation II Chapter 5: Data Acquisition and Transmission
2. Scatternet
• Interconnected piconets, one master per piconet
• A few devices shared between piconets
• No central network structure: “Ad-hoc” network
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 11
Instrumentation II Chapter 5: Data Acquisition and Transmission
• Radio layer: defines the requirements for a Bluetooth transceiver operating in the 2.4
GHz ISM band
• Baseband layer: describes the specification of the Bluetooth Link Controller (LC) which
carries out the baseband protocols and other low-level link routines
• Link Manager Protocol (LMP): is used by the Link Managers (on either side) for link set-
up and control
• Host Controller Interface (HCI): provides a command interface to the Baseband Link
Controller and Link Manager, and access to hardware status and control registers
• Logical Link Control and Adaptation Protocol (L2CAP): supports higher level protocol
multiplexing, packet segmentation and reassembly, and the conveying of quality of
service information
• RFCOMM protocol: provides emulation of serial ports over the L2CAP protocol. The
protocol is based on the ETSI standard TS 07.10
• Service Discovery Protocol (SDP): provides a means for applications to discover which
services are provided or available.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 12
Instrumentation II Chapter 5: Data Acquisition and Transmission
o Signals supported are Rx, Tx, RTS and CTS. The module is DCE, Data Circuit-
terminal Equipment. The maximum UART speed is 460.8 kbps
• PCM
o The PCM data can be: Linear PCM 13-16 bit, μ-law 8 bit, A-law 8 bit. The PCM
sync is 8 kHz and the PCM clock 200 kHz – 2 MHz.
Bluetooth Applications
• Bluetooth profiles were written to make sure that the application level works the same
way across different manufacturers' products
• Bluetooth applications:
Wireless control of and communication between a cell phone and a hands free
headset or car kit.
Wireless networking between PCs in a confined space and where little bandwidth
is required
Wireless communications with PC input devices such as mice and keyboards
Wireless communications to PC output devices such as printers
Built-in in modern laptops or dongles
Wireless communications with PC input devices such as mice and keyboards
Wireless communications to PC output devices such as printers
Transfer of files between devices via OBEX
Replacement of traditional wired serial communications in test equipment, GPS
receivers and medical equipment
Thus often a serial interface is emulated over the BT link as shown on the
following slides ...
Remote controls where infrared was traditionally used
Advantages
Uses low power
Can connect various type of devices
Free of cost
Ad Hoc hardware can be established by Bluetooth connection
Simple, Secure and Global data transfer
Less time consumption
Disadvantages
Large data transmission is difficult
Bluejack is not possible (Bluejacking problem)
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 13
Instrumentation II Chapter 5: Data Acquisition and Transmission
Components Description
Data acquisition At the heart of any data acquisition system lies the data acquisition
hardware hardware. The main function of this hardware is to convert analog signals to
digital signals, and to convert digital signals to analog signals.
Sensors and Sensors and actuators can both be transducers. A transducer is a device that
actuators converts input energy of one form into output energy of another form. For
(transducers) example, a microphone is a sensor that converts sound energy (in the form
of pressure) into electrical energy, while a loudspeaker is an actuator that
converts electrical energy into sound energy.
Signal Sensor signals are often incompatible with data acquisition hardware. To
conditioning overcome this incompatibility, the signal must be conditioned. For example,
hardware you might need to condition an input signal by amplifying it or by removing
unwanted frequency components. Output signals might need conditioning as
well. However, only input signals conditioning is discussed in this chapter.
Computer The computer provides a processor, a system clock, a bus to transfer data,
and memory and disk space to store data.
Software Data acquisition software allows you to exchange information between the
computer and the hardware. For example, typical software allows you to
configure the sampling rate of your board, and acquire a predefined amount
of data.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 14
Instrumentation II Chapter 5: Data Acquisition and Transmission
1) Input Signals
• May be
o Pressure, transducers
o Thermocouple
o AC signal
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 15
Instrumentation II Chapter 5: Data Acquisition and Transmission
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 16
Instrumentation II Chapter 5: Data Acquisition and Transmission
6) Programmer
• Control all units of data conversion and operation
• Microcontroller or microprocessor based system
• Basic units: main frames, front panel assembly, power supply unit, scanner
controller, input interface etc.
• Operation performed by programmer:
o Set amplifier
o Set linearity factor
o Set high and low alarm value
o Start A/D conversion
o Record reading channel
o Identify channel and time of recording
o Display recording
o Reset logger
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 17
Instrumentation II Chapter 5: Data Acquisition and Transmission
Data Storage
Storage Factors:
• Speed with which data can be accessed
• Cost per unit of data
• Reliability
o data loss on power failure or system crash
o physical failure of the storage device
Data Compression
• Process of encoding information using fewer bits than an un-encoded representation
would use, through specific encoding schemes.
• Reduce consumption of expensive resources such as hard drive and transmission
bandwidth.
• Trade-off between compression speed, compressed data size and quality (loss)
Types:
Lossy Lossless
For the case if loss of fidelity is acceptable Exploit statistical redundancy in such a
e.g. 6.666666 = 7 way to represent data without error
e.g. 6.666666 = 6[6]6
Examples: Pictures (JPEG), Video (MPEG), Examples: zip, rar, Picture (PNG, TIFF),
Audio (MP3) etc. Video (Huff, YUV, AVI) etc.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] References: R. Gaonkar & D.V. Hall | 19
Instrumentation II Chapter 6: Grounding and Shielding
Chapter – 6
Grounding and Shielding
Safety
Reduce the voltage differentials between external conductor surfaces.
Usually the design is – conducted energy, low frequency (less than 1 MHz) and
associated with power lines.
Microwave energy is not a shock hazard but it does pose danger and demands especial
attention to shielding.
Safety Ground
Provides a path for the dangerous leakage currents and short circuits.
Properly connected safety ground reduces voltage differential between external surfaces.
Safety ground must be a permanent, continuous, low impedance conductor with adequate
capacity that runs from the power source to load.
Don’t rely on a metallic conduct to form the conductive path for the safety ground,
corrosion and breaks can open the circuit.
Don’t rely on building steel either because circulating currents can generate large and
noisy ground potentials.
A separate dedicated conductor will avoid these problems.
Noise Sources
Noise sources generate either a periodic signal or transient pulse that disrupts other
circuits.
There are many types of sources: Power lines, Motors, High voltage equipment (e.g.
spark plug, igniter), Dischargers and sparks (e.g. lightning, static electricity), High
current equipment (e.g. arc welder)
Susceptible Circuit
• Third component of noise is susceptible circuit.
• E.g. susceptibility includes cross talk on inputs that leads to bit flips in digital logic, radio
interference and static discharge that destroy components.
• Susceptibility usually can be traced by proper grounding (or return paths) or long signal
lines that are not properly shielded.
Conductive Coupling
• Requires a connection between source and receiver that completes a continuous circuit.
• Conductive coupling usually occurs at lower frequencies and is often caused by incorrect
grounding.
• Such connections are inadvertent and difficult to find; such connections are called Sneak
circuits.
• A ground loop is a complete circuit that allows unwanted current to flow into the ground.
• Substantial current in a ground path (as opposed to a return path) can produce voltage
differences across the ground resistance and raise the ground potential at the loads.
Conversely, significant potentials in the ground can force unwanted current to flow
between circuits.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: K. R. Fowler | 4
Instrumentation II Chapter 6: Grounding and Shielding
• The use of high frequency and reduction of ground loop can reduce conductive coupling
or conductive noise.
Inductive Coupling
• An Inductive coupling mechanism requires a current loop that generates changing
magnetic flux.
• Generally, a current transient creates the changing magnetic flux, as follows:
= BA = 0 nIA
Then,
d dB di
v A( ) A 0 n( )
dt dt dt
Where, = Magnetic Flux
B = Magnetic field
A = Loop area
0 = Permeability of free space
n = Number of turns in the loop
i = Current
v = Voltage
• The induced voltage in a magnetically coupled circuit is proportional to the time rate of
change of current and loop area.
• Reducing the loop area will reduce the inductive reactance of a circuit.
• For frequencies above 3 MHz, (dv/dt) / (di/dt) << 377Ω
• Generally, the load impedance is large, while the source impedance is small.
• Current follows the path of lowest impedance, not necessarily lowest resistance.
Therefore, current will follow the path of minimum inductive reactance; this means the
current will minimize loop area in a circuit.
• A slot in the ground plane of a circuit board will increase the loop area of a circuit; below
figure shows this; so avoid such slots.
• The long, straight wires encompass significant loop area that provides an inductive
reactance. Twisting the pairs of signal and return lines together eliminates the loop area
and the mutual inductive coupling between circuits.
Capacitive Coupling
• Capacitive coupling mechanism requires both proximity between circuits and a changing
voltage.
• It occurs when two conductors are placed at some distance apart and voltage level and
frequency are changed.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: K. R. Fowler | 7
Instrumentation II Chapter 6: Grounding and Shielding
Electromagnetic Coupling
• Electromagnetic coupling or radiative coupling becomes a factor only when the
frequency of operation exceeds 20 MHz.
• f < 200 MHz, cables are primary sources and receivers for electromagnetic coupling.
• f > 200 MHz, PCB traces begin to radiate & couple energy.
• Generally, the length of conductor must be longer than 5% of the bandwidth i.e. l > ʎ/20.
• Pseudo impedance factor between 100Ω and 500Ω.
(dv/dt) / (di/dt) = 377Ω
• The frequency of signal must be reduced.
• Use magnetic plate shielding.
Safety Grounding
• Seeks to reduce the voltage differentials between exposed conducting surfaces.
• Should have many connections between the exposed conducting surfaces.
Signal Referencing
• Seeks to reduce the voltage differentials between reference points.
• Should have one connection between reference points at low frequency.
• In either case, ground is not the return path for a signal. Both safety and signal grounds
nominally conducts current.
Disadvantages
• Conductors longer than 5m (16 ft) are susceptible to high-frequency ground noise. (A
braided cable may reduce impedance at high frequencies by increasing the skin effect;
that is, current tends to flow along the surface, and braided cable has a large surface
area).
• Conductors longer than 30m (100 ft) or those conducting high fault currents are
unsafe. The inherent impedance of the conductor will cause large potential
differences exist between the instrument and ground.
• ADC is one application that needs a single point ground for signal referencing
separate references can generate noisy ground loops.
Ground Loop
• A ground loop is a complete circuit that comprises a signal path and part of the ground
structure.
• It arises whenever multiple connections to ground are physically separated.
• External currents in the ground structure generate potential differences between the
ground connections and introduce noise in the signal circuit.
• Generally, the problem arises at low frequencies (< 10 MHz); high frequencies follow the
path of minimum impedance that can avoid higher impedance ground loops.
• Ground loops are a particular problem in systems that have low level signal circuits and
multipoint grounds separated by large distances.
• Either circuit balance or signal isolation can eliminate noise from ground loops.
• For safety, coordinate the routing of power and signal to reduce noise introduces by the
ground structure.
Minimize Bandwidth
• A low-pass filter reduces high frequency emissions and susceptibility for signal
applications.
• Filtering input signals may improve the noise immunity of the circuit.
• Sharp edges on pulses will have large Fourier coefficient. Slowing the rise and fall times
of pulse edge will reduce the bandwidth of signals.
• Filtering clock signal to reduce the high-frequency harmonics is one area where we may
significantly reduce noise interference. But be careful not to violate the minimum skew
rate required by the logic circuits.
• Ferrite beads are best suited to filter low level signals and low current power feeds to
circuit board.
• A ferrite bead is a passive electric component used to suppress high frequency noise in
electronic circuits.
• It is a specific type of electronic choke. Ferrite beads employ the mechanism of high
dissipation of high frequency currents in a ferrite to build high frequency noise
suppression devices.
• The ferrite bead is effectively an inductor with a very small Q factor.
• For a simple ferrite ring, the wire is simply wrapped around the core through the center
typically 5 or 7 times. Clamp-on cores are also available, which can be attached without
wrapping the wire at all.
Inductive Shielding
• It is concerned with Self-inductance and Mutual inductance.
• It reduces noise coupling by reducing or rerouting magnetic flux.
• The most effective inductive shielding minimizes loop area, separating circuits and
reducing the change in current help, while metal or magnetically permeable enclosures
place a distant third in usefulness.
• Magnetic noise depends on loop area and current in the emitting and receiving circuits.
• Coaxial cable has minimal loop area and may be preferable for high frequencies (>
1MHz) because it provides both capacitive shielding and controlled impedance.
• Always pair signals with return, otherwise, we will not gain any inductive shielding.
• On circuit boards,
o Make sure that the return path is always under the signal conductor to minimize
loop area.
o Avoid slots in ground plane, which increase the loop area of signal path.
• Enclosures provide magnetic shielding by allowing eddy currents to reflect or absorb
interference energy. These enclosures are heavy, expensive and frequency dependent, but
sometimes they are only solution.
Capacitive Shielding
• Capacitive shielding reduces noise coupling by reducing or rerouting the electrical charge
in an electric field.
• Capacitive shields shunt to ground charge that is capacitively coupled.
• Capacitive coupling provides a path for the injection of noise charges.
• At low frequencies (< 1 MHz), connect a capacitive shield at one point if the signal
circuit is grounded. Multiple connections can form ground loops.
• Capacitive shielding can be improved by reducing:
o Noise voltage and frequency
o Signal impedance
o Floating metal surfaces
• Conversely, multiple ground connections are necessary for high frequencies (> 1 MHz).
Stray capacitance at the ungrounded end of a shield can complete a ground loop.
• Therefore, we should ground both ends of a long (relative to wavelength) shield.
• A mutual enclosure can be an effective electrostatic shield (transformer), or faraday
shield to prevent capacitive coupling.
Electromagnetic Shielding
• Electromagnetic shielding reduces emissions and reception.
• Emission sources: Lightning, Discharges, Radio and TV transmitters, High-frequency
circuits.
• Electromagnetic Interference (EMI) always begins as conductive (current in wires)
becomes radioactive, and ends as conductive (fields interact with circuitry).
• Several techniques can reduce EMI:
o Reduced bandwidth (longer wavelength)
o Good layout and signal routing
o Shielded enclosures
• As shielded enclosure should ideally be a completely closed conducting surface.
Effective enclosure is one that has watertight metallic seams and openings. Openings
include cooling vents, cable penetration with slots larger than a fraction of a wavelength
(> ʎ/20), push buttons, and monitor screens that can leak electromagnetic radiation.
• Similarly, cable shields must seal completely around each connector.
Coaxial Cable
• Have low loss and less variance in characteristic impedance from DC to very high
frequencies (> 200 MHz).
• A pigtail connection from the shield to ground presents a loop inductance that increases
impedance with frequency. Thus, high frequencies (> 10 MHz) demand a complete 360o
seal of the shield at both ends.
Ribbon cable
• Ribbon cable is ubiquitous in instrumentation.
• It is suitable for low frequency operation << 1 MHz
• We should pair each signal with a return conductor or use a return plane for low-level
signals or higher frequencies.
• Several schemes including grounding, shielding and transient limiters can protect circuits
from ESD.
• Input gates are the most susceptible to damage, so we should use surge-limiters on input
lines as shown in below figure.
Input ESD-
sensors sensesative
or circuit
switches
Fig: Preventing damage by shunting high voltage transients away from circuits with zener
diodes or MOVs
• Generally zener diodes and MOVs are used to limit surges. Zener diodes tend to turn on
faster, while MOVs are cheaper and handle large peak current.
• For prevention, we need to eliminate the activities and materials that create high static
charge control methods including the following.
o Grounding
o Protective handling
o Protective material
o Humidity
• Checklist to make work areas less prone to ESD
o Use a “static-free” workstation, and wear a wrist ground strap
o Discharge static before handling devices
o Keep parts in original container
o Minimize handling of components
o Pickup devices by their bodies, not their leads
o Never slide a semiconductor over any surface
o Use conductive or antistatic containers for storage and transport of components
o Clear all plastic, vinyl, Styrofoam from work area
Procedure
• Good design techniques for grounding and shielding have a few basic rules:
– Reduce Frequency bandwidth
– Balance currents
– Route signals for self shielding: a return (ground) plane, short traces, decoupling
capacitors
Case Study
• Enclosure Design
• Enclosure Testing
• Option Module Design
• Circuit Suppression Design
• Printed Circuit board Design
• Power Supply Filtering
• System Design
• Acknowledgements
Be important Noted:
• Example 6.5.1, Example 6.5.2, Example 6.8.1.1, Example 6.9.1
Chapter – 7
Circuit Design
From symbols to substance
Standard Cells
• Group of transistors are interconnected structures that provides Boolean logic function or
storage function.
• Simplest cells are direct representatives of adder, mux, flip-flops etc.
Gate Array
• Analogous to Cu layer of PCB.
• Transistors, standard NAND, NOR gates placed at predefined position and manufactured
in wafer.
• Late manufacture process joined to logic as desired shorter time to market.
• Software processor implemented within FPGA logic; highly configurable and flexible
than hardwire processor
• Applications: DSP, aerospace, ASIC, prototyping, medical imaging etc.
• Short time to market
• Flexibility in both hardware and software
Microcontrollers
• CPU, I/O devices, program memory, data memory all in single chip
Microprocessors
• Requires other parts to make workable computer.
Performance is determined by
o Throughput
o Resolution
o Address space and available memory
o Language choice, code size, speed
o Predominant types of calculation: integer and floating point
Memory
o Require minimum size of memory
o Always plan for and specify margin in the requirements for future updates and
modifications.
o Size of RAM/ROM Depends on
Data array
Stack
Temporary and permanent variable
Compiler overhead
I/O buffer
Fault tolerance
• Goes beyond the design and analysis for reliable operation and reduces the possibility of
dysfunction or damage from abnormal stresses and failures.
• Allows a measure of continued operation in the event of problem
• Three distinct area
– Careful design
– Testable function
– Redundant Architecture
Careful Design
• Careful design can avoid many failures from abnormal stresses. Some design
techniques that can reduce the probability of failure:
o Reduce overstress from heat with cooling and low dissipation design.
o Use optoisolation or transformer coupling to stop overvoltage and leakage
current
o Implement ESD protection
o Mount for shock and vibration
o Tie down wires and cables
o Prevent incorrect hookup; Use keyed connector
Testable Architecture
• The process of testing and diagnosing failures within a system.
• Two possible configurations of testable architecture:
– Simple Configuration: Provides Probe points / test points for a technician
or instrument to stimulate circuits and record responses. Only the trained
personnel must disassemble the system and remove the circuit for testing.
– Complex Configuration: Dedicated internal circuitry called built in test
(BIT) that tests the system and diagnoses problems without disassembly of
the equipment so adds complexity and reduces reliability. The trade off for
BIT is quicker diagnoses and repair versus higher reliability.
• An appropriate calibration standard is always necessary when you measure a
result.
Redundant Architecture
The most complex and fault tolerant architecture are redundant architectures. They use
multiple copies of circuitry and software to self check between functions. It is justified
only when downtime for repair and maintenance cannot be tolerated.
• Doubly redundant architecture: merely indicates a failure in one of the subsystems;
this allows for quick repair.
• Triply redundant architecture: uses voting between the outputs of three identical
modules to select the correct value. It can have failure and still operate correctly.
• Dissimilar redundancy: compares the output from modules with different software
and hardware to select the correct value. It can survive failure and even indicate
errors in design if one system is coded correctly and the others are not.
7.3.1 Bandwidth, Decoupling, ground bounce, cross talk, Impedance matching and timing
Bandwidth
• Limiting the bandwidth of the signals within a system is the most effective way to reduce
noise, EMI and problems with transmission lines.
• May limit the bandwidth either by increasing the rise or fall times of the signal edges or
by reducing the clock frequency.
• Selecting the appropriate logic family will set the edge rates and the consequent limit on
transmission line concerns.
• One criterion for selecting logic according to transmission line effects is a ratio less than
4 between the rise time, tr and the propagation delay, tp i.e. (tr/tp <4).
• Slower edge rates allow longer interconnections between circuits.
Decoupling
• Switching of digital logic causes transients of current on the voltage supply through
inductive impedance of the circuit
• Decoupling capacitor minimizes inductive loop area thus reducing impedance of power
supply circuit. Shortest possible path for decoupling capacitor is best.
Ground Bounce
• Ground bounce is a voltage surge that couples through the ground leads of a chip into non
switching output and injects glitches onto signal lines.
• Asynchronous signals are more prone to ground bounce.
• Can reduce ground bounce by:
o Reducing loop inductance
o Reducing input gate capacitance
o Choosing logic families that either control the signal transition or have slower fall
times.
Crosstalk
• Coupling electromagnetic energy from an active signal to a passive line
• Coupling mechanism:- capacitive or inductive
• Depends on line spacing, length and characteristic impedance, signal rise times
• To reduce crosstalk:
– Decrease coupling length and characteristic impedance
– Increase rise time of signal
– Better layout and design of circuits
Avoiding Crosstalk
– Don’t run parallel traces for long distances – particularly asynchronous signal
– Increase separation between conductors
– Shield clock lines with ground strips
– Reduce magnetic coupling by reducing the loop area of circuits
– Sandwich signal lines between return planes
– Isolate the clock, chip-select, chip-enable, read and write lines
Impedance matching
• The reflection coefficient for a signal passing from medium 1 to medium 2 is given by:
τ = (η2 – η1) / (η2 + η1)
Where ηi is the intrinsic impedance of medium i and is given by:
ηi = i / i
• Reflection coefficient will be zero when η1 = η2
• Impedance matching makes the source and termination impedance equal to the
characteristic impedance of the transmission line so that it will eliminate the reflections
of signals that cause ringing (oscillations), undershoot, and overshoot in the signal pulses.
• Impedance discontinuities occur in two configurations endpoint and stub.
End point discontinuity: - the ends of the transmission line don’t match its characteristic
impedance of the transmission line.
– Add series resistances at the end until the total impedance equals the line
impedance.
– Terminate the other end of the signal line from driver.
Stub discontinuities cause impedance mismatch and signal reflection by connecting multiple
circuits to a single line.
• Each Connection of a stub divides the impedance and splits the power of the signal
• Make them very short, even zero to reduce the effect of stub discontinuities
• Good layout and design
Timing
• Clock frequency increases, propagation delays, timing skew, and phase jitter (change in
phase) render logic design useless.
• Clock signal is skewed or arrived at different propagation delays of the clock signal to
different destinations (propagation delay different clock signal to arrive at different
time).
• Differences in propagation delay of rising and falling edges change the duty cycle of the
signal or shrink/expand it.
• Adequate setup and hold time is required to latch data reliably.
• The simple reset circuit as in figure uses the time constants R, C network to set the
desired duration of the reset signal.
• The Schmitt trigger inverter transforms the exponential changing waveform on the input
to a signal transition appropriate for logic gates.
• The diode D allows charge to drain off the capacitor if the DC voltage fails, thereby
protecting the inverter from an input voltage higher than its supply voltage.
• When pressed, the manual push button shorts the charge on the capacitor to ground to
generate a reset signal so that a user can initialize the operation of the system even while
the supply power is stable.
Interface Unit
• The input to all circuit is some sort of electrical signal
• Each signal comes from another circuit, a transducer or a switch.
• Most signals need some preprocessing or conversion before the system can assimilate
them
• E.g. Switch generates logic transitions that bounce when pressed; there is a series of rapid
glitches at the beginning and end of signal pulse.
• It is necessary to design some circuitry to suppress the glitches produced by bounce.
• Also sensors produce continuously changing analog signal that must be converted to
digital logic levels for further processing
• You will need to define the types of inputs that you expect the system will receive
• Once you know the type of input, you can decide on the necessary circuitry to manipulate
the input signals.
Chapter – 8
Circuit Layout
8.1 Circuits Boards and PCBs
• Technologies available for connecting components and circuits
• Circuit boards combine electronic components and connectors into a functional system
through electrical connections and mechanical support.
• Stitch weld, Wire wrap, PCB, Chip on board, Hybrid and MCM
[PCB= Printed Circuit Board, MCM= Multi Chip Module]
Wire-Wrap
• Easily change the connections, circuit modifications & corrections.
• Larger circuit boards, require extensive effort
• Less useful for production, suitable for prototype development
• Limited in operation to less than 5 or 10 MHz, above which the loop inductances in the
wired connections distort signals.
Stitch Weld
• Connects components with point-to-point wiring on circuit boards much like wire wrap
• Stitch weld ports are shorter and the wire is welded to the pins, not wrapped, results
lower loop inductance and much higher operation (100 MHz).
• Better vibration and shock resistance, more expensive, requires a special welding station.
Multilayer PCB
o A stack of alternate layers of copper-clad laminate or core and prepreg.
o 20 to 30 conducting layers laminated together
o Control impedance much more tightly and are absolutely necessary for high
frequency circuits
o Through-hole vias penetrate all layers and can connect signals on each layer.
o Buried vias connect traces on two sides of an internal layer
o Blind vias are exposed on one external layer and connect traces on the two sides of
that layer.
• Grouping components and circuits appropriately will reduce crosstalk and noise and will
dissipate heat efficiently.
Trace density
– Trade off between greater cost and difficulty in producing the denser circuit
board.
– As you squeeze signal traces together on a board, you can space components
closer and reduce the size of the circuit boards.
– Smaller boards, allowed by higher trace densities, provide flexibility in packaging
your product, reduce the cost of material and may degrade signal integrity.
Common Impedance
– Minimize the number of circuits that share the same return path. Voltage drops
(caused by current switching) on the ground line (return path) increase system
noise.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: K. R. Fowler | 3
Instrumentation II Chapter 7: Circuit Layout
Avoiding Crosstalk
– Simple guidelines when routing signal to a PCB:
• Don’t run parallel traces for long distances- particularly asynchronous
signals.
• Increase separation between conductors.
• Shield clock lines with guard strips.
• Reduce magnetic coupling by reducing the loop area of circuits.
• Sandwich signal lines between return planes to reduce crosstalk.
• Isolate the clock, chip select, chip enable, read and write lines
• Grounding
– Provides reference point for signal.
– Signal reference should be a single point and is as close as possible to the power
entry to the PCB.
– A ground plane connected to the single-point reference will also reduce common
impedance.
– Be sure to separate the analog and digital circuits so that current pulses from
digital circuits will not corrupt sensitive analog circuits. Use common ground
plane or different planes and connect their ground leads to the single-point
reference.
• Shielding
o A return plane is the most effective shield for any circuit.
o Power and return planes provide circuit paths with the lowest impedance, which
reduces radiation, noise and crosstalk.
o Minimizing spacing between power and return will minimize impedance
(radiation and susceptibility)
Z0 = (120π/ Er ) . (h/d)
Where, h = separation of planes
d = smaller dimension of two-dimensional plane
Er = dielectric constant of substrate board relative to air
Chapter – 9
Software for instrumentation and control applications
• Software is pervasive in electronic products such as televisions, video recorders, remote
controls, microwave ovens, sewing machines, and cloth washers all have embedded
microcontrollers.
• Software accounts for 50-75 percent of a microcontroller project.
• General methods to improve software are code generation, reliability, maintainability and
correctness.
Lots of time is spent in analyzing and Relatively little time than compiler
processing the program.
Not required extra program to execute the Requires extra program to execute
code. intermediate code.
2. Languages
• Software has many applications within embedded systems such as Firmware, Peripheral
interface and drivers, Operating system, User interface, Application programs etc.
• May use variety of languages
• Assembly language
• High level language: Basic, C, C++, Java etc.
Assembly Language High Level Language
Processor Architecture dependent and Processor Architecture Independent
closer to hardware.
Tedious because it requires steadfast Easier due to nitty-gritty details, structure and
attention to exacting detail. readability.
Best suited for small, simple projects Better for larger, more complex projects
with minimum memory, highest which require more memory and execute the
execution speed & precise control of code more slowly.
peripheral devices.
3. Methods
• Whatever language you choose, your objective will be to reduce complexity and improve
understanding of the software.
• Design architecture may be Structured or Object oriented or CASE (Computer aided
software engineering)
• Structured designs have strategy before starting to code; small modules with clear
operational flow, easy debugging and testing.
• OOP can help by incorporating data abstractions, information hiding and modularity to
aid structured design.
• CASE tools provide blend of environment, tools and language.
• Tools available are compilers, disassemblers, debuggers, emulators, monitors and logic
analysers.
• Operating system and software libraries ease the task.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: K. R. Fowler | 2
Instrumentation II Chapter 9: Software for instrumentation and control applications
4. Selection
• The selection of a particular language depends on management directives, the knowledge
and expertise of the software team, hardware and available tools.
• Function and performance depends on the speed and data path width of processor,
memory (RAM and ROM), architectural features such as coprocessors, peripherals
(ADC, timers, PWM, interrupt handlers), I/O communications, power-down modes and
the level of integration.
• Choice of language also depends on manufacturers having following questions
o Does the vendor provide reasonable documentation and support?
o Does it provide toll-free telephone support and acknowledge application
engineers?
o Does it have liability support for life-critical systems.
5. Purchase
• Purchase the software after you have defined your software requirements and surveyed
vendors for availability, reputation and experience.
• Some qualification of a vendor:
o Acceptance testing
o Review of vendor’s quality assurance
o Verification testing
o Qualification report
• Furthermore, required documentations from a vendor:
o Requirement specification
o Interface specification
o Test plans, procedures, results
o Configuration management plan
o Hazard analysis
• Don’t buy cheap software tools just to save money! You will lose much more money in
the long run from wasted time forced by delays and inadequacies of cheap tools.
Quality Assurance
• Oversees each steps of model towards producing useful, reliable software rather than
connection of modules
• Methods are necessary but not sufficient to produce useful, reliable software.
• First: Classify your system and its software according to any relevant standards.
• Second: Software development plan:
o Hazard and fault tree analysis for life critical functions
o Configuration management: ensures current and correct version is released.
o Documentation
o Traceability
Requirements
• Reduce the abstract intentions of the customer into realizable constraints.
• Tells what the software does
• Includes standards that the software must adhere to, the development process, the
constraints, and reliability or fault tolerance
• Requirements may call for several, successive specifications:
o General specification
o Functional performance specification
o Requirements specification
o Design specification
• Needs constraints considerations such as memory, timing margin, hardware,
communication, I/O and execution speed;
• Will the selected processor and associated hardware support the requirements?
• Can the software use these resources and satisfy the requirements.
Design
• Design tells how the software does its functioning.
• Specifies how the software will fulfill the requirements.
• Consider these software elements in preparing the design:
o System preparation and setup
o Operating system and procedures
o Communication and I/O
o Monitoring procedures
o Fault recovery and special procedures
o Diagnostics features
• Interfaces demands most attention communication format:
o Polled I/O
o Interrupt I/O
o Synchronization between tasks
o Intertask signaling
o Communications of polling and queuing to avoid overrunning events
• Design can specify algorithms and techniques that optimize performance, management of
memory.
• Design may reuse modules and libraries in an effort to improve productivity and
reliability.
Programming
• The methods of programming – assembly language, high level languages.
• CASE tools are on the horizon
• Tools, language, methods
Source file (Assembly language mnemonics) assembler object file linker Binary
machine code Burn PROM
Testing
A) Internal reviews
• By colleagues examine the correctness of software and can figure out mistakes and error
in logic
• More than 50% of errors, can be found and correct by code inspection or audit
Verification
• Debuggers, logic analyzer, in circuit analyzer in circuit debugger etc.
Maintenance:
• Require to control the software configurations: reports, measurement, personnel costs and
documentation
• Plans for releasing software upgrades, to achieve consistency and continuity of the
product.
• Cannot separate software maintenance from system concern
2. Prototyping Model
• In this model the developer and client interact to establish the requirements of the
software.
• Accommodates the problem of changing requirements and make a subset of the software
available early.
• Essence of prototyping is a quickly designed model that can undergo immediate
evaluation.
• Define the broad set of objectives.
• This is follow up by the quick design, in which the visible elements of the software, the
input and the output are designed.
• The quick design stresses the client’s view of the software.
• The final product of the design is a prototype.
• The client then evaluates the prototype and provides its recommendations and suggestion
to the analyst.
• The process continues in an iterative manner until the all the user requirements are met.
• Accommodates problem of changing requirements
• Creeping featurism: The customer voices new desires after each evolution, and the
project effort balloons.
3. Spiral Model
• Uses incremental approach to development that provides a combination of waterfall and
prototyping model.
• Each cycle around the development spiral provides a successively more complete version
of the software.
• Model allows flexibility to manage requirements control changes
• Used in proprietary application
• Spiral Model – risk driven rather than document driven
• The "risk" inherent in an activity is a measure of the uncertainty of the outcome of that
activity
• High-risk activities cause schedule and cost overruns
• Risk is related to the amount and quality of available information. The less information,
the higher the risk
Metrics
• Objective understanding of the completion of the software at each stage or of its
usefulness
• Software size, development time, personnel requirements, productivity, and number of
defects all interrelate metric can define those relationships
• Cost and schedule are very poor metrics for producing quality software
• To rely on your estimates, you need to track the metrics honestly and record them
carefully & consistently
• Good process model needs metrics to access performance and progress of software
– Correctness, Reliability, Efficiency, Maintainability, Flexibility, Testability,
Portability, Reuse, Utility, Size etc.
Process
• Process incorporate models of software development to generate useful, reliable and
maintainable software
• Good process keeps statistics for feedback & improvement of the software development
• Software tools are integral to the software process; don’t change them in midstream.
• Process maturity levels defined by the software engineering institute:
1) Initial: Chaos or ad hoc process
2) Repeatable: Design & Management defined
3) Defined: Fully defined & enforced technical practices
4) Managed Process: Feedback that detects and prevents problems, a control process
5) Optimizing Process: Automating, monitoring & introducing new technologies
Software Limitations
• Not all problems can be solved
• Specifications cannot anticipate all possible uses and problems
• Errors creep into development in a number of ways
• Software simulation can predict only known outcomes
• Human error can occur in operating the software
Intent
o Wrong assumption +misunderstanding
o Correctly solving wrong problems
o Viruses
o Slang-limits of operation to broadly or too narrowly defined
Translation
o Incorrect algorithm
o Incorrect analysis
o Misinterpretation
Execution
o Semantic error –does not know how command works
o Syntax error- rules of language
o Logic error- using wrong decision
o Range error-overflow /underflow error
o truncation error- incorrect rounding
o Data error –not initialing values, wrong error etc
o Language misuse-inefficient coding
o Documentation-wrong/misleading comments
Operation
o Changing paradigm
o Interface error
o Performance
o Hardware error
o Human error
Debugging
• Print statement
• Break points and watch values
• In circuit emulators ,in circuit debugger
• Logic analyzer
• White box testing
• Black box testing
• Grey Box testing
o Having knowledge of internal data structure & algorithm for purpose of designing
test case but testing is black box
o Used in reverse engineering to determine instance, boundary value
Testing Levels
• Unit test
o To test functionality of specific section of code at functional level
o Building blocks work independently of each other
o E.g. Class level testing in OOP
• Integration test
o To verify interface between components
• System test
o To test the whole system which is to be used
Comments:
• Readable and clear
• Should not be paraphrase of code
• Should be correct (incorrect comments are worse than no comment)
• Comment more than you think you need
Variables:
• Name properly
• Minimize use of global variables
• Don’t pass pointer
• Pass intact values
B) Structured Programming
• Establish framework for generating code that is more readable useful, reliable
and maintainable.
• Framework based on clearly defined modules or procedures, each doing one
task well in a variety of situations.
• Modules can isolate device dependent code for simplicity and reuse.
• Large modules: divide among team for more productive and parallel effort.
• Use of libraries of modules and procedures load faster and resist inadvertent
changes
• Structure programming encourages the installation and testing of one module
at a time to simplify the verification of the software.
Points to be noted
• 90% of processor time is spent in executing 10% of code. Identify this 1%.
• Listen to customer while developing specification
• Prototype complex task on host computer and investigate their behavior.
• Design architecture for debugging and testing.
• Code small modules so that you can test and forget
• Code single entry and exit in routine
• Document carefully
Cohesion:
• A cohesive module performs a single task
• Modules should have maximum cohesion
• Different levels of cohesion
– Coincidental, logical, temporal, procedural, communications, sequential,
functional
• Coincidental Cohesion
Coupling:
• Coupling describes the interconnection among modules
• Modules should have minimum Communication or coupling
• Data coupling
– Occurs when one module passes local data values to another as parameters
• Stamp coupling
– Occurs when part of a data structure is passed to another module as a parameter
• Control Coupling
– Occurs when control parameters are passed between modules
• Common Coupling
– Occurs when multiple modules access common data areas such as Fortran
Common or C extern
• Content Coupling
– Occurs when a module data in another module
• Subclass Coupling
– The coupling that a class has with its parent class
E) Scheduling
• Should record all efforts expended in current jobs to estimate future job
• Timing of meeting, planning, designing, debugging testing should be properly planned
• Give more time than required to debugging and testing.
Chapter - 10
Case Study
Examples chosen from local industrial situations with particular attention paid to the basic
measurement requirements, accuracy, and specific hardware employed environmental
conditions under which the instruments must operate, signal processing and transmission,
output devices:
a) Instrumentation for a power station including all electrical and non-electrical parameters.
b) Instrumentation for a wire and cable manufacturing and bottling plant
c) Instrumentation for a beverage manufacturing and bottling plant
d) Instrumentation for a complete textile plant; for example, a cotton foil from raw cotton
through to finished dyed fabric.
e) Instrumentation for a process; for example, an oil seed processing plant from raw seeds
through to packaged edible oil product.
f) Instruments required for a biomedical application such as a medical clinic or hospital.
g) Other industries can be selected with the consent of the subject teacher.
Preliminary
1. All students must team up for the case study and it is recommended to form a group of four
to six students in a group. Once formed, the group cannot be reshuffled.
2. The group will take a request letter from the department. However, before approaching to an
organization, students need to bring the responsible person’s name and post for issuing the
letter. The letter must be addressed accordingly.
3. The duration for the case study is for a month from the date of presentation. You need to
submit the report. Apart from the new recommended design, you need to present the cost
benefit analysis of the project.
During Visit
1. You need to understand the current process control system of the visited organization and
describe the same in your own word in the report. List all the variables that are included in
the process control system.
2. The systematic approach to understand the system must be presented with necessary block
and detailing diagrams, if it is required.
3. Interview managers and the personnel who are directly involved in the current system and get
to know the merits and demerits of the system.
4. Learn more from users and consumers who are directly participating and using the product of
the visited organization. Comment on the product and recommend better option for the
product in the present context, if you feel its need.
5. List down all the requirements needed to go for the improvised system.
6. Mention the cost of the current system.
7. Compare it to the latest system available in the market.
After Visit
1. Think and recommend the extra mechanism to provide a better solution the current problem.
2. Draw the block diagram of the newly recommended system. How does the current system
adjusts the demerits discussed in item no 3 of during visit.
3. Include how the cost varies and what additional benefit you get with the newly proposed
system in place.
4. Did you face a difficulty to go for the case study? How do you relate this with the real life
situation?
5. Recommend what you feel like.
6. On the basis of above prepare a report on the case study.
The final report should present the instrumentation requirements in terms of engineering
specifications, the hardware solution suggested, a listing of the particular devices chosen to satisfy
the requirements, appropriate system flow diagrams, wiring diagrams, etc. to show how the system
would be connected and operated.
Chapter - 10
Case Study
Examples chosen from local industrial situations with particular attention paid to the basic
measurement requirements, accuracy, and specific hardware employed environmental
conditions under which the instruments must operate, signal processing and transmission,
output devices:
Preliminary
1. All students must team up for the case study and it is recommended to form a group of
four to six students in a group. Once formed, the group cannot be reshuffled.
2. The group will take a request letter from the department. However, before approaching to
an organization, students need to bring the responsible person’s name and post for issuing
the letter. The letter must be addressed accordingly.
3. The duration for the case study is for a month from the date of presentation. You need to
submit the report. Apart from the new recommended design, you need to present the cost
benefit analysis of the project.
During Visit
1. You need to understand the current process control system of the visited organization and
describe the same in your own word in the report. List all the variables that are included
in the process control system.
2. The systematic approach to understand the system must be presented with necessary
block and detailing diagrams, if it is required.
3. Interview managers and the personnel who are directly involved in the current system and
get to know the merits and demerits of the system.
4. Learn more from users and consumers who are directly participating and using the
product of the visited organization. Comment on the product and recommend better
option for the product in the present context, if you feel its need.
5. List down all the requirements needed to go for the improvised system.
6. Mention the cost of the current system.
7. Compare it to the latest system available in the market.
1
Instrumentation II Chapter 10 - Case Study
After Visit
1. Think and recommend the extra mechanism to provide a better solution the current
problem.
2. Draw the block diagram of the newly recommended system. How does the current system
adjusts the demerits discussed in item no 3 of during visit.
3. Include how the cost varies and what additional benefit you get with the newly proposed
system in place.
4. Did you face a difficulty to go for the case study? How do you relate this with the real life
situation?
5. Recommend what you feel like.
6. On the basis of above prepare a report on the case study.
The final report should present the instrumentation requirements in terms of engineering
specifications, the hardware solution suggested, a listing of the particular devices chosen to
satisfy the requirements, appropriate system flow diagrams, wiring diagrams, etc. to show how
the system would be connected and operated.
2
Instrumentation II Chapter 10 - Case Study
Abstract
The course of Instrumentation II is essentially related to design issues an electronics engineer faces
in his/her career. The design we perform on classes and labs are not adequate as they don’t involve
the rightful applications. Thus we have been asked to conduct a case study on a production industry
related to our field and view how actual design principles are in practice.
This report presents an overview of the practical applications of electronics in Bottler’s Nepal Pvt.
Ltd. There is nothing such as perfect in real world. Thus, we are proposing some modification in the
plant to improve its production capacity efficiently.
We are not boasting that our proposed design is more faultless than the current one. As every coin
has two sides the proposed design can also have its own flaws along with the new efficiency.
However, being an Electronics Engineer we believe that our proposed design can improve the
efficiency of the existing plant.
3
Instrumentation II Chapter 10 - Case Study
Introduction
Coca-cola, imported from India, was, first introduced into Nepal in 1973, with local production of
coca-cola beginning in 1979.
Bottlers Nepal Limited (BNL) is the only bottler of Coca-cola products in Nepal, and has two bottling
plants; namely Kathmandu (Bottlers Nepal Limited- BNL) and Bharatpur (Bottlers Nepal (Terai)
Limited which is 160km from Kathmandu, its capital.
Coca-cola sabco operates in seven southern and East African countries and five Asian countries, and
employs more than 9500 people. It operates 25 bottling plants and aims to fulfill the refreshment
needs of more than 240 million consumers that live in its markets. It is a proud developing markets
Anchor bottler.
The main objective of doing case study is to get acquainted about use instrumentation in real field.
So we research about the application of different designs of electronics. We were guided to find any
problems in the existing plant and propose a design to solve the problem. So in our case we propose
a design to solve problems related to operation and manufacturing of coca cola.
To visit the chosen organization and learn its operation under supervision of senior
engineers and technicians.
To study the existing management system and technology of company.
To be familiar with various engineering aspects demanded by that particular company.
To learn the vital role of engineer in a particular company.
To learn about electronics design using microcontroller and microprocessor in commercial
field. To observe the current system carefully and detect any fault in existing system if any.
To propose solutions to boost the efficiency of the system.
The processing plant of coca-cola company has been installed in Balaju industrial state several years
ago. All the processing plants are being closely monitored by Nepal ease technicians and engineers.
The plant has been working smoothly.
Process of manufacturing:
1. Preparation of bottles and cans.
2. Chemicals
3. Machinery Equipments
4. Computers
1. Preparation of bottles and cans: The pre-form for preparing Bottles are imported
from India where as the pre-form for the PET bottles are manufactured in Bhutan
and blown in Nepal using Blow Mold machine which outputs bottle and cans. The
associated label is imported from India.
4
Instrumentation II Chapter 10 - Case Study
2. Chemicals: The flavor used for the production of beverage is imported from South
Africa and sugar from Dubai (U.A.E). The sugar required is of the quality prescribed
by the company.
As coca-cola company is primarily a private owned company, has an obligation to fulfill
various criteria for most of its work. The effect is seen in the procurement of materials and
machines. The department, either mechanical, electrical or AC section identifies need for
necessary equipments and prepares a report bases in it and forward it to material and
management Department. The material management then seeks for the bidders and buys
the needed materials and equipments in accordance with company rule and policy.
Generally, the bidder with equipments meeting all the required specification as produced
the coca-cola company and low in price obtains the tender to sell the equipments to
company. Then material management department forwards the equipments to the
departments that for material.
There are various operations implemented during the production and distribution of the
products. They are
Collection of bottles from every part of the country.
Cleaning of the bottles with water jet.
Testing of bottles for unwanted materials (EBI).
Mixing of the ingredients in a proportion prescribed by coca-cola company
(Atlanta).
Automatic time controlled filling.
Automatic capping.
Automatic Date coding.
COLLECTION OF BOTTLES:
Initially the empty bottles are collected from the retailers by the dealers.
Now the bottles are brought to the company’s depot from the dealers.
Further these bottles are fed to the plant for the next process.
MIXING OF INGREDIENTS
In this unit, first of all the given proportion of the flavor is diluted with specified ratio of
water with added sugar. Additional amount of flavors are also mixed up with the solution to
give it the proper flavor. The mixture thus obtained is called syrup.
5
Instrumentation II Chapter 10 - Case Study
which the mixture is filled into it. The time duration is kept different for different sizes of
bottles. Followed by the filling, the carbon dioxide gas is also introduced in the bottle with
immediate capping. The carbon dioxide gas is used to make the solution harder and give it
additional flavor. It is also used as preservative.
The capping is also done automatically. As soon as the mixture is carbonated, the caps
loaded into the machine are locked onto the bottle ensuring the proper sealing.
6
Instrumentation II Chapter 10 - Case Study
PET (Polyethylenterepthalate)
Air
Conveyor
Data Code
(Video jet)
Warmer
(Khs)
Lableller
(Krones)
Cartoon Taking
7
Instrumentation II Chapter 10 - Case Study
Decrater (Ketlner)
Bottle Washer
(Crown/Bade)
EBI
(Empty Bottle)
Filling+ Crowner
Data Code
Carter
8
Instrumentation II Chapter 10 - Case Study
PRODUCTION:
The production of drinking soft drink in coca-cola company broadly involves four steps:
1. Importing spring water from various part of Kathmandu.
2. Purification of soft drink.
3. Washing and filling of bottles.
4. Storage
2. Purification of water
Purification of water is a very important process. The brand name depends on the production pure
water. The basic block diagram for purification of water is shown below:
Chlorine
Sand filter (Removes suspended particles)
Sedimentation
AM filter (Anthracite & manganese filter)
Tank (sediment for
Spring water 6-8 hours) Carbon filter (Removes organic Residue)
Candle filter
Ozone
Generator
9
Instrumentation II Chapter 10 - Case Study
Water is obtained as spring water. The water is then collected in sedimentation Tank. The simple
process of sedimentation allows heavy suspended particles to settle down. The process of
chlorination is also performed in this tank. Chlorination is the process of adding the element to
water as a method of water purification to make it fit for human consumption as drinking water.
Water which has been treated with chlorine is effective in preventing the spread of disease.
Next, pressurized water is passed through a variety of filters as shown in the figure. First, the water
is passed through sand filter. A sand filter is a basic tool of water purification passing flocculated
water through a sand filter strains out the flock and the particles trapped within it. The medium of
filter is sand of varying grades. As water flows through the sand, impurities such as solids,
precipitates, turbidity and in some case even bacterial particles are filtered out. After being filtered
through the sand filter water is then filtered for any anthracite and manganese through AM filter.
Next, water is passed through carbon filter. Carbon filters are most effective at removing chlorine
and volatile organic compounds from water. They are not generally effective at removing minerals,
salt, and dissolved inorganic compounds. Spring water generally is exposed to variety of minerals
underground. This causes the formation of hard water. Hard water is the one with high mineral
content. Hard water deposits can serve as a medium for bacterial growth and irritation. During
purification the mineral ions are exchanged with the ions that don’t cause hardness.
Then, water is passed through bag filter to remove suspended particles smaller than 5 microns and
finally through candle filter.
After completion of the purification reverse osmosis is performed. The term reverse osmosis comes
from the process of osmosis, the natural movement of solvent from an area of low solute
concentration, through a membrane to an area of high solute concentration if no external pressure
is applied. Reverse osmosis is the process of pushing a solution through a filter that traps the solute
on one side and allows the pure solvent to be obtained from the other side. More formally, it is the
process of forcing a solvent from a region of high solute concentration through a membrane to a
region of low solute concentration by applying a pressure in excess of the osmotic pressure. This
process removes minerals in the water and is best known for it’s used in desalination.
The final stage of purification involves sterilizing water with ozone. Ozone is bubbled in ozone
contact tank to sterilize water from any remaining contamination. Ozone is an excellent sterilizing
agent without any effects. As ozone is unstable it breaks down into oxygen molecules after some
time.
The PC (polycarbonate) bottles are the reusable bottles. They have a capacity of holding 19 liters of
water. The company distributes filled bottles and collects the empty bottles from the customers.
10
Instrumentation II Chapter 10 - Case Study
The equipments used are fine at performing the corresponding job assigned to them. The
equipments are from snap co. The equipments is separated into two section for washing and filling
water respectively. The overall block diagram is shown below.
Delivery
trolley
The reusable bottles encounter a variety of environments and thus are susceptible to contamination.
The first process is thus cleaning of the bottles as soon as they arrive at the company. Although the
machine cleaning is sufficient enough, the bottles are first manually cleaned by sprinkling detergent
water. Then the bottles are transported to automatic jet washer. An employee observes for any
cracks and unwanted residues that cannot be removed. S/He then mounts them in the Automatic jet
Washer one by one. The bottles are rotated in a convey halting at certain points. When halted a jet
of detergent water with chlorine jets into the bottle. Next it is washed by recalculating water. Then
the bottle is washed by hyper assonated water to remove any remaining infections.
11
Instrumentation II Chapter 10 - Case Study
The Automatic bottle Washer performs the first three tasks. The water is filled and the bottle sealed
at filler and capper. The filler and capper section first detects the arrival of bottle and lifts them off
the convey belt. It is then filled with soft drink. The bottle is not released until the next one arrives.
After being released the caps are placed on the mouth of the bottle and sealed. The filled bottles are
then loaded in a trolley and taken to storage facility.
4. Storage
The assonated soft drink is not suitable for drinking. Since, ozone is unstable it breaks down into
oxygen molecules, the soft drink has to be left aside for at least four hours. Coca-cola Company,
however stores the recently packed bottles for one whole day. They are dispatched only on the
other day.
The purification of the water is quite perfect and employs a number of filters to remove impurities
and infections. However, the washing and filling stations employ electro mechanics. The current
system is only based on the timing sequences. The processes repeat itself in a fixed duration of time.
The disorder in any timing sequences can disrupt the whole system. Also, if any sequence is to be
rearranged the entire system may have to be dismantled for a small purpose.
Here, we purpose a microprocessor based automatic washing and filling station, which has a much
easier control structure.
1. Bottle sensor: These can be anything from simple limit switch to IR sensors to detect the
presence of the bottle at that position. The detected signal is used as an input to
microcontroller or the counter.
2. Solenoid valve: Solenoid valve are valves controlled via electrical signals. The proposed
design uses four of them. Three solenoid valves are used in the Automatic Jet Washer while
the final one is fill the bottle with pure soft drink.
3. Temperature sensors: Although sensors are already present in the previous design we
will use the temperature sensor to maintain the temperature using heaters and coolers.
4. Load cell: Previously no weighing machine was used. The time a bottle took to fill was
estimated to be around 10-12 seconds. Now we proposed to add a weighing machine and
weigh the amount of soft drink filled. The weight information will be used to control the
amount of soft drink.
5. User keypad: This is a new feature allows user to make different modifications according
to his need.
6. Electromagnetic lift: This is a magnetic lift the bottles during filling of soft drink.
7. Press: This may be a hydraulic press or any other one seal the bottle.
12
Instrumentation II Chapter 10 - Case Study
8. LCD Display: The display shows the temperature in the automatic bottle washer and the
total number of production in the factory.
The block diagram of the proposed bottle washer is as shown in fig below. The new jet
washer incorporates the use of bottle sensors to jet the soft drink in the corresponding slot.
If the bottle is into present in a slot then the corresponding jet will not eject soft drink. This
design allows the plant to save water, detergent and hyper assonated water.
First the jets are in the off state. As soon as the motors stall the sensors checks the
corresponding location. If the slot is full then the solenoid valve corresponding to the slot is
activated. After 10 seconds the jet are turned off and the motor rotates for about 2 seconds
to move the bottle to next cleaning location. Again the slots are checked and results verified
to open the equivalent solenoid valve. After the washing is complete the bottles are passed
on to the conveyer belt to pass bottle to filling and capping station.
After the bottle is washed it is transported to the filling section by a convey line. But it
should be remembered that convey should transported the bottles smoothly without any
13
Instrumentation II Chapter 10 - Case Study
14