Professional Documents
Culture Documents
AND
ITS APPLICATION
WORKSHOP
Noman Ahmed
Lecturer
SSUET
E-mail: noman_sid@hotmail.com
Introduction
It is hard to imagine the present world of electronic devices without the
microprocessor.
Cash register, scales, ovens, washing machine, alarm clock, thermostats,
1976 (Microcontrollers)
Intel 8748 (MCS-48 family) 17,000 transistors
• CPU, 1KB EPROM, 64B RAM, 27 I/O pins, and an 8-bit timer.
• Used in washing machines and traffic light controllers.
1980 (Microcontrollers)
Intel 8051 (MCS-51 family) 60,000 transistors
• CPU, 4KB ROM, 128B RAM, 32 I/O Pins, a serial port, two 16-bit
timers.
A Computer System
Computer is defined by two key traits:
The ability to be programmed to operate on data without human
intervention.
The ability to store and retrieve data.
(RAM) and read-only memory (ROM) via the address bus, data bus,
and control bus. Interface circuits connect the system buses to
peripheral devices. (see next slide)
Block Diagram of Computer System
What’s a Microcontroller?
A Microcontroller is a computer-on-a-chip, or, if you prefer, a
single-chip computer. Micro suggests that the device is small, and
controller tells you that the device might be used to control objects,
processes, or events.
Application
Automobiles
Security System
Answering Machine
Cellular Phone
Microwave
Keyless entry
Fax machine
Toys
Camera
Microprocessors vs. Microcontroller
Hardware Achitecture
Whereas a microprocessor is a single-chip CPU, a
(cont.)
Instruction set features
Microprocessor instruction sets are ‘processing intensive’
implying they have powerful addressing modes with
instructions catering to operations on large volumes of data.
Microcontrollers, on the other hand, have instruction sets
catering to the control of inputs and outputs.
Microcontrollers have built-in circuitry and instructions for
input/output operations, event timing, and enabling and
setting priority levels for interrupts caused by external stimuli.
Microprocessors often require additional circuitry (serial
interface Ics, interrupt controllers, timers, etc. ) to perform
similar operations.
Hardware Architecture
The MCS-51 is a family of microcontroller ICs developed, manufactured, and
marketed by Intel. Other IC manufacturers are
Siemens, Advanced Micro Devices (AMD), Fujitsu, Philips are licensed ‘second
Serial interface
Boolean processor
8031 128B 2
8032 256B 3
Timer 1
Timer 0
Serial port
Timer 1 T1
Interrupt Other 128B RAM 4KB
Control registers ROM Timer 0 T0
CPU
In minimum-component designs,
Port 2
Is a dual-purpose port on pins 21-28 of the 8051 IC.
Or as the high-byte of the address bus for designs with external ROM or more than 256B
of RAM.
I/O Ports (cont.)
Port 3
Is a dual-purpose port on pins 10-17 of the 8051 IC.
These pins are multifunctional, with each having an alternate purpose related to special features of
the 8051.
The PSEN signal pulses low (active stage) during the fetch stage of an instruction,
which is stored in external program memory.
The binary codes of a program (opcode) are read from EPROM, travel across the
data bus, and are latched into the 8051’s instruction register (IR) for decoding.
Control Signals
ALE (Address Latch Enable)
When port 0 is used in its alternate mode – as the data bus and low-byte of the
address bus – ALE is the signal that latches the address into an external register
during the first-half of a memory cycle. This done, the port 0 lines are then
available for data input or output during the second-half of the memory cycle.
If high
• The 8051 executes programs from internal ROM when executing in the lower
4K/8K of memory.
If low
• Programs execute from external memory only (and PSEN pulses low)
RST (Reset)
Is an input signal on pin 9.
When this signal is brought high for at least 2 machine cycles, the 8051 internal
registers are loaded with appropriate values for an orderly system start-up.
For normal operation, RST is low.
Memory Organization
Most microprocessors implement a shared memory apace for data
and programs. Both the data and programs reside in the system
RAM. Microcontroller, on the other hand, the control program must
reside in ROM.
30
2F Special Function
Bit-addressable Registers (SFR)
locations (16 bytes)
20
1F Bank registers
(32 bytes)
00 80
General-Purpose RAM
7F
General-purpose Ex: To read the contents of
RAM (80 bytes)
internal RAM address 5FH into
the accumulator.
30
2F Solution1:(direct address mode)
MOV A, 5FH
Solution2:(immediate addressing &
indirect address mode)
20 MOV R0, #5FH
1F Bank registers
(32 bytes) MOV A, @R0
00
210 (128+82) Bit-Addressable RAM
7F FF
The idea of
individually
accessing bits
30
Special Function through software
2F
Bit-addressable Registers (SFR) is a powerful
locations (16 bytes) (82 bits) feature of most
(128 bits) microcontroller.
20
1F
00 80
128 General-Purpose
Bit-Addressable Locations
2F 7F 7E 7D 7C 7B 7A 79 78
2E 77 76 75 74 73 72 71 70
2D 6F 6E 6D 6C 6B 6A 69 68
2C 67 66 65 64 63 62 61 60
2B 5F 5E 5D 5C 5B 5A 59 58
2A 57 56 55 54 53 52 51 50
29 4F 4E 4D 4C 4B 4A 49 48
28 47 46 45 44 43 42 41 40
27 3F 3E 3D 3C 3B 3A 39 38
26 37 36 35 34 33 32 31 30
25 2F 2E 2D 2C 2B 2A 29 28
24 27 26 25 24 23 22 21 20
23 1F 1E 1D 1C 1B 1A 19 18
22 17 16 15 14 13 12 11 10
21 0F 0E 0D 0C 0B 0A 09 08
20 07 06 05 04 03 02 01 00
Register Banks
1F R7
18 ~R0 Bank 3 (8 bytes)
17 R7
Bank 2 (8 bytes)
10 ~R0
0F R7
Bank 1 (8 bytes)
08 ~R0
07 R7 Bank 0 (8 bytes)
00 ~R0
These are the typical methods through which processor systems access
memory.
Arithmetic Instructions
Logical Instructions
Boolean Instructions
P2.0
P2.1
P2.2
Temperature Sensor
Physical data
(temperature, light, Output Electrical
flow, speed, and Transducers Signals (current,
etc.) (Sensors) voltage, resistance,
capacitance, and
etc.)
o
C K Ohm
Thermistor
0 29.49
Temperature Resistance 25 10
50 3.893
75 1.7
100 0.817
Interfacing of ADC808/809
ADC808/809 Chip with 8 analog channel. This means this kind of chip
allows to monitor 8 different transducers.
ADC804 has only ONE analog input: Vin(+).
ADC808
D0 ~ D7
8 channels
(IN0~IN7)
GND channel CBA
CLK EOC IN0 000
VCC OE IN1 001
Vref(+) IN2 010
Vref(-) IN3 011
SC ALE C BA IN4 100
IN5 101
IN6 110
IN7 111
Interfacing of Stepper Motor
Stepper motor translates electrical pulses into mechanical movement (for
position control).
Applications: Disk Driver, Dot matrix printer, robotics.
A 4 Step Sequences
N S
Step A B C D
C S N D
s
S
1 1 0 0 1
N
B 2 1 1 0 0
3 0 1 1 0
4 0 0 1 1
Interfacing of Keyboard
Keyboard and LCDs are the most widely used input/output devices
of the 8051, and a basic understanding of them is essential.
See Figure
Project Steps
Putting together a microcontroller project involves
several steps:
1. Define the task
2. Design and build the circuits
3. Write the control program
4. Test and debug