5. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
ADC Application: Embedded systems
receive
Embedded systems receive their inputs from
the external world in the form of analog signals.
An analog signal (amplitude varies
continuously) needs to be converted into a
digital signal as processor only
takes digital signals ( a series of ones and zeros
represented by voltages).
Thus conversions are performed by Analog-to-
Digital(ADC) and the reverse conversion of
digital to analog by Digital-to-Analog(DAC).
5
29. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
29Resolution
ADC voltage resolution ADC resolution
The resolution of the converter indicates the number of
discrete values it can produce over the range of analog values.
If this variable uses eight bits, this means it can hold values from
0 to 255 (2^8 = 256). If this variable uses 16 bits, this means it
can hold values from 0 to 65,535 (2^16 = 65,536). And so on.
ADC voltage resolution == Step size
The ADC voltage resolution is the
smallest change in input that can be
reliably detected by the system.
Resolution
The ADC has n-bit resolution, where n can be 8, 10, 12, 16, or
even 24 bits. Higher-resolution ADCs provide a smaller step
size, where step size is the smallest change that can be
discerned by an ADC.
Although the resolution of an ADC chip is decided at the time
of its design and cannot be changed, we can control the step
size with the help of what is called Vref.
32. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Major Characteristics of the ADC
Conversion Time
Conversion time is defined as the time it takes the ADC to convert the analog input to a
digital (binary) number.
The conversion time is dictated by the clock source connected to the ADC in addition to
the method used for data conversion and technology used in the fabrication of the ADC
chip such as MOS or TTL technology.
Reference Voltage ( Vref )
Vref is an input voltage used for the reference voltage.
The voltage connected to this pin, along with the resolution of the ADC chip, dictate the
step size.
For an 8-bit ADC, the step size is Vref/256 because it is an 8-bit ADC, and 2 to the power of
8 gives us 256 steps.
33. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Major Characteristics of the ADC
Digital data output
In an 8-bit ADC we have an 8-bit digital data output of D0-D7, while in the 10-bit ADC the data
output is D0-D9.
To calculate the output voltage, we use the following formula:
Dout = Vin / step size
Where
Dout = digital data output (in decimal),
Vin = analog input voltage
step size = (resolution) is the smallest change, which is
( Vref / 256 ) for an 8-bit ADC.
53. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Parallel Design
The Flash ADC, also called parallel ADC,
Use a series of comparators
It works by comparing the input voltage – i.e., the
analog signal – to a reference voltage,
which would be the maximum value achieved by the analog signal.
For example, if the reference voltage is of 5 volts, this means that
the peak of the analog signal would be 5 volts.
On an 8-bit ADC when the input signal reached 5 volts we would find
a 255 (11111111) value on the ADC output, i.e., the maximum value
possible.
Then the voltage reference is lowered through a resistor network
and other comparators added, so the input voltage (analog signal)
can be compared to other values.
53
55. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Parallel Design
Advantages/disadvantages
Although Flash ADC uses a very simple design, it requires a lot of components. The
number of required comparers is 2^n-1, where n is the number of output bits. Thus for an
eight-bit Flash ADC 255 comparers would be necessary, and for a 16-bit Flash ADC, 65,535!
On the other hand, Flash ADC is the fastest ADC type available. The digital equivalent of
the analog signal will be available right away at it output (it will only have the propagation
delay inserted by the logic gates) – hence the name “flash”.
Another advantage of Flash ADC is that you can create an ADC with non-linear
output. Usually ADCs have a linear output, i.e., each digital number corresponds to a
fixed voltage increase on the analog input. For example, on the 3-bit ADC shown above
with a Vref of 5 V, each digital number would represent 625 mV (5 V / 2^3). So 0 V = 000,
0.625 V = 001, 1.250 V = 010 and so on up to 5 V = 111.
Since Flash ADC comparisons are set by a set of resistors, one could set different values
for the resistors in order to obtain a non-linear output, i.e., one value would represent a
different voltage step from the other values.
55
58. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Ramp counter ADC
Ramp counter ADC, also called digital ramp ADC.
Vin is the analog input and Dn through D0 are the digital
outputs.
The control line found on the counter turns on the counter
when it is low and stops the counter when it is high.
The basic idea is to increase the counter until the value found
on the counter matches the value of the analog signal. When
this condition is met, the value on the counter is the digital
equivalent of the analog signal.
It requires a START pulse for each analog voltage you want to
convert into digital
So the main problem with this circuit is that it is very slow, as
it would require up to 2^n-1 clock cycles to convert each
sample. For an eight-bit ADC, it would take up to 255 clock
cycles to convert a single sample. For a 16-bit ADC it would
take up to 65,535 clock cycles to convert one sample.
58
60. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Successive Approximation ADC
the successive approximation ADC starts first setting the
MSB (most significant bit, on an eight-bit ADC it would be
D7). In order to facilitate the explanations below, consider
an eight-bit ADC.
The comparison between Vin and the DAC output will tell
the control unit if this bit should remain set at 1 or should
be set at 0, as the op amp will tell right away the control
unit if the sample value is greater or lower than 128 (2^7).
Then D6 is set to one, and from the comparison done by
the op amp, the control unit will know if this bit should
remain set or not. And so on.
The good thing about the successive approximation ADC is
its speed. At the worst case it will find the correct digital
value for the sample at n clock cycles
60
82. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
So the main features
It is a 10-bit ADC.
It has 8 analog input channels,
7 differential input channels, and
2 differential input channels with
optional gain of 10x and 200x.
The converted output binary data is
held by two special function regis-
ters called ADCL (A/D Result Low)
and ADCH (A/D Result High).
Because the ADCH:ADCL registers
give us 16 bits and the ADC data out is only 10 bits wide, 6 bits of the 16 are
unused.
90. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
How it works
The analog voltage at the input of the ADC must be greater
than 0V, and smaller than the ADC's reference voltage AREF.
The reference voltage is an external voltage you must supply
at the Aref pin of the chip.
The value the voltage at the input is converted to can be
calculated with the follwing formula:
ADC conversion value = round( (vin/vref)*1023)
Since it is a 10-bit ADC, you have 1024(1024=2^10) possible
output values (from 0 to 1023). So, if vin is equal to 0V, the
result of the conversion will be 0, if vin is equal to vref, it will
be 1023, and if vin is equal to vref/2 it will be 512
90
91. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Modes of Operation
Single Conversion mode, you have to initiate each conversion. When it is
done, the result is placed in the ADC Data register pair and no new conversion
is started.
In Free Runing mode, you start the conversion only once, and then, the
ADC automatically will start the following conversion as soon as the previous
one is finished
The analog to digital conversion is not instantaneous, it takes some time. This
time depends on the clock signal used by the ADC. The conversion time is
proportional to the frequency of the ADC clock signal, which must
be between 50kHz and 200kHz.
91
93. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Modes of Operation
To know the time that a conversion takes, just need to divide the
number of ADC clock cycles needed for conversion by the frequency of
the ADC clock.
Normaly, a conversion takes 13 ADC clock cycles.
The first conversion after the ADC is switched on (by setting the ADEN
bit) takes 25 ADC clock cycles. This first conversion is called an
"Extended Conversion".
For instance, if you are using a 200kHz ADC clock signal, a normal
conversion will take 65 microsenconds (13/200e3=65e-6), and an
extended conversion will take 125 microseconds (25/200e3=125e-6).
93
99. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
ADCSRA – ADC Control and Status
Register A
ADEN – ADC Enable – As the
name says, it enables the ADC
feature. Unless this is enabled,
ADC operations cannot take
place across PORTA i.e. PORTA
will behave as GPIO pins.
ADSC – ADC Start Conversion –
Write this to ‘1’ before starting
any conversion. This 1 is written
as long as the conversion is in
progress, after which it returns
to zero. Normally it takes 13 ADC
clock pulses for this operation.
But when you call it for the first
time, it takes 25 as it performs
the initialization together with it.
ADATE – ADC Auto Trigger Enable –
Setting it to ‘1’ enables auto-triggering
of ADC. ADC is triggered automatically
at every rising edge of clock pulse
ADIF – ADC Interrupt Flag –
Whenever a conversion is
finished and the registers are
updated, this bit is set to ‘1’
automatically
99
115. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
LM34 and LM35 Temprature Sensors
The output voltage is of LM34 is linearly proportional to the
Fahrenheit temperature. It outputs 10 mV for each degree
of Fahrenheit temperature.
Part Scale Temp. Range Accuracy Output
LM34A -50 F to +300 F +2.0 F 10 mV/F
LM34 -50 F to +300 F +3.0 F 10 mV/F
LM34CA -40 F to +230 F +2.0 F 10 mV/F
LM34C -40 F to +230 F +3.0 F 10 mV/F
LM34D -32 F to +212 F +4.0 F 10 mV/F
Table 13-9: LM34 Temperature Sensor Series Selection Guide
116. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
LM34 and LM35 Temprature Sensors
The output voltage is of LM35 is linearly proportional to the
Celsius temperature. It outputs 10 mV for each degree of
Centidgade temperature.
Table 13-9: LM35 Temperature Sensor Series Selection Guide
Part Temp. Range Accuracy Output Scale
LM35A -55 C to+150 C +1.0 C 10 mV/C
LM35 -55 C to +150 C +1.5 C 10 mV/C
LM35CA -40 C to +110 C +1.0 C 10 mV/C
LM35C -40 C to +110 C +1.5 C 10 mV/C
LM35D 0 C to +100C +2.0 C 10 mV/C
117. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
Interfacing the LM34, LM35 to the AVR
LM34 (or LM35) produces 10mV for every degree of
temperature change and the ADC has 10-bit resolution with
a maximum of 1024 steps.
if we use the step size of 10 mV, the Vout will be 10,240 mV
(10.24 V) for full-scale output.
The maximum temperature sensed by the LM34 is 300
degrees F, and its highest is 3000mV (3.00V).
If we use the internal 2.56V reference voltage, the step size
would be 2.56 V/1024 = 2.5 mV.
(10 mV/2.5 mV = 4) This is four times the real temperature
We can scale it by dividing it by 4 to get the real number for
temperature
120. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
LAB3: write a program for Reading and
displaying temperature
The following points must be noted:
1. The LM34 (or LM35) is connected to
Channel 0 (ADC0 pin).
2. The 10-bit output of the A/D is divided by
4 to get the real temperature.
3. To divide the 10-bit output of the A/D by
4 we choose the left-justified option and
only read the ADCH register. It is same as
shifting the result two bits right. See Next
Example.
122. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
PIR SENSOR:
The PIR sensor detect only bodies (hot materials and living
objects) in motions not the static ones. This sensor uses
Infra red beam to detect the motion and only covers a
certain space based on the sensor model, you should to go
through the manufacturer datasheet to know about the
range. This sensor module gives only two output states
that is logic High 1 which is equivalent to 3.3 V and logic
low 0 equivalent to 0 V.
122
124. https://www.facebook.com/groups/embedded.system.KS/
Follow us
Press
here
#LEARN_IN DEPTH
#Be_professional_in
embedded_system
GATEWAY CAR Parking
WORKING:
The PIR sensor is interfaced with Atmega32
AVR microcontroller to detect the motion
around the environment. Atmega32 considers
any voltage between 2V to 5V as logic high.
Hence PIR sensor is directly interfaced to the
input pin of the controller.
The circuit shown above will read the status
of the output of the PIR sensor and the ADC
will read the Value if the Value is less than 3
Volt that mean that the PIR detected the CAR
so the gateway will opened and the 7-
segement will count each car entered on the
PARKING and the Buzzer will run, then the
Gateway will closed after the car moved a
way from GATEWAY and the Buzzer will be
OFF.
124