You are on page 1of 100

A

Project Report on
SPEED CONTROL OF STEPPER MOTOR VIA INFRARED REMOTE
Submitted in the partial IulIillment Ior the award oI
ACHFl0R 0F TFCHt0l06Y
n
FlFCTRlCAl & FlFCTR0tlCS Ft6ltFFRlt6
By
6AuRAv SRlvASTAvA (0601821003)
KlRTl vAR0HAt Slt6H (0601821005)
KSHlTlJ SRlvASTAvA (0601821006)
SuRAYAKAtT (0601821165)
AHlSHFK KR. RAl (0401821001)
Batch: 2009-10
6ul0F . HR. RAJFFv PRASA0 6uPTA
C0-6ul0F . HR. RATtFSH CHATuRvF0l

BABU BANARSI DAS INSTITUTE OF ENGG. TECHNOLOGY & REASERCH CENTRE
Approved by A.I.C.T.E.
&
Affiliated to U.P.Technical University, Lucknow
CERTIFICATE



This is to certiIy that Project Report entitled '.............................................
................................................................ which is submitted by .............. in
partial IulIillment oI the requirement Ior the award oI degree B. Tech. in Department oI
...................................................... oI U. P. Technical University, is a record oI the candidate
own work carried out by him under my/our supervision. The matter embodied in this thesis is
original and has not been submitted Ior the award oI any other degree.




Date: Supervisor:








DECLARATION

hereby declare that this submission is my own work and that, to the best oI my
knowledge and belieI, it contains no material previously published or written by another
person nor material which to a substantial extent has been accepted Ior the award oI any
other degree or diploma oI the university or other institute oI higher learning, except
where due acknowledgment has been made in the text.

Name. Gaurav Srivastava
Roll No.. 0601821003
Date.
Signaure.

Name. Kirti Jardhan Singh
Roll No.. 0601821005
Date.
Signature.

Name. Kshitif Srivastava
Roll No.. 0601821006
Date.
Signature.

Name. Abhishek Kr. Rai
Roll No.. 0401821001
Date.
Signature.

ACKNOWLEDGEMENT

any persons have contributed to make this project on Speed Control OI Stepper otor
Via RARED Remote, a reality. We would especially like to express our appreciation
to r. Vinod Kumar (H.O.D. EC/E/E Deptt.) Ior his unstinted support, encouragement
and his painstakingly and meticulous eIIort towards the completion oI this project.
We acknowledge the help and cooperation received Irom all the Iaculty members oI
BBET&RC Bulandshahr. Several colleagues and students have contributed directly or
indirectly to the contents this project, as they had given their numerous ideas. Their
criticism gave us the much-needed hints about the areas that needed elaboration and
amendments and also to present them with greater clarity.
We sincerely express our gratitude to r. Rajeev Gupta, our esteemed project guide, Ior
his support and help in the Iinal preparation oI this report.
inally, we wish to express our sincere thanks to all Iamily members, especially our
Parents Ior their constant moral support and encouragement.
We would welcome Constructive Suggestions to improve this project, which can be
implemented in our Iurther attempts.
Thanking You.
Gaurav Srivastava(0601821003)
Kirti Vardhan Singh(0601821005)
Kshitij Srivastava(0601821006)
Suryakant Shukla (0601821165)
Abhishek Kr. Rai(0401821001)





TABLE OF CONTENTS

DECLARATO
CERTCATE
ACKOWLEDGEETS
LST O COPOETS
CHAPTER 1 (TRODUCTO, BACKGROUD O PROJECT)
1.1 EAG O PROJECT
1.2 STEPS OR AKG PCB
CHAPTER 2 : CRCUT DESCRPTO
2.1 POWER SUPPLY
2.2 DECSO SECTO
2.3 DSPLAY SECTO
CHAPTER 3 : COPOET DESCRPTO
3.1 THE REGSTER
3.2 DODE
3.3 LED
3.4 TRASSTOR
3.5 CAPACTOR
3.6 RA RED REOTE
CHAPTER 4 : SWTCH
CHAPTER 5 : TRASORER
COCLUSO
REERECES

INTRODUCTION

With the help oI this project we control the speed oI the A.C. motor or on/oII any
electrical appliances. Complete circuit is to be divided into two parts.
1. Transmitter circuit
2. Receiver circuit.
n the receiver circuit we use one A.C. motor with rotating disc and with the help oI
remote we control the working oI the A.C. motor. We speed control oI the motor and on /oII the
other electrical appliances. n both the circuit we use C 2051 is 20 pin micro controller. C 2051
is Iamily member oI the Iamous 89c51 series.
Data is transmitter through the inIra red sensor and receive on the inIra red eye.
This is a very wonder Iull project to display the powerIul aspect oI microcontroller. n
this project we show that how we control many electrical appliances and control the speed oI the
electrical Ian or light. Just two microcontroller and Iew components we make it possible to
control all electrical appliances and speed control.
n transmitter part we use one C2051 microcontroller. 2051 is a 20 pin ic. Pin no 10 oI this
ic is connected to the positive supply. Pin no 10 oI the ic is connected to the ground pin.
COMPONENT LIST


O C 89C2051
O C COSO 3021
O C 7805C
O C 4049
O C 0227
O C BT136
O LED
O Capacitors
O Resistors
O Transistor BC558
O TransIormer
O Relay
O Plug
O Holder
O Switch
O Soldering ron
O Copper Plate
O Bulb
O PCB


CIRCUIT DIAGRAM

CIRCUIT DIAGRAM
HARDWARE DESCRIPTION

n inIra red receiver we again we use one microcontroller 2051. Pin no 20 is connected to
the positive supply. Crystal is connected to the pin no 4 and 5. Complete circuit is work on 5 volt
regulated power supply. or this purpose we use one step down transIormer, two diode and on
capacitor circuit. AIter capacitor we use one 5 volt regulator circuit. Output oI the regulator is
connected to the 2051 regulator circuit. .

nIra red eye is connected to the external interrupt pin no p3.2. One point oI the inIra red
eye is connected to the positive supply. One pin is Ior the signal and third pin is ground. When
any signal is coming on the inIra red eye then inIra red eye sense the signal and this signal give
a interrupt to the p3.2.

One ac signal is also provided to the pin no p3.3 to give zero crossing action. or this
purpose we use one Iull wave rectiIier and this pulsating dc is provided to the optocoupler.
Optocupler convert this signal into opposite direction and the same time give a optical isolation
to this pin. Optocoupler is a combination oI one inIra red transmitter and one phototransistor.
Output oI the phototransistor is connected to the external interrupt no 1. There is a two external
interrupt in this microcontroller. n this microcontroller one is connected to the inIra red eye and
second is connected to the zero crossing ac voltage.

Output pin s oI the microcontroller is connected to the port p1. ote that output oI the
microcontroller is active low, so to drive the transistor and relay coil we use one inverter ic.
There is a Iour output Ior the Iour on/oII signal.

P1.1, P1.1, P1.2, P1.3 is connected to the inverter ic 4049. This inverter ic is hex inverter
ic. We use Iour output oI the inverter ic to the base oI the npn transistor through 470 ohm
resistor. Emitter oI the P transistor is connected to the Iorward bias. Collector is reverse bias
through the Relay coil. When we send the on/oII signal Irom the remote then Irom this signal
output oI the microcontroller is zero and this output is inverted by the ic 4049 and Iurther switch
on the transistor and relay coil. One reverse bias diode is connected between relay to protect the
transistor when relay oII and send a back emI to the transistor.

Six more switches are connected to the circuit to on/oII and control the speed oI the Ian.
irstly we on the switch when the microcontroller send the Ian on signal then p1.6 p1.7 pins and
low and output led is also on. ote that led is connected in reverse bias on this pin. P1.4 and
P1.5 are connected to two rest pins oI the C 4049. Output available on the p1.5 and p1.6 is
inverted by the inverter ic and this output is connected to the pin no 2 oI the opto triac. This opto
triac is a very special triac. By this triac we control the Iiring angle oI the triac. Pin no 4 and 6
are connected to the triac through load.

We control the brightness oI the triac through the pulse train oI the pulse width
modulation. As we as we press the up or down key. ew pulse width is available on the output.
By this output we compare with the zero crossing action and by the result we control the
brightness oI the lamp or speed oI the Ian. Pulse width modulation is the most important part oI
this project to control the speed oI the Ian or control the brightness oI the lamp.

BASICS OF MO1IOA COA1ROL :
DeIinitions oI motion control vary widely in industry today. Depending on the
application, motion control can reIer to simple on/oII control or a sequencing oI events,
controlling the speed oI a motor, moving objects Irom one point to another or precisely
constraining the speed, acceleration, and position oI a system throughout a move.

Varying interpretations used in the Iield may conIuse engineers working Ior the Iirst time
in some aspect oI motion control. otion control means diIIerent things to diIIerent sections oI
industry. As an introduction, this chapter diIIerentiates among motion control techniques. t puts
each technique into perspective in terms oI where typical applications arise.

n many cases, motion control techniques are intimately tied to the controller as well as to
the positioning hardware and actuator. o overview oI motion control would be complete
without a discussion oI the various control options that are widely used. These include simple
timers and counters, chip level and board level computers, programmable logic controllers, and
pneumatic sequencers.
BASIC 1YPES :
ndustrial motion control can be divided into Iour categories: sequencing, speed control,
point to point control, and incremental motion:

Sequencing reIers to the control oI several operations so that they all occur in a particular
order. Perhaps the simplest example oI sequential motion is the progression oI events that take
place through the mechanical linkages oI a player piano. When a player piano plays a tune, holes
in a paper roll cause piano wires to be struck in a speciIic sequence. Similarly, opening and
closing valves can be sequenced mechanically with camshaIts.

Sequencing generally becomes too complicated to be handled mechanically in industrial
equipment such as conveyor lines, or process machines such as Iryers in Iast Iood restaurants.
The key Iactor that deIines these as sequencing applications is a need Ior move and stop on and
oII control oI events that must take place in a certain progression. Soak time or the position oI
material on an assembly line determine when operations should start and stop.

or example, consider a conveyor line that moves parts Irom one assembly station to
another. The controller might position a part at one station until an operator punches an
'advance button. This might start the part moving to the next station. Here it might enter a
cleaning bath Ior a programmed soak time. At the end oI this period, it might move to a new
station Ior Iinal assembly, and so Iorth.

This sort oI timing and sequencing is handled through pneumatic, electronic, or
electromechanical controllers. OI these, electronic and electromechanical controls are most
common. or simple on oII control, timers and counters may suIIice. These devices contain
electrical contacts that can be opened and closed at time intervals that an operator either enters
on a keypad or sets with switches. Counters are similar devices that actuate contacts when a
count reaches a preset number. The count increments or decrements when sensors such as
proximity switches or limit switches sense an object.

When a sequencing operation consists oI more than a Iew steps, more elaborate controls
become necessary. These controls can take the Iorm oI discrete elements such as time delay
relays that act in response to input signals Irom sensors and switches. Over the past two decades,
use oI numerous relays Ior sequencing has increasingly given way to programmable logic
controllers (PLCs).

PLCs contain computers that synthesize actions such as timing and counting to sequence
operations. The advantage PLCs have over banks oI relays is that a PLC can be simply
reprogrammed to provide diIIerent sequences and diIIerent timing intervals. n contrast, changes
made to sequences controlled only by relays may require physical rewiring and reconIiguring, a
process that can be time consuming and expensive.

Speed control reIers to applications involving machines run at varying speeds or torques.
The source oI power Ior such applications is generally either an internal combustion engine, or
an electric, hydraulic, or pneumatic motor. Speed can be controlled either mechanically or, in the
case oI electric motors electronically.

n contrast to mechanical speed control technology, which usually employs gearing or
belts to change speed, electronic speed control manipulates applied electrical power to control
velocity and torque. Electronic speed control in ac motors employ special ampliIiers or drives.
These generally vary ac motor speed. Though such electronic controls are more expensive than
mechanical speed controls, they provide the advantage oI reduced energy costs. Applications Ior
such equipment include Ians, blowers, pumps and compressors.

Point to point motion control, in contrast with velocity control, generally reIers to
applications where something must move Irom one point to another at a constant speed. An
important requirement in such applications is that there are two Iactors that must be controlled
speed and distance. Examples oI point to point movement are in x-y tables and in machining,
where a tool moves in a straight line while it touches a workplace along one axis.

Because such applications demand monitoring and control oI both velocity and position,
they need a controller to keep track oI system operating conditions at any given time. These
controllers can be either hardwired electronic logic, and computer or a PLC.

n general, the simplest positioning system oI this sort might be Iound on older milling
machines. These contain an x-y positioning system Ior moving the Iixture holding the workplace.
The positioning system involves ac or dc motors, an adjustable speed drive, clutch, and a
position transducer that reads out the position oI each table axis. The positioning mechanism Ior
such a system is usually a ball screw.
any systems Ior point to point positioning use a stepping motor which is considered
particularly well suited Ior this type oI application. A.C. motors work Irom electrical signals that
are pulses. The stepping motor shaIt moves through a speciIic angle in response to each input
pulse. This allows it to rotate in Iixed, repeatable, known increments, unlike conventional
motors.

The maximum usable step rate can be determined by testing the motor and driver circuit.
The motor test is conducted with the motor connected to the actual load or to an equivalent load
representing load inertia. A pulse generator supplied motor control pulses. To determine the step
rate, the generator Irequency is slowly increased to a point just beIore the motor stall. Using 80
oI this Irequency generally provides reliable high speed operation.

The shape Iactor determines the general rate oI change oI motor acceleration. or
example, a small shape Iactor produces steep initial acceleration, whereas a large Iactor produces
nearly linear acceleration. The shape Iactor Ior the exponential equation described can vary Irom
0.005 to 0.5.

The same basic equation used Ior acceleration tables can generate deceleration tables.
However, stepping motors can generally decelerate in 10 to 20 less time than they can
accelerate, and variables can be adjusted accordingly. When a stepping motor reaches the Iinal
step in deceleration, the motor shaIt may oscillate beIore the load settles down. This setting time
depends on the motor type, load and motor drive Setting time can be reduced by selecting the
deceleration proIile and motor velocity (stopping Irequency) through empirically testing various
proIiles.

Once acceleration/deceleration tables have been stored in memory, a soItware routine
uses the table values to generate motor control pulses at proper Irequencies. The routine selects
the acceleration/deceleration constants that will give the quickest moves over a given distance.

ncremental motion control can be contrasted with point to point control by Iirst
examining some oI the shortcomings oI systems powered by the latter approach. n the simplest
case a point to point system moves a commanded distance. But Ior some applications, simply
commanding the motor to move a prescribed distance does not provide enough accuracy.
achine slippage, distortion, and other Iactors may prevent the motor Irom moving the load to
the point desired.

Closed loop (sometimes called servo-loop) control systems overcome this drawback.
They provide precise position control with Ieedback. eedback minimizes the diIIerence between
the commanded position or velocity oI the system and the actual location or velocity. n other
words, Ieedback minimizes position or velocity error.

Closed loop systems have been constructed around a variety oI controlling, Iunctions
ranging Irom mechanical displacement to pneumatic or hydraulic pressure. However, solid state
electronics made electrical currents the preIerred process variable, though the principles
described here can be applied to any closed loop positioning system. Consequently, electronic
closed loop controls are now built into several diIIerent kinds oI positioning systems that range
Irom hydraulics and pneumatics to multi axis web control.

n their simplest Iorm, electronic closed loop motion control systems consist oI a
controller, a motor, an ampliIier to drive the motor, and a transducer that monitors motion. The
controller sends out position commands periodically in increments set by a clock. These pulses
command the drive to move some distance in the next increment oI time. A pulse count Irom a
position measuring transducer indicating drive position is then subtracted Irom the commanded
position. The pulses Irom the transducer are considered negative Ieedback. Thus, subtracting the
position inIormation yields the diIIerence between drive position and the position command. The
total position diIIerence is oIten called Iollowing error or static error.

The error is sent to a digital to analog (d/a) converter Ior conversion to an analog voltage
that is proportional to the position diIIerence. Drive voltage then generates motion in a motor,
moving to a new position which attempts to reduce the Iollowing error.

The more widely used incremental transducers generate pulses corresponding to position
and direction oI motion. Each time the transducer moves a distance corresponding to one pulse
(Iorward or reverse), a counter increments or decrements by one. AIter a series oI moves, the
counter contains a sum oI pulses corresponding to position.

The controller, d/a converter, and position Ieedback are commonly called the position
loop. Position loop calculations are generally handled by a microprocessor or computer.

n the velocity loop, the voltage Irom the d/a converter is combined with voltage
produced by a tachometer attached to the positioning motor. The tachometer voltage indicates
motor speed and is also negative Ieedback. Subtracting the tech Ieedback Irom the d/a converter
voltage yields a voltage proportional to the diIIerence between actual and commanded velocity.
An ampliIied error voltage drives the positioning motor directly. The d/a converter output,
ampliIier, and motor/tach are called the velocity loop.

To understand how the basic closed loop system Iunctions, consider a case where the
controller commands the system to move ten increments, and each increment represents 0.001 in.
The number in the accumulator increases instantly to 1,000 counts. This produces a voltage
output Irom the d/a converter, which is interpreted as a velocity command by the motor.

The motor then starts to move, causing the encoder to send out a pulse Ior every
increment oI motor shaIt rotation. Each oI these pulses produces a subtraction Irom the number
in the accumulator. Thus, the Iollowing error in the accumulator represents the diIIerence
between commanded and actual position. As the motor moves, the Iollowing error decreases.

As more position commands are sent, the system accelerates and approaches the
commanded position. With each iteration oI commands, the number in the accumulator increases
and the system moves Iaster than in the preceding iteration eventually, the number subtracted
Irom the accumulator be the same as the number added. The velocity then steps increasing, and
the Iollowing error reaches a steady state value that becomes the Iollowing error Ior the system at
a speciIic velocity.

O Motor Types :
Wound Iield dc motors are usually classiIied by shunt wound, series wound, and
compound wound. n addition to these permanent magnet and brushless types are also
available, normally as Iractional horsepower motor. otors may be Iurther classiIied Ior
intermittent or continuous duty. Continuous duty motors can run without an oII period.
O Speed Control :
There are two ways to adjust the speed oI a wound Iield dc motor Combinations
oI the two are sometimes used.
O Shunt Field Control :
Reel drives require this kind oI control. aterial is wound on a reel at constant
linear speed and constant strip tension regardless oI diameter Control is obtained by
weakening the shunt Iield current oI the motor to increase speed and to reduce output
torque Ior a given armature current. Since the rating oI a dc motor is determined by
heating, the maximum permissible armature current is approximately constant over the
speed range. This means that at rated current, output torque varies inversely with speed,
and the motor has constant horsepower capability over its speed range.
This system is good Ior only obtaining speeds greater than the base speed. A momentary speed
reduction below base speed can be obtained by overexciting the Iield, but prolonged over
excitation overheats the motor. Also magnetic saturation in the motor permits only a small
reduction in speed Ior a substantial.

IA1RODUC1IOA 1O PULSE WID1H MODULA1IOA (PWM)
Pulse width modulation (PW) is a powerIul technique Ior controlling analog circuits
with a processor's digital outputs. PW is employed in a wide variety oI applications, ranging
Irom measurement and communications to power control and conversion.

Analog circuits
An analog signal has a continuously varying value, with inIinite resolution in both time
and magnitude. A nine-volt battery is an example oI an analog device, in that its output voltage is
not precisely 9 V, changes over time, and can take any real-numbered value. Similarly, the
amount oI current drawn Irom a battery is not limited to a Iinite set oI possible values. Analog
signals are distinguishable Irom digital signals because the latter always take values only Irom a
Iinite set oI predetermined possibilities, such as the set 0 V, 5 V}.

Analog voltages and currents can be used to control things directly, like the volume oI a
car radio. n a simple analog radio, a knob is connected to a variable resistor. As you turn the
knob, the resistance goes down (up). As that happens, the current Ilowing through the resistor
increases (decreases). This is the same current driving the speakers, thus the volume is increased
(decreased). An analog circuit is one, like the radio, whose output is linearly proportional to its
input.
As intuitive and simple as analog control may seem, it is not always economically
attractive or otherwise practical. or one thing, analog circuits end to driIt over time and can,
thereIore, be very diIIicult to tune. Precision analog circuits, which solve that problem, can be
very large, heavy (just think oI older home stereo equipment), and expensive. Analog circuits
can also get very hot; the power dissipated is proportional to the voltage across the active
elements multiplied by the current through them. Analog circuitry can also be sensitive to noise;
because oI its inIinite resolution, even minor perturbations oI an analog signal change its value.

Digital Control
By controlling analog circuits digitally, system costs and power consumption can be
drastically reduced. What's more, many microcontrollers and DSPs already include on-chip
PW controllers, making implementation easy.

n a nutshell, PW is a way oI digitally encoding analog signal levels. Through the use
oI high-resolution counters, the duty cycle oI a square wave is modulated to encode a speciIic
analog signal level. The PW signal is still digital because, at any given instant oI time, the Iull
DC supply is either Iully on or Iully oII. The voltage or current source is supplied to the analog
load by means oI a repeating series oI on and oII pulses. The on-time is the time during which
the DC supply is applied to the load, and the oII-time is the period during which that supply is
switched oII. Given a suIIicient bandwidth, any analog value can be encoded with PW.

Fig. PWM signals of varying duty cycles

igure shows three diIIerent PW signals. igure 1a shows a PW output at a 10 duty cycle.
That is, the signal is on Ior 10 oI the period and oII the other 90. igures 1b and 1c show
PW outputs at 50 and 90 duty cycles, respectively. These three PW outputs encode three
diIIerent analog signal values, at 10, 50, and 90 oI the Iull strength. I, Ior example, the
supply is 9 V and the duty cycle is 10, a 0.9 V analog signal results.

Fig. A simple PWM circuit
igure 2 shows a simple circuit that could be driven using PW. n the Iigure, a 9 V
battery powers an incandescent light bulb. I we closed the switch connecting the battery and
lamp Ior 50 ms, the bulb would receive 9 V during that interval. I we then opened the switch Ior
the next 50 ms, the bulb would receive 0 V. I we repeat this cycle 10 times a second, the bulb
will be lit as though it were connected to a 4.5 V battery (50 oI 9 V). We say that the duty
cycle is 50 and the modulating Irequency is 10 Hz.

ost loads, inductive and capacitative alike, require a much higher modulating Irequency than
10 Hz. magine that our lamp was switched on Ior Iive seconds, then oII Ior Iive seconds, then
on again. The duty cycle would still be 50, but the bulb would appear brightly lit Ior the Iirst
Iive seconds and oII Ior the next. n order Ior the bulb to see a voltage oI 4.5 volts, the cycle
period must be short relative to the load's response time to a change in the switch state. To
achieve the desired eIIect oI a dimmer (but always lit) lamp, it is necessary to increase the
modulating Irequency. The same is true in other applications oI PW. Common modulating
Irequencies range Irom 1 kHz to 200 kHz.

Hardware Controllers
any microcontrollers include on-chip PW units. or example, icrochip's PC16C67
includes two, each oI which has a selectable on-time and period. The duty cycle is the ratio oI the
on-time to the period; the modulating Irequency is the inverse oI the period. To start PW
operation, the data sheet suggests the soItware should:
O Set the period in the on-chip timer/counter that provides the modulating square wave
O Set the on-time in the PW control register
O Set the direction oI the PW output, which is one oI the general-purpose /O pins
O Start the timer
O Enable the PW controller
Although speciIic PW controllers do vary in their programmatic details, the basic idea
is generally the same.


Communication and Control
One oI the advantages oI PW is that the signal remains digital all the way Irom the
processor to the controlled system; no digital-to-analog conversion is necessary. By keeping the
signal digital, noise eIIects are minimized. oise can only aIIect a digital signal iI it is strong
enough to change a logic-1 to a logic-0, or vice versa.

ncreased noise immunity is yet another beneIit oI choosing PW over analog control,
and is the principal reason PW is sometimes used Ior communication. Switching Irom an
analog signal to PW can increase the length oI a communications channel dramatically. At the
receiving end, a suitable RC (resistor-capacitor) or LC (inductor-capacitor) network can remove
the modulating high Irequency square wave and return the signal to analog Iorm.

PW Iinds application in a variety oI systems. As a concrete example, consider a PW-
controlled brake. To put it simply, a brake is a device that clamps down hard on something. n
many brakes, the amount oI clamping pressure (or stopping power) is controlled with an analog
input signal. The more voltage or current that's applied to the brake, the more pressure the brake
will exert.

The output oI a PW controller could be connected to a switch between the supply and
the brake. To produce more stopping power, the soItware need only increase the duty cycle oI
the PW output. I a speciIic amount oI braking pressure is desired, measurements would need
to be taken to determine the mathematical relationship between duty cycle and pressure. (And
the resulting Iormulae or lookup tables would be tweaked Ior operating temperature, surIace
wear, and so on).

To set the pressure on the brake to, say, 100 psi, the soItware would do a reverse lookup
to determine the duty cycle that should produce that amount oI Iorce. t would then set the PW
duty cycle to the new value and the brake would respond accordingly. I a sensor is available in
the system, the duty cycle can be tweaked, under closed-loop control, until the desired pressure is
precisely achieved.

PW is economical, space saving, and noise immune. And it's now in your bag oI tricks.
So use it.

t is easy to use a microcontroller to turn LEDs on and oII in almost any pattern you
want. But you can only turn the LED on and oII. So what iI you want to control the brightness oI
the LED? The same problem comes up in robotics where you want to control the speed oI a
motor with a microcontroller. t is not good enough to just turn the motor on and oII. To control
the brightness oI the LED or speed oI the motor you have to control the amount oI current going
through the device. But how? One solution that may occur to you is to quickly turn the LED or
motor on and oII. The current only Ilows when the output is low. The output oI your
microcontroller will look like the Iollowing square wave.



I you turn an LED or motor on and oII Iast enough then it will appear to stay on
continuously and since there is less current Ilowing overall the LED will appear less bright and
the motor will run at a slower speed. With this solution you can make the LED Ilash on and oII
as slow as 30 times a second but any slower and you start to see the LED blinking which is not
the desired result. Or, Ior the motor, it will lose its smooth operation and get jerky. The solution
does not work very well because the LED is still rather bright at 30 times a second.

We are on the right track but rather than changing the number oI times the output goes on
and oII, we change how long the output stays on and oII. Let's take a closer look at one output
cycle. An output cycle consists oI a low period, low and a high period, high. Low high T,
where T is the period (length oI time) Ior one output cycle. High is also called an output pulse, or
just pulse.

We will always keep T the same so that there is always the same number oI output cycles
per second. I we increase the width oI thigh then we must decrease low to keep T the same. I
we decrease thigh then we must increase low. or the case that we make thigh small then the
output looks like the Iollowing.

You can see that the output is 0 most oI the time and the LED or motor will be on most oI
the time.

or the case that we make thigh large then the output looks like the Iollowing.

The output is Vcc most oI the time, which turns oII the LED. The current only Ilows
through the LED Ior the brieI time that the LED is on during low. But since we are still turning
the LED on and oII very Iast (we will use about 100 times a second in the examples below), you
cannot see the LED blinking and it appears very dim. The total current that Ilows through the
LED is low. or the motor it will smoothly turn at a low speed. So we can control the brightness
oI the LED or the speed oI a motor by changing the width oI thigh. This is the secret oI Pulse
Width odulation.

Making it Work
ext we will see how to make this work in an 8051. You can use the hardware setup as
shown in either the Iirst microcontroller project Ior the 2051 or the 8051. The soItware examples
work Ior either oI the hardware setups. You can also reIer to those links Ior Iree tools and more
inIormation on working with assembly language Iiles.

One delay is used to control low and the other delay is used to control thigh. The example
is set to minimize low and maximize thigh to make the LED appear very dim. To make the LED
brighter you can decrease R
4
and increase R
3
. This example works Iine and shows an easy way to
control the pulse width. The biggest disadvantage is that it assumes you will be not be doing
anything else in your program. I you try to do some other processing you will aIIect the timing
oI the pulses.

A better solution is in uses one oI the microcontrollers built in timers to control the pulse
width. A timer can be used to create delay routines while the processor is Iree to run other parts
oI your program. t is an independent piece oI hardware that you assign a task to and it goes oII
and does its work without using the main processor. When it Iinishes its task it lets you know by
generating an interrupt. You can then give it another task and get back to the other processing
you were doing.

Register R
7
is used to control the pulse width. To increase the brightness oI the LED,
increase R
7
. You can use the example code as is and adjust R
7
to control the Pulse Width without
going through the rest oI the detailed explanation oI how the code works.

We will set up Timer 0 as an 8 bit timer so it can have values oI 0 to 255. n order to keep
T constant we will make the total time T correspond to 255 counts in the timer. The thigh period
will count Irom R
7
to 255. The low period will count the rest oI the 255 counts. The timer is
designed to count up Irom some initial value and then interrupt. We just use R
7
as the initial
value Ior counting thigh. The initial value Ior low is more complicated. Lets say the initial value
Ior low is X. We want R
7
X 255. So X 255 - R
7
. n the actual program we Iind X by using
the subtract command SUBB.

Timer 0 Setup
There are a couple oI things we need to do to set up Timer 0 to tell it how to behave
beIore we start using it. irst we modiIy the Timer ode Control Register, TOD, to set Timer
0 to ode 0.
OV TOD,#00H ; set timer 0 to ode 0 (8 bit Timer with 5 bit prescalar)

There are several modes that you can use to give the timers diIIerent behaviors. Look at
Ior more inIormation on the diIIerent modes. The basic operation oI the Timer is to increase its
value by one on each machine cycle. (A machine cycle is equal to 12 clock cycles.) n ode 0
there is a 5 bit pre-scalar. This means the timer counts 32 machine cycles (5 bits goes Irom 0 to
32) beIore increasing its stored value. This means that there are 32 machine cycles Ior each count
oI the timer. I the crystal is 11.0592 Hz then each machine cycle is 0.000001085 seconds and
each timer count is 32 * 0.000001085 0.00003472 seconds per count. I there are 255 counts
per output cycle then there will be about 113 output cycles per second.

There is also a control to turn the timer on and oII. We will turn the timer on and just let
it run Ireely. The command to turn on Timer 0 is
SETB TR0 ; turn on timer 0
We also need to turn on the Timer 0 interrupt so that it will tell us every time the 8 bit
value has gotten to 255 and turned over to 0. We need to set the bit EA to enable the interrupts.
When this bit is cleared (0) it turns all the interrupts oII. (t can be useIul to turn all the interrupts
oII iI you are doing something important and don't want to be interrupted.)
SETB EA ; Enable nterrupts (each individual interrupt must also be enabled)
And then we must set the bit ET0 to speciIically turn on the interrupt Ior Timer 0.
SETB ET0 ; Enable Timer 0 nterrupt

Using the Timer
ow we can load a value into the 8 bit timer register, TH0, and it will run Ireely until it
"overIlows". The overIlow occurs when it is at its maximum value oI 255 and on the next count
goes back to 0. This is the same as what would happen to the mileage meter in your car when it
reaches all 9s and "Ilips over" to all 0s. The overIlow triggers the Timer 0 interrupt and the
processor stops whatever it is doing and goes to the point 0BH in its program. (0BH is the hex
value 0B, which is the 11th memory location). We have used the ORG command to put a
command in the 0BH location that jumps to our nterrupt Service Routine (SR) Ior Timer 0.
This just means that when the interrupt occurs the processor will go and process some code and
then return to what is was doing beIore.

Below is the code that the processor goes through each time the Timer 0 interrupt occurs.
Since we are using Timer 0 to time both low and thigh, we use a lag (which is just a bit) to
indicate whether we are currently timing low or thigh. We set the bit to 1 Ior thigh and 0 Ior low.
TER0TERRUPT:

JB 0, HGHDOE ; I 0 is set then we just Iinished the high section oI the
LOWDOE: ; cycle so Jump to HGHDOE

SETB 0 ; ake 01 to indicate start oI high section
SETB P1.0 ; Turn oII LED
OV TH0, R
7
; Load high byte oI timer with R
7
(our pulse width control value)
CLR T0 ; Clear the Timer 0 interrupt Ilag
RET ; Return Irom nterrupt to where the program came Irom

HGHDOE:
CLR 0 ; ake 00 to indicate start oI low section
CLR P1.0 ; Turn on LED
OV A,#H ; ove H (255) to A
CLR C ; Clear C (the carry bit) so it does not aIIect the subtraction
SUBB A, R7 ; Subtract R7 Irom A. A 255 - R
7
.
OV TH0, A ; so the value loaded into TH0 R
7
255
CLR T0 ; Clear the Timer 0 interrupt Ilag
RET ; Return Irom nterrupt to where the program came Irom

The basic idea oI the routine is Iairly simple. irst it checks to see iI it just Iinished thigh
or low.

I it was thigh then it jumps to HGHDOE and prepares Ior the low period. We set 0
to 0 to indicate we are timing low. Then we turn on the LED. ext we Iind the value to load into
the 8 bit timer register TH0. Timer 0 will count up Irom there.

I it was low then we continue through LOWDOE and set 0 to 1 to indicate we are
timing thigh. Then we turn oII the LED. ext we load R
7
into the 8 bit timer register TH0 and
Timer 0 will count up Irom there.

Main Code
The main part oI the code does not have to do anything. n this example we just move 01
to R
7
Ior the minimum brightness and then make an inIinite loop with
OV R
7
,#001H ; set pulse width control to dim

LOOP: AJP LOOP ;go to LOOP

The processor just sits there in an endless loop until the Timer 0 interrupt occurs. Then it
goes oII and goes through the Timer 0 interrupt routine and returns to the endless loop to wait Ior
the next interrupt. I we had some other processing to do we could put that code in here in place
oI the endless loop and the processor could actually do something useIul while it is waiting Ior
the next interrupt.

What is a Duty Cycle?
Duty cycle is a term used to describe the output pulse. t is given as a percentage such as
80. The percentage tells you what percent oI the output cycle is high. So Ior a duty cycle oI
80 thigh would be 80 oI T and low would be 20. To Iind the duty cycle, use the Iormula
Duty Cycle high / (high low)
Why does the interrupt go to 0BH?
The 8051 hardware is pre wired so that when an interrupt occurs the hardware
automatically jumps to a predeIined location in memory. These locations can not be changed.
They are
03H ;external interrupt 0
0BH ;timer 0 interrupt
13H ;external interrupt 1
1BH ;timer 1 interrupt
23H ;serial port interrupt
Some versions oI the 8051 have more interrupts and they are located close to these. These
locations are all rather close together. There is not enough room to actually write an interrupt
service routine so the general solution is to put a jump at each interrupt location you are using
that jumps to the interrupt service routine which can be anywhere later in the program memory.
ote that no interrupt service routine is needed Ior the interrupts that are not used in your
program. n the example programs a return instruction RET is put at each interrupt location Ior
the rare case that some glitch happens and the hardware ends up at that location.
COMPONENT DESCRIPTION

TRANSISTOR (BC558)
A transistor is semi conductor device consisting oI three regions separated by two P-
junctions. The three regions are Base, Emitter & Collector.

The base may be oI - type or P- type. The emitter and collector have same impurities
but diIIerent Irom that oI base. Thus iI base is oI - type then emitter and collector are oI P- type
then transistor is called P--P transistor and vice versa transistor is called -P- transistor.

The base is made thin and number density oI majority carriers is always less than emitter
and collector. The base provides junction Ior proper interaction between emitter and collector.

Electrons are majority charge carriers in - region and in P-region, holes are the majority
charge carriers. Thus two types oI charge carriers are involved in current Ilow through -P- or
P--P transistor.

SYMBOLS FOR TRANSISTORS :
n schematic symbols, the emitter is always represented by an arrow indicating the
direction oI conventional current in the device.

n case oI -P- transistor arrow points away Irom base and in case oI P--P transistor it
points towards base.

When transistor is used in circuit, emitter - base junction is always Iorward biased while
base - collector junction is always reverse biased.

Fig. Structure and symbol of P-N-P transistor

BIASING OF TRANSISTOR :
The two junctions can be biased in Iour diIIerent ways:
O Both junctions may be Iorward biased. t causes large current to Ilow across junctions.
Transistor is to be operated in 'SATURATO REGO.
O Both junctions may be reversed biased. t causes very small current to Ilow across
junctions. Transistor is to be operated in 'CUT O REGO.
O E-B junction is Iorward biased and C-B junction is reverse biased. The transistor is said
to be operated in 'ACTVE REGO. ost oI the transistors work in this region.
O E-B junction is reversed biased and C-B junction is Iorward biased. The transistor is said
to be operated in 'VERTED ODE.

Fig. (a) P-N-P transistor biasing (b) N-P-N transistor biasing
R&% NFG&RA%NS .
There are three possible ways in which a transistor can be connected in the
circuit which are Iollowing :
O Common Base Configuration : Base is made common in this conIiguration.
O Common Emitter Configuration : Emitter is made common in this
conIiguration.
O Common Collector Configuration : Collector is made common in this
conIiguration.





ig. PP Common Base ConIiguration








Fig. PNP Common Emitter Fig. NPN Common Collector
Configuration Configuration

BC558
Absolute Maximum Rating : T
a
25C unless otherwise noted
Parameter Symbol Value
Collector Emitter Voltage V
CEO
-30
Collector Base Voltage V
CBO
-30
Emitter Base Voltage V
EBO
-5
Collector Current (DC)
C
-100
Collector Dissipation P
C
500
Junction Temperature T
J
150
Storage Temperature T
STG
-65 to 150

Electrical Characteristics : T
a
25C unless otherwise noted
Parameter Symbol Test Condition Min. Type
Collector Cut-oII Current
CBO
V
CB
-30V,
E
0
DC Current Gain h
Ie
V
CB
-5V,
C
2mA 110
Collector Emitter Saturation
Voltage
V
CE(sat)

C
-10mA,
B
-0.5mA

C
-100mA,
B
-5mA
-90
-250
Collector Base Saturation
Voltage
V
BE(sat)

C
-10mA,
B
-0.5mA

C
-100mA,
B
-5mA
-700
-900
Base Emitter On Voltage V
BE(On)
V
CE
-5V,
C
-2mA
V
CE
-5V,
C
-10mA
-600 -660
Current Gain Bandwidth
Product
I
T
V
CE
-5V,
C
-10mA,
I10Hz
150
Output Capacitance C
ob
V
CB
-10V,
E
0,I1Hz
oise igure V
CE
-5V,
C
-200mA 2

DIODE
t is a P-type region and -type region Iormed in the same crystal structure, and hence a
P- junction is produced. Some oI the conduction electrons near the junction diIIuse in to P-type
semiconductor Irom the -type semiconductor across the junction combing with the holes. The
loss oI electrons makes the -type semiconductor positively charged and hence the
neutralization oI the holes on the other hand makes P-type semiconductor negatively charged.
This region where positive and negative charges develop is called depletion region.
Fig. Diode
I a P-region is made positive with respect to the -region by an external circuit then
junction is Iorward biased and junction has a very low resistance to the Ilow oI current. Holes in
the positive P-type material are attracted across the junction to the negative side and the Iree
electrons in the -type material are like wise attracted to the opposite side. I a positive voltage
is applied to -zone with respect to the P-zone terminal, the P- junction is reverse biased.
Fig. Volt-Ampere Characteristics of a P-N Diode
Temperature Dependence of V-I Characteristics
The cut-in voltage decreases at the rate oI 2.5 mV/C. Also above 25C, the reverse
saturation current
0
doubles Ior every 6C (10C) Ior Si (Ge) diodes. However, the shape oI
overall characteristic does not alter with temperature.

Diode Resistance
O Static Resistance : The static resistance oI a diode denoted by R is the ratio oI diode
voltage V to diode current . The static resistance R varies widely as the operating point
shiIts and it does not constitute a useIul parameter.
O Dynamic or Incremental Resistance : The dynamic resistance oI a diode is deIined as
the reciprocal oI the slope oI the current voltage characteristic. Thus dynamic resistance
is given by -
r dV/d ....(1)
The dynamic resistance Iorms an important parameter Ior small signal operation
oI the diode. The dynamic resistance, however, is not a constant but varies with the
operating point.

or a semiconductor diode, the dynamic resistance r as per V- characteristic is
given by,
r dV/d V
T
/
0
1
V/V
T
V
T
/(
0
) ....(2)

I the reverse bias is greater than a Iew tenth oI a volt, then <V/V

< ~~1 and r is


extremely large.

or Iorward bias exceeding a Iew tenths oI volt, ~~
0
, so that
r V
T
/ ....(3)
Thus dynamic Iorward resistance varies inversely as the current . At room
temperature, i.e.
T 300K, Ior 1.
R 26/ ....(4)
where r is in ohms and is in milli-amperes.

Depletion Layer Capacitance (Transition Capacitance) C
T

The width W oI the depletion layer at the junction increases with the increase oI reverse
bias magnitude. This depletion region along with the concentration oI uncovered immobile
charges constitutes a capacitor whose incremental capacitance C
T
is given by,
C
T
<dQ/dV<
where dQ is the increase in charge resulting Irom a change dV in voltage. Hence a
voltage change dV in time interval dt will result in a current i given by,
i dQ/dt ....(5)
C
T
dV/dt ....(6)

LICH1 EMI11IAC DIODE
LED Ialls within the Iamily oI P- junction devices. The light emitting diode (LED) is a
diode that will give oII visible light when it is energized. n any Iorward biased P- junction
there is, within the structure and primarily close to the junction, a recombination oI holes and
electrons. This recombination requires that the energy possessed by the unbound Iree electron be
transIerred to another state.

The process oI giving oII light by applying an electrical source oI energy is called
electroluminescence. As shown in Iig., with its graphic symbol, the conducting surIace
connected to the P-material is much smaller, to permit the emergence oI the maximum number oI
photons oI light energy. ote in the Iigure that the recombination oI the injected carriers due to
the Iorward-biased junction results in emitted light at the site oI recombination. There may, oI
course, be some absorption oI the packages oI photon energy in the structure itselI, but a very
large percentage are able to leave, as shown in the Iig.

Fig. Process of electroluminescence in the LED

Absolute Maximum Ratings at T
A
25C
Parameter High Eff. Red 4160 Units
Power dissipation 120 mW
Average Iorward current 20
|1|
mA
Peak Iorward current 60 mA
Operating and storage temperature range -55C to 100C
Lead soldering temperature
|1.6mm (0.063 in.) Irom body|
230C Ior 3 seconds
|1| Derate Irom 50C at 0.2 mA/C

Electrical/Optical Characteristics at T
A
25C
Parameter Symbol High Eff. Red 4160 Units Test
Conditions
Min. Type Max
Axial luminous intensity
v
1.0 3.0 mcd

10mA
ncluded angle between
halI luminous intensity
points
27
1/2

80 deg. -
Peak wave length
2
peak

635 nm easureme
nt at Peak
Dominant wave length
2
d

628 nm -
Speed oI response
:
s

90 ns
Capacitance C 11 p V

0;
I1 Hz
Thermal resistance
7
JC

120 C/W Junction to
cathode lead
at 0.79 mm
(0.031 in)
Irom body
orward voltage V

2.2 3.0 V

10mA
Reverse breakdown
voltage
BV
R
5.0 V

R
1003A
Luminous eIIicacy

v

147 Lm/V -

RESIS1AACE
Resistance is the electronic component used to control the current passing
through the circuit. They are calibrated in ohms. n the other words resistance are
circuit elements having the Iunction introducing electrical resistance into the circuit. There are
three basic types :
1. ixed Resistance
2. Rheostat
3. Potentiometer
A Iixed Resistance is a two terminal resistance whose electrical resistance is constant. A
rheostat is a resistance that can be changed in resistance value without opening the circuit to
make adjustment. potentiometer is an adjustable resistance with three terminals one each end
oI the resistance element and third movable along its length.

CAPACI1OR
A capacitor is a device capable oI storing an electric charge (static electricity). t consists
oI two metal plates separated by dielectric material. Capacitors are available in values ranging
Irom less than one picoIarad to thousands oI microIarad. While using a capacitor it`s ratings
must be careIully observed to make certain that the potential to be applied across the capacitor is
not greater than the rated value.

TYPES OF CAPACITORS :
Depends upon the basis oI dielectric used:
O Air insulated & vaccum capacitors
O Paper insulated capacitors
O ica capacitors
O Plastic Iilm capacitors
O Ceramic capacitors
O Electrolytic & tantalum capacitors

CERAMIC CAPACITOR :
n this project, 0.01 microIarad capacitor is a ceramic capacitor.
The basis oI the ceramic material is mainly barium titanate or a similar material, but other
ceramic substance including hydrous silicate oI magnesia or talc are also used. The electrodes
are applied in the Iorm oI silver which is either spread or plated on to the opposite Iaces oI a thin
tube, waIer or disc made Irom the ceramic material. Connecting wires are then soldered to this
deposit and the whole capacitor dipped in Ior a suitable coating.

Fig. Tabular and disc type ceramic capacitors

ELECTROLYTIC CAPACITOR :
n this project, 103I capacitor is an electrolytic capacitor. n this type oI capacitors, the
dielectric consists oI an extremely thin Iilm oI aluminum oxide Iormed on one oI its aluminum
Ioil plates. ntimate contact with the other plate is achieved by impregnating the paper between
the Ioils with an electrolyte in the Iorm oI viscous substance, such as ammonium borate. The
sandwich is then rolled into a cylindrical element and housed in either metallic cardboard, plastic
or ceramic protective tube.

Fig. Electrolytic and Tantalum capacitor

RELAYS
n order to enable a circuit to be isolated Irom the system only under Iaulty conditions,
protective relays are used. n normal cases, it is open circuit relay. The relay is usually provided
with 4 terminals, two oI which are connected to relay winding and other two are connected to the
circuit to be controlled. t has Iollowing characteristics :
O Sensitivity
O Speed
O Selectivity

%PES F RELAS .
O Electromagnetic Attraction Type : These relays are actuated by DC or AC quantities.
O Electromagnetic Induction Type : t`s operation depends upon E phenomena.
O Thermal Relays : t`s operation depends upon the heating eIIect oI electric Current.
O Distance Relays : t`s operation depends upon the ratio oI voltage to current.

ELECTROMAGNETIC RELAY :
These relays are electromagnetically operated. The parts oI these relays are an iron core
& its surrounding coil oI wire. An iron yoke provides a low reluctance path Ior magnetic Ilux,
the yoke being shaped so that the magnetic circuit can be closed by a movable piece oI iron
called the armature, and a set oI contacts. The armature is hinged to the yoke and is held by a
string in such a way that there is an air gap in the magnetic circuit. igure shows the principle oI
operation oI this relay. When an electric current Ilows in the coil, the armature is attracted to the
iron core. Electrical switching contacts are mounted on the armature. When the armature coil is
energized, these movable contacts break their connections with one set oI Iixed contacts and
close a connection to a previously open contact. When electric power is removed Irom the relay
coil, spring returns the armature to its original position.

Standard voltages Ior D.C. relay are 6,12,24,48 & 110 volts and Ior A.C. relays are
6,12,24,48,120 & 240 volts.

Fig. Basic Diagram Showing the Operating Principle of a Relay

1RAASFORMER
A TransIormer is a static piece oI apparatus by means oI which electric power in one
circuit is transIormer in to electric power oI the same Irequency in another circuit. t an raise or
lower the voltage in a circuit decrease or increase in current. The physical basis oI a TransIormer
is natural induction between tow circuit linked by a common magnetic Ilux.







According to construction there are two type oI TransIormer know as
1. Core Type Transformer :
The coil used are Iorm wound and are oI the cylinder cal type. The general Iorm
oI these coil may be circular or over all rectangular. n small size core type TransIormer a

simple rectangular core is used with cylinder cal coil are used which are so wound as to
Iit over a cruciIorm core sections.
2. Shell Type Transformer :
n shell type TransIormer the coil are Iorm wound but are multi layer disc type
usually wound in the Iorm oI pancakes. The diIIerent layers oI such multi layer disc are
insulated Iorm each other by paper. The completed winding consists oI takes disc with
insulation space between the coil.















INFRARED:
nIrared (R) radiation is electromagnetic radiation whose wavelength is longer than that oI
visible light (400700 nm), but shorter than that oI terahertz radiation (100 m 1 mm) and
microwaves. nIrared radiation spans more than three orders oI magnitude (roughly 700 nm to
300 m).
|1|

Direct sunlight has a luminous eIIicacy oI about 93 lumens per watt oI radiant Ilux, which
includes inIrared (47 share oI the spectrum), visible (46), and ultra-violet (only 6) light.
Bright sunlight provides luminance oI approximately 100,000 candela per square meter at the
Earth's surIace.
nIrared imaging is used extensively Ior military and civilian purposes. ilitary
applications include target acquisition, surveillance, night vision, homing and tracking. on-
military uses include thermal eIIiciency analysis, remote temperature sensing, short-ranged
wireless communication, spectroscopy, and weather Iorecasting. nIrared astronomy uses sensor-
equipped telescopes to penetrate dusty regions oI space, such as molecular clouds; detect cool
objects such as planets, and to view highly red-shiIted objects Irom the early days oI the
universe.
Humans at normal body temperature radiate chieIly at wavelengths around 10m
(micrometers).
At the atomic level, inIrared energy elicits vibrational modes in a molecule through a
change in the dipole moment, making it a useIul Irequency range Ior study oI these energy states
Ior molecules oI the proper symmetry. nIrared spectroscopy examines absorption and
transmission oI photons in the inIrared energy range, based on their Irequency and intensity.


SOFTWARE


MAIN PROGRAM
org 0000h
ljmp main
org 0003h
ljmp ex0isr
org 000bh
ljmp tim0isr
org 0013h
ljmp ex1isr
org 001bh
ljmp tim1isr
org 0023h
ljmp serisr

ex0isr:
reti

tim0isr:
cpl irout
reti
ex1isr:
reti

tim1isr:
clr tr1
clr irrun
setb irout
mov tl1,#0a4h
mov th1,#0Ich
reti

serisr:
reti

main:
mov sp,#stktop
mov keysts,#00h
mov tl0,#012h ; by this we set the Irequency delay
mov th0,#013h
mov tl1,#08h ; pulse width selector
mov th1,#0I2h
mov tmod,#02ah
setb et0
setb et1
setb ea
setb tr1
clr tr0
clr chkbit
mainlp1:
clr irrun
setb irout
jb key0,nxtkey1
ljmp actkey0
nxtkey1:
jb key1,nxtkey2
ljmp actkey1
nxtkey2:
jb key2,nxtkey3
ljmp actkey2
nxtkey3:
jb key3,nxtkey4
ljmp actkey3
nxtkey4:
jb key4,nxtkey5
ljmp actkey4
nxtkey5:
jb key5,nxtkey6
ljmp actkey5
nxtkey6:
jb key6,nxtkey7
ljmp actkey6
nxtkey7:
jb key7,nxtkey8
ljmp actkey7
nxtkey8:
jb key8,nxtkey9
ljmp actkey8
nxtkey9:
jb key9,nxtkey10
ljmp actkey9
nxtkey10:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
ljmp mainlp1

actkey0:
mov cmdvar,#01h
jb key0sts,ak0skp1
cpl chkbit
setb key0sts
ak0skp1:
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey1:
mov cmdvar,#03h
jb key1sts,ak1skp1
cpl chkbit
setb key1sts
actkey2:
mov cmdvar,#03h
jb key2sts,ak2skp1
cpl chkbit
setb key2sts
ak2skp1:
clr key0sts
clr key1sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey3:
jb key3sts,ak3skp1
cpl chkbit
setb key3sts
ak3skp1:
clr key0sts
clr key1sts
clr key2sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey4:
mov cmdvar,#06h
jb key4sts,ak4skp1
cpl chkbit
setb key4sts
ak4skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey5:
mov cmdvar,#05h
jb key5sts,ak5skp1
cpl chkbit
setb key5sts
ak5skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key6sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey6:
mov cmdvar,#08h
jb key6sts,ak6skp1
cpl chkbit
setb key6sts

ak6skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key7sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey7:
mov cmdvar,#08h
jb key7sts,ak7skp1
cpl chkbit
setb key7sts
ak7skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key8sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey8:
mov cmdvar,#09h
jb key8sts,ak8skp1
cpl chkbit
setb key8sts
ak8skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key9sts
lcall outdata
ljmp mainlp1

actkey9:
mov cmdvar,#0ah
jb key9sts,ak9skp1
cpl chkbit
setb key9sts
ak9skp1:
clr key0sts
clr key1sts
clr key2sts
clr key3sts
clr key4sts
clr key5sts
clr key6sts
clr key7sts
clr key8sts
lcall outdata
ljmp mainlp1

; jb chkbit,outskp1
setb dbit4
clr dbit5
ljmp outskp2
outskp1:
clr dbit4
setb dbit5

outskp2:
mov a,cmdvar
rl a
rl a
rl a
rl a
clr c
rlc a
jc outskp3
setb dbit6
clr dbit7
ljmp outskp4
outskp3:
clr dbit6
setb dbit7
outskp4:
rlc a
jc outskp5
setb dbit8
clr dbit9
ljmp outskp6
outskp5:
clr dbit8
setb dbit9
outskp6:
rlc a
jc outskp7
setb dbit10
clr dbit11
ljmp outskp8
outskp7:
clr dbit10
setb dbit11
outskp8:
rlc a
jc outskp9
setb dbit12
clr dbit13
ljmp outskp10
outskp9:
clr dbit12
setb dbit13
outskp10:
mov c,dbit0
mov irrun,c
setb tr1
outlp15:
jnb tr1,outskp15
sjmp outlp15
outskp15:
mov c,dbit1
mov irrun,c
setb tr1
outlp16:
jnb tr1,outskp16
sjmp outlp16
outskp16:
mov c,dbit2
mov irrun,c
setb tr1
outlp17:
jnb tr1,outskp17
sjmp outlp17
outskp17:

mov c,dbit3
mov irrun,c
setb tr1
outlp18:
jnb tr1,outskp18
sjmp outlp18
outskp18:
mov c,dbit4
mov irrun,c
setb tr1
outlp19:
jnb tr1,outskp19
sjmp outlp19
outskp19:
mov c,dbit5
mov irrun,c
setb tr1
outlp20:
jnb tr1,outskp20
sjmp outlp20
outskp20:
mov c,dbit6
mov irrun,c
setb tr1
outlp21:
jnb tr1,outskp21
sjmp outlp21

outskp21:
mov c,dbit7
mov irrun,c
setb tr1
outlp22:
jnb tr1,outskp22
sjmp outlp22
outskp22:
mov c,dbit8
mov irrun,c
setb tr1
outlp23:
jnb tr1,outskp23
sjmp outlp23
outskp23:
mov c,dbit9
mov irrun,c
setb tr1
jnb tr1,outskp24
outskp24:
mov c,dbit10
mov irrun,c
setb tr1
outlp25:
outskp25:
mov c,dbit11
mov irrun,c
setb tr1
outlp26:
jnb tr1,outskp26
sjmp outlp26
outskp26:
mov c,dbit12
mov irrun,c
setb tr1
outlp27:
jnb tr1,outskp27
sjmp outlp27
outskp27:
mov c,dbit13
mov irrun,c
setb tr1
outlp28:
jnb tr1,outskp28
sjmp outlp28
outskp28:
clr irrun
setb irout
lcall delay1
lcall delay1
pop end
Program code for the Receiver Section

t0_lo equ 022h
t0_hi equ 012h
t1_lo equ 013h
t1_hi equ 022h

sw0 bit P1.7
sw1 bit P1.6
sw2 bit P1.3
sw3 bit P1.4
fan_sw1 bit P1.2
fan_sw2 bit P1.5
fan_led1 bit p1.1
fan_led2 bit p1.0

ir_in bit P3.2
zcd_in bit P3.3

;remote key command table
cmd0 equ 01h ;1
cmd1 equ 02h ;2
cmd2 equ 03h ;3
cmd3 equ 04h ;4
cmd4 equ 05h ;5
cmd5 equ 06h ;6
cmd6 equ 07h ;7
cmd7 equ 08h ;8
cmd8 equ 09h ;9
cmd9 equ 0ah ;10

delay1 equ 30h
delay2 equ 31h
temp1 equ 32h
temp2 equ 33h
cnt1 equ 34h

rb0 equ 000H
rb1 equ 008H
rb2 equ 010h
rb3 equ 018h

flags equ 21h
control bit flags.0
new bit flags.1

fan1 bit flags.2
fan2 bit flags.3

command equ 22h
sub_ad equ 23h
buffer equ 24h
stack equ 60h

;Processor nterrupt and Reset Vectors
org 00H
ljmp main
org 0003H
ljmp ex0_isr
org 000bh
ljmp tim0_isr
org 0011h
ljmp ex1_isr
org 001bh
ljmp tim1_isr
org 0022h
reti

;external interrupt subroutine for ir_in
ex0_isr:
push psw
push a
jb ir_in,skp_ex01
clr ex0
mov tl0,#0bfh
mov th0,#0f4h
mov cnt1,#f5h
setb tr0
skp_ex01:
pop a
pop psw
reti

;timer-0 interrupt subroutine
tim0_isr:
clr tr0
mov c,ir_in
mov a,command
rlc a
mov command,a
djnz cnt1,skp_tim01
anl a,#0fh
jz skp_tim02
mov sub_ad,a
mov a,#0ah
clr c
subb a,sub_ad
jc skp_tim02
mov a,command
anl a,#1fh
jb acc.4,skp_tim03
jnb control,skp_tim02
setb new
sjmp skp_tim04
skp_tim03:
jb control,skp_tim02
setb new
sjmp skp_tim04
skp_tim04:
mov c,acc.4
mov control,c
anl a,#0fh
mov command,a
setb ex0
sjmp skp_tim05
skp_tim02:
clr new
setb ex0
sjmp skp_tim05
skp_tim01:
mov tl0,#00h
mov th0,#0f9h
setb tr0
skp_tim05:

;External interrupt-1 subroutine
ex1_isr:
push psw
push a
mov tl1,#t0_lo
mov th1,#t0_hi
setb tr1
mov a,delay1
mov temp1,a
jnz skp_ex10
jnb fan1,skp_ex10
clr fan_sw1
skp_ex10:
mov a,delay2
mov temp2,a
jnz skp_ex11
jnb fan2,skp_ex11
clr fan_sw2
skp_ex11:
pop a
pop psw
reti

;timer-1 interrupt subroutine
tim1_isr:
clr tr1
mov tl1,#t1_lo
mov th1,#t1_hi
setb tr1
setb fan_sw1
setb fan_sw2
djnz temp1,skp_tim10
jnb fan1,skp_tim10
clr fan_sw1
skp_tim10:
djnz temp2,skp_tim11
jnb fan2,skp_tim11
clr fan_sw2
skp_tim11:

main:
mov delay1,#09d
mov delay2,#09d
clr control
clr new
clr fan1
clr fan2
setb fan_sw1
setb fan_sw2
mov tcon,#00H
mov psw,#rb0
mov sp,#stack
mov tmod,#011h
mov tl1,#t1_lo
mov th1,#t1_hi
setb it0
setb it1
setb et0
setb et1
setb ex0
setb ex1
setb ea

main_loop:
jb new,nxt0
ljmp main_loop
nxt0:
clr new
mov a,command

;command selection start here

cjne a,#cmd0,nxtc1
ljmp act_cmd0
nxtc1:
cjne a,#cmd1,nxtc2
ljmp act_cmd1
nxtc2:
cjne a,#cmd2,nxtc3
ljmp act_cmd2
nxtc3:
cjne a,#cmd3,nxtc4
ljmp act_cmd3
nxtc4:
cjne a,#cmd4,nxtc5
ljmp act_cmd4
nxtc5:
cjne a,#cmd5,nxtc6
ljmp act_cmd5
nxtc6:
cjne a,#cmd6,nxtc7
ljmp act_cmd6
nxtc7:
cjne a,#cmd7,nxtc8
ljmp act_cmd7
nxtc8:
cjne a,#cmd8,nxtc9
ljmp act_cmd8
nxtc9:
cjne a,#cmd9,skipc
ljmp act_cmd9
skipc:
jmp main_loop

act_cmd0:
cpl sw0
ljmp main_loop

act_cmd1:
cpl sw1
ljmp main_loop

act_cmd2:
cpl sw2
ljmp main_loop
act_cmd3:
cpl sw3
jmp main_loop

act_cmd4:
jb fan1,skp_cmd41
ljmp main_loop
skp_cmd41:
mov a,delay1
cjne a,#09d,skp_cmd42
ljmp main_loop

skp_cmd42:
inc delay1
ljmp main_loop
act_cmd5:
jb fan2,skp_cmd51
ljmp main_loop
skp_cmd51:
mov a,delay2
cjne a,#09d,skp_cmd52
ljmp main_loop
skp_cmd52:
inc delay2
ljmp main_loop
act_cmd6:
cpl fan1
cpl fan_led1
ljmp main_loop
act_cmd7:
cpl fan2
cpl fan_led2
ljmp main_loop
act_cmd8:
jnb fan1,skp_cmd81
mov a,delay1
jz skp_cmd81
dec delay1
skp_cmd81:
ljmp main_loop
act_cmd9:
jnb fan2,skp_cmd91
mov a,delay2
jz skp_cmd91
dec delay2
skp_cmd91:
ljmp main_loop

end

Program ode for the %ransmitter Section
bitnos equ 14d ;
dlycnt1 equ 03d
stktop equ 40h

dlycntr equ 30h
bitcntr equ 31h
cmdvar equ 32h
tmpvar1 equ 33h
tmpvar2 equ 34h
tmpvar3 equ 35h

keysts equ 20h ; set Ilag oI the keys
keysts1 equ 21h
key0sts bit keysts.0
key1sts bit keysts.1
key2sts bit keysts.2
key3sts bit keysts.3
key4sts bit keysts.4
key5sts bit keysts.5
key6sts bit keysts.6
key7sts bit keysts.7
key8sts bit keysts1.0
key9sts bit keysts1.1

chkbit bit keysts1.2 ; its check the data in correct Iorm
dbit equ 22h ; data store resistor low
dbit1 equ 23h ; data stror resistor high
dbit0 bit dbit.0 ; store data in all
dbit1 bit dbit.1 ; these 14 bits
dbit2 bit dbit.2
dbit3 bit dbit.3
dbit4 bit dbit.4
dbit5 bit dbit.5
dbit6 bit dbit.6
dbit7 bit dbit.7

dbit8 bit dbit1.0
dbit9 bit dbit1.1
dbit10 bit dbit1.2
dbit11 bit dbit1.3
dbit12 bit dbit1.4
dbit13 bit dbit1.5

key0 bit p1.7 ; all the switches are connected to these pins
key1 bit p1.3
key2 bit p1.2
key3 bit p3.5
key4 bit p1.4
key5 bit p1.1
key6 bit p1.5
key7 bit p1.0
key8 bit p1.6
key9 bit p3.7

irout bit p3.1 ; inIra red ouptu pin
irrun bit p3.3 ; data is availble on this pin

P.C.B. LAYOUT

The entire circuit can be easily assembled on a general purpose PCB board. However,
actual size single side PCBs Ior the encoder and the decoder are shown in Iig. and respectively.
The component layouts Ior the PCBs in Iig. are shown in Iig., respectively. Layout oI desired
diagram and preparation is Iirst and most important operation in any printed circuit board
manuIacturing process. irst oI all layout oI component side is to be made in accordance with
available components dimensions.

Fig. P.C.B. Layout for the Circuit (Receiver)

Fig. P.C.B. Layout for the Circuit (Transmitter)


The Iollowing points are to be observed while Iorming the layout oI PCB.
1. Between two components, suIIicient space should be maintained.
2. High voltage/max. dissipated components should be mounted at suIIicient distance Irom
semiconductors and electrolytic capacitors.
3. The most important points are that the component layout is making proper compromise
with copper side circuit layout.
Printed circuit boards (PCBs) are used to avoid most oI all the disadvantages oI
conventional breadboard. These also avoid the use oI thin wires Ior connecting the components;
they are small in size and eIIicient in perIormance.

PREPARING CIRCUIT LAYOUT :
irst oI all the actual size circuit layout is to be drawn on the copper side oI the copper
clad board. Then enamel paint is applied on the tracks oI connection with the help oI a shade
brush. We have to apply the paints surrounding the point at which the connection is to be made.
t avoids the disconnection between the leg oI the component and circuit track. AIter completion
oI painting work, it is allowed to dry.

DRILLING :
AIter completion oI painting work, holes oI 1/23 inch (1 mm) diameter are drilled at
desired points where we have to Iix the components.

ETCHING :
The removal oI excess oI copper on the plate apart Irom the printed circuit is known as
etching. rom this process the copper clad board with printed circuit is placed in the solution oI
eCl with 3-4 drops oI HCl in it and is kept so Ior about 10 to 15 minutes and is taken out when
all the excess copper is removed Irom the PCB.

AIter etching, the PCB is kept in clean water Ior about halI an hour in order to get PCB
away Irom acidic Iield, which may cause poor perIormance oI the circuit. AIter the PCB has
been thoroughly washed, paint is removed by soIt piece oI cloth dipped in thinner or turbine.
Then PCB is checked as per the layout, now the PCB is ready Ior use.

SOLDERING

Soldering is the process oI joining two metallic conductors the joint where two metal
conductors are to be joined or Iused is heated with a device called soldering iron and then as
allow oI tin and lead called solder is applied which melts and converse the joint. The solder cools
and solidiIies quickly to ensure is good and durable connection between the jointed metal
converting the joint solder also present oxidation.

SOLDERING & DESOLDERING TECHNIQUES :
There are basically two soldering techniques:
. anual soldering with iron.
. ass soldering.
The iron consist oI an insulated handle connected via a metal shank to the bit the Iunction
oI bit is to
1. Stare host & convey it to the component
2. To store and deliver molten solder 7 Ilux.
3. To remove surplus solder Irom joints.
Soldering bit are made oI copper because it has good heat capacity & thermal
conductivity. t may erode aIter long term use to avoid it coating oI nickel or tin is used.

SOLDERING WITH IRON :
The surIace to be soldered must be cleaned & Iluxed. The soldering iron switched on &
bellowed to attain soldering temperature. The solder in Iorm oI wire is allied hear the component
to be soldered &b heated with iron. The surIace to be soldered is Iilled, iron is removed & the
joint is cold without disturbing.

Solder joint are supposed to
1. Provide permanent low resistance path
2. ake a robust mechanical link between PCB & leads oI components.
3. Allow heat Ilow between component, joining elements & PCB.
4. Retain adequate strength with temperature variation.
The Iollowing precaution should be taken while soldering.
1. Use always an iron plated copper core tip Ior soldering iron.
2. Slightly Iore the tip with a cut Iile when it is cold.
3. Use a wet sponge to wipe out dirt Irom the tip beIore soldering instead oI asking the iron.
4. Tighten the tip screw iI necessary beIore iron is connected to power supply.
5. Clean component lead & copper pad beIore soldering.
6. Use proper tool Ior component handling instead oI direct handling.
7. Apply solder between component leads, PCB pattern & tip oI soldering iron.
8. ron should be kept in contact with the joint s Ior 2-3 second s only instead oI keeping Ior
very long or very small time.
9. Use optimum quantity oI solder.
10. Use multistoried wire instead oI single strands solvent like isopropyl alcohol.
APPENDIX

C 7805C
C CD4049
C 89C2051
C BT136
IC 7805 :


1hree 1erminal Positive Fixed Joltage Regulators
These voltage regulators are monolithic integrated circuits designed as fixed voltage.
These regulators employ internal current limiting, thermal shutdown, and safe-area
compensation. With adequate heat sinking they can deliver output currents in excess of
1.0A. Although designed primarily as a fixed voltage regulator, these devices can be used
with external components to obtain adjustable voltages and currents.
Output Current in Excess of 1.0A
No external components required
Internal thermal overload protection
Internal short circuit current limiting

Output transistor safe - area compensation
Output voltage offered in 2 and 4 tolerance
Available in surface mount D2pAK and standard 3-lead transistor packages
Previous commercial temperature range has been extended to a junction
temperature range of -40C to +125C

DESCRIPTION
The 7805 series oI three terminal positive regulators are available in the TO-220/D-PAK
package and with several Iixed output voltages, making them useIul in a wide range oI
applications. Each type employs internal current limiting, thermal shut down and saIe operating
area protection, making it essentially indestructible. I adequate heat sinking is provided, they
can deliver over 1A output current. Although designed primarily as Iixed voltage regulators,
these devices can be used with external components to obtain adjustable voltages and currents.

Fig. Block Diagram of IC7805
Absolute Maximum Rating :
Parameter Symbol Value Unit
nput Voltage (Ior VO5V to 18V)
(Ior VO 24V)
V

V


35
40
V
V
Thermal Resistance, Junction to Cases (TO-
220)
R
7JC
5 C/W
Thermal Resistance, Junction to Air (TO-
220)
R
7JC
65 C/W
Operating Temp. Range T
OPR
0 - 125 C
Storage Temp. Range T
STG
-65 - 150 C

Electrical Characteristics (T
A
25C unless otherwise noted)
Parameter Symbol Min Type Max. Unit
Output Voltage T
J
25C V
O
4.8 5.0 5.2 V
Line Regulation (ote 1)
V
O
7V to 25V
Regline - 4.0 100 V
Load Regulation (ote 1)

O
5.0mA to 1.5A
Regload - 9 100 V
Quiescent Current T
J
25C
Q
- 5.0 8.0 mA
Quiescent Current Change

O
5.0mA to 1.0A

Q
- 0.03 0.5 mA
Output Voltage DriIt

O
5.0mA
V
O
/T - -0.8 - V/C
Output oise Voltage
I10Hz to 100Hz T
A
25C
V

- 42 - 3V/V
O

Ripple Rejection
I120Hz, V
O
8V to 18V
RR 62 73 - dB
Dropout Voltage

O
1A, T
A
25C
V
Drop
- 2 - V
Output Resistance
I1KHz
rO - 15 - m
Short Circuit Current
V

35V, T
A
25C

SC
- 230 - A
Peak Current T
A
25C
PK
- 2.2 - A

NOTE : Load and line regulation are speciIied at constant junction temperature.
Changes in VO due to heating eIIects must be taken into account separately. Pulse
testing with low duty is used.

IC 4049 HEX INVERTER :



E Q
L
H
H
L












IC AT89C2051 8-BIT MICROCONTROLLER WITH 2 KBYTES FLASH

Features
Compatible with CS-51 Products
2 Kbytes oI Reprogrammable lash emory Endurance: 1,000 Write/Erase Cycles
2.7 V to 6 V Operating Range
ully Static Operation: 0 Hz to 24 Hz
Two-Level Program emory Lock
128 x 8-Bit nternal RA
15 Programmable /O Lines
Two 16-Bit Timer/Counters
Six nterrupt Sources
Programmable Serial UART Channel
Direct LED Drive Outputs
On-Chip Analog Comparator
Low Power dle and Power Down odes
Description
The AT89C2051 is a low-voltage, high-perIormance COS 8-bit microcomputer with 2
Kbytes oI lash programmable and erasable read only memory (PERO). The device is
manuIactured using Atmel`s high density nonvolatile memory technology and is compatible with
the industry standard CS-51 instruction set and pinout.

By combining a versatile 8-bit CPU with lash on a monolithic chip, the Atmel
AT89C2051 is a powerIul microcomputer which provides a highly Ilexible and cost eIIective
solution to many embedded control applications.

The AT89C2051 provides the Iollowing standard Ieatures: 2 Kbytes oI lash, 128 bytes
oI RA, 15 /O lines, two 16-bit timer/counters, a Iive vector two-level interrupt architecture, a
Iull duplex serial port, a precision analog comparator, on-chip oscillator and clock circuitry. n
addition, the AT89C2051 is designed with static logic Ior operation down to zero Irequency and
supports two soItware selectable power saving modes. The dle ode stops the CPU while
allowing the RA, timer/counters, serial port and interrupt system to continue Iunctioning. The
Power Down ode saves the RA contents but Ireezes the oscillator disabling all other chip
Iunctions until the next hardware reset.


Pin Description
VCC
Supply voltage.
GD
Ground.
Port 1
Port 1 is an 8-bit bidirectional /O port. Port pins P1.2 to P1.7 provide internal pullups.
P1.0 and P1.1 require external pullups. P1.0 and P1.1 also serve as the positive input (A0) and
the negative input (A1), respectively, oI the on-chip precision analog comparator. The Port 1
output buIIers can sink 20 mA and can drive LED displays directly.

When 1s are written to Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7
are used as inputs and are externally pulled low, they will source current (L) because oI the
internal pullups.
BLOCK DIACRAM


Port 3
Port 3 pins P3.0 to P3.5, P3.7 are seven bidirectional /O pins with internal pullups. P3.6
is hard-wired as an input to the output oI the on-chip comparator and is not accessible as a
general purpose /O pin. The Port 3 output buIIers can sink 20 mA. When 1s are written to Port 3
pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins
that are externally being pulled low will source current (L) because oI the pullups.

Port 3 also serves the Iunctions oI various special Ieatures oI the AT89C2051 as listed
below:
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 T0 (external interrupt 0)
P3.3 T1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
Port 3 also receives some control signals Ior lash programming and programming
veriIication.

RS1
Reset input. All /O pins are reset to 1s as soon as RST goes high. Holding the RST pin
high Ior two machine cycles while the oscillator is running resets the device. Each machine cycle
takes 12 oscillator or clock cycles.

X1AL1
nput to the inverting oscillator ampliIier and input to the internal clock operating circuit.

X1AL2
Output Irom the inverting oscillator ampliIier.

Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, oI an inverting ampliIier
which can be conIigured Ior use as an on-chip oscillator, as shown in ig. Either a quartz crystal
or ceramic resonator may be used. To drive the device Irom an external clock source, XTAL2
should be leIt unconnected while XTAL1 is driven as shown in igure 2. There are no
requirements on the duty cycle oI the external clock signal, since the input to the internal
clocking circuitry is through a divide-by-two Ilip-Ilop, but minimum and maximum voltage high
and low time speciIications must be observed.

Fig. Oscillator Connections

otes: C1, C2 30 p 10 p Ior Crystals
40 p 10 p Ior Ceramic Resonators


Special Function Registers
A map oI the on-chip memory area called the Special unction Register (SR) space is
shown in the table below. That not all oI the addresses are occupied, and unoccupied addresses
may not be implemented on the chip.
Read accesses to these addresses will in general return random data, and write accesses
will have an indeterminate eIIect. User soItware should not write 1s to these unlisted locations,
since they may be used in Iuture products to invoke new Ieatures. n that case, the reset or
inactive values oI the new bits will always be 0.


Restrictions on Certain Instructions
The AT89C2051 and is an economical and cost-eIIective member oI Atmel`s growing
Iamily oI microcontrollers. t contains 2 Kbytes oI Ilash program memory. t is Iully compatible
with the CS-51 architecture, and can be programmed using the CS-51 instruction set.
However, there are a Iew considerations one must keep in mind when utilizing certain
instructions to program this device.

All the instructions related to jumping or branching should be restricted such that the
destination address Ialls within the physical program memory space oI the device, which is 2K
Ior the AT89C2051. This should be the responsibility oI the soItware programmer. or example,
LJP 7E0H would be a valid instruction Ior the AT89C2051 (with 2K oI memory), whereas
LJP 900H would not.
1. Branching instructions:
LCALL, LJP, ACALL, AJP, SJP, JP ADPTR
These unconditional branching instructions will execute correctly as long as the
programmer keeps in mind that the destination branching address must Iall within the
physical boundaries oI the program memory size (locations 00H to 7H Ior the
89C2051). Violating the physical space limits may cause unknown program behavior.

CJE |...|, DJ |...|, JB, JB, JC, JC, JBC, J, J
With these conditional branching instructions the same rule above applies. Again,
violating the memory boundaries may cause erratic execution.

or applications involving interrupts the normal interrupt service routine address
locations oI the 80C51 Iamily architecture have been preserved.

2. MOVX-related instructions, Data Memory:
The AT89C2051 contains 128 bytes oI internal data memory. Thus, in the
AT89C2051 the stack depth is limited to 128 bytes, the amount oI available RA.
External DATA memory access is not supported in this device, nor is external
PROGRA memory execution. ThereIore, no OVX |...| instructions should be
included in the program.

A typical 80C51 assembler will still assemble instructions, even iI they are
written in violation oI the restrictions mentioned above. t is the responsibility oI the
controller user to know the physical Ieatures and limitations oI the device being used and
adjust the instructions used correspondingly.

Program Memory Lock Bits
On the chip are two lock bits which can be leIt unprogrammed (U) or can be programmed
(P) to obtain the additional Ieatures listed in the table below:

Lock Bit Protection Modes
Program Lock Bits
LB1 LB2 Protection Type
1 U U o program lock Ieatures.
2 P U urther programming oI the lash is disabled.
3 P P Same as mode 2, also veriIy is disabled.
ote: 1. The Lock Bits can only be erased with the Chip Erase operation

Idle Mode
n idle mode, the CPU puts itselI to sleep while all the onchip peripherals remain active.
The mode is invoked by soItware. The content oI the on-chip RA and all the special Iunctions
registers remain unchanged during this mode. The idle mode can be terminated by any enabled
interrupt or by a hardware reset.

P1.0 and P1.1 should be set to `0` iI no external pullups are used, or set to `1` iI external
pullups are used. t should be noted that when idle is terminated by a hardware reset, the device
normally resumes program execution, Irom where it leIt oII, up to two machine cycles beIore the
internal reset algorithm takes control. On-chip hardware inhibits access to internal RA in this
event, but access to the port pins is not inhibited. To eliminate the possibility oI an unexpected
write to a port pin when dle is terminated by reset, the instruction Iollowing the one that invokes
dle should not be one that writes to a port pin or
to external memory.

Power Down Mode
n the power down mode the oscillator is stopped, and the instruction that invokes power
down is the last instruction executed. The on-chip RA and Special unction Registers retain
their values until the power down mode is terminated. The only exit Irom power down is a
hardware reset. Reset redeIines the SRs but does not change the onchip RA. The reset should
not be activated beIore VCC is restored to its normal operating level and must be held active
long enough to allow the oscillator to restart and stabilize. P1.0 and P1.1 should be set to `0` iI
no external pullups are used, iI pullups are used.

Programming The Flash
The AT89C2051 is shipped with the 2 Kbytes oI on-chip PERO code memory array in
the erased state (i.e., contents H) and ready to be programmed. The code memory array is
programmed one byte at a time. Once the array is programmed, to re-program any non-blank
byte, the entire memory array needs to be erased electrically.

Internal Address Counter:
The AT89C2051 contains an internal PERO address counter, which is always reset to
000H on the rising edge oI RST and is advanced by applying a positive going pulse to pin
XTAL1.

Programming Algorithm:
To program the AT89C2051, the Iollowing sequence is recommended.
1. Power-up sequence:
Apply power between VCC and GD pins Set RST and XTAL1 to GD. With all other
pins Iloating, wait Ior greater than 10 milliseconds
2. Set pin RST to `H`
Set pin P3.2 to `H`
3. Apply the appropriate combination oI `H` or `L` logic levels to pins P3.3, P3.4, P3.5,
P3.7 to select one oI the programming operations shown in the PERO Programming
odes table.
To Program and VeriIy the Array:
4. Apply data Ior Code byte at location 000H to P1.0 to P1.7.
5. Raise RST to 12V to enable programming.
6. Pulse P3.2 once to program a byte in the PERO array or the lock bits. The byte-write
cycle is selI-timed and typically takes 1.2 ms.
7. To veriIy the programmed data, lower RST Irom 12V to logic `H` level and set pins P3.3
to P3.7 to the appropriate levels. Output data can be read at the port P1 pins.
8. To program a byte at the next address location, pulse XTAL1 pin once to advance the
internal address counter. Apply new data to the port P1 pins.
9. Repeat steps 5 through 8, changing data and advancing the address counter Ior the entire
2 Kbytes array or until the end oI the object Iile is reached.
10. Power-oII sequence: set XTAL1 to `L`, set RST to `L`, loat all other /O pins, Turn Vcc
power oII

Flash Programming Modes



Fig. Programming the Flash Memory Fig. Verifying the Flash Memory

Flash Programming and Verification Characteristics

Flash Programming and Verification Waveforms


Absolute Maximum Ratings
Operating Temperature -55C to 125C
Storage Temperature -65C to 150C
Voltage on any pin with respect to Ground -1.0V to 7.0V
aximum Operating Voltage 6.6 V
DC output current 25.0 mA

External Clock Drive Waveforms




External Clock Drive


Serial Port Timing : ShiIt Register ode Text Conditions












DC Characteristics



Shift Register Mode Timing Waveform


AC Testing Input/Output Waveforms Float Waveforms


Ordering Information




IC B113
GENERAL DESCRIPTION
Passivated triacs in a plastic envelope intended Ior use in applications requiring high bi-
directional transient and blocking voltage capability and high thermal cycling perIormance.
Typical applications include motor control, industrial and domestic VDR Repetitive peak oII-
state 600 V lighting, heating and static switching.

QUICK REFERENCE DATA


PINNING - T0220AB
P DESCRPTO
1 ain terminal 1
2 ain terminal 2
3 Gate
4 ain terminal 2



LIMITING VALUES
Limiting values in accordance with the absolute maximum system


THERMAL RESISTANCES


STATIC CHARACERISTICS (TA 25C Unless otherwise stated)

DYNAMIC CHARACTERISCTICS (TA 25C Unless otherwise stated)


DEFINITIONS
DA1A SHEE1 S1A1US
Data Sheet Status Product Status DeIinition
Objective data Development This data sheet contains data Irom the
objective speciIication Ior product
development.
Preliminary data QualiIication This data sheet contains data Irom the
preliminary speciIication. Supplementary
data will be published at a later date. The
right to change the speciIication without
notice, in ordere to improve the design and
supply the best possible product
Product data Production This data sheet contains data Irom the
product speciIication. The right to make
changes at any time in order to improve the
design, manuIacturing and supply.

Limiting Values
Limiting values are given in accordance with the Absolute aximum Rating System.
Stress above one or more oI the limiting values may cause permanent damage to the device.
These are stress ratings only and operation oI the device at these or at any other conditions above
those given in the Characteristics sections oI this speciIication is not implied. Exposure to
limiting values Ior extended periods may aIIect device reliability.
Application Information
Where application inIormation is given, it is advisory and does not Iorm part oI the
speciIication.

BIBLIOGRAPHY

1. Basic Electronics By V.K. ehta
2. ntegrated Circuits By K.R. Botkar
3. Switch And Protection By B.V.S. Rao
4. Power Electronics By P.S. Bhimra
5. Electronics or You June, 2006

Websites:
www.google.com
www.wikipedia.en









REFERENCES

ROBERT L. BOYLSTED AD LOUS ASHELSKY
ELECTROCS DEVCES & CRCUT THEORY, PEARSO
EDU. ASA 2002

B.. WEELY, ELECRCAL POWER SYSTE, JOH WLLY & SOS,
1974

RAAKAT A. GAYAKWAD, OP APS D LEAR TEGRATED
CRCUTS, PEARSO EDU 2003

. ORRS AO, PRETCE HALL O DA, 2000

A.K. SAWEY, DHAPAT RA & SOS, 2004

C.R. ASO, WLLY EASTER LTD. 1977

WEBSITES :
www.alldatasheets.com
www.datacatalog.com
www.scielectronics.com
www.electronics-lab.com
www.microdigitaled.com

You might also like