Submitted for partial fulfillment of award of BACHELOR OF TECHNOLOGY DEGREE IN E&C ENGG. (2007-2011) A Project Report On CELL PHONE OPERATED LAND ROVERSUBMITTED TO: SUBMITTED BY:Mrs. Ritu Singh Akash Chandel (0821331005)Electronics & Communication Engineering Deptt. Anupam Singh (0821331018) HindustanInstitute of Technology, Ashutosh Singh (08 21331024)Gr. Noida--------------------------------------------------------------------------------------------------- Department of Electronics and Communication Engineering Hindustan Institute of Technology 32, 34, Knowledge Park-III, Greater Noida, U.P
TABLE OF CONTENTS Abstract……………………………………………………………....6 List Of Abbreviations………………………………………………...7 CHAPTER 1:- INTRODUCTION………………………………....9 1.1 Project overview……………………………………………….10 1.2 Significance of project………………………………………..12 1.3 History of remote controlled vehicle…………………..............13 1.4 First Remote control vehicles……………..................................15 1.5 Use of Remote control vehicles during world war II……….. CHAPTER 2:- WORKING.........……………………………..17 2.1 Cell Phone used as DTMF transmitter………………………………18 2.2 Cell Phone used as DTMF receiver …………………………21 2.3 D.C Motor Driver……………………………………..................24 2.4 Microcontroller Logic………………………………… CHAPTER 3:- PCB CONSTRUCTION……………………...…27 3.1 Shear raw material…………………………………………..28 3.2 Apply image………………………………………………… 3.3 Pattern plate………………………………………………… 3.4 Strip & Etch……………………………………………….. 3.5 Solder Marks……………………………………………….. 3.6 Nomenclature & Fabrication……………………………….. CHAPTER 4:- CIRCUIT DIAGRAM..………………36 4.1 Microcontroller device overview……………………… 4.2 PIN Diagram…………………………………………….43 4.3 PIN Description………………………………………….46 4.4 RISC Architecture……………………………………………51 4.5 Memory & Register………………………………………. 4.5.6 SFRs ……………………………………………… CHAPTER 5:- OTHER COMPONENTS……......53 5.1 Diode & V-I characteristics………………………................................55 5.2 LED……………………………………...68 5.3 Motor Driver IC L-293
ABSTRACTAs today the world of mobile is going to overlap all the old traditional devices. We are nowusing mobile for controlling the household appliances like television, fan, refrigerator etc.The mobile is used to capture the video audio files, to store them, to transmit them to othermobiles. The mobile is used for internet, commutation etc as well as the original use i.e. forcommunication. Mobiles are coming with the features like clock, stop watch, world clock,calculator, currency converter, spot light, audio/video player etc. the user needs a devicewhich can solve his all the problems and fulfill all the needs. So why can‘t we use thispopular device for controlling the ROBOT which may be a car or a personal assistant. In this project we tried to overcome with this feature of mobile. In this project we show that how we control the movement of any small robot with the help of mobile phone. By using this logic we not only control the movement of vehicle but also switch on/off other accessories on robot. Mobile as a transmitter is used having 12 keypad for control operation and can be used from anywhere in the world. Programmable, multifunctional, DTMF based receiver because of PIC16F877, which can be reprogrammed 10000 times. Robot is self powered by 12V battery High power DC motor is used to control Robot moment.
CHAPTER-1Introduction RoboticsRobotics develop man-made mechanical devices that can move by themselves, whose motionmust be modeled, planned, sensed, actuated and controlled, and whose motion behavior canbe influenced by ―programming‖. Robots are called ―intelligent‖ if they succeed in moving insafe interaction with an unstructured environment, while autonomously achieving theirspecified tasks.This definition implies that a device can only be called a ―robot‖ if it contains a movablemechanism, influenced by sensing, planning, and actuation and control componentsRobotics is, to a very large extent, all about system integration, achieving a task by anactuated mechanical device, via an ―intelligent‖ integration of components, many of which itshares with other domains, such as systems and control, computer science, characteranimation, machine design, computer vision, artificial intelligence, cognitive science,biomechanics, etc. In addition, the boundaries of robotics cannot be clearly defined, since alsoits ―core‖ ideas, concepts and algorithms are being applied in an ever increasing number of―external‖ applications, and, vice versa, core technology from other domains (vision, biology,cognitive science or biomechanics, for example) are becoming crucial components in moreand more modern robotic systems.Research in engineering robotics follows the bottom-up approach: existing and workingsystems are extended and made more versatile. Research in artificial intelligence robotics istop-down: assuming that a set of low-level primitives is available, how could one apply themin order to increase the ―intelligence‖ of a system. The border between both approaches shiftscontinuously, as more and more ―intelligence‖ is cast into algorithmic, system-theoretic form.For example, the response of a robot to sensor input was considered ―intelligent behaviour‖ inthe late seventies and even early eighties. Hence, it belonged to A.I. Later it was shown thatmany sensor-based tasks such as surface following or visual tracking could be formulated ascontrol problems with algorithmic solutions. From then on, they did not belong to A.I. anymore
BLOCK DIAGRAM: Mobile as Receiver DTMF Decoder PIC Microcontroller Left H Right H Bridge Bridge Left Right Motor Motor Fig:-1.1
1.1PROJECT OVERVIEW : Fig:-1.2In this project, the robot is controlled by a mobile phone that makes a call to the mobile phone
attached to the robot. In the coarse of a call, if any button is pressed, a tone corresponding to thebutton pressed is heard at the other end of the call. This tone is called ‗dual-tonemultiplefrequency‘ (DTMF) tone. The robot perceives this DTMF tone with thehelp of the phonestacked in the robot.The received tone is processed by the ATmega16 microcontroller with the help of DTMFdecoder MT8870. The decoder decodes the DTMF tone into its equivalent binary digit and thisbinary number is sent to the microcontroller. The microcontroller is pre programmed to take adecision for any given input and outputs its decision to motor drivers in order to drive the motorsfor forward or backward motion or a turn.The mobile that makes a call to the mobile phone stacked in the robot acts as a remote. So thissimple robotic project does not require the construction of receiver and transmitter units. DTMFsignaling is used for telephone signaling over the line in the voice-frequency band to the callswitching centre.The version of DTMF used for telephone tone dialing is known as ‗Touch-Tone‘. DTMF assignsa specific frequency (consisting of two separate tones) to each key so that it can easily beidentified by the electronic circuit. The signal generated by the DTMF encoder is a directalgebraic summation, in real time, of the amplitudes of two sine (cosine) waves of differentfrequencies, i.e., pressing ‗5‘ will send a tone made by adding 1336 Hz and 770 Hz to the otherend of the mobile phone.
1.2SIGNIFICANCE OF THE PROJECT :Robotics is an interesting field where every engineer can showcase his creative and technicalskills. Radio control (often abbreviated to R/C or simply RC) is the use of radio signals toremotely control a device. The term is used frequently to refer to the control of model vehiclesfrom a hand-held radio transmitter.Industrial, military, and scientific research organizations make [traffic] use of radio-controlledvehicles as well. A remote control vehicle is defined as any mobile device that is controlled by ameans that does not restrict its motion with an origin external to the device. This is often a radiocontrol device, cable between control and vehicle, or an infrared controller. A remote controlvehicle (Also called as RCV) differs from a robot in that the RCV is always controlled by ahuman and takes no positive action autonomously.One of the key technologies which underpin this field is that of remote vehicle control. It is vitalthat a vehicle should be capable of proceeding accurately to a target area; maneuvering withinthat area to fulfill its mission and returning equally accurately and safely to base.Recently, Sony Ericsson released a remote control car that could be controlled by any Bluetoothcell phone. Radio is the most popular because it does not require the vehicle to be limited by thelength of the cable or in a direct line of sight with the controller (as with the infrared set-up).
1.3HISTORY OF REMOTE CONTROLLED VEHICLES :1.3.1The First Remote Control Vehicle :Precision Guided Weapon : This propeller-driven radio controlled boat, built by Nikola Tesla in1898 , is the original prototype of all modern-day uninhabited aerial vehicles and precisionguided weapons. In fact , all remotely operated vehicles in air, land or sea. Powered by lead-acidbatteries and an electric drive motor, the vessel was designed to be maneuvered alongside atarget using instructions received from a wireless remote control transmitter. Once in position, acommand would be sent to detonate an explosive charge contained within the boat!s forwardcompartment.The weapon!s guidance system incorporated a secure communications link between the pilot!scontroller and the surfacerunning torpedo in an effort to assure that control could be maintainedeven in the presence of electronic countermeasures. To learn more about Tesla!s system forsecure wireless communications and his pioneering imp lementation of the electronic logic-gatecircuit read ‗Nikola Tesla — Guided Weapons & Computer Technology‘, Tesla Presents SeriesPart 3, with commentary by Leland Anderson.
1.3.2Use of Remote Controlled Vehicles During World War II :During World War II in the Europe an Theater the U.S. Air Force experimented with three basicforms radio control guided weapons. In each case, the weapon would be directed to its target bya crew member on a control plane. The first weapon was essentially a standard bomb fitted withsteering controls. The next evolution involved the fitting of a bomb to a glider airframe, oneversion, the GB-4 having a TV camera to assist the controller with targeting. The third class ofguided weapon was the remote controlled B-17. It!s known that Germany deployed a numberof more advanced guided strike weapons that saw combat before either the V-1 or V-2. Theywere the radio-controlled Henschel!s Hs 293A and Ruhrstahl!s SD1400X, known as ‘Fritz X,‘both air-launched, primarily against ships at sea.
CHAPTER- 2Working:2.1Mobile as DTMF Transmitter:Mobile is based on DTMF Technology. When you press a button of mobile keypad, aconnection is made that generates a resultant signal of two tones at the same time. These twotones are taken from a row frequency and a column frequency. The resultant frequency signal iscalled "Dual Tone Multiple Frequency". These tones are identical and unique. A DTMF signal is the algebraic sum of two different audio frequencies, one fromlow frequency group and other from high frequency group. Each of the low and high frequency groups comprise four frequencies from the variouskeys present on the telephone keypad; two different frequencies, one from the high frequencygroup and another from the low frequency group are used to produce a DTMF signal to representthe pressed key. When you send these DTMF signals to the telephone exchange through cables, the serversin the telephone exchange identifies these signals and makes the connection to the person you arecalling.The row and column frequencies are given below:
When you press the digit 5 in the keypad it generates a resultant tone signal which is made up offrequencies 770Hz and 1336Hz. Pressing digit 8 will produce the tone taken from tones 852Hzand 1336Hz. In both the cases, the column frequency 1336 Hz is the same. These signals aredigital signals which are symmetrical with the sinusoidal wave.2.2Receiver Part:The whole Receiver circuit consists of 6 major parts DTMF Receiver Light Sensor DC Motor driver Microcontroller logic DTMF Receiver: Mobile work as a DTMF receiver and encoded hybrid frequency DTMF code tone is decoded by 8870 IC. 8870 Decode DTMF tone and convert into BCD code, output depending upon which key is pressed at the transmitter side. The table shows decoded output.
D3 D2 D1 D0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1 * 1 0 1 0 0 1 0 1 1 # 1 1 0 0 Fig:-2.1 This four digit output is directly given to 89C51. It will collect this code and start comparing it with inbuilt code. When it founds perfect match it display code on 7 segment display and switch to that subroutine and perform that particular task.2.3 DC motor driver: The H-Bridge is used for motor driver. The H-Bridge is widely used inRobotics for driving DC motor in both clockwise and anticlockwise. As shown in the circuitdiagram in H Bridge two NPN and two PNP transistors is used.
Let us consider microcontroller provide high at pin No 13 and low at Pin No 14 thus right sideNPN transistor conducts and left side PNP transistor conducts.this means M12 is 12v and M11 isgrounded thus motor rotate clockwiseAgain let us consider microcontroller provide low at pin No 13 and high at Pin No 14 thus rightside PNP transistor conducts and left side NPN transistor conducts. this means M12 is groundedand M11 is 12v thus motor rotate anticlockwise..2.4 Microcontroller Logic: The function of microcontroller is to control input output based onthe programmed embedded hex logic. The microcontroller continuously scans input logic. Theinput logic is 4BCD data from 8870 one from fire sensor and one from light sensor. If any one ofthem changes their logic level microcontroller goes to particular subroutine and performparticular task.Let us consider a case at the transmitter mobile I have pressed number 2, thus at receiver side8870 generate corresponding BCD logic 0010. The microcontroller receive 0010 at pin no1,2,3,4. The microcontroller is programmed if input is 0010, move to robot left. The robot willmoves left if left DC motor rotate slow and right DC motor rotate fast. This slow and fastmoment is dine by microcontroller using pulse width modulation. Thus when we press 2 keymicrocontroller provide different pulse to left right motor. The right motor gets pulse havingmote on time then left. In the same way all microcontroller subroutine gets executed and performcorresponding task. If microcontroller sense 0001 input then it goes to right subroutine and moves robot right. If microcontroller sense 0010 inputs then it goes to left subroutine and moves robot left. If microcontroller sense 0011 input then it goes to stop subroutine and goes to standby mode. If microcontroller sense 0100 input then it goes to forward subroutine and moves robot forward.
If microcontroller sense 0101 input then it goes to backward subroutine and moves robotbackward.If microcontroller sense low input at pin No 5 then it goes to day night subroutine andsupply high pulse to on light.
CHAPTER-3.PCB CONSTRUCTION :Step 1:Generated from your design files, we create an exact film representation of your design. We willcreate one film per layer. Fig:-3.1Step 2 :3.1Shear Raw MaterialIndustry standard 0.059" thick, copper clad, two sides. Panels will be sheared to accommodatemany borads. Fig:-3.2
Step 3:3.2Apply Image:Apply photosensitive dryfilm (plate resist) to panel. Use light source and film to expose panel.Develop selected areas from panel. Fig:-3.4Step 4 :3.3Pattern Plate:Electrochemical process to build copper in the holes and on the trace area. Apply tin to surface.note: All PCB express boards are plated through holes. Fig:3.5
Step 5 :3.4Strip & Etch:Remove dryfilm, then etch exposed copper. The tin protects the copper circuitry from beingetched. Fig:3.6Step 6 :3.5Solder mask:Apply solder mask area to entire board with the exception of solder pads Fig:-3.7
Step 7 :3.6Solder coat:Apply solder to pads by immersing into tank of solder. Hot air knives level the solder whenremoved from the tank. Fig:-3.8Step 8 :3.7Nomenclature & FabricationApply white letter marking using screen printing process. Route the perimeter of the board usingNC equipment. Fig:3.9
Fig:3.12CIRCUIT DIAGRAM OF CELL PHONE OPERATED LAND ROVER
CHAPTER-4 PIC16F887A Microcontroller Device OverviewPIC16F877 belongs to a class of 8-bit microcontrollers of RISC architecture. It has 8kb flashmemory for storing a written program. Since memory made in FLASH technology can beprogrammed and cleared more than once, it makes this microcontroller suitable for devicedevelopment. IT has data memory that needs to be saved when there is no supply. It is usuallyused for storing important data that must not be lost if power supply suddenly stops. Forinstance, one such data is an assigned temperature in temperature regulators. If during a loss ofpower supply this data was lost, we would have to make the adjustment once again upon returnof supply. RISC architecture o Only 35 instructions to learn o All single-cycle instructions except branches Operating frequency 0-20 MHz Precision internal oscillator o Factory calibrated o Software selectable frequency range of 8MHz to 31KHz Power supply voltage 2.0-5.5V o Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA (stand-by mode) Power-Saving Sleep Mode Brown-out Reset (BOR) with software control option 35 input/output pins o High current source/sink for direct LED drive o software and individually programmable pull-up resistor o Interrupt-on-Change pin 8K ROM memory in FLASH technology o Chip can be reprogrammed up to 100.000 times
In-Circuit Serial Programming Option o Chip can be programmed even embedded in the target deviceData can be written more than 1.000.000 times368 bytes RAM memoryA/D converter: o 14-channels o 10-bit resolution3 independent timers/countersWatch-dog timerAnalogue comparator module with o Two analogue comparators o Fixed voltage reference (0.6V) o Programmable on-chip voltage referencePWM output steering controlEight level deep hardware stackPower-on Reset (POR)Power-up Timer (PWRT) andOscillator Start-up Timer (OST)Programmable code protectionWatchdog Timer (WDT) with its own on-chip RC oscillator for reliable operationDirect, indirect and relative addressing modesInterrupt capability (up to 14 sources)Enhanced USART module o Supports RS-485, RS-232 and LIN2.0 o Auto-Baud DetectMaster Synchronous Serial Port (MSSP) o supports SPI and I2C mode
BLOCK DIAGRAM: Fig-4.24.1PIN DESCRIPTIONAs seen in Fig. 1-1 above, the most pins are multi-functional. For example, designatorRA3/AN3/Vref+/C1IN+ for the fifth pin specifies the following functions: RA3 Port A third digital input/output AN3 Third analog input Vref+ Positive voltage reference C1IN+ Comparator C1positive inputThis small trick is often used because it makes the microcontroller package more compactwithout affecting its functionality. These various pin functions cannot be used simultaneously,but can be changed at any point during operation.
4.2Central Processor Unit (CPU)I‘m not going to bore you with the operation of the CPU at this stage, however it is important tostate that the CPU is manufactured with in RISC technology an important factor when decidingwhich microprocessor to use.RISC Reduced Instruction Set Computer, gives the PIC16F887 two great advantages: The CPU can recognizes only 35 simple instructions (In order to program some other microcontrollers it is necessary to know more than 200 instructions by heart). The execution time is the same for all instructions except two and lasts 4 clock cycles (oscillator frequency is stabilized by a quartz crystal). The Jump and Branch instructions execution time is 2 clock cycles. It means that if the microcontroller‘s operating speed is 20MHz, execution time of each instruc tion will be 200nS, i.e. the program will be executed at the speed of 5 million instructions per second! Fig.4.4 CPU Memory
MemoryThis microcontroller has three types of memory- ROM, RAM and EEPROM. All of them will beseparately discussed since each has specific functions, features and organization.ROM MemoryROM memory is used to permanently save the program being executed. This is why it is oftencalled ―program memory‖. The PIC16F887 has 8Kb of ROM (in total of 8192 locations). Sincethis ROM is made with FLASH technology, its contents can be changed by providing a specialprogramming voltage (13V).Anyway, there is no need to explain it in detail because it is automatically performed by meansof a special program on the PC and a simple electronic device called the Programmer. Fig:4.5 ROM Memory ConceptEEPROM MemorySimilar to program memory, the contents of EEPROM is permanently saved, even the powergoes off. However, unlike ROM, the contents of the EEPROM can be changed during operationof the microcontroller. That is why this memory (256 locations) is a perfect one for permanentlysaving results created and used during the operation.RAM MemoryThis is the third and the most complex part of microcontroller memory. In this case, it consists oftwo parts: general-purpose registers and special-function registers (SFR).
Even though both groups of registers are cleared when power goes off and even though they aremanufactured in the same way and act in the similar way, their functions do not have manythings in common. Fig.4.6 SFR and General Purpose RegistersGeneral-Purpose RegistersGeneral-Purpose registers are used for storing temporary data and results created duringoperation. For example, if the program performs a counting (for example, counting products onthe assembly line), it is necessary to have a register which stands for what we in everyday lifecall ―sum‖. Since the microcontroller is not creative at all, it is necessary to specify the address
of some general purpose register and assign it a new function. A simple program to incrementthe value of this register by 1, after each product passes through a sensor, should be created.Therefore, the microcontroller can execute that program because it now knows what and wherethe sum which must be incremented is. Similarly to this simple example, each program variablemust be pre-assigned some of general-purpose register.SFR RegistersSpecial-Function registers are also RAM memory locations, but unlike general-purpose registers,their purpose is predetermined during manufacturing process and cannot be changed. Since theirbits are physically connected to particular circuits on the chip (A/D converter, serialcommunication module, etc.), any change of their contents directly affects the operation of themicrocontroller or some of its circuits. For example, by changing the TRISA register, thefunction of each port A pin can be changed in a way it acts as input or output. Another feature ofthese memory locations is that they have their names (registers and their bits), whichconsiderably facilitates program writing. Since high-level programming language can use the listof all registers with their exact addresses, it is enough to specify the register‘s name in order toread or change its contents.RAM Memory BanksThe data memory is partitioned into four banks. Prior to accessing some register during programwriting (in order to read or change its contents), it is necessary to select the bank which containsthat register. Two bits of the STATUS register are used for bank selecting, which will bediscussed later. In order to facilitate operation, the most commonly used SFRs have the sameaddress in all banks which enables them to be easily accessed.
4.3 STACKA part of the RAM used for the stack consists of eight 13-bit registers. Before themicrocontroller starts to execute a subroutine (CALL instruction) or when an interrupt occurs, theaddress of first next instruction being currently executed is pushed onto the stack, i.e. onto one ofits registers. In that way, upon subroutine or interrupt execution, the microcontroller knows fromwhere to continue regular program execution. This address is cleared upon return to the mainprogram because there is no need to save it any longer, and one location of the stack isautomatically available for further use.It is important to understand that data is always circularly pushed onto the stack. It means thatafter the stack has been pushed eight times, the ninth push overwrites the value that was storedwith the first push. The tenth push overwrites the second push and so on. Data overwritten in thisway is not recoverable. In addition, the programmer cannot access these registers for write orread and there is no Status bit to indicate stack overflow or stack underflow conditions. For thatreason, one should take special care of it during program writing.Interrupt SystemThe first thing that the microcontroller does when an interrupt request arrives is to execute thecurrent instruction and then stop regular program execution. Immediately after that, the currentprogram memory address is automatically pushed onto the stack and the default address(predefined by the manufacturer) is written to the program counter. That location from where theprogram continues execution is called the interrupt vector. For the PIC16F887 microcontroller,this address is 0004h. As seen in Fig. 1-7 below, the location containing interrupt vector ispassed over during regular program execution.Part of the program being activated when an interrupt request arrives is called the interruptroutine. Its first instruction is located at the interrupt vector. How long this subroutine will be andwhat it will be like depends on the skills of the programmer as well as the interrupt source itself.Some microcontrollers have more interrupt vectors (every interrupt request has its vector), but inthis case there is only one. Consequently, the first part of the interrupt routine consists ininterrupt source recognition.Finally, when the interrupt source is recognized and interrupt routine is executed, themicrocontroller reaches the RETFIE instruction, pops the address from the stack and continuesprogram execution from where it left off.
Fig.4.7 Interrupt SystemHow to use SFRsYou have bought the microcontroller and have a good idea how to use it...There is a long list ofSFRs with all bits. Each of them controls some process. All in all, it looks like a big control tablewith a lot of instruments and switches. Now you are concerned about whether you will manageto learn how to use them all? You will probably not, but don‘t worry, you don‘t have to! Suchpowerful microcontrollers are similar to a supermarkets: they offer so many things at low pricesand it is only up to you to choose. Therefore, select the field you are interested in and study onlywhat you need to know. Afterwards, when you completely understand hardware operation, studySFRs which are in control of it ( there are usually a few of them). To reiterate, during programwriting and prior to changing some bits of these registers, do not forget to select the appropriatebank. This is why they are listed in the tables above.
4.4 Core SFRsFeatures and FunctionThe special function registers can be classified into two categories: Core (CPU) registers - control and monitor operation and processes in the central processor. Even though there are only a few of them, the operation of the whole microcontroller depends on their contents. Peripheral SFRs- control the operation of peripheral units (serial communication module, A/D converter etc.). Each of these registers is mainly specialized for one circuit and for that reason they will be described along with the circuit they are in control of.The core (CPU) registers of the PIC16F887 microcontroller are described in this chapter. Sincetheir bits control several different circuits within the chip, it is not possible to classify them intosome special group. These bits are described along with the processes they control.STATUS RegisterThe STATUS register contains: the arithmetic status of the W register, the RESET status and thebank select bits for data memory. One should be careful when writing a value to this registerbecause if you do it wrong, the results may be different than expected. For example, if you try toclear all bits using the CLRF STATUS instruction, the result in the register will be 000xx1xxinstead of the expected 00000000. Such errors occur because some of the bits of this register areset or cleared according to the hardware as well as because the bits 3 and 4 are readable only. Forthese reasons, if it is required to change its content (for example, to change active bank), it isrecommended to use only instructions which do not affect any Status bits (C, DC and Z).OPTION_REG Register Fig:-4.8The OPTION_REG register contains various control bits to configure: Timer0/WDT prescaler,timer TMR0, external interrupt and pull-ups on PORTB.
Interrupt System RegistersWhen an interrupt request arrives it does not mean that interrupt will automatically occur,because it must also be enabled by the user (from within the program). Because of that, there arespecial bits used to enable or disable interrupts. It is easy to recognize these bits by IE containedin their names (stands for Interrupt Enable). Besides, each interrupt is associated with another bitcalled the flag which indicates that interrupt request has arrived regardless of whether it isenabled or not. They are also easily recognizable by the last two letters contained in their names-IF (Interrupt Flag).As seen, everything is based on a simple and efficient idea. When an interrupt request arrives,the flag bit is to be set first. Fig:-4.9 Interrupt System RegistersIf the appropriate IE bit is not set (0), this event will be completely ignored. Otherwise, aninterrupt occurs! In case several interrupt sources are enabled, it is necessary to detect the activeone before the interrupt routine starts execution. Source detection is performed by checking flagbits.It is important to understand that the flag bits are not automatically cleared, but by softwareduring interrupt routine execution. If this detail is neglected, another interrupt will occurimmediately upon return to the program, even though there are no more requests for itsexecution! Simply put, the flag as well as IE bit remained set.All interrupt sources typical of the PIC16F887 microcontroller are shown on the next page. Noteseveral things: GIE bit - enables all unmasked interrupts and disables all interrupts simultaneously. PEIE bit - enables all unmasked peripheral interrupts and disables all peripheral interrupts (This does not concern Timer TMR0 and port B interrupt sources).To enable interrupt caused by changing logic state on port B, it is necessary to enable it for eachbit separately. In this case, bits of the IOCB register have the function to control IE bits.
Fig:-4.10 Interrupt SFRsINTCON RegisterThe INTCON register contains various enable and flag bits for TMR0 register overflow, PORTBchange and external INT pin interrupts. Fig:-4.11
PIE1 RegisterThe PIE1 register contains the peripheral interrupt enable bits. Fig:-4.12PIE2 RegisterThe PIE2 Register also contains the various interrupt enable bits. Fig:-4.13PIR1 RegisterThe PIR1 register contains the interrupt flag bits. Fig:-4.14
PIR2 RegisterThe PIR2 register contains the interrupt flag bits. Fig:-4.15PCON registerThe PCON register contains only two flag bits used to differentiate between a: power-on reset,brown-out reset, Watchdog Timer Reset and external reset (through MCLR pin). Fig:-4.16PCL and PCLATH RegistersThe size of the program memory of the PIC16F887 is 8K. Therefore, it has 8192 locations forprogram storing. For this reason the program counter must be 13-bits wide (2^13 = 8192). Inorder that the contents of some location may be changed in software during operation, its addressmust be accessible through some SFR. Since all SFRs are 8-bits wide, this register is―artificially‖ created by dividing its 13 bits into two independent registers: PCLATH and PCL.If the program execution does not affect the program counter, the value of this register isautomatically and constantly incremented +1, +1, +1, +1... In that way, the program is executedjust as it is written- instruction by instruction, followed by a constant address increment. Fig:-4.17 PCL and PCLATH Registers
If the program counter is changed in software, then there are several things that should be kept inmind in order to avoid problems: Eight lower bits (the low byte) come from the PCL register which is readable and writable, whereas five upper bits coming from the PCLATH register are writable only. The PCLATH register is cleared on any reset. In assembly language, the value of the program counter is marked with PCL, but it obviously refers to 8 lower bits only. One should take care when using the ―ADDWF PCL‖ instruction. This is a jump instruction which specifies the target location by adding some number to the current address. It is often used when jumping into a look-up table or program branch table to read them. A problem arises if the current address is such that addition causes change on some bit belonging to the higher byte of the PCLATH register. Do you see what is going on? Executing any instruction upon the PCL register simultaneously causes the Prog ram Counter bits to be replaced by the contents of the PCLATH register. However, the PCL register has access to only 8 lower bits of the instruction result and the following jump will be completely incorrect. The problem is solved by setting such instructions at addresses ending by xx00h. This enables the program to jump up to 255 locations. If longer jumps are executed by this instruction, the PCLATH register must be incremented by 1 for each PCL register overflow. On subroutine call or jump execution (instructions CALL and GOTO), the microcontroller is able to provide only 11-bit addressing. For this reason, similar to RAM which is divided in ―banks‖, ROM is divided in four ―pages‖ in size of 2K each. Such instructions are executed within these pages without any problems. Simply, since the processor is provided with 11-bit address from the program, it is able to address any location within 2KB. Figure 2-17 below illustrates this situation as a jump to the subroutine PP1 address. However, if a subroutine or jump address are not within the same page as the location from where the jump is, two ―missing‖- higher bits should be provided by writing to the PCLATH register. It is illustrated in figure 2-17 below as a jump to the subroutine PP2 address.
Fig:-4.18 PCLATH RegistersIn both cases, when the subroutine reaches instructions RETURN, RETLW or RETFIE (to return tothe main program), the microcontroller will simply continue program execution from where itleft off because the return address is pushed and saved onto the stack which, as mentioned,consists of 13-bit registers.Indirect addressingIn addition to direct addressing which is logical and clear by itself (it is sufficient to specifyaddress of some register to read its contents), this microcontroller is able to perform indirectaddressing by means of the INDF and FSR registers. It sometimes considerably simplifiesprogram writing. The whole procedure is enabled because the INDF register is not true one(physically does not exist), but only specifies the register whose address is located in the FSRregister. Because of this, write or read from the INDF register actually means write or read fromthe register whose address is located in the FSR register. In other words, registers‘ addresses arespecified in the FSR register, and their contents are stored in the INDF register. The differencebetween direct and indirect addressing is illustrated in the figure 2-18 below:As seen, the problem with the ―missing addressing bits‖ is solved by ―borrowing‖ from anotherregister. This time, it is the seventh bit called IRP from the STATUS register.
4.5 TIMERThe timers of the PIC16F887 microcontroller can be briefly described in only one sentence.There are three completely independent timers/counters marked as TMR0, TMR1 and TMR2.But it‘s not as simple as that.Timer TMR0The timer TMR0 has a wide range of applications in practice. Very few programs dont use it insome way. It is very convenient and easy to use for writing programs or subroutines forgenerating pulses of arbitrary duration, time measurement or counting external pulses (events)with almost no limitations.The timer TMR0 module is an 8-bit timer/counter with the following features: 8-bit timer/counter; 8-bit prescaler (shared with Watchdog timer); Programmable internal or external clock source; Interrupt on overflow; and Programmable external clock edge selection.Figure below represents the timer TMR0 schematic with all bits which determine its operation. These bits are storedin the OPTION_REG Register. Fig:-4.20
The function of the PSA bit 0 is shown in the two figures below: Fig:-4.21The function of the PSA bit 1 is shown in the two figures below: Fig:-4.22
As seen, the logic state of the PSA bit determines whether the prescaler is to be assigned to thetimer/counter or watch-dog timer.Additionally it is also worth mentioning: When the prescaler is assigned to the timer/counter, any write to the TMR0 register will clear the prescaler; When the prescaler is assigned to watch-dog timer, a CLRWDT instruction will clear both the prescaler and WDT; Writing to the TMR0 register used as a timer, will not cause the pulse counting to start immediately, but with two instruction cycles delay. Accordingly, it is necessary to adjust the value written to the TMR0 register; When the microcontroller is setup in sleep mode, the oscillator is turned off. Overflow cannot occur since there are no pulses to count. This is why the TMR0 overflow interrupt cannot wake up the processor from Sleep mode; When used as an external clock counter without prescaler, a minimal pulse length or a pause between two pulses must be 2 Tosc + 20 nS. Tosc is the oscillator signal period; When used as an external clock counter with prescaler, a minimal pulse length or a pause between two pulses is 10nS; The 8-bit prescaler register is not available to the user, which means that it cannot be directly read or written to; When changing the prescaler assignment from TMR0 to the watch-dog timer, the following instruction sequence must be executed in order to avoid reset:To select mode: Timer mode is selected by the T0CS bit of the OPTION_REG register, (T0CS: 0=timer, 1=counter); When used, the prescaler should be assigned to the timer/counter by clearing the PSA bit of the OPTION_REG register. The prescaler rate is set by using the PS2-PS0 bits of the same register; and When using interrupt, the GIE and TMR0IE bits of the INTCON register should be set. Reset the TMR0 register or write some well-known value to it; To measure time: Elapsed time (in microseconds when using quartz 4MHz) is measured by reading the TMR0 register; and The flag bit TMR0IF of the INTCON register is automatically set every time the TMR0 register overflows. If enabled, an interrupt occurs.To count pulses: The polarity of pulses are to be counted is selected on the RA4 pin are selected by the TOSE bit of the OPTION register (T0SE: 0=positive, 1=negative pulses); and
Number of pulses may be read from the TMR0 register. The prescaler and interrupt are used in the same manner as in timer mode.Timer TMR1Timer TMR1 module is a 16-bit timer/counter, which means that it consists of two registers(TMR1L and TMR1H). It can count up 65.535 pulses in a single cycle, i.e. before the countingstarts from zero. Fig:-4.23 Timer TMR1Similar to the timer TMR0, these registers can be read or written to at any moment. In case anoverflow occurs, an interrupt is generated.The timer TMR1 module may operate in one of two basic modes- as a timer or a counter.However, unlike the timer TMR0, each of these modules has additional functions.Parts of the T1CON register are in control of the operation of the timer TMR1. Fig:-4.24 Timer TMR1 Prescaler
Timer TMR1 has a completely separate prescaler which allows 1, 2, 4 or 8 divisions of the clockinput. The prescaler is not directly readable or writable. However, the prescaler counter isautomatically cleared upon write to the TMR1H or TMR1L register.Timer TMR1 OscillatorRC0/T1OSO and RC1/T1OSI pins are used to register pulses coming from peripheralelectronics, but they also have an additional function. As seen in figure 4-7, they aresimultaneously configured as both input (pin RC1) and output (pin RC0) of the additional LPquartz oscillator (low power).This additional circuit is primarily designed for operating at low frequencies (up to 200 KHz),more precisely, for using the 32,768 KHz quartz crystal. Such crystals are used in quartz watchesbecause it is easy to obtain one-second-long pulses by simply dividing this frequency.Since this oscillator does not depend on internal clocking, it can operate even in sleep mode. It isenabled by setting the T1OSCEN control bit of the T1CON register. The user must provide asoftware time delay (a few milliseconds) to ensure proper oscillator start-up. Fig:-4.25Table below shows the recommended values of capacitors to suit the quartz oscillator. Thesevalues do not have to be exact. However, the general rule is: the higher the capacitors capacitythe higher the stability, which, at the same time, prolongs the time needed for the oscillatorstability. Oscillator Frequency C1 C2 32 kHz 33 pF 33 pF LP 100 kHz 15 pF 15 pF 200 kHz 15 pF 15 pF Fig:-4.26 Timer TMR1 Oscillator
Timer TMR1 GateTimer 1 gate source is software configurable to be the T1G pin or the output of comparator C2.This gate allows the timer to directly time external events using the logic state on the T1G pin oranalog events using the comparator C2 output. Refer to figure 4-7 above. In order to time asignals duration it is sufficient to enable such gate and count pulses having passed through it.TMR1 in timer modeIn order to select this mode, it is necessary to clear the TMR1CS bit. After this, the 16-bitregister will be incremented on every pulse coming from the internal oscillator. If the 4MHzquartz crystal is in use, it will be incremented every microsecond.In this mode, the T1SYNC bit does not affect the timer because it counts internal clock pulses.Since the whole electronics uses these pulses, there is no need for synchronization. Fig:-4.27The microcontroller‘s clock oscillator does not run during sleep mode so the timer registeroverflow cannot cause any interrupt.Timer TMR1 OscillatorThe power consumption of the microcontroller is reduced to the lowest level in Sleep mode. Thepoint is to stop the oscillator. Anyway, it is easy to set the timer in this mode- by writing aSLEEP instruction to the program. A problem occurs when it is necessary to wake up themicrocontroller because only an interrupt can do that. Since the microcontroller ―sleeps‖, aninterrupt must be triggered by external electronics. It can all get incredibly complicated if it isnecessary the ‗wake up‘ occurs at regular time intervals...
Fig:-4.28In order to solve this problem, a completely independent Low Power quartz oscillator, able tooperate in sleep mode, is built into the PIC16F887 microcontroller. Simply, what previously hasbeen a separate circuit, it is now built into the microcontroller and assigned to the timer TMR1.The oscillator is enabled by setting the T1OSCEN bit of the T1CON register. After that, theTMR1CS bit of the same register then is used to determine that the timer TMR1 uses pulsesequences from that oscillator. The signal from this quartz oscillator is synchronized with the microcontroller clock by clearing the T1SYNC bit. In that case, the timer cannot operate in sleep mode. You wonder why? Because the circuit for synchronization uses the clock of microcontroller!; and The TMR1 register overflow interrupt may be enabled. Such interrupts will occur in sleep mode as well.TMR1 in counter modeTimer TMR1 starts to operate as a counter by setting the TMR1CS bit. It means that the timerTMR1 is incremented on the rising edge of the external clock input T1CKI. If control bitT1SYNC of the T1CON register is cleared, the external clock inputs will be synchronized ontheir way to the TMR1 register. In other words, the timer TMR1 is synchronized to themicrocontroller system clock and called a synchronous counter.When the microcontroller ,operating in this way, is set in sleep mode, the TMR1H and TMR1Ltimer registers are not incremented even though clock pulses appear on the input pins. Simply,since the microcontroller system clock does not run in this mode, there are no clock inputs to usefor synchronization. However, the prescaler will continue to run if there are clock pulses on thepins since it is just a simple frequency divider.
Fig:-4.29This counter registers a logic one (1) on input pins. It is important to understand that at least onefalling edge must be registered prior to the first increment on rising edge. Refer to figure on theleft. The arrows in figure 4-11 denote counter increments.T1CON Register Fig:-4.30T1GINV - Timer1 Gate Invert bit acts as logic state inverter on the T1G pin gate or thecomparator C2 output (C2OUT) gate. It enables the timer to mea sure time whilst the gate is highor low. 1 - Timer 1 counts when the pin T1G or bit C2OUT gate is high (1); and 0 - Timer 1 counts when the pin T1G or bit C2OUT gate is low (0).
TMR1GE - Timer1 Gate Enable bit determines whether the pin T1G or comparator C2 output(C2OUT) gate will be active or not. This bit is functional only in the event that the timer TMR1is on (bit TMR1ON = 1). Otherwise, this bit is ignored. 1 Timer TMR1 is on only if timer 1 gate is not active; and 0 Gate does not affect the timer TMR1.T1CKPS1, T1CKPS0 - Timer1 Input Clock Prescale Select bits determine the rate of theprescaler assigned to the timer TMR1. T1CKPS1 T1CKPS0 Prescaler Rate 0 0 1:1 0 1 1:2 1 0 1:4 1 1 1:8 Fig:- 4-2 Prescaler RateT1OSCEN - LP Oscillator Enable Control bit 1 - LP oscillator is enabled for timer TMR1 clock (oscillator with low power consumption and frequency 32.768 kHz); and 0 - LP oscillator is off.T1SYNC - Timer1 External Clock Input Synchronization Control bit enables synchronization ofthe LP oscillator input or T1CKI pin input with the microcontroller internal clock. Whencounting pulses from the local clock source (bit TMR1CS = 0), this bit is ignored. 1 - Do not synchronize external clock input; and 0 - Synchronize external clock input.TMR1CS - Timer TMR1 Clock Source Select bit 1 - Counts pulses on the T1CKI pin (on the rising edge 0-1); and 0 - Counts pulses of the internal clock of microcontroller.TMR1ON - Timer1 On bit 1 - Enables Timer TMR1; and 0 - Stops Timer TMR1.In order to use the timer TMR1 properly, it is necessary to perform the following: Since it is not possible to turn off the prescaler, its rate should be adjusted by using bits T1CKPS1 and T1CKPS0 of the register T1CON (Refer to table 4-2);
The mode should be selected by the TMR1CS bit of the same register (TMR1CS: 0= the clock source is quartz oscillator, 1= the clock source is supplied externally); By setting the T1OSCEN bit of the same register, the timer TMR1 is turned on and the TMR1H and TMR1L registers are incremented on every clock input. Counting stops by clearing this bit; The prescaler is cleared by clearing or writing the counter registers; and By filling both timer registers, the flag TMR1IF is set and counting starts from zero.Timer TMR2Timer TMR2 module is an 8-bit timer which operates in a very specific way. Fig:-4.32The pulses from the quartz oscillator first pass through the prescaler whose rate may be changedby combining the T2CKPS1 and T2CKPS0 bits. The output of the prescaler is then used toincrement the TMR2 register starting from 00h. The values of TMR2 and PR2 are constantlycompared and the TMR2 register keeps on being incremented until it matches the value in PR2.When a match occurs, the TMR2 register is automatically cleared to 00h. The timer TMR2Postscaler is incremented and its output is used to generate an interrupt if it is enabled.The TMR2 and PR2 registers are both fully readable and writable. Counting may be stopped byclearing the TMR2ON bit, which contributes to power saving.As a special option, the moment of TMR2 reset may be also used to determine synchronousserial communication baud rate.The timer TMR2 is controlled by several bits of the T2CON register.
T2CON Register Fig:-4.33 T2CON RegisterTOUTPS3 - TOUTPS0 - Timer2 Output Postscaler Select bits are used to determine thepostscaler rate according to the following table: TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 Postscaler Rate 0 0 0 0 1:1 0 0 0 1 1:2 0 0 1 0 1:3 0 0 1 1 1:4 0 1 0 0 1:5 0 1 0 1 1:6 0 1 1 0 1:7 0 1 1 1 1:8 1 0 0 0 1:9 1 0 0 1 1:10 1 0 1 0 1:11 1 0 1 1 1:12 1 1 0 0 1:13 1 1 0 1 1:14 1 1 1 0 1:15 1 1 1 1 1:16 Fig:4.34 Postscaler RateTMR2ON - Timer2 On bit turns the timer TMR2 on. 1 - Timer T2 is on; and 0 - Timer T2 is off.
T2CKPS1, T2CKPS0 - Timer2 Clock Prescale bits determine prescaler rate: T2CKPS1 T2CKPS0 Prescaler Rate 0 0 1:1 0 1 1:4 1 X 1:16 Fig:-4.35 Prescaler RateWhen using the TMR2 timer, one should know several specific details that have to do with itsregisters: Upon power-on, the PR2 register contains the value FFh; Both prescaler and postscaler are cleared by writing to the TMR2 register; Both prescaler and postscaler are cleared by writing to the T2CON register; and On any reset, both prescaler and postscaler are cleared.
CHAPTER-5OTHER COMPONENTS:5.1DIODE:A diode is a semiconductor device which allows current to flow through it in only one direction.Although a transistor is also a semiconductor device, it does not operate the way a diode does. A diodeis specifically made to allow current to flow through it in only one direction. Some ways in which thediode can be used are listed here. A diode can be used as a rectifier that converts AC (Alternating Current) to DC (Direct Current) for a power supply device. Diodes can be used to separate the signal from radio frequencies. Diodes can be used as an on/off switch that controls current. Fig:-5.1This symbol is used to indicate a diode in a circuit diagram. The meaning of the symbol is(Anode) (Cathode). Current flows from the anode side to the cathode side.Although all diodes operate with the same general principle, there are different types suited to differentapplications. For example, the following devices are best used for the applications noted.
Fig:-5.2Diode symbols: a - standard diode, b - LED, c, d - Zener, e - photo, f,g - tunnel, h - Schottky, i -breakdown, j - capacitativeV-I characteristics: FIG:-5.3 The graph on the right shows the electrical characteristics of a typical diode.When a small voltage is applied to the diode in the forward direction, current flows easily. Because thediode has a certain amount of resistance, the voltage will drop slightly as current flows through thediode. A typical diode causes a voltage drop of about 0.6 - 1V (VF) (In the case of silicon diode, almost0.6V)
This voltage drop needs to be taken into consideration in a circuit which uses many diodes in series.Also, the amount of current passing through the diodes must be considered. When voltage is applied inthe reverse direction through a diode, the diode will have a great resistance to current flow. Differentdiodes have different characteristics when reverse-biased. A given diode should be selected dependingon how it will be used in the circuit. The current that will flow through a diode biased in the reversedirection will vary from several mA to just µA, which is very small.The limiting voltages and currents permissible must be considered on a case by case basis. For example,when using diodes for rectification, part of the time they will be required to withstand a reverse voltage.If the diodes are not chosen carefully, they will break downRectification / Switching / Regulation Diode:The stripe stamped on one end of the diode shows indicates the polarity of the diode. The stripe showsthe cathode side. The top two devices shown in the picture are diodes used for rectification. They aremade to handle relatively high currents. The device on top can handle as high as 6A, and the one belowit can safely handle up to 1A.However, it is best used at about 70% of its rating because this current value is a maximum rating.The third device from the top (red color) has a part number of 1S1588. This diode is used for switching,because it can switch on and off at very high speed. However, the maximum current it can handle is 120mA. This makes it well suited to use within digital circuits. The maximum reverse voltage (reversebias).this diode can handle is 30V
The device at the bottom of the picture is a voltage regulation diode with a rating of 6V. When this typeof diode is reverse biased, it will resist changes in voltage. If the input voltage is increased, the outputvoltage will not change. (Or any change will be an insignificant amount.) While the output voltage doesnot increase with an increase in input voltage, the output current will.This requires some thought for a protection circuit so that too much current does not flow.The rated current limit for the device is 30 mA.Generally, a 3-terminal voltage regulator is used for the stabilization of a power supply. Therefore, thisdiode is typically used to protect the circuit from momentary voltage spikes. 3 terminal regulators usevoltage regulation diodes inside.Rectification diodes are used to make DC from AC. It is possible to do only half wave rectificationusing 1 diode. When 4 diodes are combined, full wave rectification occurrs.Devices that combine 4 diodes in one package are called diode bridges. They are used for full-waverectification. Fig:-5.4
5.2 Light Emitting Diode (LED): Fig:-5.5Light emitting diodes must be chosen according to how they will be used, because there arevarious kinds. The diodes are available in several colors. The most common colors are red andgreen, but there are even blue ones.The device on the far right in the photograph combines a redLED and green LED in one package.The component lead in the middle is common to bothLEDs. As for the remains two leads, one side is for the green, the other for the red LED. Whenboth are turned on simultaneously, it becomes orange.When an LED is new out of the package, the polarity of the device can be determined by lookingat the leads. The longer lead is the Anode side, and the short one is the Cathode side.The polarity of an LED can also be determined using a resistance meter, or even a 1.5 V battery.When using a test meter to determine polarity, set the meter to a low resistance measurementrange. Connect the probes of the meter to the LED. If the polarity is correct, the LED will glow.If the LED does not glow, switch the meter probes to the opposite leads on the LED. In eithercase, the side of the diode which is connected to the black meter probe when the LED glows, isthe Anode side. Positive voltage flows out of the black probe when the meter is set to measureresistance. Fig:-5.6
It is possible to use an LED to obtain a fixed voltage. The voltage drop (forward voltage, or V F) of an LED is comparatively stable at just about 2V. I explain a circuit in which the voltage was stabilized with an LED in "Thermometer of bending apparatus-2".. Shottky barrier diode:Diodes are used to rectify alternating current into direct current. However, rectification will not occurwhen the frequency of the alternating current is too high. This is due to what is known as the "reverserecovery characteristic."The reverse recovery characteristic can be explained as follows:IF the opposite voltage is suddenly applied to a forward-biased diode, current will continue to flow inthe forward direction for a brief moment. This time until the current stops flowing is called the ReverseRecovery Time. The current is considered to be stopped when it falls to about 10% of the value of thepeak reverse current.The Shottky barrier diode has a short reverse recovery time, which makes it ideally suited to use in highfrequency rectification. Fig:-5.7The Shottky barrier diode has the following characteristics.The voltage drop in the forward direction is low.The reverse recovery time is short.However, it has the following disadvantages.The diode can have relatively high leakage current.
The surge resistance is low. Because the reverse recovery time is short, this diode is often used for theswitching regulator in a high frequency circuitDiode Marking:European diodes are marked using two or three letters and a number. The first letter is used to identifythe material used in manufacturing the component (A - germanium, B - silicon), or, in case of letter Z, aZener diode.The second and third letters specify the type and usage of the diode. Some of the verities are:A - low power diode, like the AA111, AA113, AA121, etc. - they are used in the detector of a radioreceiver; BA124, BA125 : varicap diodes used instead of variable capacitors in receiving devices,oscillators, etc., BAY80, BAY93, etc. - switching diodes used in devices using logic circuits. BA157,BA158, etc. - these are switching diodes with short recovery time.B - two capacitive (varicap) diodes in the same housing, like BB104, BB105, etc.Y - regulation diodes, like BY240, BY243, BY244, etc. - these regulation diodes come in a plasticpackaging and operate on a maximum current of 0.8A. If there is another Y, the diode is intended forhigher current. For example, BYY44 is a diode whose absolute maximum current rating is 1A. When Yis the second letter in a Zener diode mark (ZY10, ZY30, etc.) it means it is intended for higher current.G, G, PD - different tolerance marks for Zener diodes. Some of these are ZF12 (5% tolerance), ZG18(10% tolerance), ZPD9.1 (5% tolerance).The third letter is used to specify a property (high current, for example).American markings begin with 1N followed by a number, 1N4001, for example (regulating diode),1N4449 (switching diode), etc.Japanese style is similar to American, the main difference is that instead of N there is S, 1S241 beingone of them.
Practical examples:The diagram of a power supply in figure (3.8) uses several diodes. The first four are in a single package,identified by B40C1500. This is a bridge rectifier.The LED in the circuit indicates the transformer is working. Resistor R1 is used to limit the currentthrough the LED and the brightness of the LED indicates the approximate voltage.Diodes marked 1N4002 protect the integrated circuit.Figure 5.3 below shows some other examples of diodes. The life of a globe can be increased by adding adiode as shown in 5.3a. By simply connecting it in series, the current passing through the globe is halvedand it lasts a lot longer. However the brightness is reduced and the light becomes yellow. The Diodeshould have a reverse voltage of over 400V, and a current higher than the globe. A 1N4004 or BY244 issuitable.A very simple DC voltage stabilizer for low currents can be made using 5.3c as a reference.
Fig:-5.8 - using a diode to prolong the light bulbs life span, b - stair-light LED indicator,c - voltage stabilizer, d - voltage rise indicator, e - rain noise synthesizer, f - backup supply Unstabilized voltage is marked "U", and stabilized with "UST." Voltage on the Zener diode is equal to UST, so if we want to achieve a stabilized 9V, we would use a ZPD9.1 diode. Although this stabilize has limited use it is the basis of all designs found in power supplies.
We can also devise a voltage overload detector as shown in figure. A LED indicates when a voltage is over a predefined value. When the voltage is lower than the operating voltage of the Zener, the zener acts as a high value resistor, so DC voltage on the base of the transistor is very low, and the transistor does not "turn on." When the voltage rises to equal the Zener voltage, its resistance is lowered, and transistor receives current on its base and it turns on to illuminate the LED. This example uses a 6V Zener diode, which means that the LED is illuminated when the voltage reaches that value. For other voltage values, different Zener diodes should be used. Brightness and the exact moment of illuminating the LED can be set with the value of Rx. To modify this circuit so that it signals when a voltage drops below some predefined level, theZener diode and Rx are swapped. For example, by using a 12V Zener diode, we can make a car batterylevel indicator. So, when the voltage drops below 12V, the battery is ready for recharge.Figure 5.3e shows a noise-producing circuit, which produces a rain-like sound. DC current flowingthrough diode AA121 isnt absolutely constant and this creates the noise which is amplified by thetransistor (any NPN transistor) and passed to a filter (resistor-capacitor circuit with values 33nF and100k).5.3ResistorResistors are the most commonly used component in electronics and their purpose is to create specifiedvalues of current and voltage in a circuit. A number of different resistors are shown in the photos. (Theresistors are on millimeter paper, with 1cm spacing to give some idea of the dimensions). Photo 1.1ashows some low-power resistors, while photo 1.1b shows some higher-power resistors. Resistors withpower dissipation below 5 watt (most commonly used types) are cylindrical in shape, with a wireprotruding from each end for connecting to a circuit . Resistors with power dissipation above 5 watt areshown below.
High-po resistors and rheostats power resistorsThe symbol for a resistor is shown in the following diagram (upper: American symbol, lower: Europeansymbol.) Resistor symbolsThe unit for measuring resistance is the OHM. (the Greek letter Ω - called Omega). Higher resistance valuesare represented by "k" (kilo-ohms) and M (meg ohms). For example, 120 000 Ω is represented as 120k, while 1200 000 Ω is represented as 1M2. The dot is generally omitted as it can easily be lost in the printing process. Insome circuit diagrams, a value such as 8 or 120 represents a resistance in ohms. Another common practice is touse the letter E for resistance in ohms. The letter R can also be used. For example, 120E (120R) stands for 120Ω, 1E2 stands for 1R2 etc.1.1 Carbon film resistors:This is the most general purpose, cheap resistor. Usually the tolerance of the resistance value is ±5%. Powerratings of 1/8W, 1/4W and 1/2W are frequently used.Carbon film resistors have a disadvantage; they tend to be electrically noisy. Metal film resistors arerecommended for use in analog circuits. However, I have never experienced any problems with this noise. Thephysical size of the different resistors is as follows.
Rough size Rating Thicknesspower Length (W) (mm) (mm) From the top of the photograph 1/8 23 1/8W 1/4 26 1/4 1/2 39 1/2W Fig:5.10This resistor is called a Single-In-Line(SIL) resistor network. It is made with many resistors of the same value,all in one package. One side of each resistor is connected with one side of all the other resistors inside. Oneexample of its use would be to control the current in a circuit powering many light emitting diodes (LEDs).In the photograph on the left, 8 resistors are housed in the package. Each of the leads on the package is oneresistor. The ninth lead on the left side is the common lead. The face value of the resistance is printed. ( Itdepends on the supplier. )Some resistor networks have a "4S" printed on the top of the resistor network. The 4S indicates that the packagecontains 4 independent resistors that are not wired together inside. The housing has eight leads instead of nine.The internal wiring of these typical resistor networks has been illustrated below. The size (black part) of theresistor network which I have is as follows: For the type with 9 leads, the thickness is 1.8 mm, the height 5mm,and the width 23 mm. For the types with 8 component leads, the thickness is 1.8 mm, the height 5 mm, and thewidth 20 mm. Fig:-5.11
Metal film resistors:Metal film resistors are used when a lower tolerance (more accurate value) is needed. They are much moreaccurate in value than carbon film resistors. They have about ±0.05% tolerance. They have about ±0.05%tolerance. I dont use any high tolerance resistors in my circuits. Resistors that are about ±1% are more thansufficient. Ni-Cr (Nichrome) seems to be used for the material of resistor. The metal film resistor is used forbridge circuits, filter circuits, and low-noise analog signal circuits. Rough size Rating Thicknesspower Length (W) (mm) (mm) From the top of the photograph 1/8 23 1/8W (tolerance ±1%) 1/4 26 1/4W (tolerance ±1%) 1W 13.5 (tolerance 12 ±5%) 2W (tolerance ±5%) 2515 Nonlinear resistorsResistance values detailed above are a constant and do not change if the voltage or current-flow alters. But thereare circuits that require resistors to change value with a change in temperate or light. This function may not belinear, hence the name NONLINEAR RESISTORS.There are several types of nonlinear resistors, but the most commonly used include : NTC resistors (figure a)(Negative Temperature Co-efficient) - their resistance lowers with temperature rise. PTC resistors (figure b)(Positive Temperature Co-efficient) - their resistance increases with the temperature rise. LDR resistors (figure
c) (Light Dependent Resistors) - their resistance lowers with the increase in light. VDR resistors (Voltagedependent Resistors) - their resistance critically lowers as the voltage exceeds a certain value. Symbolsrepresenting these resistors are shown below. Fig:-5.12: Nonlinear resistors - a. NTC, b. PTC, c. LDRIn amateur conditions where nonlinear resistor may not be available, it can be replaced with other components.For example, NTC resistor may be replaced with a transistor with a trimmer potentiometer, for adjusting therequired resistance value. Automobile light may play the role of PTC resistor, while LDR resistor could bereplaced with an open transistor. As an example, figure on the right shows the 2N3055, with its upper partremoved, so that light may fall upon the crystal inside.Cds Elements (LDR)light dependent resister :Some components can change resistance value by changes in the amount of light hitting them. One type is theCadmium Sulfide Photocell. (Cd) The more light that hits it, the smaller its resistance value becomes. There aremany types of these devices. They vary according to light sensitivity, size, resistance value etc.Pictured at the left is a typical CDS photocell. Its diameter is 8 mm, 4 mm high, with a cylinder form. Whenbright light is hitting it, the value is about 200 ohms, and when in the dark, the resistance value is about 2Mohms. This device is using for the head lamp illumination confirmation device of the car, for example.
Fig:-5.13 Resistor Power DissipationIf the flow of current through a resistor increases, it heats up, and if the temperature exceeds a certain criticalvalue, it can be damaged. The wattage rating of a resistor is the power it can dissipate over a long period oftime. Wattage rating is not identified on small resistors. The following diagrams show the size and wattagerating: Fig:-5.14 Resistor dimensionsMost commonly used resistors in electronic circuits have a wattage rating of 1/2W or 1/4W. There are smallerresistors (1/8W and 1/16W) and higher (1W, 2W, 5W, etc).In place of a single resistor with specified dissipation, another one with the same resistance and higher ratingmay be used, but its larger dimensions increase the space taken on a printed circuit board as well as the addedcost.
Power (in watts) can be calculated according to one of the following formulae, where U is the symbol forVoltage across the resistor (and is in Volts), I is the symbol for Current in Amps and R is the resistance inohms:For example, if the voltage across an 820W resistor is 12V, the wattage dissipated by the resistors is:A 1/4W resistor can be used.In many cases, it is not easy to determine the current or voltage across a resistor. In this case the wattagedissipated by the resistor is determined for the "worst" case. We should assume the highest possible voltageacross a resistor, i.e. the full voltage of the power supply (battery, etc).If we mark this voltage as VB, the highest dissipation is:For example, if VB=9V, the dissipation of a 220W resistor is:A 0.5W or higher wattage resistor should be used
Fig:-5.15Resistor MarkingsResistance value is marked on the resistor body. Most resistors have 4 bands. The first two bands provide thenumbers for the resistance and the third band provides the number of zeros. The fourth band indicates thetolerance. Tolerance values of 5%, 2%, and 1% are most commonly available. The following table shows thecolors used to identify resistor values: COLOR DIGIT MULTIPLIER TOLERANCE TC Silver x 0.01 ±10% Gold x 0.1 ±5% Black 0 x1 Brown 1 x 10 ±1% ±100*10-6/K Red 2 x 100 ±2% ±50*10-6/K Orange 3 x1k ±15*10-6/K Yellow 4 x 10 k ±25*10-6/K Green 5 x 100 k ±0.5% Blue 6 x1M ±0.25% ±10*10-6/K Violet 7 x 10 M ±0.1% ±5*10-6/K Grey 8 x 100 M White 9 x1G ±1*10-6/K Fig. 5.14: b. Four-band resistor, c. Five-band resistor, d. Cylindrical SMD resistor, e. Flat SMD resistor
CAPACITORS:The capacitors function is to store electricity, or electrical energy. The capacitor also functionsas a filter, passing alternating current (AC), and blocking direct current (DC). This symbol ‗F‘ isused to indicate a capacitor in a circuit diagram. The capacitor is constructed with two electrodeplates facing each other, but separated by an insulator. When DC voltage is applied to thecapacitor, an electric charge is stored on each electrode. While the capacitor is charging up,current flows. The current will stop flowing when the capacitor has fully charged.Types of Capacitor: Fig. 5.15 Types of CapacitorBreakdown voltagewhen using a capacitor, we must pay attention to the maximum voltage which can be used. Thisis the "breakdown voltage." The breakdown voltage depends on the kind of capacitor being used.We must be especially careful with electrolytic capacitors because the breakdown voltage iscomparatively low. The breakdown voltage of electrolytic capacitors is displayed as WorkingVoltage. The breakdown voltage is the voltage that when exceeded will cause the dielectric
(insulator) inside the capacitor to break down and conduct. When this happens, the failure can becatastrophic.Electrolytic Capacitors (Electrochemical type capacitors)Aluminum is used for the electrodes by using a thin oxidization membrane.Large values of capacitance can be obtained in comparison with the size of the capacitor,because the dielectric used is very thin. The most important characteristic of electrolyticcapacitors is that they have polarity. They have a positive and a negative electrode. [Polarised]This means that it is very important which way round they are connected. If the capacitor issubjected to voltage exceeding its working voltage, or if it is connected with incorrect polarity, itmay burst. It is extremely dangerous, because it can quite literally explode. Make absolutely nomistakes. Generally, in the circuit diagram, the positive side is indicated by a "+" (plus) symbol.Electrolytic capacitors range in value from about 1µF to thousands of µF. Mainly this type ofcapacitor is used as a ripple filter in a power supply circuit, or as a filter to bypass low frequencysignals, etc. Because this type of capacitor is comparatively similar to the nature of a coil inconstruction, it isnt possible to use for high-frequency circuits. (It is said that the frequencycharacteristic is bad.)The photograph on the left is an example of the different values of electrolytic capacitors inwhich the capacitance and voltage differ. Fig:-5.16 Electrolytic CapacitorsFrom the left to right:1µF (50V) [diameter 5 mm, high 12 mm]47µF (16V) [diameter 6 mm, high 5 mm]100µF (25V) [diameter 5 mm, high 11 mm]
220µF (25V) [diameter 8 mm, high 12 mm]1000µF (50V) [diameter 18 mm, high 40 mm]The size of the capacitor sometimes depends on the manufacturer. So the sizes shown here onthis page are just examples.Ceramic CapacitorsCeramic capacitors are constructed with materials such as titanium acid barium used as thedielectric. Internally, these capacitors are not constructed as a coil, so they can be used in highfrequency applications. Typically, they are used in circuits which bypass high frequency signalsto ground. These capacitors have the shape of a disk. Their capacitance is comparatively small.The capacitor on the left is a 100pF capacitor with a diameter of about 3 mm. The capacitor onthe right side is printed with 103, so 10 x 103pF becomes 0.01 µF. The diameter of the disk isabout 6 mm. Ceramic capacitors have no polarity. Ceramic capacitors should not be used foranalog circuits, because they can distort the signal. Fig:- 5.17Ceramic CapacitorsVariable Capacitors:Variable capacitors are used for adjustment etc. of frequency mainly. On the left in thephotograph is a "trimmer," which uses ceramic as the dielectric. Next to it on the right is one thatuses polyester film for the dielectric. The pictured components are meant to be mounted on aprinted circuit board.
Fig:-5.18 Variable CapacitorsWhen adjusting the value of a variable capacitor, it is advisable to be careful. One of thecomponents leads is connected to the adjustment screw of the capacitor. This means that thevalue of the capacitor can be affected by the capacitance of the screwdriver in your hand. It isbetter to use a special screwdriver to adjust these components.
5.4 Motor Driver ICs: L293/L293D and L298 L293D L298 Fig:-5.19 Fig:-5.20 The current provided by the MCU is of the order of 5mA and that required by a motor is ~500mA. Hence, motor can‘t be controlled directly by MCU and we need an interface between the MCU and the motor. A Motor Driver IC like L293D or L298 is used for this purpose which has two H-bridge drivers. Hence, each IC can drive two motors.Note that a motor driver does not amplify the current; it only acts as a switch (An H bridge isnothing but 4 switches). Fig:-5.21 Drivers are enabled in pairs, with drivers 1 and 2 being enabled by the Enable pin. When an enable input is high (logic 1 or +5V), the associated drivers are enabled and their outputs are active and in phase with their inputs.
When the enable pin is low, the output is neither high nor low (disconnected), irrespective of the input. Direction of the motor is controlled by asserting one of the inputs to motor to be high (logic 1) and the other to be low (logic 0). To move the motor in opposite direction just interchange the logic applied to the two inputs of the motors. Asserting both inputs to logic high or logic low will stop the motor. Resistance of our motors is about 26 ohms i.e. its short circuit current will be around. 0.46Amp which is below the maximum current limit. It is always better to use high capacitance (~1000μF) in the output line of a motor driver which acts as a small battery at times of current surges and hence improves battery life. Difference between L293 and L293D: Output current per channel = 1A for L293 and 600mA for L293D.
Motor Driver:H- Bridge Concept : It is an electronic circuit which enables a voltage to be applied across a load in either direction. It allows a circuit full control over a standard electric DC motor. That is, with an H- bridge, a microcontroller, logic chip, or remote control can electronically command the motor to go forward, reverse, brake, and coast. H-bridges are available as integrated circuits, or can be built from discrete components A "double pole double throw" relay can generally achieve the same electrical functionality as an H-bridge, but an H-bridge would be preferable where a smaller physical size is needed, high speed switching, low driving voltage, or where the wearing out of mechanical parts is undesirable. The term "H-bridge" is derived from the typical graphical representation of such a circuit, which is built with four switches, either solid-state (eg, L293/ L298) or mechanical (eg, relays). Fig:-5.23 Structure of an H-bridge
S1 S2 S3 S4 RESULT1 0 0 1 MOTOR ROTATE IN ONE DIRECTION0 1 1 0 MOTOR ROTATE IN OPP. DIRECTION0 0 0 0 MOTOR FREE TO RUN(COASTS)1 0 1 0 MOTOR BRAKE 0 1 0 1 MOTOR BRAKE Fig:-5.24 H-BRIDGE MOTOR DRIVER CONCEPT
5.5Sensors:5.5.1ANALOG SENSOR Fig:-5.24 Fig:-5.25The IR analog sensor consists of:Transmitter: An Infra Red emitting diodeReceiver: A Phototransistor (also referred as photodiode)It is better to keep R2 as a variac to vary the sensitivity.
The output varies from 0V to 5V depending upon the amount of IR it receives, hence the nameanalog.The output can be taken to a microcontroller either to its ADC (Analog to Digital Converter) orLM 339 can be used as a comparator.Digital IR Sensor - TSOP Sensor Fig:-5.26 TSOP 1738 Sensor is a digital IR Sensor; It is logic 1 (+5V) when IR below a threshold is falling on it and logic 0 (0V) when it receives IR above threshold. It does not respond to any stray IR, it only responds to IR falling on it at a pulse rate of 38 KHz. Hence we have a major advantage of high immunity against ambient light. No comparator is required and the range of the sensor can be varied by varying the intensity of the IR emitting diode (the variac in figure).
5.6 8870 DTMF DECODER ICThe M-8870 is a full DTMF Receiver that integrates both band split filter and decoder functionsinto a single18-pin DIP or SOIC package. Manufactured using CMOS process technology, theM-8870 offers low power consumption (35 mW max) and precise data handling. Its filter sectionuses switched capacitor technology for both the high and low group filters and for dial tonerejection. Its decoder uses digital counting techniques to detect and decode all 16 DTMF tonepairs into a 4-bit code. External component count is minimized by provision of an on-chipdifferential input amplifier, clock generator, and latched tri-state interface bus. Minimal externalcomponents required include a low-cost 3.579545 MHz color burst crystal, a timing resistor, anda timing capacitor. The M-8870-02 provides a ―power-down‖ option which, when enabled, dropsconsumption to less than 0.5 mW. The M-8870-02 can also inhibit the decoding of fourthcolumn digits Fig:-5.27Functional DescriptionM-8870 operating functions include a band split filter that separates the high and low tones of thereceived pair, and a digital decoder that verifies both the frequency and duration of the receivedtones before passing the resulting 4-bit code to the output bus.
Filter:The low and high group tones are separated by applying the dual-tone signal to the inputs of two6th order switched capacitor band pass filters with bandwidthsThat corresponds to the bands enclosing the low and high group tones. The filter alsoincorporates notches at 350 and 440 Hz, providing excellent dial tone rejection. Each filteroutput is followed by a single-order switched capacitor section that smoothes the signals prior tolimiting. Signal limiting is performed by high gaincomparators provided with hysteresis to prevent detection of unwanted low-level signals andnoise. The comparator outputs provide full-rail logic swings at the frequencies of the incomingtones. The M-8870 decoder uses a digital counting technique to determine the frequencies of thelimited tones and to verify that they correspond to standard DTMF frequencies. A complexaveraging algorithm is used to protect against tone simulation by extraneous signals (such asvoice) while tolerating small frequency variations. The algorithm ensures an optimumcombination of immunity to talk off and tolerance to interfering signals(Third tones) and noise. When the detector recognizes the simultaneous presence of two validtones (known as signal condition), it raises the Early Steering flag (Est.). Any subsequent loss ofsignal condition will cause Est. to fall.
5.7RELAYS STRIP OUT N/C OUT N/O SPRING 230V P MAGNETA relay is an electrically operated switch. The relay contacts can be made to operate inthe pre-arranged fashion. For instance, normally open contacts close and normally closedcontacts open. In electromagnetic relays, the contacts however complex they might be,they have only two position i.e. OPEN and CLOSED, whereas in case of electromagneticswitches, the contacts can have multiple positions.
NEED FOR THE USE OF RELAYThe reason behind using relay for switching loads is to provide complete electricalisolation. The means that there is no electrical connection between the driving circuitsand the driven circuits. The driving circuit may be low voltage operated low powercircuits that control several kilowatts of power. In our circuit where a high fan could beswitched on or off depending upon the output from the telephone.Since the relay circuit operated on a low voltage, the controlling circuit is quite safe. Inan electromagnetic relay the armature is pulled by a magnetic force only. There is noelectrical connection between the coil of a relay and the switching contacts of the relay. Ifthere are more than one contact they all are electrically isolated from each other bymounting them on insulating plates and washers. Hence they can be wired to controldifferent circuits independently.Some of the popular contacts forms are described below: 1. Electromagnetic relay 2. Power Relay. 3. Time Delay Relay. 4. Latching Relay. 5. Crystal Can Relay. 6. Co-axial Relay.1. Electromagnetic relay:An electromagnetic relay in its simplest form consists of a coil, a DC current passingthrough which produces a magnetic field. This magnetic field attracts an armature, which