2. Basics of A/D Conversion
•Can convert only electrical voltages to digital
values.
• A transducer is needed to convert a non-electric
quantity into an electrical voltage.
• Different names of transducers are used for
different physical quantities.
• A data acquisition system is used to referred to
those systems that perform A/D conversions.
3. Characteristics of ADC
Resolution
Conversion time
Vref
Digital data output
Dout = Vin/step size
4. Parallel VS Serial ADC
Parallel in serial ou
shift register
Speed is slow
•8 bit & 16 bit o/p line
•Speed is fast
5. The PIC18f A/D Converter
-The PIC18 has a 10-bit A/D converter.
-The number of analog inputs varies
among difference PIC18 devices.
-The contents of these registers vary
with the PIC18 members.
-Early PIC18 (PIC18FXX2) members
have only ADCON0 and ADCON1
registers.
6.
7. A/D Registers
-The A/D converter has the following
registers:
•A/D Result High Register (ADRESH)
•A/D Result Low Register (ADRESL)
•A/D Control Register 0 (ADCON0)
•A/D Control Register 1 (ADCON1)
8. Three control registers are
used to:
•Set up the I/O pins for analog signals from ports A, B,
and E that are used as inputs for A/D conversion.RA5
•Select a channel: AN4
•Set up pins RA2 and RA3 to connect external VREF +
and VREF - if specified in the control register ADCON1.
•Select an oscillator frequency divider through the
control register ADCON1.
•Select an acquisition time through the control register
ADCON2.
9. A/D Control Register 0 (ADCON0)
• Primary function of the ADCON0
register:
– Select a channel for input analog
signal
– Start a conversion
– Indicate the end of the conversion
• Bit2 is set to start the
conversion, and at the end of
the conversion this bit is reset.
10. A/D Control Register 1
(ADCON1)
ADCON1 is primarily used to set up the
I/O pins either for analog signal or for
digital signals and select VREF voltages.
An input to be converted must be an
analog input.
The ADFM bit of the ADCON1 is used for
making it Right-justified or Left-justified
because we need 10 out of 16 bits.
11. ADFM bit
Alignment to the left – the eight MSB bits
are stored in the ADRESH, and the two LSB
bits are stored in ADRESL. In this case, the
remaining six bits appear as - "0".
• Alignment to the right – the eight LSB bits are
stored in ADRESL, and two MSB bits are stored in
the ADRESH. In this case six highest bits appear
as - "0".
12.
13. A/D Acquisition Requirements
The A/D converter has a sample-and-hold
circuit for analog input.
The sample-and-hold circuit keeps the
voltage stable when it is converted.
The sample-and-hold circuit is shown in
Figure.
14. Automatic Acquisition Time
For earlier PIC18 members, when the
GO/DONE bit is set, sampling is stopped
and conversion begins.
The user is responsible for making sure
enough acquisition time is provided.
For newer PIC18 members, the A/D
module will continue to sample after the
GO/DONE bit is set for the selected
acquisition time.
The automatic acquisition time makes
A/D programming a little easier.
15. Selecting the A/D Conversion
Clock
The per bit A/D conversion time is defined
as TAD.
Each 10-bit A/D conversion takes 12 TAD
to complete.
For some devices, the options for TAD
are defined in ADCON0. For others, the
options for TAD are defined in ADCON2.
The length of TAD must be at least 1.6 .
17. Procedure for Performing A/D
Conversion
Configure the A/D module
1. Configure analog pins, reference voltages
2. Select A/D input channel
3. Select A/D acquisition time (if available)
4. Select A/D conversion clock
5. Enable A/D module
Configure A/D interrupt
1. Clear ADIF flag
2. Set ADIE bit (if desired)
3. Set GIE bit (if desired)
18. Procedure contd…..
Wait for the desired acquisition time
(if required)
Start conversion by setting the
GO/DONE bit
Wait for A/D conversion to complete
Read the A/D result registers; clear
the ADIF flag
For next conversion, go to step 1 or
step 2.
21. Digital to Analog (D/A, DAC, or
D-to-A) Conversion
Converting discrete signals into
discrete analog values that represent
the magnitude of the input signal
compared to a standard or reference
voltage
◦ The output of the DAC is discrete analog
steps.
◦ By increasing the resolution (number of
bits), the step size is reduced, and the
output approximates a continuous analog
signal.
23. Weighted Sum DAC
One way to achieve D/A conversion is
to use a summing amplifier.
This approach is not satisfactory for a
large number of bits because it
requires too much precision in the
summing resistors.
This problem is overcome in the R-2R
network DAC.
24.
25. R-2R Ladder DAC
The summing amplifier with the R-2R
ladder of resistances shown produces
the output where the D's take the
value 0 or 1.
The digital inputs could be TTL
voltages which close the switches on
a logical 1 and leave it grounded for a
logical 0.
This is illustrated for 4 bits, but can be
extended to any number with just the
resistance values R and 2R.
29. Converting Iout to Voltage in
DAC0808
In the MC0808 the digital inputs are
converted to current and to convert it
to voltage Iout is connected to a
resistor.
As the resistance affect the output
voltage so current output is isolated by
connecting it to an op-amp.
30. Generating a sine wave
To generate a sine wave we first need
a table whose values represent the
magnitude of sine of angle b/w 0 and
360 degrees.
Sin varies from -1 to +1.
This method ensures that only integer
numbers are output to the DAC by
PIC18.
Assume full-scale voltage of 10 V.
Vout = 5V + (5*sinQ)
34. Sensor interfacing
Sensor is a device which detects or
measures a physical property and
records, indicates, or otherwise
responds to it.
Transducer is a device that converts
variations in a physical quantity, such
as pressure or brightness, into an
electrical signal, or vice versa.
We are considering only temperature
sensor.
35. Temperature Sensor
• Transducer that converts temperature into an
analog electrical signal.
• Many are available as integrated circuits, and
their outputs (voltage or current) are, in
general, linearly proportional to the
temperature.
• However, output voltage ranges of these
transducers may not be ideally suited to
reference voltages of A/D converters.
• Therefore, it is necessary to scale the output
of a transducer to range of the reference
voltages of an A/D converter.
• Scaling may require amplification or shifting
of voltages at a different level.
36. Interfacing LM34/LM35 with
PIC18
The sensor of LM34 series are
precision integrated-circuit
temperature sensors.
Output voltage is linearly proportional
to fahrenheit temperature.
Outputs 10mV for each degree of
fahrenhiet temperature.
In LM35 output voltage is linearly
proportional to celsius temperature.
38. Interfacing LM35 with PIC18
Temperature calculations
◦ A/D converter has 10-bit resolution
◦ For temperature range 0ºF to +300ºF, the digital
output should be divided into 1024 steps (0 to
3FFH).
◦ Therefore, the digital value per degrees
Fahrenheit is 10.24 (1024/100 = 10.2410).
◦ This 10.24 V is exceeding the permissible max.
value i.e 3V.
◦ If step size is taken 2.5 mV then max Vout will be
2.56 V.
◦ Final value is calculated by dividing output by 4.
39. Interfacing LM35 with PIC18
LM35 is
connected to
channel
0(RA0 pin).
The channel
AN3(RA3
pin) is
connected to
the Vref of
2.56 V.