8051 Tutorial
8051 Tutorial
T R AI N I N G K I T
(8051ETK)
USER MANUAL
April 22, 2006
2
CONTENTS
I. INTRODUCTION
a. POWER MODULE
b. RESET CIRCUIT
c. DISPLAY MODULE
d. A/ D CONVERSION MODULE
(ii) ADCO8O4
3
(iii) RELAY (AC / DC SWITCH)
f. ANALOGUE COMPARATOR
h. SERIAL COMMUNICATION
i. BUZZER
IX. SOFTWARE
a. KEIL COMPILER
b. EZ-DOWNLOADER
X. COMPONENTS LIST
4
I. INTRODUCTION
5
INTRODUCTION
INTRODUCTION
7
8
9
II. FEATURES AND SPECIFICATIONS
11
III. SAFETY GUIDELINES
SAFETY GUIDELINES
12
Do not remove the microcontroller from the
programmer during the burning process. Doing so
may end up in damaging the controller
permanently.
While mounting the microcontroller on the ZIF
sockets (of both Development board and
Programmer), keep in mind the correct direction of
the microcontroller.
While testing any of the output displays (LED
array, 7-segment or LCD), select the jumpers
according to the guidelines (given in
corresponding section) for correct functionality.
Avoid continuous non-multiplexed glow of LEDs or
7-Segment Display due to power rating constraints
of on board regulators etc
While plugging the LCD cable, keep in mind the
correct direction of the cable.
Do not adjust the pot knobs without going through
the details of their working. Doing so may disturb
the resolution of ADC.
Do not touch the heat sinks, they may singe.
13
IV. PACKAGE CONTENTS
14
PACKAGE CONTENTS
8051ETK Programmer.
User Manual.
Serial Cable.
AC Adapter.
HD44780 20 × 2 Line LCD.
Data Cable for LCD.
8051ETK CD which includes:-
o Keil µVision2 Software - Full Version (4K).
o E-Z Downloader Software.
o Sample Codes in C and Assembly language.
o Lectures on 8051 Microcontroller.
o Computer Based Tutorials for use of Keil
µVi-sion2 Software.
o Datasheets of ICs used.
15
V. QUICK START GUIDE
16
QUICK START GUIDE
17
VI. 8051ETK BOARD LAYOUT
18
8051ETK BOARD LAYOUT
19
HARDWARE DETAILS OF 8051ETK
20
P2 on the 8051ETK board is so connected that its
output / control signals can be either activated or
deactivated. For this purpose, Port 2 of the
microcontroller is connected to controlling the on-board
devices through an 8 x DIP switch SW2 as shown in the
schematic of FIG 2. The devices can be isolated from the
Port if the switches are at off position.
Port 2
DS2/EN
1
2
3
7 14
P2.4 3 DS3/WR
6 13
P2.3 4 DS4
5 12
P2.2 4 11 LED
P2.1 6 RLY
3 10
P2.0 7 DC LOAD COMP
2 9
8 AC LOAD
1
Port 0
Connections to 4 × 2
Header (Port 2)
FIG 1: Port
Headers
HARDWARE DETAILS OF 8051ETK
21
Hardware of the 8051ETK board has been divided into
various modules which are explained as follow.
a. POWER MODULE
22
Power Enable / disable Jumpers (12V, 5V, GND), shown
in FIG 3 are provided as a safety precaution, fault
tracking and for external power supply (if needed).
V cc
12V
■ ■
R1
5V (Vcc)
■ ■
GND
■ ■
PWR LED
23
12V
12V IN
DC IN 1 2
2 1
12V
5V
DC IN
1 2
7812 7805
D1 VCC IN
1 3 1 3
S1 AC
V IN VOUT VIN VOUT VCC
IN AC 2
2
C2 C3
1
1 1 2
2 B
AC
-
2 GND
-
AC
-
b. RESET CIRCUIT
The reset input is the RST pin, which is the input two
a Schmitt trigger. The reset is accomplished by
holding the RST pin high for at least two machine
cycles, while the oscillator is running.
An automatic reset can be obtained when Vcc is
turned on by connecting the RST pin to VCC through a
10 micro farad capacitor (C14) and to ground through
an 8.2 k resistor (R7) providing the Vcc rise time does
not exceed to 10 ms. For manually resetting the
controller in 8051ETK board, the yellow RST push
button VCC
is available on VCC µ CReset
the board. The Power ON
and Manual Reset circuit are shown in FIG 5.
C14
R8 RESET
9
R7
RST
24
FIG 5: Reset Circuit
HARDWARE DETAILS OF 8051ETK
b. DISPLAY MODULE
25
out of other Display devices i.e. SSD and LCD, the
jumper should be fixed as shown.
< LED 7-SEG
>
1
2
3
VCC
P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0
dp g f e d c b a
U5A
1 18
IN OUT
10
C OM
U5B
2 17
IN OUT
U4 10
C OM
1 40
P1.0 Vcc
2 39 U5C
P1.1 P 0.0
3 38 3 16
P1.2 P 0.1 IN OUT
4 37 10
P1.3 P 0.2 C OM
5 36 R 14 a
P1.4 P 0.3
6 35 U5D R 15 b
P1.5 P 0.4
7 34 4 15 R 16 c
P1.6 P 0.5 IN OUT
8 33 10 R 17 d
P1.7 P 0.6 C OM
9 32 R 18 e
R ESET P 0.7
10 31 U5E R 19 f
P3.0/R XD EA
11 30 5 14 R 20 g
P3.1/TXD ALE IN OUT
12 29 10 R 21 dp
P3.2/INT0 PSEN C OM
13 28
P3.3/INT1 P 2.7
14 27 U5F
P3.4/T0 P 2.6
15 26 6 13
P3.5/T1 P 2.5 IN OUT
16 25 10
P3.6/WR P 2.4 C OM
17 24
P3.7/R D P 2.3
18 23 U5G
XTAL1 P 2.2
19 22 7 12
XTAL2 P 2.1 IN OUT
20 21 10
GND P 2.0 C OM
U5H
8 11
IN OUT
10
C OM
26
Q3 & Q4 respectively. In order to select the SSD the
jumper < LED 7-SEG > should be fixed as
■■■
123
VCC
DS4 DS3/WR DS2/EN DS1/RS
Q1 Q2 Q3 Q4
R31 R32 R33 R34
Table 1
27
7-SEGs PORT DIGIT(7- PORT
OF SSD PINS SEG) PINS
a P0.0 DS1 P2.4
b P0.1 DS2 P2.5
c P0.2 DS3 P2.6
d P0.3 DS4 P2.7
e P0.4
f P0.5
g P0.6
dp P0.7
28
HARDWARE DETAILS OF 8051ETK
1 2 3 1 2 3
VCC
LCD Port
1 2
3 4 DS1/RS
DS3/WR 5 6 DS2/EN
D0 7 8 D1
D2 1 D3
9
1 0
1
D4 D5
1 2
1 D7
D6
3
1 4
1
5 6
Table 2
29
LCD
LCD DATA PORT PORT
CONTROL
BUS PINS PINS
SIGNALS
D0 P0.0 RS P2.7
D1 P0.1 EN P2.6
D2 P0.2 WR P2.5
D3 P0.3
D4 P0.4
D5 P0.5
D6 P0.6
D7 P0.7
d. ADC MODULE
30
The other major components of the module are LM35
temperature sensor (for analogue input voltage) and
LM324 op-amp (for current and voltage amplification).
(i) SENSOR AND ANALOGUE INPUT CIRCUIT
Analog IN is a 3-pin terminal on the board and is readily
compatible for analogue input voltage through LM35
temperature sensor. The LM35 series are precision
integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius
(Centigrade) temperature. The output of the
temperature sensor is linear with slope
10mV / ºC.
31
HARDWARE DETAILS OF 8051ETK
Vo R
Gain = =1 + f
Vin Rin
Rf
5 =1 +
Rin
Rf
= 5 −1 = 4
Rin
32
HARDWARE DETAILS OF 8051ETK
12V
U2A
4
2
1
3
R3
R4
5 U2B
11
7 ADC IN
VCC 6
4
C7
Analog IN
R5
1 +
11
Vin 12V
2
3 _ Gain
+ C1
R2
33
HARDWARE DETAILS OF 8051ETK
(ii) ADC0804
The ADC0804 is an 8-bit, CMOS, successive
approximation analog to digital converter, which has a 0-
5V analogue input voltage range. It can be easily
interfaced to most microprocessors and microcontrollers.
It gives an 8-bit digital output with conversion time
<100micro-seconds.
The 8-bit Digital output from ADC is connected to the
Port 0 of the microcontroller. The control signals of ADC
i.e. WR (Start Conversion), INTR (End of Conversion) and
RD (Output Enable) are connected to P3.7, P3.6 and to
GND respectively. The functions of these control signals
are explained below.
34
(DB0-DB7) of the ADC. RD pin has been hardwired
to ground on the 8051ETK development board.
(c) INTR (End of Conversion): This is an output signal
from the ADC. At the end of conversion of a
particular analog voltage sample to the digital, the
INTR pin makes a high-to-low transition.
35
ADC ENB
ADC ENB >>
1
2
3
Port 1
8
7
6
5
4
3
2
1
VREF
VCC
20
U3 U4
7 18 1 40
Vin(-) lsbDB0 P1.0 Vcc
VccREF
17 2 39
DB1 P1.1 P0.0
ADC IN 6 16 3 38
Vin(+) DB2 P1.2 P0.1
<1.28 2.56> 15 4 37
DB3 P1.3 P0.2
14 5 36
DB4 P1.4 P0.3
1
2
3
8 13 6 35
A-GND DB5 P1.5 P0.4
12 7 34
DB6 P1.6 P0.5
1.28V 2.56V 11 8 33
msbDB7 P1.7 P0.6
9 RESET 9 32
Vref/2 RESET P0.7
5 RXD 10 31
INTR P3.0/RXD EA
TXD 11 30
R6 P3.1/TXD ALE
19 1 INT0 12 29
CLK-R CS P3.2/INT0 PSEN
2 INT1 13 28
RD P3.3/INT1 P2.7
4 3 T0 14 27
CLK-IN WR P3.4/T0 P2.6
T1 15 26
C6 P3.5/T1 P2.5
16 25
P3.6/WR P2.4
C15 17 24
P3.7/RD P2.3
18 23
XTAL1 P2.2
XTAL 19 22
XTAL2 P2.1
20 21
GND P2.0
C16
C8A C8B
Z3 Z1 Z2
36
These are three output control devices connected to the
port 2 of the microcontroller. This will give experience of
controlling / activating DC, AC and AC / DC loads. The
control devices are Triac, Darlington and Relay. The
connected load must not exceed the voltage/current
rating of the devices. The schematics, of these control
devices.
And its brief description is given in the succeeding
paragraph
12
V
VC R24 EXT
C PWR
P2.2 4N25
R25
P2.2 Q5
P2.1 4N25
P2.1 DAR
P2.0
HOT
P2.0 TRIG
MOC3041
AC Load
1
2
3
R29 PHASE
HOT
Triac
TRIG
LOAD 37
FIG 15: Triac Connections with optocoupler
(ii). Darlington Transistor (DC switch)
EXT PWR
R28
R27
DAR
DC Load
Darlington 1
2
3
1
2
3
R23
Relay B
12V VCC
Comparator HARDWARE DETAILS OF 8051ETK
1
2
9 LM324
COMP
4
Z4
LED
RP1
Ext Event1 Ext Event0 Ext INT1 Ext INT0
1
2
1
2
1
INT0
T1 T0 INT1 INT0
INT1
T0
T1
HARDWARE
FIG 19: (a) Push ButtonsDETAILS OF 8051ETK
(b) Jumpers for
External connections
40
h. Serial Communication Module
41
VCC
8 1
7 C10
5 3
9
4 C12 2 4
8 U1
3 5 C11
7
16
2 10
6 TXD 9 6
1 RXD
15 C13
RS232
HARDWARE DETAILS OF 8051ETK
FIG 20: DB9 Connector and
MAX232 IC
j. BUZZER
In 8051ETK board, BUZZER is connected to P3.5 of
the microcontroller for giving alarms and generating
tones of different frequencies depending on the
application. It is connected in active low configuration
i.e. it sounds by writing “0 “to the port pin in software
or by pressing push button T1 which results in
completing the circuit by connecting the negative
terminal of the buzzer to Ground. The schematic of
the buzzer circuit on 8051ETK board is shown in Fig-
21 .
VCC R10
BUZZER
+
T1
-
FIG 21: Buzzer
Interface
42
VIII. 8051ETK PROGRAMMER
43
8051ETK PROGRAMMER
44
A
T
M
E
AT AT
L
AT
8 8
9 9 8
8
9
C C
5 5 9
C
5
1 1 C
1
5
1
FIG 22: (a) Master Controller Inserted, (b) Target Controller inserted in the
showing the right
Direction of Target Controller Direction in the ZIF socket
45
IX. SOFTWARE
SOFTWARE
a) Keil Compiler
46
Keil µVision2 is an Integrated Development Environment
specifically designed to make it easier to get started with
application development. It is a GUI platform designed
for writing, compiling and simulating MCS-51 based
microcontroller applications. Codes can either be written
in C language or assembly language. The software
includes debugging modules which help the user test
applications. Users can simulate UART, I/O ports,
interrupts and timers etc. The 8051ETK CD contains Keil
µVision2 software and computer based tutorials.