Module 2
Sample and hold circuit
• It is a circuit which samples an input signal and holds onto its last
sampled value until the input is sampled again.
• Sample and hold circuits are commonly used in analogue to digital
converts, communication circuits, PWM circuits etc.
• uA 741 opamp , n-channel E MOSFET BS170 and few passive
components.
• MOSFET BS170 (Q1) works as a switch while opamp
• uA741 is wired as a voltage follower.
• signal to be sampled (Vin) is applied to the drain of MOSFET while
the sample and hold control voltage (Vs) is applied to the source of the
MOSFET.
• The source pin of the MOSFET is connected to the non inverting input
of the opamp through the resistor R3.
• C1 which is a capacitor serves as the charge storing device.
• Resistor R2 serves as the load resistor while preset R1 is used for
adjusting the offset voltage.
• During the positive half cycle of the Vs, the MOSFET is ON which
acts like a closed switch and the capacitor C1 is charged by the Vin
and the same voltage (Vin) appears at the output of the opamp.
• When Vs is zero MOSFET is switched off and the only discharge path
for C1 is through the inverting input of the opamp.
• Since the input impedance of the opamp is too high the voltage Vin is
retained and it appears at the output of the opamp.
• The time periods of the Vs during
which the voltage across the
capacitor (Vc) is equal to Vin are
called sample periods (Ts)
• the time periods of Vs during which
the voltage across the capacitor C1
(Vc) is held constant are called hold
periods (Th).
• ADC converts the analog signal
collected by audio input • DAC
equipment, such as a
microphone, into a digital
signal that can be processed by
computer.
• The computer may add sound
effect such as echo and adjust
the tempo and pitch of the
music.
• DAC converts the processed
digital signal back into the
analog signal that is used by
audio output equipment such as
Figure 3: Audio signal processing
a speaker.
The resistor with the lowest value R corresponds to the highest weighted binary input Bit 3 (MSB) [23 = 8], and 2R, 4R, 8R
correspond to the binary weights of Bit 2 (22 = 4), Bit 1 (21 = 2), and Bit 0 (LSB) [20 = 1] respectively.
The relationship between the digital inputs (Bit 0 to Bit 3) and the analog output VOUT is as follow:
• Assuming the value of Vref as 5 V, the Analog Output Voltages
corresponding to the Digital Input Codes is shown in Table 1.
Analog To Digital Converter
• In electronics, an Analog to Digital Converter (ADC) is a device for
converting an analog signal (current, voltage etc.) to a digital code,
usually binary. In the real world, most of the signals sensed and
processed by humans are analog signals.
• Analog-to-Digital conversion is the primary means by which analog
signal are converted into digital data that can be processed by
computers for various purposes,
Dual Slope type ADC
• In dual slope type ADC, the integrator generates two
different ramps, one with the known analog input
voltage VA and another with a known reference
voltage –Vref. Hence it is called a s dual slope A to D
converter.
• The binary counter is initially reset to 0000;
• the output of integrator reset to 0V and the input to the ramp generator or
integrator is switched to the unknown analog input voltage VA.
• The analog input voltage VA is integrated by the inverting integrator and
generates a negative ramp output. The output of comparator is positive and
the clock is passed through the AND gate. This results in counting up of
the binary counter.
• The negative ramp continues for a fixed time period t1, which is
determined by a count detector for the time period t1. At the end of the
fixed time period t1, the ramp output of integrator is given by
∴Vs=-VA/RC×t1
• When the counter reaches the fixed count at time period t1, the binary counter
resets to 0000 and switches the integrator input to a negative reference voltage
–Vref.
• Now the ramp generator starts with the initial value –Vs and increases in
positive direction until it reaches 0V and the counter gets advanced. When Vs
reaches 0V, comparator output becomes negative (i.e. logic 0) and the AND
gate is deactivated.
• Hence no further clock is applied through AND gate. Now, the conversion
cycle is said to be completed and the positive ramp voltage is given by
∴VS=Vref/RC×t2
Where Vref & RC are constants and time period t2 is variable.
Since ramp generator voltage starts at 0V, decreasing down to –Vs and then increasing up to 0V, the amplitude of negative
and positive ramp voltages can be equated as follows.
∴Vref/RC×t2=-VA/RC×t1
∴t2=-t1×VA/Vref
∴VA=-Vref×t1/t2
• Thus the unknown analog input voltage VA is proportional to the time period t2,
because Vref is a known reference voltage and t1 is the predetermined time period.
• The actual conversion of analog voltage VA into a digital count occurs during time
t2. The binary counter gives corresponding digital value for time period t2.
• The clock is connected to the counter at the beginning of t2 and is disconnected at the
end of t2. Thus the counter counts digital output as
Digital output=(counts/sec) t2
∴Digital output=(counts/sec)[t1×VA/Vref ]
• For example, consider the clock frequency is 1 MHz, the reference
voltage is -1V, the fixed time period t1 is 1ms and the RC time constant
is also 1 ms.
• Assuming the unknown analog input voltage amplitude as VA = 5V,
during the fixed time period t1 , the integrator output Vs is
∴VS=-VA/RC×t1=(-5)/1ms×1ms=-5V
During the time period t2, ramp generator will integrate all the way
back to 0V.
∴t2=VS/Vref ×RC=(-5)/(-1)×1ms=5ms=5000μs
Hence the 4-bit counter value is 5000, and by activating the decimal
point of MSD seven segment displays, the display can directly read as
5V.
Successive Approximation type ADC
• Successive Approximation type ADC is the most widely used and
popular ADC method.
• The conversion time is maintained constant in successive
approximation type ADC, and is proportional to the number of bits in
the digital output
• the basic principle of this type of A/D converter is that the unknown
analog input voltage is approximated against an n-bit digital value by
trying one bit at a time, beginning with the MSB.
• Inside a Successive-Approximation ADC, a series of digital codes, each
corresponds to a fix analog level, are generated successively by an
internal counter to compare with the analog signal under conversion.
• The generation is stopped when the analog level becomes just larger
than the analog signal. The digital code corresponds to the analog level
is the desired digital representation of the analog signal.
EXAMPLE FOR SAR ADC
• The most inexpensive type of ADC is a Successive-Approximation
ADC.
• Inside a Successive-Approximation ADC, a series of digital codes,
each corresponds to a fix analog level, are generated successively by
an internal counter to compare with the analog signal under
conversion.
• The generation is stopped when the analog level becomes just larger
than the analog signal. The digital code corresponds to the analog level
is the desired digital representation of the analog signal.
DIGITAL I/O (DIO)
• DIO interfaces are often used on PC DAQ
systems to control processes, generate patterns
for testing and communicate with peripheral
equipment.
• In each case, the important parameters include
the number of digital lines available, the rate at
which you can accept and source digital data on
these lines and the drive capability of the lines.
• If the digital lines are used for controlling
events such as turning on and off heaters,
motors or lights, a high data rate is usually not
required because the equipment cannot respond
very quickly.
• The number of digital lines, should match the number of processes to
be controlled.
• In each of these examples, the amount of current required to turn the
devices on and off must be less than the available drive current from
the device.
• DIO can also be used in industrial applications to verify that a switch
is open or closed and to check the voltage levels as high or low.
• It can also be used for simple communication methods.
• With the proper digital signal conditioning accessories, you can use the
low-current TTL signals to/from the DAQ hardware to monitor/control
high voltage and current signals from industrial hardware or to drive
external relays.
• For example, the voltage and current needed to open and close a large
valve may be on the order of 100 VAC at 2 A.
• Because the output of a DIO device is 0 to 5 VDC at several mill
amperes, a signal conditioning module such as SCXI is needed to switch
the power signal to control the valve.
• A common DIO application is to transfer data between a computer and
equipment such as data loggers, data processors and printers. Because
this equipment usually transfers data in one byte (8-bit) increments,
the digital lines on a plug-in DIO device are arranged in groups of
eight.
• In addition, some devices with digital capabilities will have
handshaking circuitry for communication-synchronization purposes.
The number of channels, data rate, and handshaking
• Data Acquisition capabilities are all important specifications that
should be understood and matched to the application needs.
COUNTERS
• digital timing device.
• used for event counting, frequency measurement, period measurement,
position measurement and pulse generation.
• Pulse generation counter/timer circuitry is useful for many applications,
including counting the occurrences of a digital event, digital pulse
timing, and generating square waves and pulses.
• It can be implemented using three counter signals—gate, source and
output.
• Count register—stores the current count of the counter.
• Source—input signal that can change the current count stored in the count
register. The counter looks for rising or falling edges on the source signal.
• Whether a rising or falling edge changes, the count is software selectable.
• The type of edge selected is referred to as the active edge of the signal.
When an active edge is received on the source signal, the count changes.
• Whether an active edge increments or decrements the current count is also
software selectable.
• Gate—it is an input signal that determines if an active edge on the
source ,changes the count.
• Counting can occur when the gate is high low, or between various
combinations of rising and falling edges. Gate settings are made in
software.
• Output—It is an output signal that generates pulses or a series of pulses,
otherwise known as a pulse train.
• When a counter is configured for simple event counting, the counter increments
when an active edge is received on the source. In order for the counter to
increment on an active edge, the counter must be armed or started.
• A counter has a fixed number it can count to as determined by the resolution of
the counter.
• Ex: A 24- Bit counter can count
2^(counter resolution)-1
2^(24)-1=16777215
• The most significant specifications for operation of a counter/timer are the
resolution and clock frequency.
• The resolution is the number of bits the counter uses.
• A higher resolution simply means that the counter can count higher.
• The clock frequency determines how fast you can toggle the digital source
input.
• With higher frequency, the counter increments faster and therefore can detect
higher frequency signals on the input and generate higher frequency pulses and
square waves on the output.
• The DAQ-STC counter/timer used on DAQ devices, for example, has 16 and
24-bit counters with a clock frequency of 20 MHz’s
• The NI-TIO counter/timer used on NI 660x counter/timer devices has eight 32-
bit counters with a maximum clock frequency of 80 MHz.
DAQ SOFTWARE ARCHITECTURE
• National Instruments data acquisition boards have a driver
engine that communicates between the board and the
application software.
• NI-DAQmx and Traditional NI-DAQ.
• The DAQ Assistant in LabVIEW can be used to communicate
with data acquisition board.
• The DAQ Assistant is an Express VI that communicates with
NI-DAQmx.
• Measurement & Automation Explorer (MAX) is useful for configuring
and testing data acquisition boards.
• Driver software is the layer of software that directly programs the
registers of the DAQ hardware, managing its operation and its integration
with the computer resources like processor interrupts and memory.
• Driver software hides the low-level, complicated details of hardware
programming, providing the user with an easy-to-understand interface or
a stand-alone application program.
Driver software
• Software transforms the PC and the DAQ hardware into a complete data
acquisition, analysis and presentation tool.
• Without software to control or drive the hardware, the DAQ device will not
work properly.
• Driver software is the layer of software that allows easy communication to the
hardware.
• It forms the middle layer between the application software and the hardware.
• Driver software also prevents a programmer from having to do register-level
programming or complicated commands in order to access the hardware
functions.
• National Instruments offers two different software options,
• one is the NI-DAQmx driver and additional measurement services
software
• the second is the NI-DAQmx base driver software.
• The DAQ Assistant, which is included with
NI-DAQmx, is a graphical, interactive guide for
configuring, testing and acquiring measurement data.
• With a single click, you can even generate code based
on your configuration, making it easier and faster to
develop complex operations.
• Because the DAQ Assistant is completely menu-
driven, fewer programming errors and drastically
decrease the time from setting up your DAQ system
to taking your first measurement.
Driver has the ability to
• Test channels without any programming
● Acquire data in the background while processing in the foreground
● Use programmed I/O, interrupts and DMA to transfer data
● Stream data to and from disk
● Perform several functions simultaneously
● Integrate multiple DAQ devices
● Integrate with sensors and a variety of signal types
● Provide examples to help get started
I/O MODULE
• Control & Timing.
CPU Communication
Device Communication
Data Buffering
Error Detection
I/O TECHNIQUES
Programmed I/O
Interrupt driven I/O
Direct Memory Access (DMA)
[Link] I/O
CPU has direct control over I/O for :
Sensing status
Read/write commands.
Transferring data
CPU waits for I/O module to complete operation.
Programmed I/O
• CPU requests I/O operation
• I/O module performs operation
• I/O module sets status bits
• CPU checks status bits periodically
• I/O module does not inform CPU directly
• I/O module does not interrupt CPU
• CPU may wait or come back later
I/O Commands
Control - telling module what to do.
Test - check status
Read/Write
[Link] Driven I/O
Overcomes CPU waiting
No repeated CPU checking of device
I/O module interrupts when ready
-> Interrupt Driven I/O in detail
• CPU issues read command
• I/O module gets data from peripheral while CPU does other work
• I/O module interrupts CPU
• CPU requests data
• I/O module transfers data
CPU Viewpoint
• Issue read command
• Do other work
• Check for interrupt at end of each
instruction cycle
• If interrupted:-
— Save context (registers)
— Process interrupt
– Fetch data & store
[Link] Memory Access :
Interrupt driven and programmed I/O require active CPU intervention , because
Transfer rate is limited
CPU is tied up
DMA Function
• Additional Module (hardware) on bus.
• DMA controller takes over from CPU for I/O
DMA Operation
• CPU tells DMA controller:-
— Read/Write
— Device address
— Starting address of memory block for data
— Amount of data to be transferred
• CPU carries on with other work
• DMA controller deals with transfer
• DMA controller sends interrupt when finished
Calibration
• The relationship between the input and the output of a
measuring system is established during the calibration
of a measuring system.
• A calibration is the act of applying a known value to
the input of the measuring system for the purpose of
observing the system output.
• The known value applied to the input is known as the
standard.
• By the application of a range of known values to the
input and observation of the system output, a direct
calibration curve can be developed for the
measurement system.
• On such a curve the input x is plotted on the abscissa
against the measurement output y on the ordinate as in
Figure 1.
• In a calibration the input value should be a controlled
input variable, while the measured output value
becomes the dependent variable of the calibration.
• A calibration curve forms the logic by which a
measurement system's indicated output can be
interpreted during an actual measurement.
• For example, the calibration curve is the basis for fixing
the output display scale on a measurement System, such
as that of Figure 1.
• Alternatively, a calibration curve can be used as part of
developing a functional relationship, an equation known
as a correlation, between input and output.
• The correlation can then be used in later measurements to
ascertain the unknown input value based on the output
value, the value indicated by the measurement system.
Assignment 2
1. Explain Digital I/O in data acquisition system
2. Define sampling . Explain the working of sample and hold
circuit with neat sketches.
3. Explain the concept of successive approximation ADC with
an example.
4. Describe Dual Slope ADC.
5. Explain different I/O techniques used in data acquisition
using a flow chart.