71
1 Report on Industrial Training Program in Microlink Peripheral Pvt. Limited Designed & Developed by Avinash Reddy P Nagendra babu B Venkatesh E in partial fulfillment of Winter Internship for the award of the degree in BACHELOR OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING RGUKT Nuzvid Campus Rajiv Gandhi University of Knowledge Technologies Nuzvid, Krishna (Dist), Andhra Pradesh February 2014

Embedded Application on Microcontroller in Assembly and Embedded C

Embed Size (px)

Citation preview

Page 1: Embedded Application on Microcontroller in Assembly and Embedded C

1

Report on Industrial Training Program in

Microlink Peripheral Pvt. Limited Designed & Developed by

Avinash Reddy P Nagendra babu B

Venkatesh E in partial fulfillment of Winter Internship for the award of the

degree in

BACHELOR OF TECHNOLOGY in

ELECTRONICS & COMMUNICATION ENGINEERING

RGUKT Nuzvid Campus Rajiv Gandhi University of Knowledge Technologies

Nuzvid, Krishna (Dist), Andhra Pradesh

February 2014

Page 2: Embedded Application on Microcontroller in Assembly and Embedded C

2

INDEX

Study and Practical Analysis 1) Computer basics page 3 2) Data representations page 4 3) Data conversions and display systems page6 4) Soldering procedure page7 5) AC distribution page8 6) Basic electronics page9 7) Electronic Components (resistors-types, applications) page11 8) Capacitors-types, applications page14 9) Inductors-types, applications page17 10) Semiconductors-types, applications page24 11) Digital electronics page 30 12) Power supplies page31 13) Op amps- applications page32 14) 555 Timer- applications page33 15) Opto couplers- applications page35 16) Comparators- applications page36 17) DTMF page38 18) Micro controller (AT89C52) page39

Design and Development of Application Pages 44 to 71

1) Design a circuit to flicker an LED light with 50% duty cycle and write a program for it. 2) Design a circuit to display the numbers 0 to 9 in a 7-segment display using micro controller in

both ascending and descending order. 3) Design a project to drive the DC linear motor with direction control and write a program for it. 4) Develop an interfacing circuit between GSM/CDMA mobile and micro controller using DTMF

network for remote switching operation. 5) Design and develop a parallel communication protocol between 16X2 LCD and micro controller. 6) Construct a project to count the no. of visitors entered into the auditorium and display it in LCD

using microcontroller. 7) Design and develop a micro controller based circuit for measurement of DC voltage, AC voltage,

AC current using ADC0809. 8) Design and develop a micro controller based circuit for measurement of temp, light intensity

using ADC0809. 9) Develop an RS-232 protocol to establish a serial UART communication between PC and micro

controller.

Page 3: Embedded Application on Microcontroller in Assembly and Embedded C

3

COMPUTER: Computer is nothing but a computing device. It is used for many applications. They are divided into two types based on applications.

1. Analog 2. Digital

COMPUTER Analog Digital Special purpose General purpose ANALOG COMPUTER: Analog computer is one which is having one scale and pointer .The pointer is always moving on the scale [All Electromechanical systems]. Analog systems are also called as continuous systems. Examples: Thermometer, Analog multi meter, Ammeter, Energy meter etc. DIGITAL COMPUTER: Digital computer is one in which the entire process is carried out through binary digits. There are 2 types of digital computers. 1. Special purpose digital computer 2. General purpose digital computer

Special purpose digital computer: It is a one designed for a specific purpose, we

can’t alter its functioning. E.g. Calculator, weighing machines etc.

General purpose digital computer: It is for generalized applications. Any type of special purpose application can be designed by a general purpose computer.

E.g. personal computer. NUMBER SYSTEM: The following number systems are widely used. They are, Binary [0 and 1] Octal [0 to 7]

Page 4: Embedded Application on Microcontroller in Assembly and Embedded C

4

Decimal [0 to 9] Hexa decimal [0 to F]

Decimal: The decimal system contains ten unique symbols from 0 to 9. Since counting in decimal involves 10 symbols, we say that its base or radix is 10. Each symbol in the number is called digit. Binary: The binary number system is a positional weighted system. The base or radix of this number system is 2. The symbols used are 0 and 1. A binary number consists of a sequence of bits, each of which is either ‘0’ or ‘1’. Advantages:

System data recognisation Simple data transmission Easy data storage

So people are widely using binary number system. Disadvantages:

It requires more length. Octal: The octal number system was extensively used by early mini computers. It is also a positional weighted system. Its base or radix is 8. It has 8 independent symbols from 0 to 7. Since its base 8=23, every 3 bit group of binary can be represented by an octal digit. Hexa decimal: Hexa decimal is the advanced system of binary. The Hexa decimal number system is the professional weighted system. The base or radix of this number system is 16, that means, it has 16 symbols used from 0 to 9 and A to F. In this A to F represents the decimal digits from 10 to 15.

DATA The information is nothing but a data, that includes, Text matter Graphics Voice

DATA REPRESENTATION AND MEASUREMENTS: In digital system data is represented in 0’s and 1’s.

Page 5: Embedded Application on Microcontroller in Assembly and Embedded C

5

In this Bit 1 = 5v (3.5 to 5v) 70% of 5v Bit 0 = 0v (0 to 1.5v) 30% of 5v 4 bits =1 Nibble 8 bits = 1 Byte 1024bytes = 1 Kilo byte 1024 Kilobytes = 1 Mega byte 1024 Megabyte = 1 Giga byte 1024 Gigabyte = 1 Tetra byte REPRESENTATION OF TEXT MATTER: For text matter representation people will go for ASCII [American Standard Code for Information Interchange]. In that, 256 combinations are there form 00H-FFH (00-255 in decimal). In those 256, 0-127 indicates general characters like A-Z, a-z, 0-9, [&, *, ^, >, < , . ,]. 128-255 indicates text mode graphics like >>, << etc. NOTE: Another standard is “SCAN CODE”. It is used in keyboards only. REPRESENTATION OF GRAPHICS: To increase the originality of picture, the following factors must be increased.

1. Number of pixels per unit area. 2. Number of bits representing a pixel.

In that we represent a colour to every pixel. The colour is may be 8 bit or 16 bit. REPRESENTAION OF VOICE: In case of analog systems sound energy is converted into magnetic energy through microphone, amplifier and a coil at the transmission side. At the receiver end the reverse operation is performed. In digital systems the sound energy is converted into digital form through microphone, amplifier, ADC at the transmission end. At the receiver end, the reverse operation i.e. the digital data converted into sound energy through DAC, amplifier and loudspeaker. Compared to analog systems, the losses in Digital systems are less.

Amplifier MIC

COIL

Amplifier Loud Speaker COIL

Magnetic

Energy

Page 6: Embedded Application on Microcontroller in Assembly and Embedded C

6

DATA CONVERSIONS:

Binary to Decimal and Decimal to Binary Octal to Decimal and Decimal to Octal Hexadecimal to decimal and decimal to Hexadecimal Octal to Binary and Binary to Octal Hexadecimal to binary and binary to Hexadecimal

7 Segment code:

It is used in 7 segment display. These displays are two types

a) Common anode b) Common cathode

The segment of the digits is connected to a common port and negative to the ground. Signal limits the current while source gives the required current. 14Segment display: Segmental dot matrix display:

Amplifier MIC ADC Amplifier Loud Speaker DAC Digital Media

PORT

Page 7: Embedded Application on Microcontroller in Assembly and Embedded C

7

Full dot matrix: There are 3 categories of display systems.

1. LCD 2. LED 3. Fluorescent tube light type

SOLDERING PROCEDURE

Tools required: Soldering iron Lead Flux PCB Petrol thinner or white petrol cleaning material.

SOLDERING PROCEDURE:

Soldering iron tip must be very cleaned by using file. Apply lead on the tip. Apply little bit flux at solder area. Put soldering iron beside the point at the rate of 45degrees. Wait for few seconds. Remove the soldering iron and wait for some time.

NOTE: The soldering lead and PCB surface must be very cleaned. DE SOLDERING PROCEDURE:

De soldering wick (shield wire with flux). De soldering pump.

PCB TYPES:

Single sided PCB. Double sided PCB. PTH (pin through hole) PCB. Multi layer.

BASIC PCB MATERIALS:

Paper epoxy material.

Page 8: Embedded Application on Microcontroller in Assembly and Embedded C

8

Glass epoxy material.

TERMS RELATEDTO PCB: Copper clad [raw PCB]. Legend [Printing symbols on PCB]. Solder mask [Paint applied on bottom side except soldering point]. Tinning [Applied lead on copper tracks].

Basic electronics

Voltage: The potential difference between the two pints is called voltage. It is denoted by “V” and their units are “volts”. Current: The flow of electrons in one direction along any path or around any circuit is called electric current. It is denoted by “I” and its units are “Ampere”. Power: Power is nothing but a product of voltage and current. It is the ratio of electric work done in the electric circuit for unit time. Electric power = Electric work done / Time taken

Power = VI Units for power are “watts”. DC Voltage: The voltage which remains constant in direction w.r.t time and may or may not have constant magnitude is knows as direct (or) steady voltage. E.g.: Battery, generator, solar panel system.

AC voltage:

The voltage which changes in magnitude as well as direction wart time is known as Alternative voltage”.

Page 9: Embedded Application on Microcontroller in Assembly and Embedded C

9

Materials: The electrical properties of different materials can be explained in terms of the electrons having energies in the valence band and conduction band, because the electrons lying in the lower energy bands which are normally filled, play no role in the conduction process. Insulators:

Insulators are the solid materials which are bad conductors of electricity. E.g.: wood, plastic, rubber.

In terms of energy bands, Insulators Have full valance band Have an empty conduction band Have a wide forbidden energy gaps

So in case of insulators a very large amount of energy must be supplied to electrons to cross from the valance band to the conduction band. Conductors: Conductors are the solid materials which are good conductors of electricity. In terms of energy bands conductors have,

No forbidden energy gap between valence band and conduction band. E.g.: Copper, Aluminum, Gold. Semi Conductors: Semi conductors are the solid materials which are neither good conductors nor bad conductors of electricity. E.g.: Silicon, Germanium. So in case of Semiconductors a very little amount of energy is sufficient to move electrons from valence band to conduction band. This energy is available at room temperature itself. A.C DISTRIBUTION:

Potential Coil

FUSECurrent Coil

Mains Switch

21

54

FUSE

FUSE

115W 920W

460W

0.5A2A

4A

4A6A6.5A

Energy Meter

Ph

Nt

Page 10: Embedded Application on Microcontroller in Assembly and Embedded C

10

The above diagram shows the single phase A.C Distribution which consists of a potential coil and current coil to which the mains and fuses are connected. The loads are connected at the output. If the mains are at ON state, the disc will rotate due to the torque produced by the two coils [Pc & Cc]. If the mains are at OFF state, the disc will not rotate. EARTHING: Earthing refers to connecting an electrical conductor to earth which is assumed to have zero electric potential. (OR) Earthing means connecting the neutral point of supply system or the non-current carrying metal part s used in electrical distribution system to the general mass of the earth by a wire of negligible resistance in such a manner that at all times an electrical discharge of electrical energy takes place without danger. This brings the body of equipment to zero potential and thus will avoid the shock to the operator IMPORTANCE OF EARTHING: It protects us from electric shocks. It reduces EMI [Electro- magnetic induction]. It reduces RFI [Radio frequency interference.

Checking the Earthing: Voltage between Nt to E:

0V = Excellent <5V = Good >5V<10V = Satisfactory >10V = Not Acceptable.

Basic Electronic Components

E

P N

230V

230V

0V

Page 11: Embedded Application on Microcontroller in Assembly and Embedded C

11

RESISTORS: Resistor is one of the basic electronic components found in almost all electronic circuits. As its name suggests, a resistor resists or opposes the flow of current through it. The property exhibited by the resistor is known as resistance. It is represented by the letter ‘R’ and its units are ohms. If it obey the ohm’s law, then the resistor is called as ‘Linear resistor’ and the resistance offered by the resistor is called as ‘Linear resistance’. If it doesn’t obey the Ohm’s law, i.e [V=IR] the resistor is called as ‘Non-Linear resistor’ and the resistance is called as Non-Linear resistance. The resistor symbol is as follows.

FIXED RESISTOR VARIABLE RESISTOR C

TAPPED RESISTOR

1 2345

Features of resistors: These are two terminal, passive bilateral elements. The effect of resistance is same for both AC and DC. Use of resistors: To limit current. To establish proper values of currents in circuits. To provide voltage drop. To provide load.

Specification of resistors: 1. Ohmic value: It represents value of the resistance. 2. Tolerance : It represents percentage of variation in the ohmic value. 3. Wattage : It represents power handling capacity of a resistor.

Eg: 10KΩ, +/- 5%, ¼ Watt. ↓ ↓ ↓ Ohmic Value, Tolerance, Power handling capacity Colour coding of resistors: For identification of specifications we have different codes. They are BS 1825 code[British Standard], SMR coding [Surface Mounted Resistor], 3 band colour coding, 4 band colour coding.

1. BS1825 CODE: It is a Britain standard coding method using for knowing the value of resistors. In this, R, E - ohms. K - Kilo ohms M - Mega ohms J, K, F, G represents tolerance value J - +/- 5% K - +/- 10% F - +/- 1%

Page 12: Embedded Application on Microcontroller in Assembly and Embedded C

12

G -+/- 2% W represents wattage. The symbol is Ex: 4K7J2W Equivalent resistance: 4.7kΩ, +/-5% 2. SMR coding: It is a surface mounted resistor coding system which is useful to know the value of the Resistor. In this system the tolerance and wattage is printed on bulk pack. EX: 10 *103 Ohms = 10KΩ 3. THREE BAND COLOUR CODE: It is a system is used to know the value of resistance. In this system the resistor Contains 3 colour bands on its body. 1st colour – 1st digit 2nd colour – 2nd digit 3rd colour – multiplication factor 4th colour – tolerance Ex: 1). 270KΩ, +/- 5% Red violet yellow gold practical value: 268KΩ, ± 5% 2) 4.7KΩ, +/- 5% Yellow violet red gold practical value:4.39KΩ, ± 5% 3) 39Ω, +/-1% Orange white black brown practical value: 35Ω, ± 5% 4. FOUR BAND COLOUR CODE:

103

4K7J2W

Page 13: Embedded Application on Microcontroller in Assembly and Embedded C

13

1STband-first digit 2ndband-second digit 3rd band-third digit 4th band-multiplication factor 5th band-tolerance

COLOUR

DIGIT

MULTIPLIER

TOLERANCE

Black Brown Red Orange Yellow Green Blue Violet Grey White Gold Silver No colour Pink colour

0 1 2 3 4 5 6 7 8 9 - - - -

100=1 101=10

102 103 104 105 106 107 108 109 0.1

0.01 - -

+/- 1% +/- 2%

+/- 5% +/- 10% +/- 20%

High stability

EX: 1. 275 K Ω ± 1% Practical value:272KΩ ± 1% Red Violet Green Orange Brown 2. 28.5 K Ω ± 1% Practical value:27.23KΩ ± 1% Red gray green red brown 3. 28.5 Ω ± 1% Red grey green gold brown Classification of resistors: Basically resistors are divided into two types namely fixed resistors and variable resistors. These two types are further classified into different types are shown below

Page 14: Embedded Application on Microcontroller in Assembly and Embedded C

14

CAPACITORS CAPACITOR: A Capacitor or condenser is a two terminal passive component which Has the ability to store electric charge and it opposes instantaneous change of voltage in the circuit. Capacitor blocks the passage of direct current (D.C) and allows the alternating current (A.C) through it. A capacitor essentially consists of two conducting surfaces separated by an insulating medium called dielectric. Capacitance is the property exhibited by a capacitor and may be defined as, “The ability of a capacitor to store electric charge per unit potential difference”. It is measured in Farads. But, in real world, all the generalized usage conditions demands much smaller units measured in milli, micro, nano, pico farads. The circuit symbol is

Page 15: Embedded Application on Microcontroller in Assembly and Embedded C

15

The quantity of charge Q is proportional to the applied voltage v in volts.

i.e. Q ∞ V Q = CV C= Q/V

The unit of capacitance farad is too large for practical purposes hence much smaller units like micro farad, nanofarad, picofarad, are generally employed.

1farad = 1Coulomb / 1volt 1µF=10-6F, 1nF=10-9F, 1mF=10-3F, 1pF=10-12F

Types of capacitors: Capacitors can be classified into various types based on the di-electric material used in them. They are:

Mica capacitors ceramic capacitors paper capacitors Electrolytic capacitors Air capacitors Aluminium capacitors Tantalum Electrolytic capacitors Variable capacitors Tuning capacitors Trimming capacitors

Specification of Capacitor: Capacitance value Tolerance Dielectric constant Dielectric strength Power factor Temperature coefficient Voltage rating (Withstanding voltage) Leakage resistance/Leakage current Factors affecting the capacitor: Capacitance is directly proportional to the area of the plates in square meters. Capacitance depends on to the permittivity of the medium between the plates and Capacitance is inversely proportional to the distance between the plates in meters. C=εA/d [ε=ε0εr] C=ε0εrA/d Where ε0 = absolute permittivity of air =8.8540X10-12F/M εr = relative permittivity of medium

Page 16: Embedded Application on Microcontroller in Assembly and Embedded C

16

Variable capacitors: The capacitors whose capacitance value can be varied are known as variable capacitors. These are of two types. They are 1. Tuning capacitors 2. Trimming capacitors (or) untunned capacitors Losses in capacitors: There are mainly 3 types of losses that will occur in a capacitor. They are Leakage resistance Absorption losses Power factor Di-electric losses

Combination of Capacitors: Capacitors may be connected in series or in parallel in order to decrease or increase the total capacitance value. Capacitors in Series:

C1

C2

C3

BATTERY

12

C=1/C1+1/C2+1/C3 C1, C2, C3 = capacitance of three capacitors. V1, V2, V3 = voltage drops across C1, C2, and C3

V = applied voltage In series combination, charge (Q) on all capacitors is same, but voltage drops are different. V = V1 + V2 + V3 Q/C = Q/C1 + Q/C2 + Q/C3 Capacitors in parallel:

C1 C2 C3BATTERY

12

Page 17: Embedded Application on Microcontroller in Assembly and Embedded C

17

C1, C2, C3 = capacitances of three capacitors Q1, Q2, Q3 = charge on three capacitors V = applied voltage In parallel combination p.d across each capacitor is same but charge on each is different. Q = Q1 + Q2 + Q3 CV = C1V + C2V + C3V

INDUCTORS

INDUCTORS: Inductor is an electro magnetic energy concentrator formed by wounding an insulated Copper wire on the core material. The inductor has got a property called as inductance. Inductance is measured in Henry’s. The symbol for an inductor is

INDUCTOR .The inductance value of an inductor depends on number of turn’s core material etc. There is no frequency for D.C. voltage. The inductor is having a parameter called as inductive reactance (XL)

XL=2╥fL

The over all resistance of inductor is called as impedance.

Z=√R2+(XL)2

Where, Z=Impedance R=Resistance of coil XL=Inductive reactance

Properties of inductors: The inductor opposes A.C. and allows D.C. At the time ( t=0sec) the inductor acts as a open circuit At the time (t=1sec) the inductor acts as a close circuit The current limiting factors of inductors are Frequency

C = C1+C2+ C3

Page 18: Embedded Application on Microcontroller in Assembly and Embedded C

18

Inductance value D.C. resistance

The current flowing through inductor In A.C.→ Z=√R2+XL

2 In D.C → The current limiting factors of inductors are 1. Frequency. 2. Inductance value. 3. D.C. resistance. Applications of Inductors:- Inductors are used by so many electronic devices. They are Chokes Line filters Electro mechanical relays Motors Generators Transformers Chokes: Choke is an AC voltage dropper. It is used in tube lights etc. Line filters: Line filters determine high frequency noise from AC 230V. The symbol Of a line filter is

LINE FILTER

123 4

Relays: Relay is an electrically operated switch. Relay can be defined as “a device opens or closes an auxiliary circuit under some predetermined condition in the main circuit”. The object of relay is to act as a sort of electric magnifier i.e., it enables a comparatively weak current to bring into operation a much stronger current.

I=V/Z

I=V/R

Page 19: Embedded Application on Microcontroller in Assembly and Embedded C

19

RELAY SPDT

35

412

Classification of Relays: Relay can be classified according to the principle of operation, polarization and application as

Based on the principle of operation Electro thermal relays Electromagnetic relays Solid state relays Hybrid relays (combination of both (b) and (c)) Based on the polarization Polarized relays Ex: Telegraph relays Non polarized relays Ex: Telephone relays Based on the application Commercial relays Industrial relays Military relays Communication relays Railways relays

Specifications of relays: Type of relay (NO, NC, CO) Coil operating Voltage Coil Resistance Contact current Eg: 1CO, 12V, 400ohms, 5A

Applications of relays: Circuit selection and switching in various system Automatic control process in industrial plants Semi-automatic processes in industrial plants Mathematical functions in computers Traffic control signals Temperature controllers Electric motor switches Automatic stabilizers Televisions Industries

Contact materials: Low contact resistance High electrical and thermal conductivity

Page 20: Embedded Application on Microcontroller in Assembly and Embedded C

20

High melting point Long operating life and Should not oxidize in atmosphere

Types of contacts:

Make contact (or) normally open contact (abbreviated as N/O): It close when the relay gets energized. Break contact (or) normally closed contact (abbreviated as N/C): It gets broken when the relay is energized. Change-over contact: In this, the movable contact which while changing over its position by the operation of the relay, breaks with one contact and makes with the other. Make-before-break contact: In this type, when the relay is operated, one normally broken contact is first made when it is operated, then only a second normally made contact is broken.

Transformers: A transformer is a static device (or stationary) piece of apparatus by means of which electrical power in one circuit is transformed in to electrical power of the save frequency in another circuit. It can rise or lower the voltage in a circuit but with a corresponding decrease or increase in current. The physical bias of a transformer is “Mutual Induction” between two circuits linked by a common magnetic flux. The first coil, in which electric energy is fed from the A.C supply mains, is called “primary winding” and the other from which energy is drawn out, is called “secondary winding”. In brief, a transformer is a device that transformer electrical power from one circuit to another It does so without a change of frequency It accomplish this by electro magnetic induction Where the two electronic circuits are in mutual inductance to each other.

TRANSFORMER

1 5

4 8

Types of Transformers: Transformer is a device converts AC to AC in following manner Step down transformer Step up transformer Isolation transformer Auto transformer Power transformer

Page 21: Embedded Application on Microcontroller in Assembly and Embedded C

21

Step down transformer: Transformer is a linear device. In this type of transformer the secondary voltage always less than the primary voltage.

Step Down TRANSFORMER

15

48

VS < VP NS < NP Where, VS = Secondary voltage VP = Primary voltage NS = No of turns of secondary Np = No of turns of primary Step up transformer: In this type the secondary voltage is always greater than the primary voltage.

Step Up TRANSFORMER

1 5

48

VS > VP NS > NP Isolation transformer: It is a 1: 1 transformer provides isolation between primary and secondary

TRANSFORMER

1 5

4 8

VS = VP

NS = NP If voltage reduces at the output then it is step down transformer. If voltage increases at the output then it is step up transformer. If input voltage is equal to output voltage then it is isolation transformer

Page 22: Embedded Application on Microcontroller in Assembly and Embedded C

22

TRANSFORMER

1 5

4 8

230v, 12v, 1Amp Auto transformer: It is a transformer with one winding part only.

Variac2 5 3 4 1

It is a transformer with one winding part only. common to both primary and secondary, in this transformer the primary and secondary are not electrically isolated from each other as is the case with a two winding transformer. Because of one winding it uses less copper and hence is cheaper. It is used where transformation ratio differs little from unity. Losses in a transformer: i) Core (or) Iron loss: It includes both hysterisis loss and eddy Current loss. The core loss is practically the same at all loads. ii) Copper loss: This loss is due to ohmic resistance of the transformer windings. Current Relations of transformers: Vp/Vs = Is/Ip = Np/Ns If the no. of turns increases, it results in increase in the coil resistance which makes current decrement. Transformers types: Single tapped transformer: It is an ordinary transformer. In this type of transformer it contains two Output terminals.

TRANSFORMER

1 5

4 8

Page 23: Embedded Application on Microcontroller in Assembly and Embedded C

23

Centre tapped transformer: In this type of transformer it contains three output terminals. From 1&2 terminals of secondary windings we get positive voltage and from 2&3 terminals we get the output voltage as negative. From 1&3 terminals we get the sum of voltage at the 1&2 terminals and the voltage at the 2&3 terminals.

Centre Tap

1

4

5

6

8

Multi tapped transformer: It will contain 3 or more output terminals. It produces different outputs at the different terminals from 1 to 4 of the secondary windings.

MultipleTap

9

8

4

3

2

1

Isolated tapped transformer: In this type of transformer the output is same as the applied voltage.It is used for provide between the input and output.

Isolated Tap

11

109

8

7

5

6

4

3

2

1

Current Transformer: It is setup transformer. It used measure the high currents. The primary windings of the current transformer must have 2 or 3 windings. In this in terms of voltage we calculate the current. In this we increase the current depending on the number of secondary windings. Voltage Transformer: It is a step down transformer, used to measure high voltages. In this transformer we decrease the voltage depending on the number of secondary windings.

Page 24: Embedded Application on Microcontroller in Assembly and Embedded C

24

SEMICONDUCTORS SEMICONDUCTORS: Semiconductors are solid materials whose electrical properties lie in between conductors and insulators. All semiconductors are negative temperature coefficient materials i.e resistance of semi conductors decreases with increase in temperature and vice versa. These are half filled valency electrons. Example: Silicon, Germanium The process of adding impurities to the pure semi conductors is called “Doping”. Depending on the process of doping, semi conductors are classified into two types.

1. Intrinsic semiconductors 2. Extrinsic semiconductors

Intrinsic semiconductors: A Semiconductor in its pure form is called intrinsic semiconductor. In intrinsic semi conductor, equal no. of electrons and holes will be available at room temperature. So current conduction takes place by both electrons and holes equally. It has poor conductivity because of less no. of free charge carriers. Eg: pure silicon, pure germanium.

Extrinsic semiconductors: Impure or doped semi conductors are called as extrinsic semiconductors. These have more conductivity because of more no. of free charge carriers. The current conduction of these semiconductors depends upon level of impurity or amount of doping. The impurities may be pentavalent or trivalent atoms. The atoms whose valence electrons are five are called as “Pentavalent atoms”. These are also called as donor impurities because they donate electrons to the conduction band. The atoms whose valence electrons are three are called as trivalent atoms. These are also called as acceptor impurities because they accept electrons from conduction band. TYPES OF EXTRINSIC SEMICONDUCTORS: Depending upon the type of impurities added these are further divided into two types. Namely 1. N-TYPE 2. P-TYPE

Si

Page 25: Embedded Application on Microcontroller in Assembly and Embedded C

25

N-TYPE SEMICONDUCTORS: These are formed by adding pentavalent impurities such as Arsenic (33), to pure semiconductor like germanium (32). These are the donor materials. P-TYPE SEMICONDUCTORS: These are formed by adding trivalent impurities such as boron (5) to pure semiconductor like silicon (14). These are acceptor materials. FORMATION OF PN JUNCTION: When P and N type materials are placed together then the free electron in n-type material is combine with the hole i.e free electrons are diffuse from N region to P- region to N-region. Then positive charge developed in N-type & negative charge in the p-type. At the junction potential barrier is formed. The barrier voltage is 0.3v for Ge and 0.7v for Si .The barrier potential opposes the flow of majority charge carriers from one side to another side and it assist the flow of minority charge carriers in crossing the P-N junction. The barrier potential can be decreased or increased by applying external voltage.

PN JUNCTION DIODE

1 2

Al

P

Page 26: Embedded Application on Microcontroller in Assembly and Embedded C

26

P-N JUNCTION WITH FORWARD BIAS: If the positive voltage is connected to the p-side or anode and negative voltage is connected to the n-side or cathode then the P-N junction is said to be forward biased. In forward bias holes in the p side and electrons in the N-side are compelled to move towards the junction. As a result the width of the depletion region is reduced. With the increase in external voltage the barrier voltage decreases smaller and smaller and at one particular external voltage the barrier potential totally disappears. Then the junction offers very low resistance.

PN JUNCTION DIODE FORWARD BIAS1 2

BATTERY

1 2

1. With the increase in external voltage the barrier potential decreases. 2. The junction offers low resistance (almost zero resistance) 3. Forward current P-N JUNCTION WITH REVERSR BIAS: If the positive terminal is connected to the N-type (or) cathode and negative terminal is connected to the P-type (or) anode then the PN junction is said to be Reverse biased. In reverse bias the majority charge carriers will be attracted towards the external voltage without crossing the PN junction. These majority carriers will leave the immobile ions at the junction. Thus the width of depletion region increases. As a result there is no current due to majority charge carriers When the PN junction is reverse biased.

BATTERY

1 2

PN JUNCTION DIODE REVERSE BIAS

With increase in external voltage the Barrier potential increases. The junction offers very high resistance (Almost infinite) &current flow is low.Very little amount of current (In the order of Nano & Micro ampere flows which can be treated as zero) due to minority carriers. DIODE SPECIFICATIONS:

Maximum forward current (IF max): It is the maximum forward current through the diode when it is conducting. Peak inverse voltage (PIV): This is the maximum reverse voltage that a diode can withstand without being destroyed. Maximum forward voltage drop (VF): It gives the maximum forward voltage drop for a given forward current. Recovery time: It is the time taken by a diode to change its state from forward bias to reverse and vice versa.

Page 27: Embedded Application on Microcontroller in Assembly and Embedded C

27

Applications: Used in rectifier circuits for converting A.C current into D.C current. Used as signal diodes in Modulation & Demodulation circuits. Used as regulators. Used in Radio &T.V receivers in tuning circuits. Used in Digital logic gates. Light emitting diodes used as visual displays

OTHER DIODES

Zener diode: Zener diode is the heavily doped silicon or germanium PN junction diode . It is always operated in the breakdown region. By varying the doping level it is possible to produce Zener diodes with breakdown voltages from about 2v to 200v. Zener diode is heavily doped PN junction diode which is operated in the reverse bias only. The operation depends on the Zener breakdown voltage. The breakdown voltage is based on the doping concentration. If the doped concentration increases Zener breakdown voltage decreases & vice versa.

If the Zener diode is operated in the forward bias, the characteristics are same as that of a rectifier diode. Zener diode is always operated in reverse bias mode. Zener breakdown voltage is defined as the reverse voltage at which current increases suddenly& sharply. After breakdown takes place the voltage across Zener diode remains constant at Vz.

The main application of Zener diode is “VOLTAGE REGULATER”. The diode regulates the o/p voltage according to the load.

ZENER DIODE SPECIFICATIONS :

Breakdown voltage. Wattage

Ex: 5.6v (ZBV);1W(Max. Power) LIGHT EMITTING DIODE: It is a forward bias operated diode. The energy is required to generate an electron hole pair, Due to recombination of this electrons & holes an energy is liberated from its junction in the form of light. Light emitting device (LED) converts electrical energy into optical energy.

LED Gallium phosphide – Red Magnesium Phosphide - Green Light Gallium arsenide – Infrared Radiations Gallium arsenide Phosphide – Red (or) Yellow

Page 28: Embedded Application on Microcontroller in Assembly and Embedded C

28

Under forward bias if forward voltage increases then the electrons & holes combines each other at the junction and results radiation of light energy. The efficiency of light generating increases with increasing current or by decreasing temperature i,e The generating light is directly proportional to current applied and inversely proportional to temperature. Applications:

Instrument displays. Telephone exchange. Over load indications. Digital watches.

Specifications of LED: Colour. Size. Voltage. Max .current

Ex: Red, 5mm, 3V, 5mA IR LED: It is forward bias operated diode used to generate infrared rays. This type of LED’s are used in remote control systems, light vision cameras. These are manufacture with Gallium Arsenide materials.

VCC

RESISTOR

IR LED

Laser Diode: It is forward operated diode used to generate Laser light. This type of are most widely used in medical applications.

VCC

RESISTOR

LASER DIODE

Photo Diode: A Photo diode is a two terminal PN junction device which operates in the reverse bias on “PHOTO CONDUCTIVE EFFECT”. When there is no light applied current in the diode is

Page 29: Embedded Application on Microcontroller in Assembly and Embedded C

29

called Dark current. As light intensity increases the reverse current also increases. Hence the diode current is directly proportional to reverse bias current & light intensity.

VCC

RESISTOR

PHOTODIODE

12

Applications:

Light operated switches. Light detector. High speed counting & switching. Encoders. Decoders. Alarm circuits.

TRANSISTORS: Transistor is a three layers, two junction & three terminal semiconductor device. A transistor may be regarded as two back to back PN junctions in a single piece of semiconductor. The two junctions give rise to three regions. The middle region is called Base & the outer two regions are called as Emitter & Collector. The PN junction b/w Emitter & Base is called Emitter Base region (or) Emitter region. The PN junction b/w collector & base is called Collector region (or) Collector Base region. Emitter is one of the transistors which emit majority charge carriers into base region. Physical area of emitter is < collector & > base. Doping concentration is more than collector & base. Base is the middle region of the transistor which is very thin & lightly doped as compared to either emitter or collector. Collector is third region which collects the charge carriers emitted by the electrons trough the base. Doping concentration of Collector > Base < Emitter>Collector. Collector region is made physically larger than emitter & base to dissipate much heat generated. Transistor is a variable resistor whose resistance between emitter and collector lies between zero and infinity. The value of this resistance is continuously changes with changes in base current. If there is no base current, then the transistor offers infinity resistance b/w collector & emitter. This state is known as “Cut off state” acts as open switch. If the base current goes on increasing the resistance b/w collector & emitter is decreases from infinity to zero. Then this state is known as ” Active state ”. In this state transistor acts as an “amplifier”. If there is a maximum base current the R value is zero. It is known as “Saturation state” and the transistor acts as “Closed Switch”. Depending on the type of material added the transistors are classified into two types.

1) NPN transistor

Page 30: Embedded Application on Microcontroller in Assembly and Embedded C

30

2) PNP transistor For NPN transistor arrow points from base to emitter mean’s that the base is at positive potential with respect to emitter.

PNP

12

3

NPN1

23

In transistor the emitter current IE is equal to sum of base current IB and collector current Ic i.e.

IE=IB+IC. Transistor Testing:

With respect to base collector, emitter forward bias test>>B-C, B-E=Forward bias. With respect to base collector, emitter forward bias test>>B-C, B-E=Reverse bias. Collector & Emitter forward bias (or) Reverse bias.

Transistor Specifications: Maximum collector to emitter voltage (Vce max). Maximum collector current (Ic max) Maximum power dissipation (PDmax)

Transistor Applications: Used as amplifiers. 4. Modulators. Oscillators. 5. Relay drivers. Mixers. 6. Switching circuits.

These are the applications of a Transistor.

DIGITAL ELECTRONICS

In digital electronics the total circuit operations are performed by using Logic Gates. In Logic Gates the most widely used gates are NAND and NOR gates. These gates are called UNIVERSAL GATES as these are used to implement any gate such as AND, OR & NOT. AND GATE: It is used as multiplier. The output of this gate is HIGH only when the two inputs are at active high. The output is LOW when any one of the input is low. OR GATE: It is used as adder. The output of this gate is HIGH when any one of the input is at active high. The output is LOW when two inputs are at active low. NOT GATE: It used as inverter. If the input is high, the output is LOW. If the input is low, the output is HIGH. EX-OR GATE: It is also called as EXCLUSIVE OR gate. Output of this gate is = A`B+AB`

POWER SUPPLIES

HALF WAVE:

Page 31: Embedded Application on Microcontroller in Assembly and Embedded C

31

0V-12V

1 5

4 8

D11 2

Capacitor

1. The above figure shows Half Wave rectifier. 2. Half Wave Rectifier consists of Ordinary transformer, 1N4007diodes (1). 3. The input is applied to the primary windings of the transformer and one

diode connected in series to the secondary. 4. During the positive half cycle of the AC input signal the diode D1 is forward

biased which results the Positive cycle is rectified. 5. During the Negative half cycle of the AC input signal the diode D1 is reverse

biased which results the negative half cycle is not rectified. 6. Hence the Half wave rectifier rectified only one half cycle.

FULLWAVE:

12V-0V-12V

1 5

6

4 8

1N4007

1 2

1N4007

1 2Capacitor

1. The above figure shows Full Wave Rectifier. 2. Full Wave Rectifier consists of Center tapped transformer, 1N4007diodes (2). 3. The input is applied to the primary windings of the transformer and two diodes

connected in series to the secondary. 4. During the positive half cycle of the AC input signal the diode D1 is forward biased

and diode D2 is reverse biased which results the Positive cycle is rectified. 5. During the Negative half cycle of the AC input signal the diode D2 is forward

biased and diode D1 is reverse biased which results the negative half cycle is rectified.

6. Hence the full wave rectifier rectifies full cycle.

BRIDGE RECTIFIER:

160uF/16V330uF/25V

- +

BRIDGE

1

4

3

2

T7

12V-0V, 500mA

1 5

4 8

7805

1 3

2

VIN VOUT

GN

D

AC 230V

AC230V +

-

Page 32: Embedded Application on Microcontroller in Assembly and Embedded C

32

1. The above figure shows the Bridge Rectifier with 5v regulation. 2. Bridge Rectifier is also called as ‘Ordinary Full Wave Rectifier’. 3. It consists of one ordinary transformer, 1N4007 diodes (4) and 7805 regulator. 4. The input is applied to the primary windings of the transformer and bridge circuit is

connected to the secondary. 5. During the Positive half cycle of the A.C input signal, the diodes D1 and D3 are

forward biased & D2 and D4 are reverse biased, which results the positive half cycle rectification.

6. During the Negative half cycle of the A.C input signal, the diodes D2 and D4 are forward biased & D1 and D3 are reverse biased, which results the negative half cycle rectification.

7. Hence Bridge Rectifier rectifies the full cycle of the A.C input signal. 8. The output of the rectifier is connected to 7805 Regulator. 9. In this 78 represents the positive voltage and 05 represents 5v output. 10. Hence we obtain 5v at the output of bridge rectifier.

Operational amplifier:

The above block diagram shows the basic operational amplifier simply called as Op-Amp. The first stage of an Op-Amp differential amplifier has high input impedance and large gain. The second stage is intermediate stage provides the additional gain to the output of differential amplifier. A level shifting circuit / level translate circuit is placed between second and final stage to eliminate DC component without entering in to the output stage. By eliminating DC level at the final stage. The output voltage is varying between the ‘0’ to reference voltage. Thus preventing any undesired DC current entering into load.

+

-

IC 741

3

26

74

The above figure shows the symbol of Op-Amp in which it has two inputs namely non inverting input with positive sign and inverting input with negative sign. If the signal is given to inverting input the OP-Amp is said to be Inverting amplifier. If the input is given to the non inverting input then the Op-Amp is said to be Non-inverting amplifier.

Differential input stage

Intermediate stage

Level shifting Output Stage

Page 33: Embedded Application on Microcontroller in Assembly and Embedded C

33

The above figure shows the pin diagram of the Op-Amp (IC 741) which is an 8 pin DIP IC.

Functions of Op-Amp:

1. inverting amplifier 2. Non- inverting amplifier 3. Summer 4. Sub tractor 5. Multiplier 6. Voltage follower 7. Current follower 8. Integrator 9. Differentiator 10. Comparator.

Astable multi Vibrator:

VCC

NE555

2

5

37

6

4

TR

CV

QDIS

THR

R

1K

1K

1500uF/25V

10KLED

0.1uF

The astable multivibrator using IC 555 is shown above during the charging period the transistor it is held open by the flipflop and the capacitor charges through the resistor Ra& Rb when the voltage across the capacitor reaches the reference level of the upper comparator the comparator changes the state of the flipflop and this turns on the transistor.

Page 34: Embedded Application on Microcontroller in Assembly and Embedded C

34

The capacitor discharges through resistor Rb until its voltage reaches the reference level of the comparator. This comparator changes the state of the flipflop again which turns off the transistor the charging time of the capacitor is determined by

T1= C[RA+RB]

The capacitor discharges from 2/3 Vcc forwards 0V hence the discharge period of the capacitor is determined by T2= (CRB log 0-2/3 Vcc) / 0-1/3 Vcc

T2= 0.7 RB C

The total time period is given by

T= T1+T2 = 0.7 (RA+2RB) C

Applications:

1. Used in Timing circuits.

2. Used in hobby circuits.

Mono stable Multivibrator:

VCC

VCC

1K

TSOP 1738

12

3

10K

1500uF/25V 0.1uF47- -̂

LED

10uF/25V

NE555

2

5

376

4

TR

CV

QDISTHR

R

10K

Mono stable multivibrator using IC 555 is shown above. In the absence of trigger input the timing capacitor C is held in the discharged state. In this state the output is low. If the trigger voltage is above the threshold level then the state of the circuit may change. (VT>VTH) when the negative going trigger pulse is applied at trigger terminal and if it is greater than 1/3 VCC then the flipflop will set and the transistor will cutoff. Causing discharge capacitor starts charging exponentially it is given by,

Page 35: Embedded Application on Microcontroller in Assembly and Embedded C

35

V=VCC (1-e-t/RC)

When the voltage at the threshold terminal is greater than 2/3 VCC the flip flop will reset which makes transistor T1 to ON. Causing discharge of the capacitor C. the trigger pulse width must be less than the timing signal for proper operation of the timer. The mono stable timing period can be varied by a voltage applied to the control terminal and is given by,

T=RC log [Vcc/ (Vcc-⅔Vcc)]

T=1.1 RC

Applications:

1. It produces stretched rectangular wave hence is used in timing circuits and control circuits.

2. It is used in auto cut voltage stabilizer.

Opto-coupler:

VCC VCC

10K

PHOTODIODE

12

330- -̂

LED

Vout

Opto Coupler

Principle:

An opto-coupler is a solid state component which light emitter (led) the light path and the light detector are contained in a light tight encapsulation. The photo detector may be photo diode, photo transistor or a photo thermistor.

Working:

When current flows in the diode the emitted light is directed to the photo transistor and causes current flow in transistor since the coupling is optical. There is a high degree of isolation. Typically the transistor current is about 60% of the led input current

The Opto isolator provides complete isolation between the i/p & o/p signals. This feature allows it to be used as an interface between high voltage and low voltage systems.

Page 36: Embedded Application on Microcontroller in Assembly and Embedded C

36

Applications:

1. In fiber optic communication 2. To reduce common ground connection 3. In switching applications 4. In chopping applications 5. It is used where electronic isolation is required

Comparator:

1. The above fig(a) shows the pin diagram of the LM393 comparator 2. This diagram comparator internally consists of two comparators 3. The main application of the LM393 comparator is, it compares the input voltage and

gives the output as active high or active low

Temperature stability using LM393 comparator:

VCC

VCC

VCC

LM393

1

3

2

411

OUT

+

-

V+V-

10K

10K

3.3K

t4.7K

12

LED

Page 37: Embedded Application on Microcontroller in Assembly and Embedded C

37

Working:

1. The above fig(b) shows the thermistor in LM393 comparator 2. From the figure at the 3rd pin of the comparator two equal values of the resistors are

connected in the potential divider manner. 3. From this connection we get 2.5v at the 3rd pin 4. This 2.5v voltage is treated as the reference voltage of the comparator for

comparison 5. The LDR and resistor are connected in potential divider network manner. 6. The thermistor is a NTC type I, e the temperature increases resistance decreases

and voltage across the thermistor is also decreases. 7. This voltage is applied across the 2nd pin of the comparator. 8. Then the comparator compares the voltage with the ref voltage and gives the output. 9. If V1>V2 the led will glow. 10. If v1=v2 or v1<v2 the comparator produce negative voltage.

Then the LED comes under reverse bios and will not glow.

Light intensity monitoring using LM393 comparator:

VCC

VCC

VCC

LM393

1

3

2

411

OUT

+

-

V+V-

10K

10K

3.3K

t4.7K

12

LED

Working:

1. The above fig(b) shows the thermistor in LM393 comparator 2. From the figure at the 3rd pin of the comparator two equal values of the resistors are

connected in the potential divider manner. 3. From this connection we get 2.5v at the 3rd pin 4. This 2.5v voltage is treated as the reference voltage of the comparator for

comparison 5. The LDR and resistor are connected in potential divider network manner. 6. The thermistor is a NTC type I, e the temperature increases resistance decreases

and voltage across the thermistor is also decreases. 7. This voltage is applied across the 2nd pin of the comparator. 8. Then the comparator compares the voltage with the ref voltage and gives the output.

Page 38: Embedded Application on Microcontroller in Assembly and Embedded C

38

9. If V1>V2 the led will glow. 10. If v1=v2 or v1<v2 the comparator produce negative voltage.

Then the LED comes under reverse bios and will not glow.

DTMF

Features • Full DTMF receiver

• Less than 35mW power consumption

• Industrial temperature range

• Uses quartz crystal or ceramic resonators

• Adjustable acquisition and release times Applications • PABX

• Central office

• Mobile radio

• Remote control

• Remote data entry

• Call limiting

• Telephone answering systems

• Paging systems Pin Diagram

Page 39: Embedded Application on Microcontroller in Assembly and Embedded C

39

MICRO CONTROLLER

Microcontrollers are generally dedicated for specific applications. A microcontroller may take an Input from the device it is controlling and controls the device by sending signals to different components in the device. Microcontroller normally contains a processor, memory, serial ports, and necessary logic circuits to perform the specific function.

A microcontroller is a computer (or) processor (CPU) with most of the necessary chips on board. The actual processor used to implement a microcontroller can vary widely. In many products, such as microwave ovens, the demand on the CPU is fairly low and price is an important consideration. In these cases, manufactures turn to dedicated microcontroller chips- devices that were originally designed to be low-cost, small low power, embedded CPUs. The Intel 8052 is good example for it. Microcontroller normally contains RAM, ROM, Timer-counter, serial I/O Ports, Oscillator etc.

THE BLOCK DIAGRAM OF A GENERAL MICRO CONTROLLER IS AS FOLLOWS:

Page 40: Embedded Application on Microcontroller in Assembly and Embedded C

40

Features of AT89C52 Microcontroller Total pins = 40 External Memory Interface

Data lines = 08 Address lines = 16

I/O lines = 32 Interrupt lines = 03 Registers = 34(8-bit) & 02(16-bit) Internal ROM = 8K Bytes Internal RAM = 256B (256 x 8-Bit Internal RAM ) Flags = 04 Timer / Counter = 03 (16-bit) Serial port(UART) = 01 (Programmable Serial Channel ) Parallel ports = 04 Endurance = 1,000 Write/Erase Cycles Operating Range = 0 Hz to 24 MHz Three-level Program Memory Lock Eight Interrupt Sources Low Power Idle and Power Down Modes

Functional block diagram of 8052 microcontroller: The 8052 is a 40 pin chip with NMOS (N-channel metal oxide silicon) technology. The functional block diagram of 8052 can be represented in several ways.

Page 41: Embedded Application on Microcontroller in Assembly and Embedded C

41

1. Central Processing Unit (CPU) : The CPU of 8052 is capable in performing arithmetic and logical operation, subtraction, multiplication, division, logical AND, OR, EX-OR, rotate, clear and complement. This CPU can do Bit wise as well as byte wise manipulations. The 8052 contains several registers, such as accumulator, B-, data pointer, program counter, stack pointer, and program status- word (PSW).

2. Internal Memory: In general CPU requires program codes and relevant data while performing a task. In order to make them available the 8052 has two types of internal memories, i.e.: RAM and ROM. The i-RAM is of 256 bytes. It is divided into three parts, such as:

i. 32 resisters in four banks of ‘8’ each. ii. 16 resisters – bit addressable. iii. 80 resisters – byte addressable.

The i-ROM is of 8KBin size ranging from 0000H to 0FFFH. 3. Special Function Registers:

The 8052 has several Special Function Registers (SFRs) known as A, B, DPTR, PSW, IP, IE, TCON, SCOON, PCON, P0,P1,P2,P3, SBUF etc. all these are byte addressable and some of them are bit addressable also. The SFRs can be accessed by their names or by their addresses. These are useful in accessing I/O Ports, timer/counters, UART, Power Controlling etc.

4. Timers / counters: The 8052 has two timers / counters. Many microcontroller applications are requires the counting of external events happened around the microcontroller or in maintaining the time delays between the actions occurred inside of the microcontroller. Counters are used to count the events where as timers are used to maintain time delays between the actions. This unit has two 16-bit registers named as T0 & T1. Since the 8052 is a 8-bit controller, these registers are also byte addressable i.e., low byte and high byte (TL0, TL1& TH0, TH1) Two SFRs TMOD and TCON are used to monitor the nature of working of the said registers T0 & T1.

5. Serial port: This unit provides serial data transfer. This feature is required in certain communications with other communications with other computers and while accessing with some peripherals like printer. A SEF known as SBUF is used to hold the data transfer and after serial data transfer. Two other SFRs, SCON and PCON are used to determine the baud rate, transmission, reception, etc. In fact SBUF has two 8-bit registers, one for holding the data while transmission. Another register receives the data and

Page 42: Embedded Application on Microcontroller in Assembly and Embedded C

42

carries during reception. The serial data communication can be held in one of the four modes.

6. Interrupt Control: This unit alters the microcontroller’s attention from one task to some other. This may generate in the inside of the 8052 or provided from the external sources. The 8052 has eight interrupts. These interrupts either all or selectively enabled / disabled through a SFR ‘IE’. Further the priority among these can be determined by another SFR ‘IP’.

7. I/O Ports: In 8052, there are four I/O ports with 8 lines of each. Some of these ports can be configured as an Input or as an Output port. In addition port 3 performs some specified functions. Special circuits like latch, buffer and driver are built in these ports to perform the said actions.

8. Oscillator and Clock: In order to synchronize all the internal operations of the microcontroller, an on-chip oscillator is used. However requires an external oscillator to run the on- chip oscillator to run the on-chip oscillator. A quartz crystal oscillator is connected as an input to the said purpose. The 8052 designs are available with wide range of frequencies, typically from 1MHz to 16 MHz

Register structure of 8052:

Registers are used to store the data temporarily. The data may be of opcodes or operands or address of a memory location or address of a peripheral. The 8052 has wide range of registers. These are classified as

Bit addressable (or) byte addressable General purpose (or) special function 8-bit length (or) 16 bit length Independent (or) dependent (part of RAM)

Pin diagram of 8052:

Page 43: Embedded Application on Microcontroller in Assembly and Embedded C

43

The Pin diagram of 8052micro controller is shown in above fig. it is available in a 40 pin plastic and ceramic packages. All 40 pins are easily distinguishable a carrying the specific functions. It is worth noted that the 32 pins will have two different functions. A brief discussion of these pins is explained here under.

Pin 1-8: P1.0- P1.7: A total of 8 lines named as port-1 and used for input or output.

Pin 9: RESET: Active HIGH input used to reset the microcontroller and terminate all activities.

Pin 10-17: P 3.0 – P 3.7: A total of lines named as port-3 and used for input or output. In addition, these lines provide special functions, as listed below.

*P 3.0 (R×D) : Data received in serial form.

*P 3.1(T×D) : Data transmitted in serial form.

*P 3.2 (INTO): Hardware interrupts of vectored location 0003H.

*P3.3 (INTI): Hardware interrupts of vectored location 0013H.

*P3.4 (T O): Pulse input given to the Counter – 0.

*P 3.5(T I): Pulse input given to the Counter-1.

*P 3.6 (WR) : A control signal activates memory (I/O device) for read operation.

Pin 18-19 (XTL1 & XTL2) : A quartz crystal oscillator and capacitors formed age s pulse generator and is connected to inputs X T A L 1 & X T A L 2 to run the on- chip oscillator.

Pin 20 (GND): This is a return (ground) pin for the supply.

Pin 21-28: P 2.0- p2.7(Ag-A15) : A total of 8 lines named as port and used for input and output. In addition, these lines provide high order address byte (An 8–A15) through which the 8052 can access 64K bytes memory.

Pin 29: (PSEN) : “Program Store Enable” is an output pin used to access the external program memory (ROM) while connecting it to ‘OE’ terminal of ROM chip.

Pin 30 : (ALE) : “Address Latch Enable” is an output pin used to latch the low order address byte (A0-A7). This is for demultiplexing the address and data.

Pin 31: (EA): “External Access” is an input pin used to access the external program code memory (ROM) only. If this is at Vcc level then the 8052 can access 4K bytes of internal ROM (000H-0FFFH) and external ROM of 60K bytes (1000H-FFFFH).

Pin 32-39: P 0.0 – P 0.7(A D0- a D7): A total of 8 lines named as port-0 and used for input and output. In addition these lines also provide a dual function carrying of address (low order byte)

Page 44: Embedded Application on Microcontroller in Assembly and Embedded C

44

and data (D0-D7). ALE pin indicates that these lines are having either address or data. When ALE =1, these lines represents the low order address byte otherwise data byte. Pin 40: Vcc : This is a +5V supply voltage pin. Design a circuit to flicker an LED light with 50% duty cycle and write a program for it. The main concept of this project is to generate a 50% duty cycle square wave indicated by the blinking of a LED connected to the micro controller. It is constructed using 12-0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V & 470uF/16V filtering capacitors, AT89c52 micro controller, BC547 NPN transistor and a 3mm LED. Here we used an AT89C52 microcontroller from the 8051 family. A 3mm red LED is connected to the P2.0 of micro controller. The micro controller is provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the noise signal. The LED is connected to P2.0 using a general purpose NPN driver transistor BC547 with base resistor 10kΩ for limiting the base current. A 1kΩ is used in series with LED for its forward current limitation. We write a program to configure the port 2 as output port and continuously set and clear the P2.0 with one second delay. Circuit diagram:

VCC

VCC

VCC+12v

VCC

VCC

VCCVCC

1

23456789

TRANSFORMER1 5

6

4 8 +100/16

4007

33p123456789

L7805

1

3

2VIN

GN

D VOUT

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

11.0592

33p

+1000/25

1 2 3 4 5 6 7 8 9

1

2 3 4 5 6 7 8 9

4007

104p

+10/16

8.2K

4148

BC547

LED

RESISTOR

AC230V

Page 45: Embedded Application on Microcontroller in Assembly and Embedded C

45

Program: 1) Blinking of LED p2.0-LED ;******************STARTING MODULE********************* ORG 0000H LJMP START ;****************MAIN MODULE************************* START: ORG 0050H SETB P2.0 LCALL DELAY CLR P2.0 LCALL DELAY ACALL START ;********************DELAY MODULE********************** DELAY: MOV R7,#FFH L3 : MOV R6,#FFH L2 : MOV R5,#FFH L1 : DJNZ R5,L1 DJNZ R6,L1 DJNZ R7,L1 RET END; 2) Flickering of LED for 10 times when switch at P1.0 is pressed. ;***************STARTING MODULE******************** ORG 0000H LJMP START ;******************MAIN MODULE*********************** ORG 0050H BLINK : MOV R0,#0AH START: SETB P2.0 LCALL DELAY CLR P2.0 LCALL DELAY DJNZ R0, START HERE: SJMP HERE ;******************DELAY MODULE************************* DELAY: MOV R7,#05H L3 : MOV R6,#FFH L2 : MOV R5,#FFH L1 : DJNZ R5,L1 DJNZ R6,L2 DJNZ R7,L3 RET END;

Page 46: Embedded Application on Microcontroller in Assembly and Embedded C

46

Design a circuit to display the number of persons entering into the auditorium in a 7-segment display using micro controller.

The main concept of this project is to display the number of persons entering into a room in a seven segment display connected to the micro controller. It is constructed using 12-0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V & 470uF/16V filtering capacitors, AT89c52 micro controller, common anode 7-segment display. Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the noise signal. The project is having an opto coupler designed using an IRLED and Photo Diode connected to P1.0. This opto coupler senses the obstruction occurring and displays the count in the 7-segment display connected to P2.

Circuit Diagram:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCC

VCC

VCC

VCC

330- -̂ 10K

PHOTODIODE

12

LED

ULN2803

1234567

18171615141312

9811

1B2B3B4B5B6B7B

1C2C3C4C5C6C7C

COM8B8C

33p123456789

1

23456789

TRANSFORMER1 5

6

4 8

11.0592

33p

+100/16

4007

1

2 3 4 5 6 7 8 9

4007L7805

1

3

2VIN

GN

D VOUT

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

+1000/25

1 2 3 4 5 6 7 8 9

+10/16

8.2K104p

AC230V

Page 47: Embedded Application on Microcontroller in Assembly and Embedded C

47

Program: P3.0 =Switch ;******************STARTING MODULE********************** ORG 0000H LJMP START ;******************MAIN MODULE**************************** ORG 0050H START: MOV P1,#00H xx: MOV R0,#FFH YY: INC RO LCALL DISP CJNE R0,#0AH,YY LJMP xx DISP: SW: JB P3.0,SW LCALL DELAY JB P3.0,SW SW1: JNB P3.0,SW1 LCALL DELAY JB P3.0,SW1 D0: CJNE R0,#00H,D1 MOV P1,#3FH RET D1: CJNE R0,#01H,D2 MOV P1,#06H RET D2: CJNE R0,#02H,D3 MOV P1,#5BH RET D3: CJNE R0,#03H,D4 MOV P1,#4H RET D4: CJNE R0,#04H,D5 MOV P1,#66H RET D5: CJNE R0,#05H,D6 MOV P1,#6DH RET D6: CJNE R0,#06H,D7 MOV P1,#7DH

Page 48: Embedded Application on Microcontroller in Assembly and Embedded C

48

RET D7: CJNE R0,#07H,D8 MOV P1,#07H RET D8: CJNE R0,#08H,D9 MOV P1,#7FH RET D9: CJNE R0,#09H,D10 MOV P1,#6FH D10: RET ;*************************DELAY***************************** DELAY: MOV R7,#FFH DJNE R7,$ RET END;

Page 49: Embedded Application on Microcontroller in Assembly and Embedded C

49

Design a project to drive the DC linear motor with direction control and write a program for it. The main concept of this project is to display the number of persons entering into a room

in a seven segment display connected to the micro controller. It is constructed using 12-0-12

centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller,BC557 PNP transistor, ULN2803, and

12V linear motor.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal.

The kit is constructed with ULN2803 Darlington 8 transistor packs using as motor driver

along with two PNP driver transistors BC557 used as protection transistors. The logic is

developed so that, when the two inputs are 0,0 the motor is at OFF state and (1,0), (0,1) as two

directional controls inputs for forward and reverse directions. Circuit:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCC

TRANSFORMER1 5

6

4 8

33p

4007

123456789

1

23456789

33p

11.0592AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

+100/16

+1000/25

1

2 3 4 5 6 7 8 9

L7805

1

3

2VIN

GN

D VOUT

4007

1 2 3 4 5 6 7 8 9

Switch1 2

8.2K

+10/16

104p

Linear Motor

1 2

ULN2003

1234567

16151413121110

8

1B2B3B4B5B6B7B

1C2C3C4C5C6C7C

COM

AC230V

BC557BC557

Page 50: Embedded Application on Microcontroller in Assembly and Embedded C

50

Program: ;**************STARTING MODULE***********************

ORG 0000H

LJMP START

;*******************MAIN MODULE********************

ORG 0050H

START: JB P3.0,START

LCALL DELAY

JB P3.0,START

SW1: JNB P3.0,SW1

LCALL DELAY

JNB P3.0,SW1

SETB P1.0

CLR P1.0

LCALL DELAY

CLR P1.0

SETB P1.1

LCALL DELAY

CLR P1.0

SETB P1.1

LCALL DELAY

;********************DELAY MODULE**************************

DELAY: MOV R7,#05H

L3 : MOV R6,#FFH

L2 : MOV R5,#FFH

L1 : DJNZ R5,L1

DJNZ R6,L2

DJNZ R7,L3

RET

;********************************************************

END;

Page 51: Embedded Application on Microcontroller in Assembly and Embedded C

51

Develop an interfacing circuit between GSM/CDMA mobile and micro controller using DTMF network for remote switching operation.

The main concept of this project is to display the number of persons entering into a room

in a seven segment display connected to the micro controller. It is constructed using 12-0-12

centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller, DTMF decoder CM8870, BC547 NPN

transistors, 12V electromechanical Relays.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal.

The phone line is taken from the mobile earphones and is connected to the DTMF

decoder IC CM8870. The decoder generates a 4-bit BCD code along with a strobe (STB) signal

for each DTMF code received. This is connected to P1 of micro controller and the outputs are

connected to P0 of micro controller.

Circuit:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCC

+12v

+

SW2

SW1

TRANSFORMER1 5

6

4 8

1

23456789

123456789 33p

4007+

100/16

33p

11.0592AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

L7805

1

3

2VIN

GN

D VOUT

4007

1

2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9

+1000/25

104p8.2K

+10/16

3.579

100k

104pcm8870 18

16

17

1234

567

8

1112131415

9 10

Vcc

ESt

St/GT

in+in_gsV-ref

inHPDosc 1

osc 2

Q0Q1Q2Q3

StD

Gnd TOE

33p

33p

330K

104 j

10k

4007

BC547

4007

35

412

35

412

4007

BC547

4148

AC230V

PhoneLine

Page 52: Embedded Application on Microcontroller in Assembly and Embedded C

52

Program: ;***************STARTING MODULE************************ ORG 0000H LJMP START ;********************MAIN MODULE************************** ORG 0050H START: MOV P1,#00H AA: JB P3.0,AA LCALL DELAY JB P3.0,AA K1: SETB P1.0 CLR P1.0 K2: JB P3.0,K2 LCALL DELAY JB P3.0,K2 BB: JNB P3.0,BB LCALL DELAY CLR P1.0 CLR P1.1 K3: JB P3.0,K3 LCALL DELAY JB P3.0,K3 K4: JNB P3.0,K4 LCALL DELAY JNB P3.0,K4 SETB P1.0 CLR P1.0 LJMP START ;*******************DELAY********************************** DELAY: MOV R7,#FFH DJNE R7,$ RET ;************************************************************* END;

Page 53: Embedded Application on Microcontroller in Assembly and Embedded C

53

Design and develop a parallel communication protocol between 16X2 LCD and micro controller. The main concept of this project is to display the data to be displayed in a 16X2

segmental dot matrix LCD display connected to the micro controller. It is constructed using 12-

0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller, 16X2 dot matrix LCD display.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal.

The LCD display is having three control lines (RS, RW, and E), eight data lines (D0-D7)

and three voltage lines (Vcc, Gnd and Vee/Contrast). The control lines are connected to P2.5,

P2.6 and P2.7 respectively. The data lines are connected to P0. Circuit:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCCVCC

LCD

1A2A3A4A5A6A7A8A9A

10A11A12A13A14A

RESISTOR VAR

1

23456789

123456789 33p

+100/16

33p

11.0592

TRANSFORMER1 5

6

4 8

L7805

1

3

2VIN

GN

D VOUT

4007

1

2 3 4 5 6 7 8 9

4007

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

+10/16

1 2 3 4 5 6 7 8 9

+1000/25

104p8.2K

AC230V

16 X 2 LCD

Page 54: Embedded Application on Microcontroller in Assembly and Embedded C

54

Program: P0=DISP DATA P2.7=RS P2.6=R/W P2.5=EN ;*****************STARTING MODULE************************* ORG 0000H LJMP START ;*******************MAIN MODULE************************* ORG 0050H START: MOV P0,#FFH MOV P1,#FFH MOV P2,#FFH MOV P3,#FFH ;********************************************************* LCALL LCDINI MOV DPTR,#0900H LCALL TLINE MOV DPTR,#0910H LCALL BLINE ZZ: LJMP ZZ ;************************************************************ LCDINI: CLR P2.5 MOV P0,#30H LCALL WRI MOV P0,#30H LCALL WRI MOV P0,#30H LCALL WRI MOV P0,#38H LCALL WRI MOV P0,#01H LCALL WRI MOV P0,#01H LCALL WRI MOV P0,#01H LCALL WRI MOV P0,#02H LCALL WRI MOV P0,#0CH LCALL WRI MOV P0,#1CH LCALL WRI

Page 55: Embedded Application on Microcontroller in Assembly and Embedded C

55

MOV P0,#38H LCALL WRI MOV P0,#06H LCALL WRI MOV P0,#01H LCALL WRI RET ;*******************HEADER WRITE************************** TLINE: MOV P0,#80H LCALL WRI MOV R7,#00H NEXTCH: CLR A MOVC A,@A+DPTR MOV P0,A LCALL WRD INC DPTR INC R7 CJNE R7,#10H,NEXTCH RET ;******************************************************* BLINE: MOV P0,#00H LCALL WRI MOV P0,#00H NCH: CLR A MOVC A,@A+DPTR MOV P0,A LCALL WRD INC DPTR INC R7 CJNE R7,#10H,NCH RET ;****************INSTRUCTION/DATA WRITE***************** WRI: CLR P2.7 CLR P2.6 SETB P2.5 MOV R0,#FFH DJNZ RO,$ CLR P2.5 MOV R0,#FFH DJNZ R0,$ RET WRD: SETB P2.7;REGISTER SELECT CLR P2.6;READ WRITE

Page 56: Embedded Application on Microcontroller in Assembly and Embedded C

56

SETB P2.5;ENABLE MOV R0,#FFH DJNZ R0,$ CLR P2.5 CLR P2.6 CLR P2.7 MOV R0,#FFH DJNZ R0,$ RET ;************************************************************ ORG 0900H DB 'MICRO LINK INFO ' DB 'POLY TRAINING ' END;

CODE(HEX) COMMAND TO INSTRUCTION REGISTER

01: CLEAR DISPLAY 02: RETURN HOME 04: DECREMENT CURSOR(Shift cursor to left) 06: INCREMENT CURSOR(Shift cursor to right) 05: SHIFT DISPLAY RIGHT 07: SHIFT DISPLAY LEFT 08: DISPLAY OFF,CUSOR OFF A : DISPLAY OFF,CUSOR ON C : DISPLAY ON,CUSOR OFF E : DISPLAY ON,CUSOR BLINKING F : DISPLAY ON,CUSOR BLINKING 10: SHIFT CURSOR POSITION TO LEFT 14: SHIFT CURSOR POSITION TO RIGHT 18: SHIFT THE ENTIRE POSITION TO THE LEFT 1c: SHIFT THE ENTIRE POSITION TO THE RIGHT 80: FORCE CURSOR TO BEGINNING TO FIRST LINE co: FORCE CURSOR TO BEGINNING TO 2nd LINE 38: 2 LINES AND 5*7 MATRIX

Page 57: Embedded Application on Microcontroller in Assembly and Embedded C

57

Construct a project to count the no. of visitors entered into the auditorium and display it in LCD using microcontroller The main concept of this project is to display the data to be displayed in a 16X2

segmental dot matrix LCD display connected to the micro controller. It is constructed using 12-

0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller, 16X2 dot matrix LCD display, an IR

LED and Photo diode.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal.

The LCD display is having three control lines (RS, RW, and E), eight data lines (D0-D7)

and three voltage lines (Vcc, Gnd and Vee/Contrast). The control lines are connected to P2.5,

P2.6 and P2.7 respectively. The data lines are connected to P0. The optical sensors designed

using IRLED and Photo Diode are connected to P1.0 and P1.2 and are configured as IN and

OUT sensors respectively. Circuit:

VCC

VCC

VCC

VCC+12v

VCC

VCC

VCCVCC

VCC

VCC

1

23456789

8.2K

+1000/25

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

TRANSFORMER1 5

6

4 8

L7805

1

3

2VIN

GN

D VOUT

104p

33p

33p

+100/16

4007

11.0592

1 2 3 4 5 6 7 8 9

+10/16

RESISTOR VAR

LCD

1A2A3A4A5A6A7A8A9A

10A11A12A13A14A

1

2 3 4 5 6 7 8 94007

123456789

IR LED Photo Diode

1K

1K

Photo DiodeIR LED

16 X 2 LCD

AC230V

OUTSensor

IN Sensor

Page 58: Embedded Application on Microcontroller in Assembly and Embedded C

58

Program : ;P0 =DISP DATA ; P2.5 = ENABLE ; p2.6 = READ/WRITE ; P2.7 = REG INS=0 /DATA=1 ;P1.0 = UP COUNTER INPUT PULSE ;P1.1 = DOWN COUNTER INPUT PULSE ;********************************************** ORG 0000H LJMP START ORG 0050H START: MOV P0,#FFH MOV P1,#FFH MOV P2,#00H MOV P3,#FFH LCALL LCDINI LCALL DEL MOV DPTR,#0900H LCALL TLINE MOV DPTR,#0910H LCALL BLINE LCALL SSEC MOV DPTR,#0920H LCALL TLINE MOV DPTR,#0930H LCALL BLINE MOV 33H,#00H TOP: LCALL COUNT CJNE R4,#01H,TOPD MOV R7,33H CJNE R7,#FFH,LXX1 DEC 33H LXX1: INC 33H MOV R7,33H LCALL CONVERT LCALL DISP LCALL BEEP

Page 59: Embedded Application on Microcontroller in Assembly and Embedded C

59

LJMP TOP XX1: SETB P2.1 LJMP TOP ;------------------------ TOPD: CJNE R4,#02H,TOP MOV R7,33H CJNE R7,#00H,MXX1 INC 33H MXX1: DEC 33H MOV R7,33H LCALL CONVERT LCALL DISP LCALL BEEP LJMP TOP ;***************************** BEEP: SETB P2.0 LCALL SEC CLR P2.0 RET ;------------------------ SSEC: MOV R1,#1FH CSM1: MOV R2,#FFH CSM2: MOV R3,#FFH CSM3: DJNZ R3,CSM3 DJNZ R2,CSM2 DJNZ R1,CSM1 RET SEC: MOV R1,#01H DSM1: MOV R2,#FFH DSM2: MOV R3,#FFH DSM3: DJNZ R3,DSM3 DJNZ R2,DSM2 DJNZ R1,DSM1 RET ;----------------------------- CONVERT: MOV 32H,#30H MOV 31H,#30H MOV 30H,#30H NDEC: DEC R7 CJNE R7,#FFH,INC1

Page 60: Embedded Application on Microcontroller in Assembly and Embedded C

60

RET INC1: INC 30H MOV A,30H CJNE A,#3AH,NDEC MOV 30H,#30H INC 31H MOV A,31H CJNE A,#3AH,NDEC MOV 31H,#30H INC 32H LJMP NDEC ;********************************** DISP: CLR p2.7 CLR p2.6 MOV P0,#8CH LCALL WRI MOV P0,32H LCALL WRD MOV P0,31H LCALL WRD MOV P0,30H LCALL WRD RET ;************************************* COUNT: MOV R4,#00H CX1: JNB P1.0,CX3 LCALL DEL JNB P1.0,CX1 LCALL DEL CX2: JB P1.0,CX2 LCALL DEL JB P1.0,CX2 MOV R4,#01H RET ;------------------ CX3: JNB P1.1,CX1 LCALL DEL JNB P1.1,CX3 LCALL DEL

Page 61: Embedded Application on Microcontroller in Assembly and Embedded C

61

MCX2: JB P1.1,MCX2 LCALL DEL JB P1.1,MCX2 MOV R4,#02H RET ;********** LCD INI **************** LCDINI: CLR P0.0 CLR P0.1 CLR P0.2 CLR P2.5 CLR p2.7 CLR p2.6 MOV P0,#30H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#38H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#01H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#02H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#0CH LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#1CH LCALL WRI

Page 62: Embedded Application on Microcontroller in Assembly and Embedded C

62

CLR p2.7 CLR p2.6 MOV P0,#38H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#06H LCALL WRI CLR p2.7 CLR p2.6 MOV P0,#01H LCALL WRI RET ;---------------------------- TLINE: CLR p2.7 CLR p2.6 MOV P0,#80H LCALL WRI MOV R7,#00H TKL: CLR A MOVC A,@A+DPTR MOV P0,A LCALL WRD INC DPTR INC R7 CJNE R7,#10H,TKL RET BLINE: CLR p2.7 CLR p2.6 MOV P0,#C0H LCALL WRI MOV R7,#00H BKL: CLR A MOVC A,@A+DPTR MOV P0,A LCALL WRD INC DPTR INC R7

Page 63: Embedded Application on Microcontroller in Assembly and Embedded C

63

CJNE R7,#10H,BKL RET ;******** INSTRUCTION /DATA WRITE ********* WRI: SETB P2.5 MOV R0,#FFH DJNZ R0,$ CLR P2.5 MOV R0,#FFH DJNZ R0,$ RET WRD: SETB p2.7 ; REGISTER CLR p2.6 ;READ WRITE SETB P2.5 ;ENABLE MOV R0,#FFH DJNZ R0,$ CLR P2.5 CLR p2.6 CLR p2.7 RET ;****************************** DEL: MOV R5,#FFH DJNZ R5,$ RET ;******************************************* ORG 0900H DB 'BIDIRECTIONAL ' DB 'V.C POWER CTRL ' DB 'VISITORS: ' DB ' ' ;******************************************** END;

Page 64: Embedded Application on Microcontroller in Assembly and Embedded C

64

Design and develop a micro controller based circuit for measurement of DC voltage, AC voltage, AC current using ADC0809. The main concept of this project is to display the data to be displayed in a 16X2

segmental dot matrix LCD display connected to the micro controller. It is constructed using 12-

0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller, eight channel eight bit ADC0809,

NE555, 16X2 dot matrix LCD display.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal. The ADC 0809 is having eight data lines (D0-D7) and three address lines (A, B, C) along with three control lines (ALE, START, EOC). The input is given to one of the eight analog inputs and the clock is provided to CLK pin which is generated using a 555 connected in astable mode. The data is collected through P1 and is converted into ASCII code and then displayed on the LCD. Circuit:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCC

VCCVCC

VCC

103

+100/16

33p123456789

1

23456789

L7805

1

3

2VIN

GN

D VOUT

TRANSFORMER1 5

6

4 8

11.0592

33p

8.2K

4007

1

2 3 4 5 6 7 8 9

4007

10K

+1000/25

1 2 3 4 5 6 7 8 9

+10/16

C?104p

104p

4.7K

104p

ADC0809

10

9

7

171415818192021

622

11

13

12

16

26272812345

252423

CLK

OE

EOC

D0D1D2D3D4D5D6D7

STARTALE

VCC

GND

REF

+

REF-

IN0IN1IN2IN3IN4IN5IN6IN7

A0A1A2

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

LM555 3

48

5

26

7

1

LCD

1A2A3A4A5A6A7A8A9A

10A11A12A13A14A

RESISTOR VAR

Capacitor

D11 2

AC230V

16 X 2 LCDDC Voltage

Page 65: Embedded Application on Microcontroller in Assembly and Embedded C

65

Program: ; ^^^^^^^^^^^^^^^ Write an assembly language program for ADC ^^^^^^^^^^^^^^ P2.5= ENABLE P2.6= READ/WRITE P2.7= REGISTER SELECT INS=0/DATA=1 P1= DATA OF ADC 8BIT P3.2 =ALE P3.3= START P3.4=A P3.5=B ;********** STARTING MODULE ********************************** ORG 0000H LJMP START ORG 0050H START: MOV P0,#FFH MOV P1,#FFH MOV P2,#FFH MOV P3,#FFH ;*******************MAIN MODULE ******************************** MAIN: LCALL LCD INI LCALL HDISP TOP: LCALL VSEN LCALL CONVERT LCALL DISP LJMP TOP ;************** ************** LCD INI ********************************* LCD INI: CLR P2.5 MOV P0,#30H LCALL WRI MOV P0,#30H LCALL WRI MOV P0,#30H LCALL WRI MOV P0,#38H LCALL WRI MOV P0,#01H LCALL WRI MOV P0,#01H LCALL WRI

Page 66: Embedded Application on Microcontroller in Assembly and Embedded C

66

MOV P0,#02H LCALL WRI MOV P0,#0CH LCALL WRI MOV P0,#1CH LCALL WRI MOV P0,#38H LCALL WRI MOV P0,#06H LCALL WRI MOV P0,#01H LCALL WRI RET ;***************************** VSEN ****************************** VSEN: MOV P1,#FFH CLR P3.4 CLR P3.5 SETB P3.2 SETB P3.3 LCALL DEL CLR P3.2 CLR P3.3 LCALL DEL LCALL DEL SETB P3.2; ALE LCALL DEL SETB P3.3; START LCALL DEL CLR P3.2 LCALL SEC MOV R7,P1 RET ;********************** CONVERT *************************** CONVERT: MOV 32H,#00H MOV 31H,#00H MOV 30H,#00H

Page 67: Embedded Application on Microcontroller in Assembly and Embedded C

67

;******************** NDEC ********************************** NDEC: DEC R7 CJNE R7,#FFH, INC1 MOV A,30H ADD A,#30H MOV 30H,A MOV A,31H ADD A,#30H MOV 31H,A MOV A,32H ADD A,30H MOV 32H,A RET ;******************INCREMENT***************************** INC1: INC 30H MOV A, 30H CJNE A, #0AH, NDEC MOV 30H, #00H INC 31H MOV A,31H CJNE A, #0AH, NDEC MOV 31H,#00H INC 32H LJMP NDEC ;***********************DISPLAY******************************* DISP: MOV P0,#8AH LCALL WRI MOV P0, 32H LCALL WRD MOV P0, 31H LCALL WRD MOV P0,30H LCALL WRD RET ;************************ HDISP ************************************ HDISP: MOV DPTR,#0900H LCALL TLINE MOV DPTR,#0910H

Page 68: Embedded Application on Microcontroller in Assembly and Embedded C

68

LCALL BLINE RET ;***************************************************** SEC: MOV R1,#03H CSM1:MOV R2,#FFH CSM2:MOV R3,#FFH CSM3:DJNZ R3,CSM3 DJNZ R2,CSM2 DJNZ R1,CSM1 RET ;************************************************************ ORG 0900H DB 'COUNT: ' DB ' ' ;********************************************************* END;

Page 69: Embedded Application on Microcontroller in Assembly and Embedded C

69

Design and develop a micro controller based circuit for measurement of temp, light intensity using ADC0809.

The main concept of this project is to display the data to be displayed in a 16X2

segmental dot matrix LCD display connected to the micro controller. It is constructed using 12-

0-12 centre tapped transformer, 7805 voltage regulator, 1N4007 rectifier diodes, 2200uF/25V &

470uF/16V filtering capacitors, AT89c52 micro controller, eight channel eight bit ADC0809,

NE555, 16X2 dot matrix LCD display.

Here we used an AT89C52 microcontroller from the 8051 family. The micro controller is

provided with a reset logic for 9th pin using a RC network with values R=8.2kΩ, C=10μF/16V. A

crystal oscillator with 11.0592MHZ frequency is connected to pins 18 and 19. Two 33pF Non-

polar ceramic capacitors are used on both the legs of crystal to the ground to eliminate the

noise signal. The ADC 0809 is having eight data lines (D0-D7) and three address lines (A, B, C) along with three control lines (ALE, START, EOC). The input is given to one of the eight analog inputs and the clock is provided to CLK pin which is generated using a 555 connected in astable mode. The data is collected through P1 and is converted into ASCII code and then displayed on the LCD. Circuit:

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCCVCC

VCC

VCC

VCC

VCC

33p123456789

1

23456789

TRANSFORMER1 5

6

4 8

11.0592

33p

+100/16

4007

1

2 3 4 5 6 7 8 9

4007L7805

1

3

2VIN

GN

D VOUT+

1000/25

1 2 3 4 5 6 7 8 9

+10/16

8.2K104p

4.7K

104p

10K

ADC0809

10

9

7

171415818192021

622

11

13

12

16

26272812345

252423

CLK

OE

EOC

D0D1D2D3D4D5D6D7

STARTALE

VCC

GND

RE

F+

REF-

IN0IN1IN2IN3IN4IN5IN6IN7

A0A1A2

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

LM555 3

48

5

26

7

1

C?104p

RESISTOR VAR

LCD

1A2A3A4A5A6A7A8A9A

10A11A12A13A14A

NTC

103

C

LDR

103

AC230V

16 X 2 LCD

Page 70: Embedded Application on Microcontroller in Assembly and Embedded C

70

Develop an RS-232 protocol to establish a serial UART communication between PC and micro controller.

Circuit:

VCC

VCC

VCC

VCC+12v

VCC

VCC

VCC

VCCVCC

RESISTOR VAR

LCD

1A2A3A4A5A6A7A8A9A

10A11A12A13A14A

+100/16

33p1234567891

23456789

L7805

1

3

2VIN

GN

D VOUT

TRANSFORMER1 5

6

4 8

11.0592

33p

AT89C52

9

1819

20

2930

31401

2345678

2122232425262728

1011121314151617

3938373635343332RST

XTAL2XTAL1

GND

PSENALE/PROG

EA/VPPVCCP1.0/T2

P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9

P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

4007

1

2 3 4 5 6 7 8 9

4007

104p

+1000/25

1 2 3 4 5 6 7 8 9

+10/16

8.2K

+

10/16+10/16

+10/16

+10/16

MAX232

1345

1615

26

12

9

11

10

13

8

14

7

C1+C1-C2+C2-

VCC

GN

DV+V-

R1OUT

R2OUT

T1IN

T2IN

R1IN

R2IN

T1OUT

T2OUT1A2A3A

+10/16

AC230V

16 X 2 LCD

Program: TXD: MACRO

JNB TI,$

CLR TI

MOV SBUF,R6

MACEND

RXD: MACRO

JNB RI,$

CLR RI

MOV R7,SBUF

MACEND

;*****************************************

ORG 0000H

LJMP START

Page 71: Embedded Application on Microcontroller in Assembly and Embedded C

71

ORG 0050H

START: MOV P1,#FFH

MOV P2,#FFH

MOV P3,#FFH

MOV P0,#FFH

LCALL SPINI

MOV DPTR,#0900H

LCALL TLINE

SS: LJMP SS

SPINI: MOV A,#00H

MOV TCON,#40H

MOV TMOD,#20H

MOV SCON,#52H

MOV IE,#9AH

MOV TL1,#FDH

MOV TH1,#FDH

RET

TLINE: MOV R1,#00H

SSS: CLR A

MOVC A,@A+DPTR

MOV R6,A

TXD

INC DPTR

INC R1

CJNE R1,#18H,SSS

RET

;****************************************

ORG 0900H

DB 'POLYTECHNIC COLLEGE'

END