Lecture7_Analog Interfacing
Lecture7_Analog Interfacing
3
Outline
• Sensor and Actuators
• Converting Between Analog and
Digital Values
• Analog to Digital conversion concepts
• Summary
4
Why It’s Needed
• Embedded systems often need to measure values of physical parameters
• These parameters are usually continuous (analog) and not in a digital form
which computers (which operate on discrete data values) can process
• Temperature • Pressure
– Thermometer (do you have a fever?) – Blood pressure monitor
– Thermostat for building, fridge, – Altimeter
freezer – Car engine controller
– Car engine controller – Scuba dive computer
– Chemical reaction monitor – Tsunami detector
– Safety (e.g. microprocessor thermal • Acceleration
management)
• Light (or infrared or ultraviolet) – Air bag controller
intensity – Vehicle stability
– Digital camera – Video game remote
– IR remote control receiver • Mechanical strain
– Tanning bed
– UV monitor • Other
– Touch screen controller
• Rotary position – EKG, EEG
– Wind gauge – Breathalyzer
– Knobs
Simplified Block Diagram
actuator
s
Sensors and Actuators
• Sensors:
– Capture physical stimulus
(e.g., heat, light, sound,
pressure, magnetism, or
other mechanical motion) mic
– Typical generate a
proportional electrical
current
– May require analog Temperature
+ Humidity compass
interface
accelerometer
Sensors
• Processing of physical data starts with capturing this data.
MEMS device
Small mass in
center
When accelerated:
Mass displaced from
center
Resistance of wires
connected to mass
change
Detect change in
resistance and model
acceleration
Integrated into ID
mouse.
Other examples of sensors
– Heart monitoring sensors
• “Managing Care Through the Air”
» IEEE Spectrum Dec 2004
– Rain sensors for wiper control
• High-end autos
– Pressure sensors
• Touch pads/screens
– Proximity sensors
• Collision avoidance
– Engine control sensors
– Audio sensors
– Motion sensors
– Thermal sensors
• SARS detection (“high fever”)
Simplified Block Diagram
actuators
15
Sensors and Actuators
• Actuators
– Convert a command to a
physical stimulus (e.g., heat,
light, sound, pressure,
magnetism, or other solenoid
mechanical motion) speaker
– May require analog
interface
laser diode/transistor
dc motor
16
Actuators
• Output physical stimulus varies in range and modality
– Large (industrial) control actuators
• Pneumatic systems: physical motion
– Optical output
• IR
– Thermal output
– Small motor controllers (stepper motors)
– MEMS devices
– List goes on…..
17
MEMS Actuators
Huge variety of actuators and output devices.
(© MCNC)
18
Outline
• Sensor and Actuators
• Converting Between Analog and
Digital Values
• Analog to Digital conversion concepts
• Summary
19
The Big Picture – A Depth Gauge
V_ref // Your software
ADC_Code = ADC0->R[0];
Analog to V_sensor = ADC_code*V_ref/1023;
Pressure Pressure_kPa = 250 * (V_sensor/V_supply+0.04);
Digital
Sensor Depth_ft = 33 * (Pressure_kPa –
Converter
Atmos_Press_kPa)/101.3;
Water
Pressure
V_sensor Voltages ADC
Output Codes
ADC_Code V_ref 111..111
111..110
111..101
111..100
V_sensor ADC_Code
000..001
Ground 000..000
1. Sensor detects water pressure and generates a
proportional output voltage V_sensor
2. ADC generates a proportional digital integer
(code) based on V_sensor and V_ref
3. Code can convert that integer to a something
more useful
1. first a float representing the voltage,
2. then another float representing pressure,
3. finally another float representing depth
Getting From Analog to Digital
• A Comparator tells us “Is Vin > Vref?”
– Compares an analog input voltage with
an analog reference voltage and Comparator
fraction of Vref. 0
Clock 1
– Reads an analog input signal (usually a
voltage) and produces a corresponding
multi-bit number at the output.
– E.g. calculate the depth
Digital to Analog Conversion
• May need to generate an analog voltage or
current as an output signal
– E.g. audio signal, video signal brightness.
• DAC: “Generate the analog voltage which is
this fraction of Vref ” D/A Converter
0
• Digital to Analog Converter equation 1
– n = input digital value 0
Vout
1
– B = number of bits of resolution of converter
Vref
– Vref = reference voltage
– Vout = output voltage. Either
• Vout = Vref * n/(2B) or
• Vout = Vref * (n+1)/(2B)
• The offset +1 term depends on the internal
tap configuration of the DAC – check the
datasheet to be sure
Waveform Sampling and Quantization
Digital value
time
3.30v 210
V B
in V ref 2
n
5v
1/ 2
676
n 1/ 2
V ref Vref
27
A/D – Flash Conversion
• A multi-level voltage divider is used to
set voltage levels over the complete
1V
range of conversion. 7/8 V
R Comparators
Vin
1 0
ADC - Successive Approximation Conversion
Converter Schematic
Analog Input +
Comparator output
D/A Converter
Clock
ADC - Successive Approximation Conversion
Voltage
• Set all DAC input bits to 0 100100
100000
• Start with DAC’s most
• Nyquist criterion
– Fsample >= 2 * Fmax frequency component
– Frequency components above ½ Fsample are aliased, distort measured
signal
Inputs
• Differential
– Use two channels, and compute difference between them
– Very good noise immunity
– Some sensors offer differential outputs (e.g. Wheatstone Bridge)
• Multiplexing
– Typically share a single ADC among multiple inputs
– Need to select an input, allow time to settle before sampling
• Signal Conditioning
– Amplify and filter input signal
– Protect against out-of-range inputs with clamping diodes
Outline
• Sensor and Actuators
• Converting Between Analog and
Digital Values
• Analog to Digital conversion concepts
• Summary
35
Summary
• How a digital microcontroller can measure and generate
analog signals