Professional Documents
Culture Documents
04 IOports Updated
04 IOports Updated
Chapter 4
2
I/O unit in AVR
3
I/O ports in AVR family
4
ATmega8 pinout
+5 V
1. Vital Pins:
1. Power
■ VCC
■ Ground
2. Crystal +5 V
■ XTAL1 +5 V
■ XTAL2
3. Reset
2. I/O pins
• PORTB, PORTC, and
PORTD
4. Internal ADC pins
• AREF, AVCC, ADCn
5
Crystal Oscillator
https://www.watelectronics.com/crystal-oscillator-circuit-working-applications/
https://www.youtube.com/watch?v=t3b0ZNKvgqo 6
The structure of I/O pins
7
Time delay
1
TMachine cycle =
FXTAL
1
TMachine cycle = = 62.5 ns
16MHz
8
I/O bit manipulation programming
9
AVR Output Interfacing
10
AVR Fan-out
■ Each I/O port can sink 20
mA at VCC = 5V and 10
mA at VCC = 3V
11
Interfacing Light Emitting Diodes (LED)
■ LED is a diode that is lit
■ When the voltage across it is
above some threshold. 0 🡪 ON
1 🡪 OFF
■ The LED does not lit
■ When the voltage is below that or the
diode is reverse biased.
■ To limit the current
■ Important to include a resistor in series
with the LED, Otherwise, the LED will burn
■ a lit LED display that the output is on or off
■ Depending on how it is connected 0 🡪 OFF
■ The configuration on top (LED0) is 1 🡪 ON
preferred
■ Software design with knowledge on how
hardware is connected
12
LED Resistor
■ Series LED must be well chosen
■ Too low a resistor
■ leads to excessive current and the LED 0 🡪 ON
burn out 1 🡪 OFF
■ Too high resistor
■ limit the current more than necessary
and thus reduce the LED’s brightness
■ The LED resistor is calculated
■ Voltage drop is about 2 V
■ Maximum allowed current about 20
mA .
■ For 5 V power supply, Rmin = 150 Ω 0 🡪 OFF
1 🡪 ON
■ Real designs: select the next higher
standard value for safety margins
13
High Current Output
■ Many devices like small lamps, servo and stepper motors can
operate at relatively low voltages. However, they require
much more current than can be supplied by a typical
microcontroller.
■ Drivers are usually needed as an interface between the digital
world and the analog world.
VCC
14
Darlington Transistor
■ Darlington Configuration c
b
■ Higher current gain c
e b
■ Single integrated unit or e
constructed using a pair of
NPN transistors
15
ULN2003
■ There are 7 Darlington
transistors in a
ULN2003.
16
Relay
■ Relay is an electronic
controlled switch.
■ It isolates two parts
of a circuit from each
other.
■ A small amount of
current and voltage
causes to switch a
large amount of
voltage and current.
Relay DPDT
Maximum output: 250V 8A ~AC
Input: 24V DC
17
Relay
■ Relay has the following parts:
■ Coil
■ Contacts
■ Spring
+
- 12V ~ 220V
18
AVR connection to relay
Darlingto Lamp
Micro Relay
n
19
Opto-isolator
■ Opto-isolator isolates two parts
of a circuit from each other.
■ There is an LED in the input,
and a photo-transistor in the TLP521
output. When the LED lights
up, the photo-transistor,
senses the light and becomes
conductor, and passes the
current.
■ can be used in input or output
circuits.
20
Opto-isolator
16mA 10mA
TLP521
21
Opto-isolator
22
AVR Input Interfacing
23
Switches
■ Switches are used as inputs
■ Simple circuits are designed to make the switches produce TTL
or CMOS levels.
■ Hardware and software must be compatible to interpret what
a closed switch indicate
output to microcontroller
Closed 🡪 1
Open 🡪 0
24
Switches
■ This circuit is read as 0 when the switch is closed and as 1
when it is open.
Closed 🡪 0
Rup Open 🡪 1
25