Embedded Systems Using 8051 Microcontroller
Embedded Systems Using 8051 Microcontroller
VINEET CHACHRA UNIVERSITY INSTITUTE OF ENGINEERING AND TECHNOLOGY MAHARSHI DAYANAND UNIVERSITY , ROHTAK
WHAT IS A MICROCONTROLLER?
A microcontroller can be called as a computer on chip. It consists of on-chip RAM,ROM, I/O ports Examples: Intels 8051,Motorolas 6811, Zilogs Z8, Atmels AT89C51
CPU RAM ROM
A single chip
Microcontroller
WHAT IS A MICROPROCESSOR?
A general purpose digital computer CPU. No RAM,ROM,I/O on CPU chip itself. Examples: Intels x86,Motorolas 680x0.
Data Bus
RAM
ROM
I/O Port
Timer
Microprocessor Microprocessor CPU is stand alone. RAM,ROM,I/O are separate. Designer can decide on amount of RAM, ROM. General purpose and versatile. Unique pins.
Microcontroller Microcontroller CPU,RAM, ROM,I/O on single chip. Fixed amount of RAM,ROM. Specific purpose generally having fixed programs Programmable pins.
EMBEDDED SYSTEMS
An embedded system is a special-purpose computer system designed to perform one or few designated functions, often with real time computing constraints. It is usually embedded as a part of complete device including hardware and mechanical parts. Since an embedded system is dedicated to specific tasks, they are optimized and hence mass produced. Processing function is done by a microcontroller or microprocessor.
8-bit data bus and 16-bit address bus. 128 bytes on-chip RAM. 4 k bytes on-chip ROM. Four byte bi-directional input/output ports. 4 parallel and one serial port. Two 16 bit counter/timers ,4 flags and on chip clock oscillator. Two-level interrupt priority with 6 interrupt sources.. 16 bytes of addressable and 80 bytes of general purpose memory.
BLOCK DIAGRAM
External interrupts Interrupt Control On-chip ROM for program code
Timer/Counter
On-chip RAM
Timer 1 Timer 0
Counter Inputs
CPU
Serial Port
OSC
Bus Control
4 I/O Ports
P0 P1 P2 P3
TxD RxD
Address/Data
PIN DIAGRAM
P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD)P3.0 (TXD)P3.1 (INT0)P3.2 (INT1)P3.3 (T0)P3.4 (T1)P3.5 (WR)P3.6 (RD)P3.7 XTAL2 XTAL1 GND
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
8051
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8)
8051 CLOCK
A quartz crystal oscillator connected at pins XTAL1 and XTAL2. The circuit shown below generates a pulse train at the frequency of crystal.
Time of an instruction: Tinst = C x 12d crystal frequency Where c= no. of cycles
INTERFACING OF LED
LEDs are generally connected at port 0 of 8051 i.e. p0.0-p0.8. From 0-0.5volts logic 0 i.e. LED glows. From 3-5volts logic 1 i.e. LED is off.
INTERFACING OF RELAY
A relay is an electromechanical switch. Depending upon contact types it can be: one C/O(change over),2 C/O,3C/O or 4 C/O. Connected on port 2 of 8051.
INTERFACING OF DC MOTORS
Motor could be dc series, dc shunt, pmdc or stepper motor. Ports p2.2 and p2.3 as alternate high and low for PMDC and p2.4 to p2.7 for stepper motor.
INTERFACING OF TIMER/COUNTER
The 8051 has two timers, TIMER0 and TIMER1 registers. Both can be used as either timer for internal pulse counting and as counter for external pulse counting. SFR TCON used to control the timer operation and TMOD used to select the timer mode i.e. (a). Mode 0 13-bit timer mode. 8192 pulses (b). Mode 1 16-bit timer mode. 65536 pulses (c). Mode 2 - 8-bit timer mode. 256 pulses (d). Mode 3 8-bit split timer mode.
INTERFACING OF OPTO-COUPLER
An opto-coupler is used to provide a short optical transmission path to transfer a signal b/w elements of a circuit while transmitter and receiver are electrically isolated. It consists of a LED and a transistor. Port pins P1.7 and p3.2 are used.
INTERFACING OF PIEZO-BUZZER
A buzzer is made of piezo-electric crystals. It produces oscillation when electric field is applied to its terminals. Since the oscillation are in audible range i.e. 20Hz to 20KHz, a alarm sound gets generated. It is connected with pin p1.6 of microcontroller. When it is set i.e. value is one a sound is generated.
INTERFACING OF LCD
A liquid crystal display (LCD) is an electronically modulated optical amplification shaped into a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source (backlight) or reflector. LCD can be classified as: a. Graphics LCD b. Character LCD c. LCD with controller
The LCD memory has two 8-bit registers: Instruction Register and Data Register. The IR stores instruction codes and address information for DRAM and CGRAM. While the DR temporarily stores data to be written into DDRAM or CGRAM.
The pins of LCD are : o Data pins D0-D7. o Register select pin RS. When RS=0 command register selected. When RS =1 data register is selected. oRead or write pin R/W. When R/W=0 write and when R/W =1 read function created. o Enable pin E. A high to low edge needed to latch the data. oContrast control pin VEE. Used to control contrast voltage.
LCDs internal controller accepts several commands to modify the display accordingly. e.g. 38h 8-bit interface, 5*7 pixels. 01h clear screen. 1Eh - scroll display one character right.
Features: 1. Easy interface with 8-bit analog channel. 2. Uses successive approximation(SAR) as conversion technique. 3. TTL voltage level specifications with 28-pin dip package. 4. Thus can produce numbers 0 through 255.
PROJECT ASSIGNED:
Microcontroller AT89C2051
DTMF Encoder
RF Signal Transmitter
Key Pad
Block Diagram of Transmitter
WORKING:
The key pressed by the user is read by the microcontroller. The key value is send to the DTMF (Dual Tone Multi-Frequency) encoder. The encoder generates voice tone for that particular key value. The Tone is modulated (FM) with Carrier Frequency (433MHZ) and transmitted using RF module.
(B)RECIEVER:
The receiver design is based on ATMEL AT89C51 microcontroller. The Microcontroller is used as the master in the receiver end which is used to control all the devices. It decodes the Signal from the transmitter and control the relays according to the signal. It is designed in such way to control different equipment /appliance using relays. Also this receiver can produce a variable Power source, which can be used to vary the speed of any motor/fan . The block diagram of the receiver is shown next.
RF Signal Receiver
DTMF Decoder
Microcontroller AT89C51
Relays
LOAD
Trigger Mains Step-dow n voltage Zero Crossing Detector Phase Ref erence TRIAC Mains 230V A C
WORKING:
The RF signal transmitted by remote control is received by RF receiver module. The output of the RF Receiver will be DTMF signal. This DTMF signal is decoded and the binary value is generated using the decoder. The AT89C51 microcontroller gets the signal from the DTMF decoder and based on the information the microcontroller changes the output status of the relays. The controller does not drive the relays. So the relay driver circuitry is implemented in between the microcontroller and relays. The microcontroller can also vary the power applied to the motor / Fan by varying the firing angle of a TRIAC. The information about varying the motor power is read from the remote controller.