theory

150
Monday, June 6, 20 Monday, June 6, 20 22 22 WELCOME WELCOME

Upload: kallipavankumar

Post on 26-Oct-2014

40 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Theory

Friday, April 7, 2023Friday, April 7, 2023

WELCOMEWELCOME

Page 2: Theory

Friday, April 7, 2023Friday, April 7, 2023

BASIC ELECTRICAL AND BASIC ELECTRICAL AND ELECTRONIC COMPONENTSELECTRONIC COMPONENTS

• RESISTORSRESISTORS• DIODESDIODES• CAPACITORSCAPACITORS• INDUCTORSINDUCTORS• TRANSISTORSTRANSISTORS• BATTERYBATTERY• TRANSFORMERTRANSFORMER• VOLTAGE REGULATORSVOLTAGE REGULATORS• LDR (LIGHT DEPENDENT RESISTOR)LDR (LIGHT DEPENDENT RESISTOR)• RELAYSRELAYS

Page 3: Theory

Friday, April 7, 2023Friday, April 7, 2023

The first band gives the first digitThe first band gives the first digit The second band gives the second digit The second band gives the second digit The third band indicates the number of The third band indicates the number of zeroes.zeroes.

RESISTOR:

A resistor is a device which opposes the flow of current.

Page 4: Theory

Friday, April 7, 2023Friday, April 7, 2023

ColourColour NumberNumber

BlackBlack 00BrownBrown 11

RedRed 22

OrangeOrange 33

YellowYellow 44

GreenGreen 55

BlueBlue 66

VioletViolet 77

GreyGrey 88

WhiteWhite 99

Page 5: Theory

Friday, April 7, 2023Friday, April 7, 2023

DIODE:

A Diode is a two terminal electronic component that conducts electric current only in one direction.

Based on applications diodes are divided into two types

-> PN junction

-> ZENER diode

Page 6: Theory

Friday, April 7, 2023Friday, April 7, 2023

PN junction diode: The most common function of a diode is to

allow an electric current in one direction (called the forward direction) while blocking current in the opposite direction (the reverse direction).

Page 7: Theory

Friday, April 7, 2023Friday, April 7, 2023

ZENER DIODE:ZENER DIODE:

A Zener diode is a type of diode that permits current in the forward direction like a normal diode, but also in the reverse direction if the voltage is larger than the breakdown voltage known as "Zener knee voltage" or "Zener voltage".

Page 8: Theory

Friday, April 7, 2023Friday, April 7, 2023

LIGHT EMITTING DIODE (LED)LIGHT EMITTING DIODE (LED)

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices, and are increasingly used for lighting.

k

A

Page 9: Theory

Friday, April 7, 2023Friday, April 7, 2023

capacitors easily pass AC (changing) signals.

capacitor block DC (constant) signals.

s

CAPACITOR:

Page 10: Theory

Friday, April 7, 2023Friday, April 7, 2023

INDUCTOR:INDUCTOR:• An inductor or a reactor can store energy in a

magnetic field created by the electric current passing through it. It is denoted in Henry.

• Typically an inductor is a conducting wire shaped as a coil, the loops helping to create a strong magnetic field inside the coil due to Faraday's Law of Induction.

Page 11: Theory

Friday, April 7, 2023Friday, April 7, 2023

TRANSISTORS:A transistor is a semi conductor device commonly used to amplify or switch electronic signals. A voltage or current applied to one pair of the transistor's terminals changes the current flowing through another pair of terminals. Because the controlled (output) power can be much more than the controlling (input) power, the transistor provides amplification of a signal.

Page 12: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 13: Theory

Friday, April 7, 2023Friday, April 7, 2023

Transformer:Transformer:

Page 14: Theory

Friday, April 7, 2023Friday, April 7, 2023

VOLTAGE REGULATOR:VOLTAGE REGULATOR:

• A voltage regulator is an electrical regulator designed A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level.to automatically maintain a constant voltage level.

• It may use an electromechanical mechanism, or It may use an electromechanical mechanism, or passive or active electronic components. Depending passive or active electronic components. Depending on the design, it may be used to regulate one or more on the design, it may be used to regulate one or more AC or DC voltages.AC or DC voltages.

Page 15: Theory

Friday, April 7, 2023Friday, April 7, 2023

The voltage regulators are classified into two types.The voltage regulators are classified into two types.

positive series(7805)positive series(7805)

negative series(7905)negative series(7905)

7805

I/P GND O/P

7805SERIES Output

voltage

7905

I/P O/PGND

Page 16: Theory

Friday, April 7, 2023Friday, April 7, 2023

Light Dependent Resistor (LDR):Light Dependent Resistor (LDR):

An LDR is an input transducer (sensor) which converts brightness (light) to resistance. It is made from cadmium sulphide (CdS) and the resistance decreases as the brightness of light falling on the LDR increases.

Page 17: Theory

Friday, April 7, 2023Friday, April 7, 2023

RELAY:

A Relay is an electrically controllable switch widely used in industrial controls, automobiles, etc…

inductor

Page 18: Theory

Friday, April 7, 2023Friday, April 7, 2023

OPERATION OF RELAY:OPERATION OF RELAY:

• The relay's switch connections are usually labeled COM, NC and NO:

• COM = Common, always connect to this, it is the moving part of the switch.

• NC = Normally Closed, COM is connected to this when the relay coil is off.

• NO = Normally Open, COM is connected to this when the relay coil is on.

• Connect to COM and NO if you want the switched circuit to be on when the relay coil is on.

• Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

Page 19: Theory

Friday, April 7, 2023Friday, April 7, 2023

N/C

COM

N/O

AC230V

BULB

IND

UC

TO

R

IRONARM

ON

OFF

Diagrammatic explanation:Diagrammatic explanation:

Page 20: Theory

Friday, April 7, 2023Friday, April 7, 2023

WINE YARDT E C H N O L O G I E S

REGULATED POWER SUPPLY:

Page 21: Theory

Friday, April 7, 2023Friday, April 7, 2023

7812

7805

C1

C2

5V

12V

REGULATED POWER SUPPLY CIRCUIT:

C

C=1000uF C1,C2=104pF R1,R2=330

R1

R2

Page 22: Theory

Friday, April 7, 2023Friday, April 7, 2023

RECTIFIER:RECTIFIER:

• The primary application of rectifiers is to derive usable DC power from an AC supply. Virtually all electronics except simple motor circuits such as fans require a DC supply but mains power is AC so rectifiers find uses inside the power supplies of virtually all electronic equipment.

Page 23: Theory

Friday, April 7, 2023Friday, April 7, 2023

FILTERS:• Electronic filters are electronic circuits which

perform signal processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both.

RECTIFIER OUTPUT

FILTER PURE DC

AC+DC DC

AC

Page 24: Theory

Friday, April 7, 2023Friday, April 7, 2023

How the Transistor act as a switch ?How the Transistor act as a switch ?

what is a transistor?

A transistor is a semi conductor device commonly used to amplify or switch electronic signals.

Page 25: Theory

Friday, April 7, 2023Friday, April 7, 2023

What is a switch?What is a switch?

In electronics, a switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another.

Page 26: Theory

Friday, April 7, 2023Friday, April 7, 2023

Transistor as a switch:Transistor as a switch:

• Transistor can be used as an electronic switch, in grounded-emitter configuration.

• Transistors are commonly used as electronic switches, for both high power applications including switched mode power supply and low power applications such as logic gates.

Page 27: Theory

Friday, April 7, 2023Friday, April 7, 2023

• In a grounded-emitter transistor circuit, such as the light-switch circuit shown, as the base voltage rises the base and collector current rise exponentially, and the collector voltage drops because of the collector load resistor.

• If the emitter-base and base-collector are in forward bias then it act as a switch.

• At that instant the collector to emitter is shorted, it act as a closed switch.

Page 28: Theory

Friday, April 7, 2023Friday, April 7, 2023

N/C

COM

N/O

LDR

100KPRESET

Vcc

relay

330

LED

LIGHT VB<0.7V

T-OFF

NOLIGHT

VB>0.7VT-ON

R

LOAD

Transistor as a switch

example

Page 29: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 30: Theory

Friday, April 7, 2023Friday, April 7, 2023

• In general, "embedded system" is not a strictly

definable term, as most systems have some

element of extensibility or programmability.

• For example, handheld computers share some

elements with embedded systems such as the

operating systems and microprocessors which

power them, but they allow different

applications to be loaded and peripherals to

be connected or a few dedicated functions",

and is thus appropriate to call "embedded".

Page 31: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Moreover, even systems which don't expose

programmability as a primary feature

generally need to support software updates.

On a continuum from "general purpose" to

"embedded", large application systems will

have subcomponents at most points even if

the system as a whole is "designed to

perform one or a few dedicated functions",

and is thus appropriate to call "embedded".

Page 32: Theory

Friday, April 7, 2023Friday, April 7, 2023

Embedded systemEmbedded system• An embedded system is a special purpose computer An embedded system is a special purpose computer

system designed to perform one or a few dedicated system designed to perform one or a few dedicated functions, often with real time computing functions, often with real time computing constraints.constraints.

• It is usually embedded as part of a complete device It is usually embedded as part of a complete device including hardware and mechanical parts.including hardware and mechanical parts.

• Since the embedded system is dedicated to specific Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the size and cost of the product, or increasing the reliability and performance.reliability and performance.

• Embedded systems span all aspects of modern life.Embedded systems span all aspects of modern life.

Page 33: Theory

Friday, April 7, 2023Friday, April 7, 2023

Characteristics:Characteristics:

• Embedded systems are designed to do some specific Embedded systems are designed to do some specific task, rather than be a general-purpose computer for task, rather than be a general-purpose computer for multiple tasks. multiple tasks.

• Embedded systems are not always standalone devices. Embedded systems are not always standalone devices. Many embedded systems consist of small, Many embedded systems consist of small, computerized parts within a larger device that serves computerized parts within a larger device that serves a more general purpose. a more general purpose.

• The program instructions written for embedded The program instructions written for embedded systems are referred to as firmware, and are stored in systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. read-only memory or Flash memory chips.

Page 34: Theory

Friday, April 7, 2023Friday, April 7, 2023

Applications:Applications:

• TelecommunicationsTelecommunications

• Consumer electronics like PDA’s, mp3 players, Consumer electronics like PDA’s, mp3 players, mobile phones, digital cameras, DVD's, ovens, mobile phones, digital cameras, DVD's, ovens, washing machine, to control lights, to provide washing machine, to control lights, to provide security, climate, etc..security, climate, etc..

Page 35: Theory

Friday, April 7, 2023Friday, April 7, 2023

User InterfaceUser Interface

• Embedded systems range from no user Embedded systems range from no user

interface at all — dedicated only to one task — interface at all — dedicated only to one task —

to complex graphical user interfaces that to complex graphical user interfaces that

resemble modern computer desktop operating resemble modern computer desktop operating

systems.systems.

• Simple embedded devices use buttons, LEDs, Simple embedded devices use buttons, LEDs,

graphic or character LCDs (for example popular graphic or character LCDs (for example popular

HD44780 LCD) with a simple menu system.HD44780 LCD) with a simple menu system.

Page 36: Theory

Friday, April 7, 2023Friday, April 7, 2023

• A more sophisticated devices use graphical A more sophisticated devices use graphical

screen with touch sensing or screen-edge screen with touch sensing or screen-edge

buttons provide flexibility while minimizing buttons provide flexibility while minimizing

space used: the meaning of the buttons space used: the meaning of the buttons

can change with the screen, and selection can change with the screen, and selection

involves the natural behavior of pointing at involves the natural behavior of pointing at

what's desired. what's desired.

Page 37: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Serial Communication Interfaces (SCI): RS-Serial Communication Interfaces (SCI): RS-

232, RS-422, RS-485 etc232, RS-422, RS-485 etc

• Synchronous Serial Communication Synchronous Serial Communication

Interface: I2C, SPI, SSC and ESSI (Enhanced Interface: I2C, SPI, SSC and ESSI (Enhanced

Synchronous Serial Interface)Synchronous Serial Interface)

• Universal Serial Bus (USB)Universal Serial Bus (USB)

• Multi Media Cards (SD Cards, Compact Flash Multi Media Cards (SD Cards, Compact Flash

etc)etc)

Peripherals

Page 38: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Networks: Ethernet, Controller Area Network, Networks: Ethernet, Controller Area Network,

LanWorks, etcLanWorks, etc

• Timers: PLL(s), Capture/Compare and Time Timers: PLL(s), Capture/Compare and Time

Processing UnitsProcessing Units

• Discrete IO: aka General Purpose Input/Output Discrete IO: aka General Purpose Input/Output

(GPIO)(GPIO)

• Analog to Digital/Digital to Analog (ADC/DAC)Analog to Digital/Digital to Analog (ADC/DAC)

• Debugging: JTAG, ISP, ICSP, BDM Port, BITP DP9 Debugging: JTAG, ISP, ICSP, BDM Port, BITP DP9

port …port …

Peripherals

Page 39: Theory

Friday, April 7, 2023Friday, April 7, 2023

• 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.

• Example: printer, keyboard, video game player.

Overview of Embedded System

Page 40: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 41: Theory

Friday, April 7, 2023Friday, April 7, 2023

ContentsContentsIntroductionIntroductionBlock Diagram and Block Diagram and Pin Pin Description of the 8051Description of the 8051I/O Port DescriptionI/O Port DescriptionLed InterfacingLed InterfacingSwitch InterfacingSwitch InterfacingLed And switch InterfacingLed And switch InterfacingLCD InterfacingLCD InterfacingSerial communicationSerial communicationRelay InterfacingRelay Interfacing

Page 42: Theory

Friday, April 7, 2023Friday, April 7, 2023

Why do we need to learn Why do we need to learn Microprocessors/controllers?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..

Page 43: Theory

Friday, April 7, 2023Friday, April 7, 2023

Aspects of a microprocessor/controller• Hardware : Interface to the real world. Ex- LCD, LED,

printers, keyboard etc.

• Software : order how to deal with inputs. By using

software we can control the hardware to obtain the desired outputs.

Page 44: Theory

Friday, April 7, 2023Friday, April 7, 2023

Tools for a microprocessor/controller: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

Page 45: Theory

Friday, April 7, 2023Friday, April 7, 2023

CPU

General-Purpose Micro-processor

RAM ROM I/O Port

TimerSerial COM Port

Data Bus

Address Bus

General-Purpose Microprocessor System

• CPU for Computers.

• No RAM, ROM, I/O on CPU chip itself.

• Example: Intel's x86, Motorola’s 680x0.Many chips on mother’s board

General-purpose microprocessor:

Microprocessors:Microprocessors:

Page 46: Theory

Friday, April 7, 2023Friday, April 7, 2023

RAM ROM

I/O Port

TimerSerial COM Port

Microcontroller

CPU

• A smaller computer.• On-chip RAM, ROM, I/O ports...• Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and

PIC 16X.

A single chip

Microcontroller:

Page 47: Theory

Friday, April 7, 2023Friday, April 7, 2023

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

Microprocessor vs Microcontroller

Page 48: Theory

Friday, April 7, 2023Friday, April 7, 2023

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

2. Availability of software development tools• assemblers, debuggers, C compilers, emulator,

simulator, technical support3. Wide availability and reliable sources of the

microcontrollers.

Three criteria in Choosing a Microcontroller:

Page 49: Theory

Friday, April 7, 2023Friday, April 7, 2023

Block Diagram:Block Diagram:

CPU

On-chip RAM

On-chip ROM for program code

4 I/O Ports

Timer 0

Serial PortOSC

Interrupt Control

External interrupts

Timer 1

Timer/Counter

Bus Control

TxD RxDP0 P1 P2 P3

Address/Data

Counter Inputs

Page 50: Theory

Friday, April 7, 2023Friday, April 7, 2023

FeatureFeature 8051 8051 8052 8052 80318031

ROM (program space in bytes) 4K 8K 0KROM (program space in bytes) 4K 8K 0KRAM (bytes) 128 256 128RAM (bytes) 128 256 128Timers 2 3 2Timers 2 3 2I/O pins 32 32 32 I/O pins 32 32 32 Serial port 1 1 1 Serial port 1 1 1 Interrupt sources 6 8 6 Interrupt sources 6 8 6

Comparison of the 8051 Family Members

Page 51: Theory

Friday, April 7, 2023Friday, April 7, 2023

4K Bytes On Chip ROM

128 bytes On Chip RAM

6 Interrupts

32 I/O channels

Bit Addressability

2 Timers

4K Bytes On Chip ROM

128 bytes On Chip RAM

6 Interrupts

32 I/O channels

Bit Addressability

2 Timers

Features of 8051:Features of 8051:

Page 52: Theory

Friday, April 7, 2023Friday, April 7, 2023

Pin Description of the 8051:Pin Description of the 8051:1234567891011121314151617181920

4039383736353433323130292827262524232221

P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7RST

(RXD)P3.0(TXD)P3.1

(T0)P3.4(T1)P3.5

XTAL2XTAL1

GND

(INT0)P3.2

(INT1)P3.3

(RD)P3.7(WR)P3.6

VccP0.0(AD0)P0.1(AD1)P0.2(AD2)P0.3(AD3)P0.4(AD4)P0.5(AD5)P0.6(AD6)P0.7(AD7)

EA/VPPALE/PROG

PSENP2.7(A15)P2.6(A14)P2.5(A13)P2.4(A12)P2.3(A11)P2.2(A10)P2.1(A9)P2.0(A8)

8051

Page 53: Theory

Friday, April 7, 2023Friday, April 7, 2023

8051 Description:8051 Description:

Vcc, gnd and xtal:

• Vcc pin 40

– Vcc provides supply voltage to the chip.

– The voltage source is +5V.

• GND: pin 20 ground

• XTAL1 and XTAL2 pins 19,18

Page 54: Theory

Friday, April 7, 2023Friday, April 7, 2023

8051 Description:8051 Description:

• Reset: pin 9 reset

– It is an input pin and is active high normally low .

• The high pulse must be high at least 2 machine cycles.

– It is a power-on reset.

• Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost.

• Reset values of some 8051 registers

Page 55: Theory

Friday, April 7, 2023Friday, April 7, 2023

Figure (b). Power-On RESET Circuit:Figure (b). Power-On RESET Circuit:

30 pF

30 pF

8.2 K

10 uF

+

Vcc

11.0592 MHz

EA/VPPX1

X2

RST

31

19

18

9

Page 56: Theory

Friday, April 7, 2023Friday, April 7, 2023

Pins of 8051:Pins of 8051:

• EA: pin 31 external 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.

• PSEN: pin 29 program store enable

– This is an output pin and is connected to the OE pin of the ROM.

Page 57: Theory

Friday, April 7, 2023Friday, April 7, 2023

Pins of 8051:Pins of 8051:

• ALE: pin 30 address 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 the address and data by connecting to the G pin of the 74LS373 latch.

• I/O port pins

– The four ports P0, P1, P2, and P3.

– Each port uses 8 pins.

– All I/O pins are bi-directional..

Page 58: Theory

Friday, April 7, 2023Friday, April 7, 2023

Pins of I/O Pins of I/O Port:Port:• The 8051 has four I/O ports

– Port 0: pins 32-39, P0 P0.0-P0.7– Port 1: pins 1-8 , P1 : P1.0-P1.7– Port 2: pins 21-28, P2 : P2.0-P2.7– Port 3: pins 10-17, P3 : P3.0-P3.7– Each port has 8 pins.

• Named P0.X ,X=0,1,...,7, P1.X, P2.X, P3.X• Ex: P0.0 is the bit 0, LSB of P0 • Ex: P0.7 is the bit 7, MSB of P0• These 8 bits form a byte.

• Each port can be used as input or output (bi-direction).

Page 59: Theory

Friday, April 7, 2023Friday, April 7, 2023

Other Pins:Other Pins:

• P1, P2, and P3 have internal pull-up resisters.– P1, P2, and P3 are not open drain.

• P0 has no internal pull-up resistors and does not connects to Vcc inside the 8051.– P0 is open drain.

• However, for a programmer, it is the same to program P0, P1, P2 and P3.

• All the ports upon RESET are configured as output.

Page 60: Theory

Friday, April 7, 2023Friday, April 7, 2023

Port 0 with Pull-Up Resistors:

Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected.

Pull-up resistors may also be used at the interface between two different types of logic devices, possibly operating at different power supply voltages.

Page 61: Theory

Friday, April 7, 2023Friday, April 7, 2023

P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7

DS5000

8751

8951

Vcc10 K

Port 0

Page 62: Theory

Friday, April 7, 2023Friday, April 7, 2023

Port 3 Alternate Functions:Port 3 Alternate Functions:

1717RDRDP3.7P3.7

1616WRWRP3.6P3.6

1515T1T1P3.5P3.5

1414T0T0P3.4P3.4

1313INT1INT1P3.3P3.3

1212INT0INT0P3.2P3.2

1111TxDTxDP3.1P3.1

1010RxDRxDP3.0P3.0

PinPinFunctionFunctionP3 BitP3 Bit

Page 63: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 64: Theory

Friday, April 7, 2023Friday, April 7, 2023

ADDRESSING MODES:ADDRESSING MODES:

There are five addressing modes available in the There are five addressing modes available in the 8051:8051:

• RegisterRegister• DirectDirect• IndirectIndirect• ImmediateImmediate• IndexedIndexed

Page 65: Theory

Friday, April 7, 2023Friday, April 7, 2023

REGISTER ADDRESSING:REGISTER ADDRESSING:

• 8051 has access to eight working registers (R0 8051 has access to eight working registers (R0 to R7)to R7)

• Some instructions are specific to a certain Some instructions are specific to a certain register, such as the accumulator etc.register, such as the accumulator etc.

Example: ADD A,R7Example: ADD A,R7

Example: MUL AB Example: MUL AB

Page 66: Theory

Friday, April 7, 2023Friday, April 7, 2023

Direct Addressing:Direct Addressing: • Direct addressing is so-named because the Direct addressing is so-named because the

value to be stored in memory is obtained by value to be stored in memory is obtained by directly retrieving it from another memory directly retrieving it from another memory location. location.

Example: MOV A,30hExample: MOV A,30h

Page 67: Theory

Friday, April 7, 2023Friday, April 7, 2023

Indirect Addressing:Indirect Addressing:

• In 8051 assembly language, indirect addressing is In 8051 assembly language, indirect addressing is represented by an @ before R0 or R1.represented by an @ before R0 or R1.

Example: MOV A, @R0Example: MOV A, @R0

Moves a byte of data from internal RAM at Moves a byte of data from internal RAM at location whose address is in R0 to the location whose address is in R0 to the accumulator.accumulator.

Page 68: Theory

Friday, April 7, 2023Friday, April 7, 2023

Immediate Addressing:Immediate Addressing:

• In assembly language, immediate operands are In assembly language, immediate operands are preceded by #.preceded by #.

• Operand my be a numeric constant, a symbolic Operand my be a numeric constant, a symbolic variable or an arithmetic expression using variable or an arithmetic expression using constants, symbols and operators.constants, symbols and operators.

Example: MOV A,#12Example: MOV A,#12

Page 69: Theory

Friday, April 7, 2023Friday, April 7, 2023

Indexed Addressing:Indexed Addressing:

• Indexed addressing uses a base register (either the Indexed addressing uses a base register (either the program counter or data pointer) and an offset program counter or data pointer) and an offset (the accumulator) in forming the effective address (the accumulator) in forming the effective address for a JMP or MOVC instruction.for a JMP or MOVC instruction.

Example: MOVC A, @A+DPTRExample: MOVC A, @A+DPTR

Page 70: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 71: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 72: Theory

Friday, April 7, 2023Friday, April 7, 2023

LED (Light Emitting Diode):

• Light-emitting diodes are elements for light signalization in electronics.• They are manufactured in different shapes, colors and sizes. • Low price, low consumption and simple use• These LED’s are used for indication purpose i.e., ON & OFF.

LED (Light Emitting Diode):

• Light-emitting diodes are elements for light signalization in electronics.• They are manufactured in different shapes, colors and sizes. • Low price, low consumption and simple use• These LED’s are used for indication purpose i.e., ON & OFF.

Page 73: Theory

Friday, April 7, 2023Friday, April 7, 2023

Symbol of LED:Symbol of LED:

Page 74: Theory

Friday, April 7, 2023Friday, April 7, 2023

Some different colors of LED:Some different colors of LED:

Page 75: Theory

Friday, April 7, 2023Friday, April 7, 2023

How to interface LED with How to interface LED with microcontroller ?microcontroller ?

• Anode is connected through a resistor to Vcc & Anode is connected through a resistor to Vcc & the Cathode is connected to the Microcontroller the Cathode is connected to the Microcontroller pin. pin.

• So when the Port Pin is HIGH the LED is OFF & So when the Port Pin is HIGH the LED is OFF &

when the Port Pin is LOW the LED is turned ON.when the Port Pin is LOW the LED is turned ON.

Page 76: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 77: Theory

Friday, April 7, 2023Friday, April 7, 2023

Can we connect like thisCan we connect like this??

Page 78: Theory

Friday, April 7, 2023Friday, April 7, 2023

• When the port Pin is HIGH the Anode is positive When the port Pin is HIGH the Anode is positive with respect to the Cathode so the LED should with respect to the Cathode so the LED should turn ON right? turn ON right?

• But the internal pull-up resistor comes in series But the internal pull-up resistor comes in series with the resistor thus limiting the current flowing with the resistor thus limiting the current flowing through the LED. This current is not sufficient through the LED. This current is not sufficient enough to Turn ON the LED. enough to Turn ON the LED.

Page 79: Theory

Friday, April 7, 2023Friday, April 7, 2023

A Simple Program to glow an LED:A Simple Program to glow an LED:

ORG 0000HORG 0000H

CLR P1.0 //Turn ON LED CLR P1.0 //Turn ON LED

CLR P1.1CLR P1.1

CLR P1.2CLR P1.2

ENDEND

Page 80: Theory

Friday, April 7, 2023Friday, April 7, 2023

A program using port to glow an LEDA program using port to glow an LED ::

ORG 0000HORG 0000H

MOV p1,#OOH //Copy P1 to AMOV p1,#OOH //Copy P1 to A

ENDEND

Page 81: Theory

Friday, April 7, 2023Friday, April 7, 2023

A program to ON &OFF the LED:A program to ON &OFF the LED:

CASE1: CASE1:

ORG 0000HORG 0000H

MOV P1,#OFFHMOV P1,#OFFH

MOV P1,#OOHMOV P1,#OOH

ENDEND

Page 82: Theory

Friday, April 7, 2023Friday, April 7, 2023

CASE 2:CASE 2: ORG 0000HORG 0000H

MOV P1,#OFFHMOV P1,#OFFH MOV A,P1MOV A,P1

CPL A //ComplimentCPL A //Compliment ENDEND

Page 83: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 84: Theory

Friday, April 7, 2023Friday, April 7, 2023

SWITCH INTERFACING

An electrical switch is any device used to interrupt the flow of electrons in a circuit. Switches are essentially binary devices: they are either completely on ("closed") or completely off ("open").

• CPU accesses the switches through ports. Therefore these switches are connected to a microcontroller. This switch is connected between the supply and ground terminals.

• These switches are connected to an input port.

Page 85: Theory

Friday, April 7, 2023Friday, April 7, 2023

• In 8051 PORT 1, PORT 2 & PORT 3 have In 8051 PORT 1, PORT 2 & PORT 3 have internal 10k Pull-up resistors whereas this Pull-up internal 10k Pull-up resistors whereas this Pull-up resistor is absent in PORT 0. Hence PORT 1, 2 resistor is absent in PORT 0. Hence PORT 1, 2 & 3 can be directly used to interface a switch & 3 can be directly used to interface a switch whereas we have to use an external 10k pull-up whereas we have to use an external 10k pull-up resistor for PORT 0 to be used for switch resistor for PORT 0 to be used for switch interfacing or for any other input. interfacing or for any other input.

• When no switch is pressed, reading the input port When no switch is pressed, reading the input port will yield 1s since they are all connected to high will yield 1s since they are all connected to high (Vcc). But if any switch is pressed, one of the input (Vcc). But if any switch is pressed, one of the input port pins will have 0 since the switch pressed port pins will have 0 since the switch pressed provides the path to groundprovides the path to ground. .

Page 86: Theory

Friday, April 7, 2023Friday, April 7, 2023

P2.1

        Vcc

        Vcc

R R

GND GND

Interfacing switch with the microcontroller

8051

Page 87: Theory

Friday, April 7, 2023Friday, April 7, 2023

Thus now the two conditions are to be Thus now the two conditions are to be remembered:remembered:

• When the switch is open, i.e., when not pressed the When the switch is open, i.e., when not pressed the total supply i.e., Vcc appears at the port pin P2.0total supply i.e., Vcc appears at the port pin P2.0

P2.0 = 1P2.0 = 1

• When the switch is closed i.e., when it is pressed, When the switch is closed i.e., when it is pressed, the total supply path is provided to ground. Thus the total supply path is provided to ground. Thus the voltage value at the port pin P2.0 will be zero.the voltage value at the port pin P2.0 will be zero.

P2.0 = 0P2.0 = 0

Page 88: Theory

Friday, April 7, 2023Friday, April 7, 2023

P2.1

        Vcc

        Vcc

R R

GND GND

Interfacing Led And Switch with the Microcontroller

8051

Vcc

P1.0

Page 89: Theory

Friday, April 7, 2023Friday, April 7, 2023

Simple program to turn on led when Simple program to turn on led when switch is pressed:switch is pressed:

ORG 0000H ORG 0000H 

SETB P1.0 SETB P1.0

LOOP: LOOP: JB P2.1, LOOP JB P2.1, LOOP

    CLR P1.0 CLR P1.0

END   END  

Page 90: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 91: Theory

Friday, April 7, 2023Friday, April 7, 2023

Liquid crystal display (LCD):Liquid crystal display (LCD):

• A liquid crystal display (LCD) is a thin, flat panel used for electronically displaying information such as text, images, and moving pictures.

• Its uses include monitors for computers, televisions, instrument panels, and other devices ranging from aircraft cockpit displays, to every-day consumer devices such as gaming devices, clocks, watches, calculators, and telephones.

Page 92: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Among its major features are its lightweight construction, its portability, and its ability to be produced in much larger screen sizes than are practical for the construction of cathode ray tube (CRT) display technology.

Page 93: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Its low electrical power consumption enables it to be used in battery-powered electronic equipment. It is an electronically-modulated optical device made up of any number of pixels filled with liquid crystals and arrayed in front of a light source (backlight) or reflector to produce images in color or monochrome.

Why we are using LCD ?

Page 94: Theory

Friday, April 7, 2023Friday, April 7, 2023

Liquid Crystal Display (LCD )is finding wide spread use replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the following reasons:

The declining prices of LCD’s.

The ability to display numbers, characters ,graphics and limited to numbers and a few characters

Ease of programming for characters and graphics.

Page 95: Theory

Friday, April 7, 2023Friday, April 7, 2023

1.1. GroundGround

2.2. Vcc +5VVcc +5V

3.3. Contrast controlContrast control

4.4. Register select (RS)Register select (RS)

5.5. Read/Write (RD/WR)Read/Write (RD/WR)

6.6. Enable (EN)Enable (EN)

7 – 14 pins all are data pins D0 – D77 – 14 pins all are data pins D0 – D7

15.15. Vcc +5V }Vcc +5V }

16.16. Ground }Ground }

Pin Description of LCD:

For backlight purpose

Page 96: Theory

Friday, April 7, 2023Friday, April 7, 2023

RS (register select): The register select pin is used for the selection of

the required register either data or command register

If RS=0 ; command register is selected If RS=1 ; data register is selected R/W (read or write): This pin is for the selection of read or write mode If R/W=0 ; write mode is selected If R/W=1 ; read mode is selectedEN (enable):• Enable pin is a active high to low pin used for

writing the data to the LCD.

Page 97: Theory

Friday, April 7, 2023Friday, April 7, 2023

• 01 Clear display screen01 Clear display screen

• 06 Increment cursor06 Increment cursor

• 38 2lines and 5 by 7 matrix38 2lines and 5 by 7 matrix

• 80 Force cursor to beginning of 180 Force cursor to beginning of 1stst line line

• 0E Display on, cursor blinking0E Display on, cursor blinking

• C0 Force cursor to beginning 0f 2C0 Force cursor to beginning 0f 2ndnd line line

LCD COMMAND CODES:

Page 98: Theory

Friday, April 7, 2023Friday, April 7, 2023

P0.0 P0.1P0.2P0.3P0.4P0.5P0.6P0.7

D0D1D2D3D4D5D6D7

RS R/W E

P2.0

P2.1

P2.2

Vss

Vee

Vss

10k

POT

8051

LCD

GND

LCD INTERFACING WITH MICRO CONTROLLER:

Page 99: Theory

Friday, April 7, 2023Friday, April 7, 2023

How To Send Commands To LCD:How To Send Commands To LCD:

COMMAND:COMMAND:

CLR RSCLR RS

CLR R/WCLR R/W

SETB ENSETB EN

CLR ENCLR EN

Page 100: Theory

Friday, April 7, 2023Friday, April 7, 2023

How to send Data to LCD:How to send Data to LCD:

DATA:DATA:

SETB RSSETB RS

CLR R/WCLR R/W

SETB ENSETB EN

CLR ENCLR EN

Page 101: Theory

Friday, April 7, 2023Friday, April 7, 2023

A Simple Program Of LCD:A Simple Program Of LCD: ORG OOHORG OOH MOV A,#38HMOV A,#38H ACALL COMMANDACALL COMMAND MOV A,#0EHMOV A,#0EH ACALL COMMANDACALL COMMAND MOV A,# ’H’MOV A,# ’H’ ACALL DATAACALL DATA MOV A,# ‘I’MOV A,# ‘I’ ACALL DATAACALL DATA

Page 102: Theory

Friday, April 7, 2023Friday, April 7, 2023

COMMAND : CLR RSCOMMAND : CLR RS

CLR R/WCLR R/W

SETB ENSETB EN

CLR ENCLR EN

RET RET

DATA: DATA:

SETB RSSETB RS

CLR R/WCLR R/W

SETB ENSETB EN

CLR ENCLR EN

RETRET

ENDEND

Page 103: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 104: Theory

Friday, April 7, 2023Friday, April 7, 2023

Relay Interfacing With Relay Interfacing With

MicrocontrollerMicrocontroller Relay: It can be defined as an electrical switch that opens Relay: It can be defined as an electrical switch that opens and closes under the control of another electrical circuit. and closes under the control of another electrical circuit. The switch is operated by an electromagnet to open or The switch is operated by an electromagnet to open or close one or more of contacts. A relay is able to control an close one or more of contacts. A relay is able to control an output circuit of higher power than the input circuitoutput circuit of higher power than the input circuit. .

Relays are devices which allow low power circuits to switch Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. a relatively high Current/Voltage ON/OFF.

For a relay to operate a suitable pull-in & holding current For a relay to operate a suitable pull-in & holding current should be passed through its coil.should be passed through its coil.

Generally relay coils are designed to operate from a Generally relay coils are designed to operate from a particular voltage often its 5V or 12V. particular voltage often its 5V or 12V.

Page 105: Theory

Friday, April 7, 2023Friday, April 7, 2023

Types:Types:There are many types of relays which are as There are many types of relays which are as follows:follows:SPDTSPDTDPDTDPDTSymbol Of Relay:Symbol Of Relay:

Page 106: Theory

Friday, April 7, 2023Friday, April 7, 2023

• The relay's switch connections are usually labelled The relay's switch connections are usually labelled COM, NC and NO: COM, NC and NO:

• COM = Common, always connect to this, it is the COM = Common, always connect to this, it is the moving part of the switch. moving part of the switch.

• NC = Normally Closed, COM is connected to this NC = Normally Closed, COM is connected to this when the relay coil is off. when the relay coil is off.

• NO = Normally Open, COM is connected to this NO = Normally Open, COM is connected to this when the relay coil is on. when the relay coil is on.

• Connect to COM and NO if you want the switched Connect to COM and NO if you want the switched circuit to be on when the relay coil is on. circuit to be on when the relay coil is on.

• Connect to COM and NC if you want the switched Connect to COM and NC if you want the switched circuit to be on when the relay coil is off. circuit to be on when the relay coil is off.

Page 107: Theory

Friday, April 7, 2023Friday, April 7, 2023

Advantages of relays:Advantages of relays:

• Relays can switch AC and DC, transistors Relays can switch AC and DC, transistors can only switch DC. can only switch DC.

• Relays can switch high voltages, transistors Relays can switch high voltages, transistors cannot. cannot.

• Relays are a better choice for switching Relays are a better choice for switching large currents (> 5A). large currents (> 5A).

• Relays can switch many contacts at once. Relays can switch many contacts at once.

Page 108: Theory

Friday, April 7, 2023Friday, April 7, 2023

Disadvantages Of Relay:Disadvantages Of Relay:

• Relays are bulkier than transistors for Relays are bulkier than transistors for switching small currents. switching small currents.

• Relays cannot switch rapidly , transistors Relays cannot switch rapidly , transistors can switch many times per second. can switch many times per second.

• Relays use more power due to the current Relays use more power due to the current flowing through their coil. flowing through their coil.

Page 109: Theory

Friday, April 7, 2023Friday, April 7, 2023

SPDT Relay  (Single Pole Double Throw) : SPDT Relay  (Single Pole Double Throw) :

An electromagnetic switch, consist of a coil , 1 An electromagnetic switch, consist of a coil , 1 common terminal , 1 normally closed terminal , common terminal , 1 normally closed terminal , and one normally open terminal. and one normally open terminal.

When the coil of the relay is at rest (not When the coil of the relay is at rest (not energized), the common terminal and the energized), the common terminal and the normally closed terminal have continuity. When normally closed terminal have continuity. When the coil is energized, the common terminal and the the coil is energized, the common terminal and the normally open terminal have continuity. normally open terminal have continuity.

Page 110: Theory

Friday, April 7, 2023Friday, April 7, 2023

DPDT (Double Pole Double Throw):DPDT (Double Pole Double Throw):

• Can be used to isolate float switches from spiking Can be used to isolate float switches from spiking voltage or excessive current. voltage or excessive current.

• Avoids risk that spiking pump voltage will hurt Avoids risk that spiking pump voltage will hurt float switches.   float switches.  

Specifications: Specifications:

• Coil voltage: 12VDC Coil voltage: 12VDC

• Coil resistance: 160 Ohms Coil resistance: 160 Ohms

• Contact rating: 10A at 250VAC or 30VDC.Contact rating: 10A at 250VAC or 30VDC.

Page 111: Theory

Friday, April 7, 2023Friday, April 7, 2023

Why do I want to use a relay and do I really Why do I want to use a relay and do I really

need to?need to?

• The coil of an SPDT relay that we most commonly The coil of an SPDT relay that we most commonly use draws very little current (less than 200 use draws very little current (less than 200 milliamps) and the amount of current that you can milliamps) and the amount of current that you can pass through a relay's common, normally closed, pass through a relay's common, normally closed, and normally open contacts will handle up to 30 or and normally open contacts will handle up to 30 or 40 amps. This allows you to switch devices such as 40 amps. This allows you to switch devices such as headlights, parking lights, horns, etc., headlights, parking lights, horns, etc.,

Page 112: Theory

Friday, April 7, 2023Friday, April 7, 2023

SPDT & DPDT:SPDT & DPDT:

Page 113: Theory

Friday, April 7, 2023Friday, April 7, 2023

Relay Interfacing with the Microcontroller:Relay Interfacing with the Microcontroller:

1 U 16 2 L 153 N 144 2 135 8 126 0 117 3 108 9

RELAY LOAD

GroundVcc

AT 89S52

P1.0

Page 114: Theory

Friday, April 7, 2023Friday, April 7, 2023

ULN2003 CURRENT DRIVER:ULN2003 CURRENT DRIVER:• The ULN2003 current driver is a high voltage, high The ULN2003 current driver is a high voltage, high

current Darlington arrays each containing seven current Darlington arrays each containing seven open collector Darlington pairs with common open collector Darlington pairs with common emitters. Each channel is rated at 500mA and can emitters. Each channel is rated at 500mA and can withstand peak currents of 600mA.withstand peak currents of 600mA.

Page 115: Theory

Friday, April 7, 2023Friday, April 7, 2023

ULN DRIVER CIRCUIT

This ULN2003 driver can drive seven relays at a time. The pins 8 and 9 provide ground and Vcc respectively.

Page 116: Theory

Friday, April 7, 2023Friday, April 7, 2023

Working Of ULN Driver:Working Of ULN Driver:

• It can accept seven inputs at a time and produces It can accept seven inputs at a time and produces seven corresponding outputs. If the input to any seven corresponding outputs. If the input to any one of the seven input pins is high, then the value one of the seven input pins is high, then the value at its corresponding output pin will be low, for at its corresponding output pin will be low, for example if the input at pin 6 is high, then the value example if the input at pin 6 is high, then the value at the corresponding output i.e., output at pin 11 at the corresponding output i.e., output at pin 11 will be low. Similarly if the input at a particular will be low. Similarly if the input at a particular pin is low, then the corresponding output will be pin is low, then the corresponding output will be highhigh..

Page 117: Theory

Friday, April 7, 2023Friday, April 7, 2023

• Thus for the output to be low, the input applied at Thus for the output to be low, the input applied at that corresponding input pin should be high. The that corresponding input pin should be high. The input to the ULN driver is provided by the input to the ULN driver is provided by the microcontroller. Thus the instruction required to microcontroller. Thus the instruction required to operate the relay through the microcontroller isoperate the relay through the microcontroller is

SETB PX.YSETB PX.Y

• Where X is the port number (P0, P1, P2 Where X is the port number (P0, P1, P2

and P3).and P3).

• And Y is the pin number of Port X.And Y is the pin number of Port X.

Page 118: Theory

Friday, April 7, 2023Friday, April 7, 2023

Applications:Applications:

• To control a high-voltage circuit with a low-To control a high-voltage circuit with a low-voltage signalvoltage signal

• To control a high-current circuit with a low-To control a high-current circuit with a low-current signal, current signal,

• To detect and isolate faults on transmission and To detect and isolate faults on transmission and distribution lines by opening and closing circuit distribution lines by opening and closing circuit breakers.breakers.

Page 119: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 120: Theory

Friday, April 7, 2023Friday, April 7, 2023

What is communication?What is communication?

• Communication is nothing but sharing of data or Communication is nothing but sharing of data or transferring the data from one system to another.transferring the data from one system to another.

system1 system2

Page 121: Theory

Friday, April 7, 2023Friday, April 7, 2023

Types of communication:

In Serial communications means information is transmitted from source to destination over a single pathway.

In Parallel Communication, often 8 or more lines are used to transfer data to a device that is only a few feet.

Page 122: Theory

Friday, April 7, 2023Friday, April 7, 2023

COMPUTERS TRANSFER DATA IN TWO WAYS:

Sender Receiver Sender Receiver

Serial Transfer Parallel Transfer

D0-D7D0

Other control lines

Other control lines

Page 123: Theory

Friday, April 7, 2023Friday, April 7, 2023

Why we prefer serial transmission over parallel transmission?

• In Parallel data transfers, often 8 or more lines are used to transfer data to a device that is only a few feet.

• Where as serial transmission uses only single line to transmit the same data over long distances

• There are chances of loosing data in parallel communication rather than in serial communication.

Page 124: Theory

Friday, April 7, 2023Friday, April 7, 2023

Simplex vs. Duplex TransmissionSimplex vs. Duplex Transmission

• Simplex transmission: the data can sent in one Simplex transmission: the data can sent in one direction.direction.

– Example: the computer only sends data to the Example: the computer only sends data to the printer. printer.

• Duplex transmission: the data can be transmitted Duplex transmission: the data can be transmitted and received.and received.

Transmitter Receiver

Transmitter

ReceiverReceiver

Transmitter

Page 125: Theory

Friday, April 7, 2023Friday, April 7, 2023

Half vs. Full DuplexHalf vs. Full Duplex

• Half duplex: if the data is transmitted one way at Half duplex: if the data is transmitted one way at a time.a time.

• Full duplex: if the data can go both ways at the Full duplex: if the data can go both ways at the same time. Two wire conductors for the data lines.same time. Two wire conductors for the data lines.

Transmitter

Receiver

Receiver

Transmitter

Transmitter

Receiver

Receiver

Transmitter

Page 126: Theory

Friday, April 7, 2023Friday, April 7, 2023

Registers Used in Serial Transfer CircuitRegisters Used in Serial Transfer Circuit

• SBUF (Serial data buffer)SBUF (Serial data buffer)

• SCON (Serial control register)SCON (Serial control register)

• TMOD (Timer mode register)TMOD (Timer mode register)

Page 127: Theory

Friday, April 7, 2023Friday, April 7, 2023

SBUF

• This is an 8-bit register used for serial communication in 8051.For a byte of data to be transferred it must be placed in sbuf register and in similar way sbuf holds the data when it is received.

Page 128: Theory

Friday, April 7, 2023Friday, April 7, 2023

SCON Register (serial control)

SM0SM0 SM1SM1 SM2SM2 RENREN TB8TB8 RB8RB8 TITI RIRI

It used to program the start bit, stop bit and data bits of data framing

SM0 , SM1:These two bits determine the framing of data by specifying the number of bits per character, and the start and stop bits.

Page 129: Theory

Friday, April 7, 2023Friday, April 7, 2023

SM0 SM1SM0 SM1

00 0 Serial Mode 0 0 Serial Mode 0

00 1 Serial Mode 1, 8-bit data, 1 stop bit, 1 Serial Mode 1, 8-bit data, 1 stop bit,

1 start bit1 start bit

11 0 Serial Mode 2 0 Serial Mode 2

1 1 Serial Mode 31 1 Serial Mode 3

Page 130: Theory

Friday, April 7, 2023Friday, April 7, 2023

RECEIVE - Data receive through the RXD pin starts upon the two following conditions are met: bit REN=1 and RI=0(both of them are stored in the SCON register). When all 8 bits have been received, the RI bit of the SCON register is automatically set indicating that one byte receive is complete.

TRANSMIT - Data transmit is initiated by writing data to the SBUF register. In fact, this process starts after any instruction being performed upon this register. When all 8 bits have been sent, the TI bit of the SCON register is automatically set.

Page 131: Theory

Friday, April 7, 2023Friday, April 7, 2023

TMOD TMOD

• TMOD is an 8 bit register in which the lower 4 bits are set aside for Timer0 and the upper 4 bits for Timer1.

GATGATEE

C/TC/T M0M0 M1M1 GATGATEE

C/TC/T M1M1 M0M0

Page 132: Theory

Friday, April 7, 2023Friday, April 7, 2023

 TMOD -Timers

Bit Number Type Working Timer Type

7 GATE1 Gating Control when set

1

6 C/T1

To decide whether timer is used as a delay generator or as an event counter

1

5 M1 Timer mode bit 1

4 M0 Timer mode bit 1

3 GATE0 Gating Control Purpose

0

2 C/T0

To decide whether timer is used as a delay generator or as an event counter

0

1 M1 Timer mode bit 0

0 M0 Timer mode bit 0

Page 133: Theory

Friday, April 7, 2023Friday, April 7, 2023

M1 M0 Timer Mode Description of Mode

0 0 0 13-bit Timer.

0 1 1 16-bit Timer

1 0 2 8-bit auto-reload

1 1 3 Split timer mode

Page 134: Theory

Friday, April 7, 2023Friday, April 7, 2023

RS232To ensure fast and reliable data transmission between two devices

In RS232 it consists of 9 pins but we generally use only three pins 2,3 and 5 namely TXD RXD GND respectively.

Page 135: Theory

Friday, April 7, 2023Friday, April 7, 2023

MAX232To convert TTL or CMOS voltages to RS232 voltages, and vice versa

Complementary metal–oxide–semiconductor (CMOS)

CMOS uses complementary and symmetrical pairs of p-type and n-type metal oxide semiconductor field effect transistors (MOSFET’s) for logic functions.

Two important characteristics of CMOS devices are high noise immunity and low static power consumption.

Page 136: Theory

Friday, April 7, 2023Friday, April 7, 2023

TTL (Transistor transistor logic)TTL (Transistor transistor logic)

• TTL integrated circuits were a standard method of construction for the processors of mini-computer and mainframe processors

• Transistor–transistor logic (TTL) is a class of digital circuits built from bipolar junction transistors (BJT) and resistors. It is called transistor–transistor logic because both the logic gating function (e.g., AND) and the amplifying function are performed by transistors

Page 137: Theory

Friday, April 7, 2023Friday, April 7, 2023

Baud Rates in the 8051:Baud Rates in the 8051:

• Baud rate is the number of signal changes per second• The 8051 transfers and receives data serially at many

different baud rates by using UART.• UART divides the machine cycle frequency by 32 and

sends it to Timer 1 to set the baud rate. • Signal change for each roll over of timer 1.

XTAL oscillator

÷ 12÷ 32

By UART

Machine cycle frequency

28800 Hz

To timer 1 To set the Baud rate

921.6 kHz

11.0592 MHz

Timer 1

Page 138: Theory

Friday, April 7, 2023Friday, April 7, 2023

135

14TxD0(P3.1)

RxD0(P3.0)

11

11

10 12

2

3

8

0

5

1

M

A

X

2

3

2

DB9 GND

MAX 232 INTERFACING WITH MICRO CONTROLLER

Page 139: Theory

Friday, April 7, 2023Friday, April 7, 2023

Page 140: Theory

Friday, April 7, 2023Friday, April 7, 2023

ANALOG TO DIGITAL CONVERTERANALOG TO DIGITAL CONVERTER

• Analog-to-digital converters are among the most widely used devices for data acquisition. Digital systems use binary values, but in the physical world everything is continuous i.e., analog values. Temperature, pressure (wind or liquid), humidity and velocity are the physical analog quantities.

• These physical quantities are to be converted into digital values for further processing. Thus, an analog-to-digital converter is needed to convert these electrical signals into digital values so that the microcontroller can read and process them.

Page 141: Theory

Friday, April 7, 2023Friday, April 7, 2023

ADC0804:ADC0804:

• The ADC chip that is used in this project is The ADC chip that is used in this project is ADC0804. The ADC0804 IC is an 8-bit parallel ADC0804. The ADC0804 IC is an 8-bit parallel ADC in the family of the ADC0800 series from ADC in the family of the ADC0800 series from National Semiconductor. It works with +5 volts National Semiconductor. It works with +5 volts and has a resolution of 8 bits. In the ADC0804, the and has a resolution of 8 bits. In the ADC0804, the conversion time varies depending on the clocking conversion time varies depending on the clocking signals applied to the CLK IN pin, but it cannot be signals applied to the CLK IN pin, but it cannot be faster than 110µs.faster than 110µs.

Page 142: Theory

Friday, April 7, 2023Friday, April 7, 2023

PIN Diagram of ADCPIN Diagram of ADC

Page 143: Theory

Friday, April 7, 2023Friday, April 7, 2023

Pin description of ADCPin description of ADC

CS (Chip selection):Chip select is a active low input used to activate the ADC 0804.

RD (read):This is also a active low pin used to get the converted data out of the ADC 0804.

WR (write):This is also active low used to inform the ADC to start the conversion process.

Page 144: Theory

Friday, April 7, 2023Friday, April 7, 2023

CLK IN & CLK R:CLK IN is connected to external clock when external clock is used and if internal clock is used both clocks are connected to capacitor and a resistor.

INTR (INTERRUPT):It is an active low output pin using for stop the conversion.

Vin(+) & Vin(-):Vin(+) is used for the conversion of analog to digital by connecting Vin(-) to the ground.

Page 145: Theory

Friday, April 7, 2023Friday, April 7, 2023

Vcc:It is the +5v power supply to the chip.

Vref/2: Pin 9 is used for the reference voltage. If we need

the input range 0-4V, Vref/2 is connected to 2V.D0-D7:

These are the digital data output pins.D7 is the MSB.

Analog ground & Digital ground:Analog ground is connected to ground of analog Vin while taking the inputs in the same way digital ground is also used for the digital outputs.

Page 146: Theory

Friday, April 7, 2023Friday, April 7, 2023

ADC INTERFACE WITH MICROCONTROLLERADC INTERFACE WITH MICROCONTROLLER

89C51

20 P2.5 P2.6 A P2.7 D P1.7 C P1.6 0 P1.5 8 P1.4 0 P1.3 4 P1.2 P1.1 P1.0

Page 147: Theory

Friday, April 7, 2023Friday, April 7, 2023

Keypads are a part of HMI or Human Machine Interface and play really important role in a small embedded system where human interaction or human input is needed. Matrix keypads are well known for their simple architecture and ease of interfacing with any microcontroller.

Interfacing the Keyboard to the 8051

At the lowest level, keypads are organized in a matrix of rows and columns. The CPU accesses both rows and column through ports; therefore, an 4*4 matrix of keys can be connected to a microprocessor. When a key pressed, a row and column make a connect; otherwise, there is no connection between row and column.

KEYPAD INTERFACING

Page 148: Theory

Friday, April 7, 2023Friday, April 7, 2023

Constructing a Matrix Keypad:

Construction of a keypad is really simple. As per the outline shown in the figure below we have four rows and four columns. In between each overlapping row and column line there is a key.keeping this outline we can construct a keypad using simple SPST Switches as shown below:

Page 149: Theory

Friday, April 7, 2023Friday, April 7, 2023

Consider an exampleConsider an example

Row4-row1 = 1110Row4-row1 = 1110

Col4-col1 = 1011Col4-col1 = 1011

That means the row 1 and the col 3 intersected i.e. That means the row 1 and the col 3 intersected i.e. sw3 is pressed.sw3 is pressed.

Page 150: Theory

Friday, April 7, 2023Friday, April 7, 2023