We take immense pleasure in thanking Lect.Mrs.Manjeet Sandhu
and Dr.H.S.Sagar, our beloved Director for having permitted us to carry out this project ork. We ish to e!press our deep sense of gratitude to our "nternal guide, Ms.#ajneesh $aur for her able guidance and useful suggestions, hich helped us in completing the project ork, in time. Words are inade%uate in offering our thanks to the &roject 'rainees and &roject (ssistants, S))S"*' for their encouragement and cooperation in carrying out the project ork. +inally, yet importantly, e ould like to e!press our heartfelt thanks our beloved parents or their blessings, our friends , classmates for their help and ishes for the successful completion of this project. -.arun Dadal/ -Sumit $umar/ -Saminder Singh/ Certificate TO WHOM IT MAY CONCERN 'his is to certify that &roject entitled 0Power Factor Controller is submitted in partial fulfillment for the aard of degree )1'*2H -*lectronics and 2ommunication *ngineering/ of &unjab 'echnical 3niversity has been successfully completed by Mr..arun Dadal having #oll 4o. 567898:;;<. He has done as good job under my guidance=supervision. -Mrs.Manjeet Sandhu/ -Ms.#ajneesh $aur/ -Dr.&arampal Singh/ &roject >uide &roject 2oordinator H?D 1 *2* Certificate 'his is to certify that &roject entitled 0Power Factor Controller is submitted in partial fulfillment for the aard of degree )1'*2H -*lectronics and 2ommunication *ngineering/ of &unjab 'echnical 3niversity has been successfully completed by Mr.Sumit $umar having #oll 4o. 567898:;6<. He has done as good job under my guidance=supervision. -Mrs.Manjeet Sandhu/ -Ms.#ajneesh $aur/ -Dr.&arampal Singh/ &roject >uide &roject 2oordinator H?D 1 *2* Certificate 'his is to certify that &roject entitled 0Power Factor Controller is submitted in partial fulfillment for the aard of degree )1'*2H -*lectronics and 2ommunication *ngineering/ of &unjab 'echnical 3niversity has been successfully completed by Mr.Saminder Singh having #oll 4o. 567898:;:7. He has done as good job under my guidance=supervision. -Mrs.Manjeet Sandhu/ -Ms.#ajneesh $aur/ -Dr.&arampal Singh/ &roject >uide &roject 2oordinator H?D 1 *2* 'able of 2ontents @. "ntroduction to the &roject. A. )lock Diagram <. 2ircuit Diagram. 9. 2omponent List. 7. Working 5. 4otes on Microcontroller 7.@ "ntroduction 7.A (rchitecture 7.< &in Description 7.9 Special +unction #egisters 7.7 "nstructions :. &oer Supply 6. )ibliography. ! Introd"ction# 'he poer factor of an (2 electrical poer system is defined as the ratio of the real poer floing to the load, to the apparent poer in the circuit, and is a dimensionless number beteen 1@ and @. #eal poer is the capacity of the circuit for performing ork in a particular time. (pparent poer is the product of the current and voltage of the circuit. Due to energy stored in the load and returned to the source, or due to a non1linear load that distorts the ave shape of the current dran from the source, the apparent poer ill be greater than the real poer. ( negative poer factor occurs hen the device hich is normally the load generates poer hich then flos back toards the device hich is normally considered the generator. "n an electric poer system, a load ith a lo poer factor dras more current than a load ith a high poer factor for the same amount of useful poer transferred. 'he higher currents increase the energy lost in the distribution system, and re%uire larger ires and other e%uipment. )ecause of the costs of larger e%uipment and asted energy, electrical utilities ill usually charge a higher cost to industrial or commercial customers here there is a lo poer factor. Linear loads ith lo poer factor -such as induction motors/ can be corrected ith a passive netork of capacitors or inductors. 4on1linear loads, such as rectifiers, distort the current dran from the system. "n such cases, active or passive poer factor correction may be used to counteract the distortion and raise the poer factor. 'he devices for correction of the poer factor may be at a central substation, spread out over a distribution system, or built into poer1 consuming e%uipment. $! %lock &iagram#' &oer Supply "ncrement Sitch
687@ #elay L*D Decrement Sitch
L2D (! Circ"it &iagram ) Main Circ"it#' *! +i,t of Com-onent,#' .!No! Com-onent /t0! @ "26;287@, @ A 2rystal B @A MHC @ < 2ap B <<p+ A 9 Sitch < 7 "2 )ase B 98 &in @ 5 ?pto1coupler B M2'Ae @ : 'ransistor 776 1 &4& @ 6 'ransistor 79: 1 4&4 @ @8 L*D @ @@ #esistances 9.:k,8.A7W A @A #esistances @8k,8.A7W A @< 2onnecting ires @8 "nch @9 'ransformer AA8=@A, @( @ @7 Diodes "4988: 9 @5 2ap.9:8 D+ @ @: 2ap.@888 D+ @ @6 #elay @ @; L2D @ 1!Working#' "n our project e have to sitches through hich e can change the value of poer factor -one for increment and other for decrement/ and to observe the output e have a relay circuit, if the value of poer factor increases then at a certain level relay ill sitch into on state automatically hich ill further sitch on the L*D hich shos that the capacitive load is added. Here @5!A L2D ill be used to display &oer +actor value.
2! Microcontroller 34516#' WE+COME TO THE WOR+& OF THE MICROCONTRO++ER.! Look around. 4otice the smart 0intelligentE systemsF )e it the '.., ashing machines, video games, telephones, automobiles, aero planes, poer systems, or any application having a L*D or a L2D as a user interface, the control is likely to be in the hands of a micro controllerG Measure and control, thatHs here the micro controller is at its best. Micro controllers are here to stay. >oing by the current trend, it is obvious that micro controllers ill be playing bigger and bigger roles in the different activities of our lives. 'hese embedded chips are very small, but are designed to replace components much bigger and bulky in siCe. 'hey process information very intelligently and efficiently. 'hey sense the environment around them. 'he signals they gather are tuned into digital data that streams through tributaries of circuit lines at the speed of light. "nside the microprocessor collates and calculators. 'he softare has middling intelligence. 'hen in a split second, the processed streams are shoved out. W7at i, t7e -rimar0 difference 8etween a micro-roce,,or and a micro controllerF 3nlike the microprocessor, the micro controller can be considered to be a true 02omputer on a chipE. "n addition to the various features like the (L3, &2, S& and registers found on a microprocessor, the micro controller also incorporates features like the #?M, #(M, &orts, timers, clock circuits, counters, reset functions etc. While the microprocessor is more a general1purpose device, used for read, rite and calculations on data, the micro controller, in addition to the above functions also controls the environment. T7e 451# 'he 687@ developed and launched in the early 68Is, is one of the most popular micro controller in use today. "t has a reasonably large amount of built in #?M and #(M. "n addition it has the ability to access e!ternal memory. 'he generic term I6!7@I is used to define the device. 'he value of ! defining the kind of #?M, i.e. !J8, indicates none, !J<, indicates mask #?M, !J:, indicates *&#?M and !J; indicates **&#?M or +lash. A note on ROM# 'he early 687@, namely the 68<@ as designed ithout any #?M. 'his device could run only ith e!ternal memory connected to it. Subse%uent developments lead to the development of the &#?M or the programmable #?M. 'his type had the disadvantage of being highly unreliable. 'he ne!t in line, as the *&#?M or *rasable &rogrammable #?M. 'hese devices used ultraviolet light erasable memory cells. 'hus a program could be loaded, tested and erased using ultra violet rays. ( ne program could then be loaded again. (n improved *&#?M as the **&#?M or the electrically erasable &#?M. 'his does not re%uire ultra violet rays, and memory can be cleared using circuits ithin the chip itself. +inally there is the +L(SH, hich is an improvement over the **&#?M. While the terms **&#?M and flash are sometimes used interchangeably, the difference lies in the fact that flash erases the complete memory at one stroke, and not act on the individual cells. 'his results in reducing the time for erasure. &ifferent microcontroller, in market! &"2 K ?ne of the famous microcontrollers used in the industries. "t is based on #"S2 (rchitecture hich makes the microcontroller process faster than other microcontroller. "4'*LK 'hese are the first to manufacture microcontrollers. 'hese are not as sophisticated other microcontrollers but still the easiest one to learn. ('M*LK (tmelHs (.# microcontrollers are one of the most poerful in the embedded industry. 'his is the only microcontroller having @kb of ram even the entry stage. )ut it is unfortunate that in "ndia e are unable to find this kind of microcontroller. Intel 451 "ntel 687@ is 2"S2 architecture hich is easy to program in assembly language and also has a good support for High level languages. 'he memory of the microcontroller can be e!tended up to 59k. 'his microcontroller is one of the easiest microcontrollers to learn. 'he 687@ microcontroller is in the field for more than A8 years. 'here are lots of books and study materials are readily available for 687@. &eri9ati9e, 'he best thing done by "ntel is to give the designs of the 687@ microcontroller to everyone. So it is not the fact that "ntel is the only manufacture for the 687@ there more than A8 manufactures, ith each of minimum A8 models. Literally there are hundreds of models of 687@ microcontroller available in market to choose. Some of the major manufactures of 687@ are (tmel &hilips P7ili-, 'he &hilipsLs 687@ derivatives has more number of features than in any microcontroller. 'he costs of the &hilips microcontrollers are higher than the (tmelHs hich makes us to choose (tmel more often than &hilips. &alla,# allas has made many revolutions in the semiconductor market. DallasHs 687@ derivative is the fastest one in the market. "t orks < times as fast as a 687@ can process. )ut e are unable to get more in "ndia. Atmel# 'hese people ere the one to master the flash devices. 'hey are the cheapest microcontroller available in the market. (tmelHs even introduced a A8pin variant of 687@ named A87@. 'he (tmelHs 687@ derivatives can be got in "ndia less than :8 rupees. 'here are lots of cheap programmers available in "ndia for (tmel. So it is alays good for students to stick ith 687@ hen you learn a ne microcontroller. 1!$ Arc7itect"re (rchitecture is must to learn because before learning ne machine it is necessary to learn the capabilities of the machine. 'his is some thing like before learning about the car you cannot become a good driver. 'he architecture of the 687@ is given belo. 'he 687@ doesnHt have any special feature than other microcontroller. 'he only feature is that it is easy to learn. (rchitecture makes us to kno about the hardare features of the microcontroller. 'he features of the 687@ are
9$ )ytes of +lash Memory @A6 ! 61)it "nternal #(M +ully Static ?perationK @ MHC to A9 MHC <A &rogrammable "=? Lines 'o @51)it 'imer=2ounters Si! "nterrupt Sources -7 .ectored/ &rogrammable Serial 2hannel Lo &oer "dle and &oer Don Modes LetHs no move on to a practical e!ample. We shall ork on a simple practical application and using the e!ample as a base, shall e!plore the various features of the 687@ microcontroller. 2onsider an electric circuit as follos, 'he positive side -Mve/ of the battery is connected to one side of a sitch. 'he other side of the sitch is connected to a bulb or L*D -Light *mitting Diode/. 'he bulb is then connected to a resistor, and the other end of the resistor is connected to the negative -1ve/ side of the battery. When the sitch is closed or Lsitched onH the bulb glos. When the sitch is open or Lsitched offH the bulb goes off. "f you are instructed to put the sitch on and off every <8 seconds, ho ould you do itF ?bviously you ould keep looking at your atch and every time the second hand crosses <8 seconds you ould keep turning the sitch on and off. "magine if you had to do this action consistently for a full day. Do you think you ould be able to do itF 4o if you had to do this for a month, a yearFF 4o ay, you ould sayG 'he ne!t step ould be, then to make it automatic. 'his is here e use the Microcontroller. )ut if the action has to take place every <8 seconds, ho ill the microcontroller keep track of timeF E:ec"tion time Look at the folloing instruction, Clr -!5 'his is an assembly language instruction. "t means e are instructing the microcontroller to put a value of LCeroH in bit Cero of port one. 'his instruction is e%uivalent to telling the microcontroller to sitch on the bulb. 'he instruction then to instruct the microcontroller to sitch off the bulb is, .et -!5 'his instructs the microcontroller to put a value of LoneH in bit Cero of port one. DonHt orry about hat bit Cero and port one means. We shall learn it in more detail as e proceed. 'here are a set of ell defined instructions, hich are used hile communicating ith the microcontroller. *ach of these instructions re%uires a standard number of cycles to e!ecute. 'he cycle could be one or more in number. Ho is this time then calculatedF 'he speed ith hich a microcontroller e!ecutes instructions is determined by hat is knon as the crystal speed. ( crystal is a component connected e!ternally to the microcontroller. 'he crystal has different values, and some of the used values are 5MHN, @8MHN, and @@.87; MHC etc. 'hus a @8MHN crystal ould pulse at the rate of @8,888,888 times per second. 'he time is calculated using the formula. 4o of cycles per second J 2rystal fre%uency in HN = @A. +or a @8MHN crystal the number of cycles ould be, @8,888,888=@AJ6<<<<<.<<<<< cycles. 'his means that in one second, the microcontroller ould e!ecute 6<<<<<.<<<<< cycles. 'herefore for one cycle, hat ould be the timeF 'ry it out. 'he instruction clr p@.8 ould use one cycle to e!ecute. Similarly, the instruction setb p@.8 also uses one cycle. So go ahead and calculate hat ould be the number of cycles re%uired to be e!ecuted to get a time of <8 secondsG >etting back to our bulb e!ample, all e ould need to do is to instruct the microcontroller to carry out some instructions e%uivalent to a period of <8 seconds, like counting from Cero upards, then sitch on the bulb, carry out instructions e%uivalent to <8 seconds and sitch off the bulb. Oust put the hole thing in a loop, and you have a never ending on1off se%uence. Let us no have a look at the feat"re, of t7e 451 core, keeping the above e!ample as a reference, ! 4'8it CP;! 3Con,i,ting of t7e <A= and <%= regi,ter,6 Most of the transactions ithin the microcontroller are carried out through the L(H register, also knon as the (ccumulator. "n addition all arithmetic functions are carried out generally in the L(H register. 'here is another register knon as the L)H register, hich is used e!clusively for multiplication and division. 'hus an 61bit notation ould indicate that the ma!imum value that can be input into these registers is L@@@@@@@@H. &uCCledF 'he value is not decimal @@@, @@,@@@G "t represents a binary number, having an e%uivalent value of L++H in He!adecimal and a value of A77 in decimal. We shall read in more detail on the different numbering systems namely the )inary and He!adecimal system in our ne!t module. $! *> on'c7i- ROM ?nce you have ritten out the instructions for the microcontroller, here do you put these instructionsF ?bviously you ould like these instructions to be safe, and not get deleted or changed during e!ecution. Hence you ould load it into the L#?MH 'he siCe of the program you rite is bound to vary depending on the application, and the number of lines. 'he 687@ microcontroller gives you space to load up to 9$ of program siCe into the internal #?M. 9$, thatHs allF Well just ait. Pou ould be surprised at the amount of stuff you can load in this 9$ of space. ?f course you could alays e!tend the space by connecting to 59$ of e!ternal #?M if re%uired. (! $4 80te, on'c7i- RAM 'his is the space provided for e!ecuting the program in terms of moving data, storing data etc. *! ($ I?O line,! 3Fo"r' 4 8it -ort,@ la8eled P5@ P@ P$@ P(6 "n our bulb e!ample, e used the notation p@.8. 'his means bit Cero of port one. ?ne bit controls one bulb. 'hus -ort one ould have 6 bits. 'here are a total of four ports named p8, p@, pA, p<, giving a total of <A lines. 'hese lines can be used both as input or output. 1! Two 2 8it timer, ? co"nter,! ( microcontroller normally e!ecutes one instruction at a time. Hoever certain applications ould re%uire that some event has to be tracked independent of the main program. 'he manufacturers have provided a solution, by providing to timers. 'hese timers e!ecute in the background independent of the main program. ?nce the re%uired time has been reached, -remember the time calculations described aboveF/, they can trigger a branch in the main program. 'hese timers can also be used as counters, so that they can count the number of events, and on reaching the re%uired count, can cause a branch in the main program. 2! F"ll &"-le: ,erial data recei9er ? tran,mitter! 'he 687@ microcontroller is capable of communicating ith e!ternal devices like the &2 etc. Here data is sent in the form of bytes, at predefined speeds, also knon as baud rates. 'he transmission is serial, in the sense, one 8it at a time. A! 1' interr"-t ,o"rce, wit7 two -riorit0 le9el, 3Two e:ternal and t7ree internal6 During the discussion on the timers, e had indicated that the timers can trigger a branch in the main program. Hoever, hat ould e do in case e ould like the microcontroller to take the branch, and then return back to the main program, ithout having to constantly check hether the re%uired time = count has been reachedF 'his is here the interrupts come into play. 'hese can be set to either the timers, or to some e!ternal events. Whenever the background program has reached the re%uired criteria in terms of time or count or an e!ternal event, the branch is taken, and on completion of the branch, the control returns to the main program. &riority levels indicate hich interrupt is more important, and needs to be e!ecuted first in case to interrupts occur at the same time. 4! On'c7i- clock o,cillator! 'his represents the oscillator circuits ithin the microcontroller. 'hus the hardare is reduced to just simply connecting an e!ternal crystal, to achieve the re%uired pulsing rate. 1!( PIN &e,cri-tion OF IC 4BC1! ."--l0 pin of this ic is pin no 98. 4ormally e apply a 7 volt regulated dc poer supply to this pin. +or this purpose either e use step don transformer poer supply or e use ; volt battery ith :687 regulator. $ Cro"nd pin of this ic is pin no A8. &in no A8 is normally connected to the ground pin -4ormally negative point of the poer supply. ( DTA+ is connected to the pin no @6 and pin no @; of this ic. 'he %uartC crystal oscillator connected to Q'(L@ and Q'(LA &"4. 'hese pins also needs to capacitors of <8 pf value. ?ne side of each capacitor is connected to crystal and other pis are connected to the ground point. 4ormally e connect a @A MHC or @@.87;A MHC crystal ith this "2. )ut e use crystal up to A8 MHC to this pin. * RE.ET &"4. &in no ; is the reset pin of this ic.. "t is an active high pin. ?n applying a high pulse to this pin, the micro controller ill reset and terminate all activities. 'his is often referred to as a poer on reset. 'he high pulse must )e high for a minimum of A machine cycles before it is alloed to go lo. 7. PORT5 &ort 8 occupies a total of 6 pins. Pin no ($ to -in no (B. "t can be used for input or output. We connect all the pins of the port 8 ith the pull1up resistor -@8 k ohm/ e!ternally. 'his is due to fact that port 8 is an open drain mode. "t is just like a open collector transistor. 2! PORT. (LL the ports in microcontroller are 6 bit ide -in no to -in no 4 because it is a 6 bit controller. (ll the main register and sfr all is mainly 6 bit ide. &ort @ is also occupies a 6 pins. )ut there is no need of pull up resistor in this port. 3pon reset port @ act as a input port. 3pon reset all the ports act as a input port :. ORT$! &ort A also have a 6 pins. "t can be used as a input or output. 'here is no need of any pull up resistor to this pin! 6. PORT (. &ort< occupies a total 6 pins from pin no @8 to pin no @:. "t can be used as input or output. &ort < does not re%uire any pull up resistor. 'he same as port @ and portA. &ort < is configured as an output port on reset. &ort < has the additional function of providing some important signals such as interrupts. &ort < also use for serial communication. ;. A+E (L* is an output pin and is active high. When connecting an 68<@ to e!ternal memory, port 8 provides both address and data. "n other ords, the 68<@ multiple!es address and data through port 8 to save pins. 'he (L* pin is used for de1multiple!ing the address and data by connecting to the "2 :9ls<:< chip. @8. P.EN! &S*4 stands for program store enable. "n an 68<@ based system in hich an e!ternal rom holds the program code, this pin is connected to the ?* pin of the rom. @@. EA! *(. "n 6;c7@ 6:7@ or any other family member of the ateml 6;c7@ series all come ith on1chip rom to store programs, in such cases the *( pin is connected to the .cc. +or family member 68<@ and 68<A is hich there is no on chip rom, code is stored in e!ternal memory and this is fetched by 68<@. "n that case *( pin must be connected to >4D pin to indicate that the code is stored e!ternally. 1!* .PECIA+ F;NCTION RECI.TER 3 .FR6 A&&RE..E.! (22 (223M3L('?# 8*8H ) ) #*>"S'*# 8+8H &SW &#?>#(M S'('3S W?#D 8D8H S& S'(2$ &?"4'*# 6@H D&'# D('( &?"4'*# A )P'*S D&L L?W )P'* ?+ D&'# 6AH D&H H">H )P'* ?+ D&'# 6<H &8 &?#'8 68H &@ &?#'@ ;8H &A &?#'A 8(8H &< &?#'< 8)8H 'M?D'"M*#=2?34'*# M?D* 2?4'#?L 6;H '2?4'"M*# 2?34'*#S 2?4'#?L 66H 'H8 '"M*# 8 H">H )P'* 62H 'L? '"M*# 8 L?W )P'* 6(H 'H@ '"M*# @ H">H )P'* 6DH 'L@ '"M*# @ L?W )P'* 6)H S2?4S*#"(L 2?4'#?L ;6H S)3+ S*#"(L D('( )3++*# ;;H &2?4&?W*# 2?4'#?L 6:H 1!1 In,tr"ction,#' .ingle %it In,tr"ction,#' .ET% %IT S*' 'H* )"' J@ C+R %IT 2L*(# 'H* )"' J8 CP+ %IT 2?M&L"M*4' 'H* )"' 8 J@, @J8 E% %IT@ TARCET O3M& '? '(#>*' "+ )"' J@ EN% %IT@ TARCET O3M& '? '(#>*' "+ )"' J8 E%C %IT@ TARCET O3M& '? '(#>*' "+ )"' J@ ,'H*4 2L*(# 'H* )"'
MOF IN.TR;CTION. M?. instruction simply copy the data from one location to another location MOF &@ . 2opy the data from-S/ source to D-destination/ MOF R5@A R 2opy contents of ( into #egister #8 MOF R@A R 2opy contents of ( into register #@ MOF A@R( R 2opy contents of #egister #< into (ccumulator. D"#*2' L?(D"4> 'H#?3>H M?. MOF A@G$(H R Direct load the value of A<h in ( MOF R5@G$7 R direct load the value of @Ah in #8 MOF R1@G5FBH R Load the +; value in the #egister #7 A&& IN.TR;CTION.. (DD instructions adds the source byte to the accumulator - (/ and place the result in the (ccumulator. MOF A@ G$1H A&& A@G*$H R )P 'his instruction e add the value 9Ah in (ccumulator - 9AHM A7H/ A&&A@R( R)y 'his instruction e move the data from register r< to accumulator and then add the contents of the register into accumulator . S3)#?3'"4* 2(LL +342'"?4. ACA++@ TARCET A&&RE.. )y 'his instruction e call subroutines ith a target address ithin Ak bytes from the current program counter. +CA++, '(#>*' (DD#*SS. ACA++ is a limit for the A k byte program counter, but for upto 59k byte e use L2(LL instructions.. 4ote that L2(LL is a < byte instructions. (2(LL is a to byte instructions. AEMP TARCET A&&RE... 'his is for absolute jump AEMP stand for absolute jump. "t transfers program e!ecution to the target address unconditionally. 'he target address for this instruction must be ithin A k byte of program memory. +EMP is also for absolute jump. "t transfers program e!ecution to the target address unconditionally. 'his is a < byte instructions LOM& jump to any address ithin 59 k byte location. IN.TR;CTION. RE+ATE& TO THE CARRY EC TARCET O3M& '? 'H* '(#>*' "+ 2P +L(> J@ ENC TARCET O3M& '? 'H* '(#>*' (DD#*SS "+ 2P +L(> "S J 8 IN.TR;CTION. RE+A.TE& TO E;MP WITH ACC;M;+ATOR EH TARCET O3M& '? '(#>*' "+ ( J 8 ENH TARCET O3M& "+ (223M3L('?# "S 4?' N*#? 'his instruction jumps if register ( has a value other than Cero IN.TR;CTION. RE+ATE& TO THE ROTATE #L ( #?'('* L*+' 'H* (223M3L('?# )P 'his instruction e rotate the bits of ( left. 'he bits rotated out of ( are rotated back into ( at the opposite end ## ( )y this instruction e rotate the contents of the accumulator from right to left from LS) to MS) ##2 ( 'his is same as ## ( but difference is that the bit rotated out of register first enter in to carry and then enter into MS) R+C A #otate Left through carry. Same as above but shift the data from MS) to carry and carry to LS) RET 'his is return from subroutine. 'his instruction is used to return from a subroutine previously entered by instructions L2(LL and (2(LL. RET 'his is used at the end of an interrupt service routine. We use this instruction after interrupt routine, P;.H! 'his copies the indicated byte onto the stack and increments S& by one. 'his instruction supports only direct addressing mode. POP! &?& +#?M S'(2$. 'his copies the byte pointed to be S& to the location hose direct address is indicated, and decrements S& by @. 4otice that this instruction supports only direct addressing mode. &PTR In,tr"ction,# MOF &PTR@G2 %IT FA+;E L?(D D('( &?"4'*# 'his instruction load the @5 bit D&'# register ith a @5 bit immediate value M?. 2 (,S(MD&'# 'his instruction moves a byte of data located in program #?M into register (. 'his allos us to put strings of data, such as look up table elements. M?.2 (,S(M&2 'his instruction moves a byte of data located in the program area to (. the address of the desired byte of data is formed by adding the program counter -&2/ register to the original value of the accumulator. "42 )P'* 'his instruction adds @ to the register or memory location specified by the operand. "42 ( "42 #n "42 D"#*2' D*2 )P'* 'his instruction subtracts @ from the byte operand. 4ote that 2P is unchanged D*2 ( D*2 #n D*2 D"#*2' Arit7metic In,tr"ction,# (4L test1byte, source1byte 'his perform a logical (4D operation 'his performs a logical (4D on the operands, bit by bit, storing the result in the destination. 4otice that both the source and destination values are byte BsiCe only
D". () 'his instruction divides a byte accumulator by the byte in register ). "t is assumed that both register ( and ) contain an unsigned byte. (fter the division the %uotient ill be in register ( and the remainder in register ). 'M?D -'"M*# M?D*/ #*>"S'*# )oth timers is the 6;c7@ share one register 'M?D. 9 LS) bit for the timer 8 and 9 MS) for the timer @. "n each case loer A bits set the mode of the timer 3pper to bits set the operations. CATE# >ating control hen set. 'imer=counter is enabled only hile the "4'Q pin is high and the '#! control pin is set. When cleared, the timer is enabled henever the '#! control bit is set C?T# 'imer or counter selected cleared for timer operation - input from internal system clock/ M@ Mode bit @ M8 Mode bit 8 M M5 MO&E OPERATINC MO&E 8 8 8 @< )"' '"M*#=M?D* 8 @ @ @5 )"' '"M*# M?D* @ 8 A 6 )"' (3'? #*L?(D @ @ < S&L"' '"M*# M?D* &SW - &#?>#(M S'('3S W?#D/ 2P &SW.: 2(##P +L(> (2 &SW.5 (3Q"L"(#P 2(##P +8 &SW.7 (.("L()L* +?# 'H* 3S*# +#? >*4*#(L &3#&?S* #S@ &SW.9 #*>"S'*# )(4$ S*L*2'?# )"' @ #S8 &SW.< #*>"S'*# )(4$ S*L*2'?# )"' 8 8. &SW.A ?.*#+L?W +L(> 11 &SW.@ 3S*# D*+"4()L* )"' & &SW.8 &(#"'P +L(> S*'=2L*(#*D )P H(#DW(#* PCON RECI.ATER 3 NON %IT A&&RE..A%+E6 "f the SM?D J 8 - D*+(3L' ?4 #*S*'/ 'H@ J 2#PS'(L +#*T3*42P A751111 UUUUUUUUUUUUUUUUUUUU <69 Q )(3D #('* "f the SM?D "S J @ 2#PS'(L +#*T3*42P 'H@ J A7511111111111111111111111111111111111111 @;A Q )(3D #('* 'here are to ays to increase the baud rate of data transfer in the 687@ @. 'o use a higher fre%uency crystal A. 'o change a bit in the &2?4 register &2?4 register is an 6 bit register. ?f the 6 bits, some are unused, and some are used for the poer control capability of the 687@. 'he bit hich is used for the serial communication is D:, the SM?D bit. When the 687@ is poered up, D: - SM?D )"'/ ?+ &2?4 register is Cero. We can set it to high by softare and thereby double the baud rate )aud #ate 2omparison for SM?D J 8 (4D SM?D J@ TH 3 &ECIMA+6 HED .MO& I5 .MO& I 1< +D ;588 @;A88 15 +( 9688 ;588 1@A +9 A988 9688 1A9 *6 @A88 A988 DTA+ I !51B$ MHH
"* -"4'*##3&' *4()L* #*>"S'?#/ *( "*.: Disable all interrupts if *( J 8, no interrupts is acknoledged "f *( is @, each interrupt source is individually enabled or disabled )y sending or clearing its enable bit. "*.5 4?' implemented *'A "*.7 enables or disables timer A overflag in 6;c7A only *S "*.9 *nables or disables all serial interrupt *'@ "*.< *nables or Disables timer @ overflo interrupt *Q@ "*.A *nables or disables e!ternal interrupt *'8 "*.@ *nables or Disables timer 8 interrupt. *Q8 "*.8 *nables or Disables e!ternal interrupt 8 "4'*##3&' &#"?#"'P #*>"S'*# "f the bit is 8, the corresponding interrupt has a loer priority and if the bit is @ the corresponding interrupt has a higher priority "&.: 4ot "mplemented, #eserved +or +uture 3se. "&.5 4ot "mplemented, #eserved +or +uture 3se &'A "&.7 Define the 'imer A "nterrupt &riority Level &S "&.9 Defines the Serial &ort "nterrupt &riority Level &'@ "&.< Defines the 'imer @ "nterrupt &riority Level &Q@ "&.A Defines *!ternal "nterrupt @ &riority Level &'8 "&.@ Defines the 'imer 8 "nterrupt &riority Level &Q8 "&.8 Defines the *!ternal "nterrupt 8 &riority Level S2?4K S*#"(L &?#' 2?4'#?L #*>"S'*# , )"' (DD#*SS()L* S2?4 SM8 K S2?4.: Serial &ort mode specifier SM@ K S2?4.5 Serial &ort mode specifier SMA K S2?4.7 #*4 K S2?4.9 Set=cleared by the softare to *nable=disable reception ')6 K S2?4.< the ; th bit that ill be transmitted in modes A and <, Set=cleared )y softare #)6 K S2?4.A "n modes A ,<, is the ; th data bit that as received. "n mode @, "f SMA J 8, #)6 is the stop bit that as received. "n mode 8 #)6 is not used '@ K S2?4.@ 'ransmit interrupt flag. Set by hardare at the end of the 6 th bit 'ime in mode 8, or at the beginning of the stop bit in the other Modes. Must be cleared by softare #@ S2?4.8 #eceive interrupt flag. Set by hardare at the end of the 6 th bit 'ime in mode 8, or halfay through the stop bit time in the other Modes. Must be cleared by the softare. CON TIMER CO;NTER CONTRO+ RECI.TER 'his is a bit addressable '+@ '2?4.: 'imer @ overflo flag. Set by hardare hen the 'imer=2ounter @ ?verflos. 2leared by hardare as processor '#@ '2?4.5 'imer @ run control bit. Set=cleared by softare to turn 'imer 2ounter @ ?n=off '+8 '2?4.7 'imer 8 overflo flag. Set by hardare hen the timer=counter 8 ?verflos. 2leared by hardare as processor '#8 '2?4.9 'imer 8 run control bit. Set=cleared by softare to turn timer 2ounter 8 on=off. "*@ '2?4.< *!ternal interrupt @ edge flag "'" '2?4.A "nterrupt @ type control bit "*8 '2?4.@ *!ternal interrupt 8 edge "'8 '2?4.8 "nterrupt 8 type control bit. 451 In,tr"ction .et Arit7metic O-eration, Mnemonic Description SiCe 2ycles (DD (,#n (dd register to (ccumulator -(22/. @ @ (DD (,direct (dd direct byte to (22. A @ (DD (,S#i (dd indirect #(M to (22 . @ @ (DD (,Vdata (dd immediate data to (22 . @ A (DD2 (,#n (dd register to (22 ith carry . @ @ (DD2 (,direct (dd direct byte to (22 ith carry. A @ (DD2 (,S#i (dd indirect #(M to (22 ith carry. @ @ (DD2 (,Vdata (dd immediate data to (22 ith carry. A @ S3)) (,#n Subtract register from (22 ith borro. @ @ S3)) (,direct Subtract direct byte from (22 ith borro A @ S3)) (,S#i Subtract indirect #(M from (22 ith borro. @ @ S3)) (,Vdata Subtract immediate data from (22 ith borro.A @ "42 ( "ncrement (22. @ @ "42 #n "ncrement register. @ @ "42 direct "ncrement direct byte. A @ "42 S#i "ncrement indirect #(M. @ @ D*2 ( Decrement (22. @ @ D*2 #n Decrement register. @ @ D*2 direct Decrement direct byte. A @ D*2 S#i Decrement indirect #(M. @ @ "42 D&'# "ncrement data pointer. @ A M3L () Multiply ( and ) #esultK ( W1 lo byte, ) W1 high byte. @ 9 D". () Divide ( by ) #esultK ( W1 hole part, ) W1 remainder. @ 9 D( ( Decimal adjust (22. @ @ +ogical O-eration, Mnemonic Description SiCe 2ycles (4L (,#n (4D #egister to (22. @ @ (4L (,direct (4D direct byte to (22. A @ (4L (,S#i (4D indirect #(M to (22. @ @ (4L (,Vdata (4D immediate data to (22. A @ (4L direct,( (4D (22 to direct byte. A @ (4L direct,Vdata (4D immediate data to direct byte. < A ?#L (,#n ?# #egister to (22. @ @ ?#L (,direct ?# direct byte to (22. A @ ?#L (,S#i ?# indirect #(M to (22. @ @ ?#L (,Vdata ?# immediate data to (22. A @ ?#L direct,( ?# (22 to direct byte. A @ ?#L direct,Vdata ?# immediate data to direct byte. < A Q#L (,#n *!clusive ?# #egister to (22. @ @ Q#L (,direct *!clusive ?# direct byte to (22. A @ Q#L (,S#i *!clusive ?# indirect #(M to (22. @ @ Q#L (,Vdata *!clusive ?# immediate data to (22. A @ Q#L direct,( *!clusive ?# (22 to direct byte. A @ Q#L direct,Vdata Q?# immediate data to direct byte. < A 2L# ( 2lear (22 -set all bits to Cero/. @ @ 2&L ( 2ompliment (22. @ @ #L ( #otate (22 left. @ @ #L2 ( #otate (22 left through carry. @ @ ## ( #otate (22 right. @ @ ##2 ( #otate (22 right through carry. @ @ SW(& ( Sap nibbles ithin (22. @ @ &ata Tran,fer Mnemonic Description SiCe 2ycles M?. (,#n Move register to (22. @ @ M?. (,direct Move direct byte to (22. A @ M?. (,S#i Move indirect #(M to (22. @ @ M?. (,Vdata Move immediate data to (22. A @ M?. #n,( Move (22 to register. @ @ M?. #n,direct Move direct byte to register. A A M?. #n,Vdata Move immediate data to register. A @ M?. direct,( Move (22 to direct byte. A @ M?. direct,#n Move register to direct byte. A A M?. direct,direct Move direct byte to direct byte. < A M?. direct,S#i Move indirect #(M to direct byte. A A M?. direct,Vdata Move immediate data to direct byte. < A M?. S#i,( Move (22 to indirect #(M. @ @ M?. S#i,direct Move direct byte to indirect #(M. A A M?. S#i,Vdata Move immediate data to indirect #(M. A @ M?. D&'#,Vdata@5 Move immediate @5 bit data to data pointer register. < A M?.2 (,S(MD&'# Move code byte relative to D&'# to (22 -@5 bit address/. @ A M?.2 (,S(M&2 Move code byte relative to &2 to (22 -@5 bit address/. @ A M?.Q (,S#i Move e!ternal #(M to (22 -6 bit address/. @ A M?.Q (,SD&'# Move e!ternal #(M to (22 -@5 bit address/. @ A M?.Q S#i,( Move (22 to e!ternal #(M -6 bit address/. @ A M?.Q SD&'#,( Move (22 to e!ternal #(M -@5 bit address/. @ A &3SH direct &ush direct byte onto stack. A A &?& direct &op direct byte from stack. A A Q2H (,#n *!change register ith (22. @ @ Q2H (,direct *!change direct byte ith (22. A @ Q2H (,S#i *!change indirect #(M ith (22. @ @ Q2HD (,S#i *!change lo order nibble of indirect #(M ith lo order nibble of (22 @ @ %oolean Faria8le Mani-"lation Mnemonic Description SiCe 2ycles 2L# 2 2lear carry flag. @ @ 2L# bit clear direct bit. A @ S*') 2 Set carry flag. @ @ S*') bitSet direct bit A @ 2&L 2 2ompliment carry flag. @ @ 2&L bit 2ompliment direct bit. A @ (4L 2,bit (4D direct bit to carry flag. A A (4L 2,=bit (4D compliment of direct bit to carry. A A ?#L 2,bit ?# direct bit to carry flag. A A ?#L 2,=bit ?# compliment of direct bit to carry. A A M?. 2,bit Move direct bit to carry flag. A @ M?. bit,2 Move carry to direct bit. A A O2 rel Oump if carry is set. A A O42 rel Oump if carry is not set. A A O) bit,rel Oump if direct bit is set. < A O4) bit,rel Oump if direct bit is not set. < A O)2 bit,rel Oump if direct bit is set , clear bit. < A Program %ranc7ing Mnemonic Description SiCe 2ycles (2(LL addr@@ (bsolute subroutine call. A A L2(LL addr@5 Long subroutine call. < A #*' #eturn from subroutine. @ A #*'" #eturn from interrupt. @ A (OM& addr@@ (bsolute jump. A A LOM& addr@5 Long jump. < A SOM& rel Short jump -relative address/. A A OM& S(MD&'# Oump indirect relative to the D&'# @ A ON rel Oump relative if (22 is Cero. A A O4N rel Oump relative if (22 is not Cero. A A 2O4* (,direct,rel 2ompare direct byte to (22 and jump if not e%ual. < A 2O4* (,Vdata,rel 2ompare immediate byte to (22 and jump if not e%ual. < A 2O4* #n,Vdata,rel 2ompare immediate byte to register and jump if not e%ual. < A 2O4* S#i,Vdata,rel 2ompare immediate byte to indirect and jump if not e%ual. < A DO4N #n,rel Decrement register and jump if not Cero. A A DO4N direct,rel Decrement direct byte and jump if not Cero. < A ?ther "nstructions Mnemonic DescriptionSiCe 2ycles 4?& 4o operation. @ @ 2 Power ."--l0 Circ"it#' Tran,former#' 'ransformer orks on the principle of mutual inductance. We kno that if to coils or indings are placed on the core of iron, and if e pass alternating current in one inding, back emf or induced voltage is produced in the second inding. We kno that alternating current alays changes ith the time. So if e apply (2 voltage across one inding, a voltage ill be induced in the other inding. 'ransformer orks on this same principle. "t is made of to indings ound around the same core of iron. 'he inding to hich (2 voltage is applied is called primary inding. 'he other inding is called as secondary inding.
.oltage and current relationshipK Let . @ volts be input alternating voltage applied to primary inding. " @ (mp is input alternating current through primary inding. . A volt is output alternating voltage produced in the secondary. " A amp be the current floing through the secondary. 'hen relationship beteen input and output voltages is given by . @ =. A J 4 @ =4 A #elationship beteen input and output currents is " @ =" A J 4 A =4 @ -Where 4 @ is no. of turns of coil in primary and 4 A is number of turns in secondary / We kno that &oer J 2urrent Q .oltage. "t is to be noted that input poer is e%ual to output poer. &oer is not changed. "f . A is greater than . @ , then " A ill be less than " @ . 'his type of transformer is called as step up transformer. "f . @ is greater than . A , then " @ ill be less than " A . 'his type of transformer is called as step don transformer. +or step up transformer, 4 A X4 @ , i.e., number of turns of secondary inding is more than those in primary. +or step don transformer, 4 @ X4 A , i.e., numbers of turns of primary inding is more than those in secondary. #*S"S'?#S 'he flo of charge -or current/ through any material, encounters an opposing force similar in many respect to mechanical friction. 'his opposing force is called resistance of the material. "t is measured in ohms. "n some electric circuits resistance is deliberately introduced in the form of the resistor. #esistors are of folloing typesK @. Wire ound resistors. A. 2arbon resistors. <. Metal film resistors. Wire Wo"nd Re,i,tor,# Wire ound resistors are made from a long -usually 4i12hromium/ ound on a ceramic core. Longer the length of the ire, higher is the resistance. So depending on the value of resistor re%uired in a circuit, the ire is cut and ound on a ceramic core. 'his entire assembly is coated ith a ceramic metal. Such resistors are generally available in poer of A atts to several hundred atts and resistance values from @ohm to @88k ohms. 'hus ire ound resistors are used for high currents. Car8on Re,i,tor,# 2arbon resistors are divided into three typesK a. 2arbon composition resistors are made by mi!ing carbon grains ith binding material -glue/ and moduled in the form of rods. Wire leads are inserted at the to ends. (fter this an insulating material seals the resistor. #esistors are available in poer ratings of @=@8, @=6, @=9 , @=A , @.A atts and values from @ ohm to A8 ohms. b. 2arbon film resistors are made by deposition carbon film on a ceramic rod. 'hey are cheaper than carbon composition resistors. c. 2ement film resistors are made of thin carbon coating fired onto a solid ceramic substrate. 'he main purpose is to have more precise resistance values and greater stability ith heat. 'hey are made in a small s%uare ith leads.
Metal Film Re,i,tor,# 'hey are also called thin film resistors. 'hey are made of a thin metal coating deposited on a cylindrical insulating support. 'he high resistance values are not precise in valueR hoever, such resistors are free of inductance effect that is common in ire ound resistors at high fre%uency. Faria8le Re,i,tor,# &otentiometer is a resistor here values can be set depending on the re%uirement. &otentiometer is idely used in electronics systems. *!amples are volume control, tons control, brightness and contrast control of radio or '... sets. F",i8le Re,i,tor,# 'hese resistors are ire ound type and are used in '... circuits for protection. 'hey have resistance of less than @7 ohms. 'heir function is similar to a fuse made to blo off henever current in the circuit e!ceeds the limit. #esistance of a ire is directly proportional to its length and inversely proportional to its thickness. # L # @=( RE.I.TOR CO+OR CO&E E:am-le# k or 555 o7m,
CAPACITOR. ( capacitor can store charge, and its capacity to store charge is called capacitance. 2apacitors consist of to conducting plates, separated by an insulating material -knon as dielectric/. 'he to plates are joined ith to leads. 'he dielectric could be air, mica, paper, ceramic, polyester, polystyrene, etc. 'his dielectric gives name to the capacitor. Like paper capacitor, mica capacitor etc. 'ypes of 2apacitorsK
Ca-a 2apacitors can be broadly classified in to categories, i.e., *lectrolytic capacitors and 4on1*lectrolytic capacitors as shon if the figure above. Electrol0tic Ca-acitor# *lectrolytic capacitors have an electrolyte as a dielectric. When such an electrolyte is charged, chemical changes takes place in the electrolyte. "f its one plate is charged positively, same plate must be charged positively in future. We call such capacitors as polariCed. 4ormally e see electrolytic capacitor as polariCed capacitors and the leads are marked ith positive or negative on the Fi:ed Faria8le Electr Non' Gang conden Trimme r Mica Paper Ceramic can. 4on1electrolyte capacitors have dielectric material such as paper, mica or ceramic. 'herefore, depending upon the dielectric, these capacitors are classified. Mica Ca-acitor# "t is sandich of several thin metal plates separated by thin sheets of mica. (lternate plates are connected together and leads attached for outside connections. 'he total assembly is encased in a plastic capsule or )akelite case. Such capacitors have small capacitance value -78 to 788pf/ and high orking voltage -788. and above/. 'he mica capacitors have e!cellent characteristics under stress of temperature variation and high voltage application. 'hese capacitors are no replaced by ceramic capacitors. Ceramic Ca-acitorK Such capacitors have disc or hollo tabular shaped dielectric made of ceramic material such as titanium dio!ide and barium titanate. 'hin coating of silver compounds is deposited on both sides of dielectric disc, hich acts as capacitor plates. Leads are attached to each sides of the dielectric disc and hole unit is encapsulated in a moisture proof coating. Disc type capacitors have very high value up to 8.88@uf. 'heir orking voltages range from <. to 58888.. 'hese capacitors have very lo leakage current. )reakdon voltage is very high. Pa-er Ca-acitor# "t consists of thin foils, hich are separated by thin paper or a!ed paper. 'he sandich of foil and paper is then rolled into a cylindrical shape and enclosed in a paper tube or encased in a plastic capsules. 'he lead at each end of the capacitor is internally attached to the metal foil. &aper capacitors have capacitance ranging from 8.888@uf to A.8uf and orking voltage rating as high as A888.. THE &IO&E Diodes are polariCed, hich means that they must be inserted into the &2) the correct ay round. 'his is because an electric current ill only flo through them in one direction -like air ill only flo one ay trough a tyre valve/. Diodes have to connections, an anode and a cathode. 'he cathode is alays identified by a dot, ring or some other mark. 'he &2) is often marked ith a Msign for the cathode end. Diodes come in all shapes and siCes. 'hey are often marked ith a type number. Detailed characteristics of a diode can be found by looking up the type number in a data book. "f you kno ho to measure resistance ith a meter then test some diodes. ( good one has lo resistance in one direction and high in other. 'hey are specialiCed types of diode available such as the Cener and light emitting diode -L*D/.
IC "2 -"ntegrated 2ircuit/ means that all the components of the circuit are fabricated on same chip. Digital "2s are a collection of resistors, diodes, and transistors fabricated on a single piece of semiconductor, usually silicon called a substrate, hich is commonly referred to as LaferH. 'he chip is enclosed in a protective plastic or ceramic package from hich pins e!tend out connecting the "2 to other device. Suffi! 4 or & stands for dual1in1line -plastic package -D"&// hile suffi! O or " stands for dual1in1lime ceramic package. (lso the suffi! for W stands for flat ceramic package. 'he pins are numbered counter clockise hen vieed from the top of the package ith respect to an identity notch or dot at one end of the chip.'he manufacturerHs name can usually be guessed from its logo that is printed on the "2. 'he "2 type number also indicates the manufacturerHs code. +or e.g. DM 986 4 S4 :989 indicates 4ational Semiconductor and 'e!as "nstruments. ?ther e!amples areK +air 2hild K 3(, 3(+ 4ational Semiconductor K DM, LM, LH, L+, and '(. Motorola K M2, M+2. Sprague K 3$4, 3LS, 3LQ. Signetic K 4=s, 4*=S*, and S3. )urr1)ron K )). 'e!as "nstruments K S4. 'he middle portion i.e. the "2 type number tells about the "2 function and also the family, hich the particular "2 belongs to."2Hs that belongs to standard ''L series have an identification number that starts ith :9R for e.g. :98A, :9LS89, :9S89 etc. "2Hs that belongs to standard 2M?S family their number starts ith 9, like 9888, 97@), 9:A9), @988. 'he :92, :9H2, :9(2 , :9(2' series are neer 2M?S series. .arious series ith ''L logic family areK1
Standard ''L :9. Schottky ''L :9s. Lo poer Schottky :9LS. (dvance Schottky :9(S. (dvanced Lo &oer Schottky :9(Ls. (lso there are various series ith 2M?S logic family as metal state 2M?S 98 or @98. Power ."--l0 +or ''L circuits, the poer supply pin is labeled . cc and its nominal value. +or 2M?S "2s, the poer supply pin is labeled as . DD , its nominal value range from '< to @6.. ;nconnected In-"t, (n unconnected input is called 0floating inputE. 'he floating ''L input acts as logic @. High level is applied to it. 'his characteristic is often used hen testing a ''L circuit. ( floating ''L input ill measure a D2 level beteen @.9. to @.6. hen checked ith .?M as oscilloscope. "f a 2M?S input is left floating, it may have disastrous results. 'he "2 may become overheated and eventually destroy itself. +or this reason, all inputs to 2M?S circuit must be connected to a L?W or H">H level or to the output of another "2. A!%i8iliogra-70 @. *D2 by Sanjeev >upta. A. 687@ Microcontroller by $ennith (yala