Professional Documents
Culture Documents
Minggu Ke-14
Sistem Mikroprosesor
DISPLAY INTERFACING
7 Segment - Display
• There are two important types of
7-segment LED display.
• Common cathode display
– the cathodes of all the LEDs are
joined together and the individual
segments are illuminated by HIGH
voltages.
• Common anode display
– the anodes of all the LEDs are
joined together and the individual
segments are illuminated by
connecting to a LOW voltage.
Basic LED Operations
• To Turn an LED ON
• The ANODE must be at a higher
voltage potential (up to 3V) than
the CATHODE.
• The amount of current flowing
through the LED will determine
the brightness of the LED.
• The amount of current is
controlled by a series resistor.
LED
5 − 1.5
R= = 233.33 → R = 220
15mA
Connections
• A timer interrupt could be used to switch from one display to the next. For
example, timer zero could be set to interrupt once every five milliseconds. The
operation of the timer zero ISR would be:
– Turn off all displays by setting the display enable port pins.
– Send data for next display to the data port.
– Turn on next display (if current display is 4, next display is 1) by clearing the appropriate
enable port pin.
Example
http://embedded-lab.com/blog/lab-11-multiplexing-seven-segment-led-displays/
SENSORS - TEMPERATURE
Temperature Sensing
• Thermoresistive : resistance changes with
temperature
• Thermoelectric : voltage changes with
temperature
• Semiconductor junction : using semiconductor
property that changes with temperature
• Thermoswitches : expansion of two different
metal
Resistance Temperature Detector
(RTD)
• Resistance is a function of temperature
• α is temperature coefficient
– Nickel 0.0067
– Platinum 0.0039 Rnew = Rold (1 + (Tnew − Told ) )
– Copper 0.0038
• Example
• A nickel RTD has a resistance of 200Ω at 100°C. Calculate
the resistance at 150°C.
– R = 200*(1 + 0.0067*(150 - 100)) = 267 Ω
• A nickel RTD has a resistance of 140Ω at 25°C. Calculate the
resistance at -10°C.
– R = 140*(1 + 0.0038*(-10 - 25)) = 121.38 Ω
RTD construction
• The advantages of platinum
resistance thermometers
include:
– High accuracy
– Low drift
– Wide operating range
– Suitability for precision
applications
• Standard platinum Resistance
Thermometers (SPRTs)
– 0.385 ohm/°C
– -200°C to 1000°C
– approximately accurate to
±0.001°C
RTD interface
• Two wire RTD
RTD interface
• Three wire RTD
• Uses bridge
configuration or non-
inverting amplifier
• Bridge is more precise
(does not depend on
voltage supply)
Thermoelectric Effect
Type J : Iron-Constantan : 50 mV
Type K : Chromel-Alumel : 56 mV
Type T : Copper-Constantan: 26 mV
Thermoelectric Interfacing
• Sensitive to Noise
Solution
(
i = IS ev /VT − 1 )
kT
VT =
q
VT
rd =
I
Reverse Bias (no current flow)
Temperature changes the resistance
Using Semiconductor Sensor
• Position sensing
• Resolution depends on
the number of wire
turn
– % resolution = 100/N
• If a resistor has 2000
turns
– % resolution is
100/2000 = 0.2%
Interfacing
• Problem of loading
• If the sensor is at the middle, Vout = 6 V
• Let say that we connect the sensor to a signal
conditioning circuit that has a load of 5 KΩ.
– Vout = (5K || 5K)/(5K + (5K || 5K))*12 V = 4 V
• Need an opamp with unity gain so that the load
resistance is very large
Capacitive sensor
o KA 1
C= →C
d d
ε0 is the permittivity of free space constant
K is the dielectric constant of the material
A is the area of the plates
d is the distance between the plates
• Need an AC
supply with
constant
frequency f
Interfacing
Rectifier Filter
V sensor +
with
constant f
Vout
(DC)
-
+ +
V RL Vpeak
sensor (DC)
with
constant f
-
( rN )
2
L= r
9r + 10l
• L inductance in μH
• r radius
• N number of turns
• l is effective length
• μr is the relative permeability
– Air 1
– Iron 7000, etc
Position sensing
X L = 2 f L
• Needs an AC voltage source with constant
frequency
• Interfacing is the same as capacitive sensors
More accurate position sensing
• Linear variable differential transformer (LVDT)
• Like a bridge
• Vout = 0 when core is in the middle position
More accurate position sensing
• Linear variable differential transformer (LVDT)
SENSOR - PROXIMITY
Proximity Sensor
• Capacitive sensor
R
GF = R
Strain
Interfacing
R2 Rcal
Vout = − Vin
R1 + R2 Rg + Rcal
Read
Value
• Why we make other Columns High Impedance
while one column is made LOW?
H L H H
Short Circuit !!
Hardware connections
PA0 PA1 PA2 PA3 • Using PortA
• PA0-3 as output
PA4 • PA4-7 as input
PA5
PA6
PA7
Remember Port I/O
• To set Hi-Z on PA0-3
– DDRA = 0x00
– PortA = 0x00
• To set Low on PA0-3
– DDRA = 0x0F
– PortA = 0x00
• To set Input and Pull-
Up on PA4-7
– DDRA = 0x00
– PortA = 0xF0
Scanning Keypad
• Step 1 : make all column Hi-Z (also PA4-7 as input with
pull-up)
– DDRA = 0x00 and PortA=0xF0
• Turn on (make low) C1
– DDRA = 0x01
• Read Rows (R1-R4) (PA4-7)
– Key = PINA & 0xF0
– If any key on C1 is pressed, then the value should be low,
i.e key = 0x70 (R4-C1 is pressed)
– If no key is pressed the continue to C2, otherwise exit
• Turn on C2
– DDRA = 0x02
• Continue scanning….
Scanning Keypad
unsigned char GetKeyPressed()
{
unsigned char c;
for(c=1;c<=0x04;c=c<<1)
{
DDRA = c;
k = PINA & 0xF0;
if(k != 0xF0)
{
DDRA=0x00; // back to Hi-Z
return (k^0xF0 + c); // return key location (r,c)
}
}
return(0);//Indicate No key pressed
}
int main(void)
{
unsigned char key;
DDRA = 0x00;
PORTA = 0xF0; // Set PA for keypad scan, Hi-Z and Pull-ups
key = GetKeyPressed;
}