You are on page 1of 73

BASIC ELECTRONIC COMPONENTS

Resistors

Capacitors
Inductors Diodes Integrated Circuits Transistor

Battery

RESISTOR
A resistor is a passive two-terminal electrical component that implements electrical resistance as a circuit element. A resistor is part of an electrical circuit that resists the flow of current. Limits and regulates the flow of current for a specific device. Resistor values are normally shown using coloured bands.

RESISTOR

CAPACITOR
A capacitor is a passive electronic component that stores energy in the form of an electrostatic field. A capacitor may be used with a resistor to produce a timer. An ideal capacitor is characterized by a single constant value, capacitance, measured in farads.

INDUCTOR
An inductor is a passive two-terminal electrical component that stores energy in its magnetic field. An inductor is usually made from a coil of conducting material, like copper wire, that is then wrapped around a core made from either air or a magnetic metal. Henry (symbol H) is the SI unit of Inductance.

DIODES
A diode is an electrical device allowing current to move through it in one direction with far greater ease than in the other. Two types: Signal diodes which pass small currents of 100mA or less Rectifier diodes which can pass large currents.

TYPES OF DIODE
PN junction diode Diode specifications Gunn diode IMPATT diode Laser diode Photo diode PIN diode Schottky barrier diode Step recovery diode Tunnel diode Varactor diode Zener diode Light emitting diode, LED

INTEGRATED CIRCUIT
Electronic circuit manufactured by the patterned diffusion of trace elements(semiconductor material). It is a semiconductor wafer on which thousands or millions of tiny resistors, capacitors, and transistors are fabricated on a single chip.

IC GENERATION
Small Scale Integration Medium Scale Integration Large scale Integration Very Large scale Integration Ultra Large scale Integration Wafer-Scale Integration System-On-a-Chip 3D-IC

TRANSISTOR
A transistor is a device used to amplify and switch electronic signals and power. Types of Transistor: By Structure: BJT JFET MOSFET, Etc By Electrical Polarity: NPN PNP

BATTERY
An electrical battery is one or more electrochemical cells that convert stored chemical energy into electrical energy. Categories Of Battery

Primary

Battery Secondary Battery.

EMBEDDED SYSTEM
Embedded system means the processor is embedded into that application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Exampleprinter, keyboard, video game player.

Microprocessor vs. Microcontroller


Microprocessor CPU is stand-alone, RAM, ROM, I/O, timer are separate designer can decide on the amount of ROM, RAM and I/O ports. expansive versatility general-purpose Microcontroller CPU, RAM, ROM, I/O and timer are all on a single chip fix amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical single-purpose

Three criteria in Choosing a Microcontroller


1.

meeting the computing needs of the task efficiently and cost effectively speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption easy to upgrade cost per unit availability of software development tools assemblers, debuggers, C compilers, emulator, simulator, technical support wide availability and reliable sources of the microcontrollers.

2.

3.

Why do we need to learn Microprocessors/Controllers?


The microprocessor is the core of computer systems. Nowadays many communication, digital entertainment, portable devices, are controlled by them. A designer should know what types of components he needs, ways to reduce production costs and product reliable.

Different aspects of a Microprocessor/Controller

Hardware :Interface to the real world

Software:order how to deal with inputs

The necessary tools for a Microprocessor/Controller


CPU: Central Processing Unit I/O: Input /Output Bus: Address bus & Data bus Memory: RAM & ROM Timer Interrupt Serial Port Parallel Port

MICROPROCESSOR:
General-purpose microprocessor

CPU for Computers No RAM, ROM, I/O on CPU chip itself ExampleIntels x86, Motorolas 680x0
Data Bus
Serial COM Port

CPU GeneralPurpose Microprocessor

RAM

ROM

I/O Port

Timer

Address Bus General-Purpose Microprocessor System

MICROCONTROLLER :
A smaller computer On-chip RAM, ROM, I/O ports... ExampleMotorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X.

CPU

RAM ROM

A single chip
I/O Port
Serial Timer COM Port Microcontroller

CONTENTS
General Physical Features Microcontroller Architecture Block Diagram Pin Description of the 8051 Registers Memory mapping in 8051 Stack in the 8051 I/O Port Programming Timer Interrupt

GENERAL PHYSICAL FEATURES


4KB ROM 128 bytes internal RAM

4 register banks of 8 bytes each (R0-R7) 16 bytes of bit-addressable area 80 bytes of general purpose memory
Four 8-bit I/O ports (P0-P3) Two 16-bit timers (Timer0 & Timer1) One serial receiver-transmitter interface Five interrupt sources (2 external & 3 internal) One oscillator (generates clock signal)

MICROCONTROLLER ARCHITECTURES

Architecture
Address Bus CPU Data Bus
2n Memory 0

Program + Data

Von Neumann Architecture

Address Bus
CPU Fetch Bus

Program

Address Bus 0 Data Bus Data

Harvard Architecture

8051 BLOCK DIAGRAM

Block diagram
4K byte ROM 128 byte RAM
Timer 1 Timer 0

External Interrupts Counter Inputs

Interrupt Control

CPU

OSC

Bus Control

I/O Ports

Serial Port

TXD RXD P0 P2 P1 P3 (Address/Data)

PIN DESCRIPTION

8051 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 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 VCC P0.0 P0.1 P0.2 P0.3 P0.4 (AD0) (AD1) (AD2) (AD3) (AD4)

8051

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)

PINS OF 8051
Vccpin

40 Vcc provides supply voltage to the chip. The voltage source is +5V. GNDpin 20ground XTAL1 and XTAL2pins 19,18 RSTpin 9reset It is an input pin and is active highnormally low. The high pulse must be high at least 2 machine cycles. It is a power-on reset.

PINS OF 8051
EApin 31external access There is no on-chip ROM in 8031 and 8032 . The EA pin is connected to GND to indicate the code is stored externally. PSEN ALE are used for external ROM. For 8051, EA pin is connected to Vcc. PSENpin 29program store enable This is an output pin and is connected to the OE pin of the ROM.

PINS OF 8051

ALEpin 30address latch enable It is an output pin and is active high. 8051 port 0 provides both address and data. The ALE pin is used for de-multiplexing.

= 0, it provides data D0 D7 When ALE = 1, it provides data A0 A7


When ALE

I/O port pins The four ports P0, P1, P2, and P3. Each port uses 8 pins. All I/O pins are bi-directional.

PINS OF 8051

The 8051 has four I/O ports Port 0 pins 32-39P0P0.0P0.7 Port 1pins 1-8 P1P1.0P1.7 Port 2pins 21-28P2P2.0P2.7 Port 3pins 10-17P3P3.0P3.7 Each port has 8 pins. Named P0.X X=0,1,...,7, P1.X, P2.X, P3.X ExP0.0 is the bit 0LSBof P0 ExP0.7 is the bit 7MSBof P0 These 8 bits form a byte. Each port can be used as input or output (bidirection).

PORT 3 Alternate Functions


P3 Bit
P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7

Function
RxD TxD INT0 INT1 T0 T1 WR RD

Pin
10 11 12 13 14 15 16 17

MACHINE CYCLE

Machine cycle is the basic repetitive process that the CPU performs once it is powered on. A machine cycle consists of a fixed number of clock cycles (pulses). It is different for different kinds of CPU. The 8051 family needs 12 clock cycles for a machine cycle. The CPU takes one or more machine cycles to complete an instruction. More complex instructions require more number of machine cycles to complete the instruction. The number of machine cycles of the 8051 instructions are ranging from 1 to 4.

REGISTER
A B R0 R1 R2 PC PC DPTR DPH DPL

R3
R4 R5 R6 R7 Some 8-bitt Registers of the 8051 Some 8051 16-bit Register

ACCUMULATOR (A Register)
Most versatile CPU register and is used for many operations, including addition, integer multiplication and division, and Boolean bit manipulations A register is also used for all data transfer between the 8051 and any external memory

B Register
B register is used with the A register for multiplication and division operations (eg. MUL AB DIV AB) No other special function other than as a location where data may be stored

FLAGS
Flags are 1-bit registers provided to store the results of certain program instructions Flags are grouped inside the program status word (PSW) and the power control (PCON) registers for convenient addressing Math flags: respond automatically to the outcomes of math operations (CY, AC, OV, P) User flags: general-purpose flags that may be used by the programmer to record some event in the program (F0, GF0, GF1)

Program Status Word (PSW)

PSW contains the math flags, user program flag F0, and the register select bits (RS1, RS0) that identify which of the four general-purpose register banks is currently in use by the program
7 CY 6 AC 5 4 3 2 F0 RS1 RS0 OV 1 -0 P

INTERNAL MEMORY
A functioning computer must have memory for program code bytes, commonly in ROM, and RAM memory for variable data that can be altered as the program runs 8051 has internal RAM (128 bytes) and ROM (4Kbytes) 8051 uses the same address but in different memories for code and data Internal circuitry access the correct memory based on the nature of the operation in progress Can add memory externally if needed

Memory mapping in 8051


ROM memory map in 8051 family
0000H 0000H

0000H

0FFFH

1FFFH 8751 AT89C51 8752 AT89C52 7FFFH

RAM memory space allocation in the 8051


7FH Scratch pad RAM

30H 2FH Bit-Addressable RAM

20H
1FH 18H 17H 10H 0FH 08H 07H 00H Register Bank 2 (Stack) Register Bank 1

Register Bank 3

Register Bank 0

Stack and Stack Pointer (SP)


SP is a 8-bit register used to hold an internal RAM address that is called the top of the stack SP holds the internal RAM address where the last byte of data was stored by a stack operation When data is to be placed on the stack, the SP increments before storing data on the stack so that the stack grows up as data is stored SP = 07H after reset

Stack Operation
SP = 0A
Store Data Get Data

Address 0A
Get Data

SP = 0A

SP = 09

Store Data

Address 09
Get Data

SP = 09

SP = 08

Store Data

Address 08

SP = 08

SP = 07
Storing Data on the Stack (Increment then store)

Address 07 Internal RAM (Get then decrement)

SP = 07
Getting Data From the Stack

Special Function Registers (SFR)


8051 has 21 SFRs which occupy the addresses from 80H to FFH (128bytes) Not all of the addresses from 80H to FFH are used for SFRs Attempt to use the empty addresses may get unpredictable result

Read-Modify-Write Feature
A method used to access the 8051 ports Combining all 3 actions in a single instructions : Read the data at the port Modify (do operation on) the data at the port Write the results to the port

TIMER
TCON Register

Gate : When set, timer only runs while INT(0,1) is high. C/T : Counter/Timer select bit. M1 : Mode bit 1. M0 : Mode bit 0.

TIMER/COUNTER

8051 has two 16-bit Timer/Counter registers


Timer/Counter 0 Timer/Counter 1

These registers can be used as timers or as event counters When a register is in Timer state, it is incremented every machine cycle In Counter state, the register is incremented when there is a 1-to-0 transition at its external input pin, pin T0 or T1 Both registers have additional four operating modes

INTERRUPT

EA : Global enable/disable. --: Undefined. ET2 :Enable Timer 2 interrupt. ES :Enable Serial port interrupt. ET1 :Enable Timer 1 interrupt. EX1 :Enable External 1 interrupt. ET0 : Enable Timer 0 interrupt. EX0 : Enable External 0 interrupt

Numerical Bases Used in Programming


(43)10 (0100 0011)BCD

( 0010 1011 )2
( 2 B )16

Assembler Directives

DATA

Used to define a name for memory locations


SP DATA 0x81 ;special function registers MY_VAL DATA 0x44 ;RAM location

EQU Used to create symbols that can be used to represent registers, numbers, and addresses
LIMIT EQU 2000 VALUE EQU LIMIT 200 + 'A' SERIAL EQU SBUF COUNT EQU R5 MY_VAL EQU 0x44

Data Transfer Instructions


MOV dest, source 6 basic types: MOV a, byte MOV byte, a MOV Rn, byte dest source

;move byte to accumulator ;move accumulator to byte ;move byte to register of ;current bank MOV direct, byte ;move byte to internal RAM MOV @Rn, byte ;move byte to internal RAM ;with address contained in Rn MOV DPTR, data16 ;move 16-bit data into data ;pointer Stack instructions PUSH byte ;increment stack pointer, ;movebyte on stack POP byte ;move from stack to byte, ;decrement stack pointer

ADDRESSING MODES
Immediate Mode specify data by its value mov a, #0 ;put 0 in the accumulator a = 00000000 Direct Mode specify data by its 8-bit address mov a, 0x70 ; copy contents of RAM at 70h to a Register Addressing either source or destination is one of R0-R7 Register Indirect the address of the source or destination is specified in registers Register Indexed Mode source or destination address is the sum of the base address and the accumulator.

INSTRUCTION SET
Arithmetic
Mnemonic
ADD A, byte ADDC A, byte SUBB A, byte INC A INC byte INC DPTR DEC A DEC byte MUL AB DIV AB DA A

Instructions

INSTRUCTION SET

Logic Instructions Bitwise logic operations (AND, OR, XOR, NOT, CPL) Clear Rotate Swap CLR - clear RL rotate left RLC rotate left through Carry RR rotate right RRC rotate right through Carry SWAP swap accumulator nibbles OTHER INSTRUCTION SET Jump Loop Call Return

Structure of Assembly language and Running an 8051 program


EDITOR PROGRAM

Myfile.asm
ASSEMBLER PROGRAM Myfile.lst Other obj file Myfile.obj LINKER PROGRAM

OH PROGRAM

Myfile.hex

Serial Port (UART)

Original 8051 had one serial port


TX (transmit)

Serial Port

RX (receive)

Data sent and received serially BAUD rate must agree between sender and receiver Transmission modes selected using SFR

PROJECTS
Circuit designing ALU LCD interface Keypad interface 7-Segment interface Sensor and Driver Circuit

VOLTAGE DIVIDER

RECTIFIER

ENCODER & DECODER

LCD-KEYPAD INTERFACE

7 SEGMENT-KEYPAD INTERFACE

LED-KEYPAD INTERFACE

SERVO MOTOR INTERFACE

MOTOR AND SENSOR INTERFACE

Electronic Code Lock System With User Defined Password Using Micro Controller

Automatic bidirectional visitor counter using Micro Controller

LCD based Voting machine using Micro Controller

8 Candidate Quiz Buzzer Using Micro Controller

RFID based Secured Access System

Electronic Voting Machine Using 7-Segment Multiplexing

RFID Based Toll Plaza System

Interfacing Stepper Motor with Micro Controller

You might also like