A Project Report On
ENGINE OIL PURITY INDICTOR Submitted in partial fulfillment of requirements for award of
Bachelor of technology In
ELECTRONICS AND COMMUNICATION ENGINEERING SUBMITTED BY
A.ANURAG A.ANURA G SHARMA
08R01A0406
CH.NAGA SAI SRUJAN
08R01A0413
CH.VAMSHI KRISHNA
08R01A0414
Under the guidance of
SHAIK BASHA Assistant professor,
Department of Electronics and Communication Engineering,
CMR Institute of Technology (Affiliated to JNTU, HYD, AP) Kandlakoya, Kandl akoya, Medchal, Medchal, A.P . (2008-12)
ABSTRACT
Purity in engine oil ensures proper working of engine. Degradation in purity will gradually decrease performance of vehicle and further degradation may completely damage engine.To avoid this, engine oil is changed in particular interval of kilometer. Even in this case some times it happens to change engine oil after degrading in its quality. This situation can be avoided if we can change engine oil basins on its quality rather than kilometers travelled and arbitrary check engine oil purity indication system dynamically. This project involves optical sensor( IR-PHOTO DIODE pair) to indicate purity level comparator for setting different levels of purity by user to get indicated on purity level. Micro controller(AT89C2051) is used to collect sensor data an indicate it through LEDs for level of purity
INDEX LIST OF FIGURES LIST OF TABLES
CONTENT
PAGE
NO CHAPTER 1: INTRODUCTION CHAPTER 2: POWER SUPPLY 2.1
9V LITHIUM LITHIU M BATTERY 2.1.1 2.1.2 2.1.3
2.2
RECTIFIERS 2.2.1 2.2.2 2.2.3 2.2.4 2.2.4.1
2.3
CONNECTERS TECHNICAL SPECIFICATIONS FEATURES OF LITHIUM BATTERY
HALF WAVE RECTIFICATION FULL WAVE RECTIFICATION PEAK LOSS BRIDGE RECTIFIER CURRENT FLOW IN BRIDGE RECTIFIER
FILTERS 2.3.1 2.3.1.1 2.3.1.2 2.3.2 2.3.2.1
PASSIVE FILTERS SINGLE ELEMENT TYPES MULTIPLE ELEMENT TYPES ACTIVE FILTERS DESIGN OF ACTIVE FILTERS
2.4
VOLTAGE REGULATORS 2.4.1 ADVANTAGES 2.4.2 DISADVANTAGES 2.4.3 INDIVIDUAL INDIVIDU AL DEVICES IN THE SERIES
CHAPTER 3: PIC MICROCONTROLLER MICROCONTROLLER 3.1 3.2
3.3 3.4
INTRODUCTION TO MICROCONTROLLER FEATURES OF PIC 16F73 3.2.1 HIGH PERFORMANCE PERFORMANC E RISC CPU 3.2.2 SPECIAL MICROCONTROLLE MICROCONTR OLLER R FEATURES 3.2.3 PERIPHERAL FEATURES 3.2.4 CMOS TECHNOLOGY PIN DIAGRAM 3.3.1 PIC16F73 PINOUT DESCRIPTION DESCRIPTION OF CONTROLLER CONTRO LLER 3.4.1 POWER-ON POWER-O N RESET (POR) 3.4.2 POWER-UP TIMER (PWRT) 3.4.3 OSCILLATOR START-UP START-U P TIMER (OST) 3.4.4 BROWN-OUT BROWN-O UT RESET (BOR) 3.4.5 WATCHDOG TIMER 3.4.6 MEMORY ORGANIZATION ORGANIZATIO N 3.4.6.1 3.4.6.1 PROGRAM MEMORY ORGANIZATION 3.4.6.2 DATA MEMORY ORGANIZATION ORGANIZATIO N 3.4.7 STATUS REGISTER 3.4.8 I/O PORTS 3.4.8.1 PORTA AND THE TRISA REGISTER 3.4.8.2 PORTB AND THE TRISB REGISTER 3.4.8.3 PORTC AND THE TRISC REGISTER 3.4.9 TIMER0 MODULE 3.4.10 TIMER1 MODULE
INTRODUCTION
Nowadays, human has become too busy and he is unable to find time even to switch the lights wherever not necessary. This can be seen more effectively in the case of street lights. The present system is like, the street lights will be switched on in the evening before the sun sets and they are switched off the next day morning after there is sufficient light on the roads. But the actual timings for these street lights to be switched on are when there is absolute darkness. With this, the power will be wasted up to some extent. This project gives the best solution for electrical power wastage. Also the manual operation of the lighting system is completely eliminated. The Project Embedded Automatic Street light control with LDR Interfacing using PIC 16F73 controller is an interesting project which uses PIC 16F73 controller as its brain. This project is very useful for commercial sign boards, advertising boards, street lights for automation lighting system. This system switches on the lights only in darkness. As it works with LDR sensor, no programming of timings and battery back-up is required. This is a simple, fit and forget system. This project uses regulated 5V, 500mA power supply. Unregulated 9V DC is used. 7805 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the AC output of 9V battery. The original PIC was built to be used with General Instruments new 16bit CPU, the CP1600. While generally a good CPU, the CP1600 had poor I/O performance, and the 8-bit PIC was developed in 1975 to improve performance of the overall system by offloading I/O tasks from the CPU. The
PIC used simple microcode stored in ROM to perform its tasks, and although the term was not used at the time, it shares some common features with RISC designs. In 1985, General Instruments spun off their microelectronics division and the new ownership cancelled almost everything which by this time was mostly out of date. The PIC, however, was upgraded with internal EPROM to produce a programmable channel controller and today a huge variety of PICs are available with various on-board peripherals (serial communication modules, UARTs, motor control kernels, etc.) and program memory from 256 words to 64k words and more (a word is one assembly language instruction, varying from 12, 14 or 16 bits depending on the specific PIC micro family). PIC and PIC micro are registered trademarks of Microchip Technology. It is generally thought that PIC stands for Peripheral Interface Controller, although General Instruments original acronym for the initial PIC 1640 and PIC 1650 devices was Programmable Interface Controller. A microcontroller (some times abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications; in contrast to the microprocessors used in the personal computers or other general purpose applications.
BLOCK DIAGRAM OF ENGINE OIL PURITY INDICATING SYSTEM
Power Supply
T
LCD
Oscillator
IR sensor
U
PIC
B
16F73
E
LED indictor
COMPONENTS: The major building blocks of this project are:1. Power Supply 2. LED Indicator 3. PIC 16F73 4. Oscillator 5. IR Sensor (Infrared Sensor) 6. High Power LED 7. LCD 8. TRANSPARENT TUBE
High Power LED
The main technical performance comparison between the LED street light and conventional road light: Description
LED street light
Traditional street light
Methods
Electric network
Electric network
Light source
LED
High Pressure Sodium Lamp
Color Temperature
3000 8000K
2700 5000K
Lifespan
50,000 hours
3,000 hours
Power
144W (energy
400W
saving>60%) Actual power
160W
500W
>0.35, Good
>0.40, Excellent
Illuminated area
Radius>15M, Good
Radius>15M, Excellent
Glare control
maximum light
maximum light
intensity<65 degree,
intensity<65 degree,
Excellent
Good
Good fog penetrating
Bad fog penetrating
ability
ability
Ballast
No ballast
Need ballast
Environmental
Flicker-free, Flicker-free , cold light
Heating, result yellow
source
shell
consumption Illumination uniformity
Fireproof rating
ADVANTAGES & APPLICATIONS:
1. High-power LED street lamp with long lifespan. 2. The quality of LED chip, values of light attenuation. 3. LED package quality, Consistency and reliability. LED is cold light source, but the LED semiconductor itself generates heat, so good heat dissipation is the condition for LED lighting. 4. The lifespan of power supply and constant current drive. 5. High energy saving efficiency. 6. It has the features of point light source, high brightness, and narrowbeam output and so on. 7. Have considerable space for technology improvement. 8. Reasonable optical light.
POWER SUPPLY 2.1 BATTERY An electrical battery is one or more electrochemical cells that convert stored chemical energy into electrical energy. A nine-volt battery, also called a PP3 battery, is shaped as a rounded rectangular prism and has a nominal output of nine volts. Its nominal dimensions are 48 mm × 25 mm × 15 mm. 9V batteries are commonly used in pocket transistor radios, smoke detectors, carbon monoxide alarms, guitar effect units, and radio-controlled vehicle controllers. They are also used as backup power to keep the time in digital clocks and alarm clocks. Nine-volt alkaline batteries are often constructed of six individual 1.5V LR61 cells enclosed in a wrapper. These cells are sometimes confused with standard LR8D425 AAAA cells and can be used in their place for some devices, even though they are 3.5 mm shorter.
2.1.1 CONNECTORS The connector (snap) consists of two connectors: one smaller circular (male) and one larger, typically either hexagonal or octagonal (female). The connectors on the battery are the same as on the connector itself, the smaller one connects connects to the larger one and vice versa .
2.1.2 TECHNICAL SPECIFICATIONS The battery has both the positive and negative terminals on one end. The negative terminal is fashioned into a snap fitting which mechanically and electrically connects to a mating terminal on the power connector. The power connector has a similar snap fitting on its positive terminal which mates to the battery. This makes battery polarization obvious since mechanical connection
is only possible in one configuration. configuration. The clips on the nine -volt battery can be used to connect several nine-volt batteries in series. One problem with this style of connection is that it is very easy to connect two batteries together in a short circuit, which quickly discharges both batteries, generating heat and possibly a fire. Multiple nine volt batteries can be snapped together in series to create higher voltage. Inside a PP3 there are six cells, either cylindrical alkaline or flat carbonzinc type, connected in series. Some brands use welded tabs internally to attach to the cells, others press foil strips against the ends of the cells. Rechargeable NiCd and NiMH batteries have various numbers of 1.2 volt cells. Lithium versions use three 3.2 V cells - there is a rechargeable lithium polymer version. There is also a Hybrid NiMH version that has a very low selfdischarge rate (85% of capacity after one year of storage). Formerly, mercury batteries were made in this size. They had higher capacity than carbon-zinc types, a nominal voltage of 8.4 volts, and very stable voltage output. Once used in photographic and measuring instruments or long life applications, they are now unavailable due to environmental restrictions. Battery Life Comparison - Ultralife lithium versus other common 9V battery types
2.1.3 FEATURES OF LITHIUM BATTERY
1.
Replaces standard 9V radio battery size.
2.
Excellent for long life in smoke detectors.
3.
9 Volt, 1200 MilliAmpHour capacity.
4.
Twice the power capacity of alkaline, and can last up to four times longer.
5.
Extended shelf life of up to ten years.
6.
Slightly smaller size than standard 9V, because it has no metal outer jacket.
7.
1/3 lighter in weight than an alkaline.
8.
Maximum unit weight is 33.8 grams.
9.
Superior hot and cold performance.
10.
Operating temperature range: -20° to +60°C (-5° to +140°F).
11.
Storage temperature range: -40° to +60°C (-40° to +140°F).
.
2.2 RECTIFIERS A rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), which is in only one direction, a process known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid state diodes, silicon-controlled rectifiers, vacuum tube diodes, mercury arc valves, and other components.
A device which performs the opposite function (converting DC to AC) is known as an inverter . When only one diode is used to rectify AC (by blocking the negative or positive portion of the waveform), the difference between the term diode and the term rectifier is merely one of usage, i.e., the term rectifier describes a diode that is being used to convert AC to DC. Almost all low power rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting AC to DC than is possible with only one diode. Before the development of silicon semiconductor rectifiers, vacuum tube diodes and copper (I) oxide or selenium rectifier stacks were used. High power rectifiers, such as are used in high-voltage direct current power transmission, now uniformly employ silicon semiconductor devices of various types. These are not diodes (two-layer devices), but rather thyristors and certain more-complicated solid-state switches which effectively function as diodes to pass current in only one direction. Early radio receivers, called crystal radios, used a "cat's whisker" of fine wire pressing on a crystal of galena (lead sulfide) to serve as a point-contact rectifier or "crystal detector". Rectification may occasionally serve in roles other than to generate direct current per se. For example, in gas heating systems flame rectification is used to detect presence of flame. Two metal electrodes in the outer layer of the flame provide a current path, and rectification of an applied alternating voltage will happen in the plasma, but only while the flame is present to generate it.
2.2.1
HALF WAVE RECTIFICATION In half wave rectification, either the positive or negative half of the AC
wave is passed, while the other half is blocked. Because only one half of the input waveform reaches the output, it is very inefficient if used for power transfer. Half-wave rectification recti fication can be achieved with a single diode in a one phase supply, or with three diodes in a three-phase supply.
The The output DC voltage oltage of a half wave wa ve rectifi ectifie er can be calc alculate ulate following two ide ideal e uations uations ¡
2.2.2 F
W A
¥
£
¤
¤
¦
with the the
¢
RECTIF RECTI FIC A ATION TION
A fullfull-wave wave rectifi ectifie er conve onvert rtss the the whole whole of the the input wave waveform form to one one of cons onstant polarity polarity (pos (positive itive or negative gative at its its output. Fullull-wave wave rectifi ectificcation §
conve onvert rtss both polarities polarities of the the input wave waveform form to DC (direc (directt curre urrent), and is is more more effic fficient. Howeve However, r, in a circ ircuit with a non-ce non-cent nte er tappe tapped trans transforme former, four diodes diodes are are re uire uired ins in stead of the the one one need eeded for half half -wave wave rectifi ectificcation. ¨
Four diodes diodes arrange arrang ed this this way way are are calle alled a diode diode bridge bridge or bridge bridge rectifi ectifie er.
Grae Graetz bridge bridge rectifi ectifie er: a fullfull-wave wave rectifi ectifie er us using 4 diodes diod es.
For singleingle-pha phase se AC, if the the trans transforme former is cent cente er -tappe tapped, the then two
diodes diodes bac bac -toto-bac bac (i.e (i.e. anodesanodes-to to--anode anode or cathodeathode-to to-c -cathod athode e) can form a ©
©
fullfull-wave wave rectifi ectifie er. Twice Twice as many many windings windings are are re uire uired on the the trans transforme former
secondar secondary y to obtain the the same ame output voltage oltage compare ompared to the the bridge bridge rectifi ectifie er above above..
Fullull-wave wave rectifi ectifie er us using a cent cente er tap trans transforme former and 2 diodes diodes
A ver very common vacuum tube tube rectifi ectifie er configuration containe ontained one one cathode athode and twin anodes anodes ins inside ide a single ingle envelop velope e in this this way way, the th e two diodes diodes
re uire uired only only one one vacuum tube tube. The The 5 4 and 5 3 were popular e amples amples of
this this configuration.
For threethree-pha phase se AC, six diodes diodes are are used. sed. Ty Typic pically ally the there are are three three pairs pairs of diodes diodes,, each pair, though, is i s not the the same ame kind of double double diode diode that would be used sed for a full wave wa ve singleingle-pha phase se rectifi ectifie er. Ins Instead the the pairs pairs are are in seri series es (anode (anode to cathode athode). Typic pically ally , comme ommercially ially available ailable double double diodes diodes have have four terminals rminals so the the user ser can configure onfigure the them as singleingle-pha phase se split supply upply use, se, for half a bridge bridge, or for threethr ee-pha phase se use. se. Mos Most dev deviices that ge generate rate alte alternating curre urrent (s (such dev deviices are are calle alled alte alternators rnator s) generate rate threethree-pha phase se AC. For example xample, an automobile automobile alte alternator
has has six diodes diodes ins inside ide it to func function as as a fullfull-wave wave rectifi ec tifie er for batte battery charging applic applications ations. The The averag verage e and rootroot-mean-s an-s uare uare output voltages oltages of an ide ideal single ingle
phase phase full wave wave rectifi ectifie er can be be calc alculate ulated as as:
Whe Where: the averag verage e or DC output voltage oltage, Vd V v - the
the peak value alue of half wave wa ve,, Vp - the V
s
- the the rootroot-mean-s an-s uare uare value alue of output voltage oltage.
2.2.3
PE AK AK LO LOSS SS An as aspect ect of mos most rec r ectifi tificcation is is a loss loss from the the peak input voltage oltage to
the the peak output voltage oltage, cause aused d by the the builtbuilt -in voltage oltage drop ac across ro ss the the diodes diodes (around 0.7 V for ordinary ordinar y silic ilicon p-n-jun -juncction diodes diodes and 0.3 V for Schottk Sc hottky y diodes diodes). ). Half -wave wave rectifi ectificcation and fullfull-wave wave rectifi ectificcation us using two separat separate e secondar secondary y s will have have a pe peak voltage oltage loss loss of one one diode diode drop. Bridge ridge rectifi ec tificcation !
will have have a loss loss of two diode diode drops drops. This This may may represe present nt signific ignificant powe power loss loss in ver very low voltage oltage supplies upplies.. In addition, the the diodes diodes will not conduc onduct below this this voltage oltage, so the the circ ircuit is is only only pass passing ing curre urrent through for a portion of e of each half cycl cyc le, caus ausing short segm segme ents nts of ze zero voltage oltage to appe appear be betwee tween n each "hump".
2.2.4
BRI RID D E RECTIF RECTIFIER "
The The Bridge ridge rectifi ectifie er is a circ ircuit, whic which conve onvert rtss an ac voltage oltage to dc voltage oltage using both half cycl cyc les of the the input ac ac voltage oltage. The The Bridge ridge rectifi ectifie er circ ircuit is is shown in the the figure figure. The The circ ircuit has has four diodes diodes connec onnectted to form a bridge bridge. The The ac input voltage oltage is applie applied to the the diagonally diagonally oppos opposite ite ends nds of the the bridge bridge. The The load res resiistance tance is connec onnectted betwee tween n the the othe other two ends nds of the the
bridge.
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally.
Bridge Rectifier, RC Filter
Bridge Rectifier, LC Filter
2.2. .1 #
CURRENT FLOW IN BRIDGE RECTIFIER
For both positive and negative swings of the transformer, there is a forward path through the diode bridge. Both conduction paths cause current to flow in the same direction through the load resistor, accomplishing fullwave rectification .
While one set of diodes is forward biased, the other set is reverse biased and effectively eliminated from the circuit.
2.
FIL ILT TERS: Electronic
filters
are
electronic
circuits
which
perform
signal
processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both. Electronic filters can be: 1. Passive or Active 2. Analog or Digital 3. High-pass, Low-pass, Band pass, Band-reject (Band reject; Notch), or Allpass. 4. Discrete-time (Sampled) or Continuous-time 5. Linear or Non-linear 6. Infinite Impulse Response (IIR type) or Finite Impulse Response (FIR type) The most common types of electronic filters are linear filters, regardless of other aspects of their design. The oldest forms of electronic filters are passive analog linear filters,
constructed using only resistors and capacitors or resistors and inductors. These are known as RC and RL single-pole filters respectively. More complex multi-pole LC filters have also existed for many years, and their operation is well understood. Hybrid filters are also possible, typically involving a combination of analog amplifiers with mechanical resonators or delay lines. Other devices such as CCD delay lines have also been used as discrete -time filters. With the availability of digital signal processing, active digital filters have become common.
2. .1 PASSIVE FILTERS $
A passive filter is a kind of electronic filter that is made only from passive elements in contrast to an active filter, it does not require an external power source (beyond the signal). Since most filters are linear, in most cases, passive filters are composed of just the four basic linear elements resistors, capacitors, inductors, and transformers. More complex passive filters may involve nonlinear elements, or more complex linear elements, such as transmission lines.
Television signal splitter consisting of a passive high-pass filter (left) and a passive low-pass filter (right). (right). The antenna is connected to the screw terminals to the left of center
A passive filter has several advantages over an active filter: 1. Guaranteed stability 2. Passive filters scale better to large signals (tens of amperes, hundreds of
volts), where active devices are often impractical 3. No power consumption. 4. May be less expensive in discrete designs (unless la rge coils are required) 5. For linear filters, may be, more linear than filters including active (and therefore non-linear) elements, depending on components required. They are commonly used in speaker crossover design (due to the moderately large voltages and currents, and the lack of easy access to power), filters in power distribution networks (due to the large voltages and currents), power supply bypassing (due to low cost, and in some cases, power requirements), as well as a variety of discrete and home brew circuits (for lowcost and simplicity). Passive filters are uncommon in monolithic integrated circuit design, where active devices are inexpensive compared to resistors and capacitors, and inductors are prohibitively expensive. Passive filters are still found, however, in hybrid integrated circuits. Indeed, it may be the desire to incorporate a passive filter that leads the designer to use the hybrid format. Passive implementations of linear filters are based on combinations of resistors (R), inductors (L) and capacitors (C). These types are collectively known as passive filters, because they do not depend upon an external power supply and they do not contain active components such as transistors. Inductors block high-frequency signals and conduct low-frequency signals, while capacitors do the reverse. A filter in which the signal passes through an inductor, or in which a capacitor provides a path to ground, presents less attenuation to low-frequency signals than high-frequency signals and is a low-pass filter. If the signal passes through a capacitor, or has a path to ground through an inductor, then the filter presents less attenuation to highfrequency signals than low-frequency signals and is a high-pass filter. Resistors on their own have no frequency-selective properties, but are added to inductors and capacitors to determine the time-constants of the circuit, and therefore the frequencies to which it responds. The inductors and capacitors are the reactive elements of the filter. The number of elements determines the order of the filter. In this context, an LC tuned circuit being used in a band-pass or band-stop filter is considered a
single ingle element even even though it cons onsists of two compone omponents nts. At high fre fre uencies (above (above about 100 MHz), some ometimes times the the induc inductors tors %
cons onsist of single ingle loops loops or strips trips of sheet eet metal, and the the capac apacitors itor s cons onsist of ad ja jacent cent strips trips of metal. These These induc inductive tive or capac apacitive itive pieces pieces of metal are are calle alled stubs tubs.
2.3. . &
&
SINGLE ELEMENT TYP TY PES The The simples implestt pass passiive filte filters, RC and RL filte filters, inc include lude only only one one reactive tive
element, except cept hybrid LC filte filter whic which is charac haracterize riz ed by induc inductance tance and capac apacitance itance inte integrate grated in one one element.
L-F LFILTER
An L filte filter cons onsists of two re r eactive tive elements nts, one one in seri series es and one one in paralle parallel.
A lowlow-pass pass electroni ectronicc filte filter re realize alized by b y an RC circ ircuit
T A AN ND FILTER ILTERS S Capac Capacitoritor-input filte filter
LowLow-pass pass filte filter
2.3. .2 MULTIP MULTIPLE ELEMENT TYP TY PES '
Multiple Multiple element filte filters are are usually ually cons onstruc tru cted as a ladde ladder network. These These can be seen seen as a continuation of the the L, T and des d esign ignss of filte filters. More More elements nts are are need eeded whe when it is is desir esire ed to improve improve some ome parame parameter of the the filte filter such as as stoptop-band rejec rejection tion or slope lope of trans transition from passpa ss-band band to stoptopband.
2.3. .3.2 2 A ACTIVE CTIVE FILTER ILTERS S An active tive filte filter is a type of analog electroni ectronicc filte filter, dis distinguis tinguished by the the use of one one or more more active tive compone omponents nts i.e i.e. voltage oltage amplifie amplifiers or buff er amplifie amplifiers. Typic pically ally this this will be be a vacuum tube tube, or solid-s olid-stat tate e (trans (transistor or ope operational amplifie amplifier). Active tive filte filters have have three three main adv advantages antages over ver pass pa ssiive filte filters: 1. Induc Inductors tor s can be be avoide oided. Without the them, pass passiive filte filters cannot obtain a high Q (low damping), but induc inductors tors are are ofte often large large and expe xpensive (at low fre fre uencies), es ), may may have have signific ignificant inte internal res resiistance tance,, and may may pi ck (
up surrounding electromagnetic signals. 2. The shape of the response, the Q (quality factor), and the tuned frequency can often be set easily by varying resistors, in some filters one parameter can be adjusted without affecting the others. Variable inductances for low-frequency filters are not practical. 3. The amplifier powering the filter can be used to buffer the filter from the electronic components it drives or is fed from variations in which could otherwise significantly affect the shape of the frequency response. Active filter circuit configurations (electronic filter topology) include: 1. Sallen and Key, and VCVS filters (low dependency on accuracy of the components) 2. State variable and biquadratic filters 3. Dual Amplifier Band pass (DABP) 4. Wien notch 5. Multiple Feedback Filter 6. Fliege (lowest component count for 2 op amp but with good controllability over frequency and type) 7. Akerberg Mossberg (one of the topologies that offer complete and independent control over gain, frequency, and type) All the varieties of passive filters can also be found in active filters. Some of them are: 1. High-pass filters attenuation of frequencies below their cut-off points. 2. Low-pass filters attenuation of frequencies above their cut-off points. 3. Band-pass filters attenuation of frequencies both above and below those they allow to pass. 4. Notch filters attenuation of certain frequencies while allowing all others to pass. Combinations are possible, such as notch and high-pass (in a rumble filter where most of the offending rumble comes from a particular frequency). Another example is elliptic filters. 2. .2.1 )
DESIGN OF ACTIVE FILTE FILTERS RS
To design filters, the specifications that need to be established include: y
y
y
The range of desired frequencies (the pass band) together with the shape of the frequency response. This indicates the variety of filter and the center or corner frequencies. Input and output impedance requirements. These limit the circuit topologies available; for example, most, but not all active filter topologies provide a buffered (low impedance) output. However, remember that the internal output impedance of operational amplifiers, if used, may rise markedly at high frequencies and reduce the attenuation from that expected. Be aware that some high -pass filter topologies present the input with almost a short circuit to high frequencies. The degree to which unwanted signals should be rejected. In the case of narrow-band band pass filters, the Q determines the -3dB bandwidth but also the degree of rejection of frequencies far removed from the center frequency; if these two requirements are in conflict then a staggered-tuning band pass filter may be needed. For notch filters, the degree to which unwanted signals at the notch frequency must be rejected determines the accuracy of the components, but not the Q, which is governed by desired steepness of the notch, i.e. the bandwidth around the notch before attenuation becomes small. For high-pass and low-pass (as well as band-pass filters far from the center frequency), the required rejection may determine the slope of attenuation needed, and thus the "order" of the filter. A second-order all-pole filter gives an ultimate slope of about 12 dB per octave (40dB/decade), but the slope close to the corner frequency is much less, sometimes necessitating a notch be added to the filter. The allowable "ripple" (variation from a flat response, in decibels) within the pass band of high-pass and low-pass filters, along with the shape of the frequency response curve near the corner frequency, determine the damping factor (reciprocal of Q). This also affects the phase response, and the time response to a square-wave input. Several important response shapes (damping factors) have well-known names: Chebyshev filter slight peaking/ripple in the pass band before the corner; Q>0.7071 for 2nd-order filters Butterworth filter flattest amplitude response; Q=0.7071 for o
o
o
y
o
o
o
2ndnd-orde order filte filters Linkwitz Ril Riley ey filte filter desirabl es irable e prope properties rties for audio cross rosso over ve r applic applications ations Q = Q = 0.5 (critic ritically ally dampe damped) Paynte nter or trans tran sitional Thomps Thompson-B on-Butt utte erworth or "c " compromise ompromise"" Bessel; Q =0. =0.639 for 2ndfilte filter fas faster fallfall-off than Bessel; nd -orde order filte filters Bessel Bessel filte filter best est timetime-d delay lay, best est over ve rshoot res respon ponse se;; Q =0. =0.577 for 2ndnd-orde order filte filters Elliptic lliptic filte filter or Caue Cauer filte filter add a notc notch (or "ze "zero") ju just outs outside ide the the pass pass band, to give give a muc mu ch gre greate ater slope lope in this this region than the the combination of orde order and damping fac factor without the the notc notch. 0
o
o
o
Active tive filte filters are are imple implemente nted using a combination of pass passiive and active tive (amplif ying) compone omponents nts, and re re uire uire an outs outside ide powe power source ource.. 1
Ope Operational amplifie amplifiers are are fre fre uently ntly used sed in ac a ctive tive filte filter design esignss. These These can 1
have have high Q fac fa ctor, and can achieve hieve resonan esonance ce without the the use of induc inductors tors. Howeve However, r, the their uppe upper fre fre uency limit is is limite limited by the the bandwidth of the the 1
amplifie amplifiers used. sed. Digital signal process processing ing allows allow s the the ine inexpe xpensive cons onstruc tru ction of a wide wide varie ariety of filte filters. Th T he signal is is sample ampled and an analog - toto-digital conve onvert rte er turns turns the the signal into a stre tream of numbe numbers. A compute omputer program running on a CPU or a specializ ec ialize ed DS D SP (or less less ofte often running on a hardware hardwar e imple implementation of the the algorithm) calc alculates ulates an output numbe number stre tream. This This output can be conve onvert rte ed to a signal by by pass passing ing it through a digitaldigital -toto-analog conve onvert rte er. The There are are proble problems with noise noise introduce introduced d by the the conve onverrsions ion s, but these these can be controlle ontrolled and limite limited for many many useful seful filte filters. Due Due to the the sampling inv inv olve olved, d, the the input signal mus must be be of limite limited fre fre uency conte ontent or alias alia sing will occ occur. ur. 1
The The trans transf er func function to that of the the input signal
With
of a filte filter is i s the the ratio of the the output signal as as a func function of the the comple omplex fre fre uency: cy : 1
.
The The trans transf er func function of all line linear time time -inv invariant filte filters, whe when
constructed of discrete components, will be the ratio of two polynomials in, i.e. a rational function of. The order of the transfer function will be the highest power of encountered in either the numerator or the denominator.
2.4
VOLTAGE REGULATOR
A voltage regulator is an electrical regulator designed to automatically maintain maintain a constant voltage level. level. A voltage regulator regulator may be a simple "feed forward" design or may include negative feedback control loops. It may use an electromechanical mechanism, or electronic components. Depending on the design, it may be used to regulate one or more AC or DC voltages. voltage s. Electronic voltage regulators are found in devices such as computer power supplies where they stabilize the DC voltages used by the processor and other elements. In automobile alternators and central power station generator plants, voltage regulators control the output of the plant. In an electric power distribution system, voltage regulators may be installed at a substation or along distribution lines so that all customers receive steady vol tage independent of how much power is drawn from the line.
AN ASSORTMENT OF 78XX ICS: The 78xx (sometimes LM78xx) is a family of self-contained fixed linear voltage regulator integrated circuits. The 78xx family is commonly used in electronic circuits circuit s requiring a regulated power supply due to their ease -of-use and low cost. For ICs within the family, the xx is replaced with two digits,
indicating the output voltage (for example, the 7805 has a 5 volt output, while the 7812 produces 12 volts). The 78xx lines are positive voltage regulators: they produce a voltage that is positive relative to a common ground. There is a related line of 79xx devices which are complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to provide positive and negative supply voltages in the same circuit. 78xx ICs have three terminals and are commonly found in the TO220 form factor, although smaller surface-mount and larger TO3 packages are available. These devices support an input voltage anywhere from a couple of volts over the intended output voltage, up to a maximum of 35 or 40 volts, and typically provide 1 or 1.5 amps of current (though smaller or larger packages may have a lower or higher current rating).
2. .1 2
ADVANTAGES
1. 78xx series ICs do not require additional components to provide a constant, regulated source of power, making them easy to use, as well as economical and efficient uses of space. Other voltage regulators may require additional components to set the output voltage level, or to assist in the regulation process. Some other designs (such as a switching power
supply)
may
need
substantial
engineering
expertise
to
implement. 2. 78xx series ICs have built-in protection against a circuit drawing too much power. They have protection against against overheating and short circuits, making them quite robust in most applications. In some cases, the current-limiting features of the 78xx devices can provide protection not only for the 78xx itself, but also for other parts of the circuit.
2. .2 DISADVANTAGES 3
1. The input voltage must always be higher than the output voltage by some minimum amount (typically 2 volts). This can make these devices unsuitable for powering some devices from certain types of power sources (for example, powering a circuit that requires 5 volts using 6-volt batteries will not work using a 7805).
2. As they are based on a linear regulator design, the input current required is always the same as the output current. As the input voltage must always be higher than the output voltage, this means that the total power (voltage multiplied by current) going into the 78xx will be more than the output power provided. The extra input power is dissipated as heat. This means both that for some applications an adequate heat sink must be provided, and also that a (often substantial) portion of the input power is wasted during the process, rendering them less efficient than some other types of power supplies. When the input voltage is significantly higher than the regulated output voltage (for example, powering a 7805 using a 24 volt power source), this inefficiency can be a significant issue. 3. Even in larger packages, 78xx integrated circuits cannot supply as much power as many designs which use discrete components, and are generally inappropriate for applications requiring more than a few amps of current.
2. . 4
5
INDIVIDUAL DEVICES IN THE SERIES There are common configurations for 78xx ICs, including 7805 (5 volt),
7806 (6 volt), 7808 (8 volt), 7809 (9 volt), 7810 (10 volt), 7812 (12 volt), 7815 (15 volt), 7818 (18 volt), and 7824 (24 volt) versions. The 7805 is common, as its regulated 5 volt supply provides a convenient power source for most TTL components. Less common are lower-power versions such as the LM78Mxx series (500mA) and LM78Lxx series (100mA) from National Semiconductor. Some devices provide slightly different voltages than usual, such as the LM78L62 (6.2 volts) and LM78L82 (8.2 volts).
PIC MICROC M ICROCONTROLLER ONTROLLER .1 INTRODUCTION INTRODUCTION TO MICROCONTROLLER Looking back into the history of microcomputers, one would first come across the development of microprocessor i.e. the processing element, and later on the peripheral devices. The three basic elements the CPU, I/O devices and memory have developed in distinct directions. While the CPU has been the proprietary item, the memory devices fall into general purpose category and I/O devices may be grouped somewhere in between. A microcontroller is a computer on chip device. The design incorporates all off the features found in microprocessor CPU, ALU, PC, SP and registers. It also has added the other features needed to make a complete computer like ROM, RAM, parallel I/O, Serial I/O, counters and clock circuits. The device is manufactured by Microchip Company. It consists of three timers/counters,
two
8-bit,
one
16-bit.
It
also
includes
two
serial
communication ports, Universal Synchronous Receive- Transmit (USART), Synchronous Serial Port (SSP). PIC16f73 is a powerful microcontroller which provides which provides a highly flexible and cost-effective solution to many embedded control applications. 3.2
FEATURES OF PIC16F7 PIC16 F73
3.2.1
HIGH PERFORMANCE PERFORM ANCE RISC RISC CPU
1.
Only 35 single word instructions
2.
All single cycle instructions except for program branches which are two-cycle
3.
Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
4.
Up to 4K x 14 words of FLASH Program Memory, Up to 192 bytes of Data Memory
5.
Pin out compatible to the PIC16C72B, PIC16F872
6.
Interrupt capability (up to 11 sources)
7.
Eight level deep hardware stack
8.
Direct, Indirect and Relative Addressing modes
9.
Processor read access to program memory
3.2.2
SPECIAL MICROCONTROLLER FEATURES 1. Power-on Reset (POR) 2. Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) 3. Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation 4. Programmable code protection 5. Power saving SLEEP mode 6. Selectable oscillator options 7. In-Circuit Serial Programming (ICSP) via two pins
3.2.3
PERIPHERAL FEATURES
i. Timer0: 8-bit timer/counter with 8-bit prescaler ii. Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external crystal/clock iii. Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler iv. Two Capture, Compare, PWM modules 1. Capture is 16-bit, max. Resolution is 12.5 ns 2. Compare is 16-bit, max. Resolution is 200 ns 3. PWM max. Resolution is 10-bit v. 8-bit, up to 8-channel Analog-to-Digital converter vi. Synchronous Serial Port (SSP) with SPI
2 TM
(Master mode) and I C
(Slave) vii. Universal Synchronous Asynchronous Receiver Transmitter (USART) viii. Brown-out detection circuitry for Brown-out Reset (BOR) 3.2. 6
CMOS TECHNOLOGY 1. Low power, high speed CMOS FLASH technology 2. Fully static design
3. Wide Wide ope operating voltage oltage range range: 2.0V to 5.5V 4. High Sink/S ink/Source ource Curre Current: 25 mA 5. Indus Industrial te tempe mperature rature range range 6. Low powe power cons onsumption: 7. < 2 mA ty typic pical @ 5V, 5V, 4 MHz 8. 20 A ty typic pical @ 3V, 3V, 32 kHz 9. < 1 A ty typic pical standby tandby curre urrent
3.3 PIN DI AGR AM
3.3.1
PIC16F7 3 PINOUT DESCRIPTION
There are 28 pins on PIC16F73. Most of them can be used as an IO pin. Others are already for specific functions. These are the pin functions. 1. MCLR to reset the PIC 2. RA0 port A pin 0 3. RA1 port A pin 1 4. RA2 port A pin 2 5. RA3 port A pin 3 6. RA4 port A pin 4 7. RA5 port A pin 5 8. VSS ground 9. OSC1 connect to oscillator 10. OSC2 connect to oscillator 11. RC0 port C pin 0 VDD power supply 12. RC1 port C pin 1 13. RC2 port C pin 2 14. RC3 port C pin 3 15. RC4 - port C pin 4 16. RC5 - port C pin 5 17. RC6 - port C pin 6 18. RC7 - port C pin 7 19. VSS - ground 20. VDD power supply 21. RB0 - port B pin 0 22. RB1 - port B pin 1 23. RB2 - port B pin 2 24. RB3 - port B pin 3 25. RB4 - port B pin 4 26. RB5 - port B pin 5 27. RB6 - port B pin 6 28. RB7 - port B pin 7
3.
DESCR DESCRIPT IPTION ION OF CONT CONTRO ROLL LLER ER
Power-on Reset (POR), Power-up Timer (PWRT),Oscillator Start-up Timer (OST), Brown-out Reset (BOR), and Parity Error Reset (PER)
The reset logic is used to place the device into a known state. The source of the reset can be determined by using the device status bits. The reset logic is designed with features that reduce system cost and increase system reliability. Devices differentiate between various kinds of reset: a) Power-on Reset (POR) b) MCLR reset during normal operation c) MCLR reset during SLEEP d) WDT reset during normal operation e) Brown-out Reset (BOR) Most registers are unaffected by a reset their status is unknown on POR and unchanged by all other resets. The other registers are forced to a "reset state" on Power-on Reset, MCLR, WDT reset, Brown-out Reset and on MCLR reset during SLEEP. The on-chip parity bits that can be used to verify the contents of program memory. Most registers are not affected by a WDT wake-up, since this is viewed as the resumption of normal operation. Status bits TO, PD, POR and BOR.are set or cleared differently in different reset situations. These bits are used in software to determine the nature of the reset. All new devices will have a noise filter in the MCLR reset path to detect and ignore small pulses.
3. 7
.1 POWER-ON RESET (POR) A Power-on Reset pulse is generated on-chip when VDD rise is detected.
To take advantage of the POR, just tie the MCLR pin directly (or through a resistor) to VDD. This will eliminate external RC components usually needed to create a Power-on Reset. A minimum rise time for VDD is required. When the device exits the reset condition (begins normal operation), the device operating parameters (voltage, frequency, temperature, etc.) must be within their operating ranges, and otherwise the device will not function correctly. 3. 8
.2 POWER-UP TIMER (PWRT) The Power-up Timer provides a nominal 72 ms delay on Power-on Reset
(POR) or Brown-out Reset (BOR).The Power-up Timer operates on a dedicated internal RC oscillator. The device is kept in reset as long as the PWRT is active. The PWRT delay allows VDD to rise to an acceptable level. The Power -up Timer should always be enabled when Brown-out Reset is enabled. The polarity of the Power-up Timer configuration bit is now PWRTE = 0 for enabled, while the initial definition of the bit was PWRTE = 1 for enabled. Since all new devices will use the PWRTE = 0 for enabled, the text will describe the operation for such devices. The power-up time delay will vary from device to device due to VDD, temperature, and process variations. 3. 9
.3 OSCILLATOR START-UP TIMER (OST) The Oscillator Start-Up Timer (OST) provides a 1024 oscillator cycle delay
(from OSC1 input) after the PWRT delay is over. This ensures that the crystal oscillator or resonator has started and is stable. The OST time-out is invoked only for XT, LP and HS modes and only on Power -on Reset, Brown-out Brown- out Reset, or wake-up from SLEEP. The OST counts the oscillator pulses on the OSC1/CLKIN pin. The counter only starts incrementing after the amplitude of the signal rea ches the oscillator input thresholds. This delay allows the crystal oscillator or resonator to
stabilize before the device exits the OST delay. The length of the time -out is a function of the crystal/resonator frequency. For low frequency crystals this start-up time can become quite long. That is because the time it takes the low frequency oscillator to start oscillating is longer than the power-up timer's delay. So the time from when the power-up timer times-out, to when the oscillator starts to oscillate is a dead time.There is no minimum or maximum time for this dead time (TDEADTIME). Tosc1 = time for the crystal oscillator to react to an oscillation level detectable by the Oscillator Start-up Timer (OST). TOST = 1024TOSC. 3. @
. @
BROWN-OUT RESET (BOR): On-chip Brown-out reset circuitry places the device into reset when the
device voltage falls below a trip point (BVDD). This ensures that the device does not continue program execution outside the valid operation range of the device. Brown-out resets are typically used in AC line applications or large battery applications where large loads may be switched in (such as automotive), and cause the device voltage to temporarily fall below the specified operating minimum. The BODEN configuration bit can disable (if clear/programmed) or enable (if set) the Brown-out Reset circuitry. The Power-up Timer will now be invoked and will keep the chip in reset an additional 72 ms. If VDD drops below BVDD while the Power-up Power-u p Timer is running, running , the chip will will go back into Rese t and the Power-up Timer will be re-initialized. Once VDD rises above BVDD, the Power-up Timer will again start a 72 ms time delay. With the BODEN bit set, all voltages below BVDD will hold the device in the reset state. This includes during the power-up sequence. 3. A
.5 WATCHDOG TIMER (WDT) During normal operation, a WDT time-out generates a device RESET. If
the device is in SLEEP mode, a WDT time-out causes the device to wake-up and continue with normal operation, this is known as a WDT wake-up. The WDT
can be permanently disabled by clearing the WDTE configuration bit. The postscaler assignment is fully under software control, i.e., it can be changed "on the fly" during program execution. 3. B
.6 MEMORY ORGANIZATION There are two memory blocks in each of these PICmicro MCUs. The
Program Memory and Data Memory have separate buses so that concurrent access can occur .The Program Memory can be read internally by user code. 3. C
.6.1
PROGRAM MEMORY ORGANIZATION ORGANIZATIO N
The PIC16F7X devices have a 13-bit program counter capable of addressing an 8K word x 14-bit program memory space. The PIC16f73 device has 4K words. Accessing a location above the physically implemented address will cause a wraparound. The RESET Vector is at 0000h and the Interrupt Vector is at 0004h. 3. C
.6.2
DATA MEMORY ORGANIZATION ORGANIZATIO N
The Data Memory is partitioned into multiple banks, which contain the General Purpose Registers and the Special Function Registers. Bits RP1 (STATUS<6>) and RP0 (STATUS<5>) are the bank sel sel ect bits. Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented implemented banks contain Special Function Registers. Registers. Some fre quently used Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker access. 3. D
.7 STATUS REGISTER The STATUS register contains the arithmetic status of the ALU, the RESET
status and the bank select bits for data memory.
The The STATUS regis gister can be the the destination estination for any any ins instruc truction, as as with any any othe other regis gister. If the the STATUS regis gister is the the destination estination for an ins in struc truction that aff ect ec ts the the Z, DC, or C bits bit s, the then the the write write to these these three three bits bits is dis disable abled. These These bits bits are are set set or cleare ared acc according ording to the the devi evice logic logic. Furthe urthermore rmore, the the TO and PD bits bits are are not writable writable, the therefore fore, the the result es ult of an ins in struc truction with the th e STATUS regis gister as as destination estination may may be diff erent than inte intende nded. For example xample, CLRF CLRF STATUS will clear the the uppe upper three three bits bits and set set the the Z bit. It is is recomm ec omme ende nded, the therefore fore, that only only BCF, BSF, BSF, SWAPF and MOV MOVWF ins instruc tructions tions are are used sed to alte alter the the STATUS regis gister, becau ec ause se these these ins instruc tru ctions tions do not aff ect ect the the Z, C, or DC bits bit s from the the STATUS regis gister. For othe other ins instruc tructions tions not aff ecting ecting any any status tatus bits bits, see the the "Ins "Instruc truction Set Set Summary ummary".
Bit 7 IRP: Regis gister Bank Sel Select ect bit (use (used d for indirec indirectt address addressing) ing) 1 = Bank 2, 3 (100h 100h - 1FFh) 1FF h) 0 = Bank 0, 1 (00h 00h - FFh) FF h) Bit 6-5
RP1:RP0:
Select ec t bits Re Regis gister Bank Sel bits (use (used d for direc directt address addressing) ing)
11 = Bank 3 (180h 180h - 1FFh) 1FF h) 10 = Bank 2 (100h 100h - 17Fh) 17F h) 01 = Bank 1 (80h 80h - FFh) FF h) 00 = Bank 0 (00h 00h - 7Fh) 7Fh) Eac h
Bit 4
bank is is 128 by tes E
F
: TimeTime-out out bit
1 = afte after powe power-up, CLRWDT ins instruc tru ction, or SLEEP ins instruc tru ction
0 = A WDT time-out occurred Bit 3 PD: Power-down bit 1 = after power-up or by the CLRWDT instruction 0 = by execution of the SLEEP instruction Bit 2 Z: Zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero Bit 1 DC: Digit carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions) 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result Bit 0 C: Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions) 1 = A carry-out from the Most Significant bit of the result occurred 0 = No carry-out from the Most Significant bit of the result occurred 3. G
.8
I/O PORTS Some pins for these I/O ports are multiplexed with an alternate function
for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. 3. G
.8.1
PORTA AND THE TRISA REGISTER
PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= '1') will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= '0') will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).
Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read; the value is modified and then written to the port data latch. Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open drain output. All other PORTA pins have TTL input levels and full CMOS output drivers. Other PORTA pins are multiplexed with analog inputs and analog VREF input. The operation of each pin is selected by clearing/setting the control bits in the ADCON1 register (A/D Control Register1). The TRISA register controls the direction of the RA pins, even when they are being used as analog inputs. The user must ensure the bits in the TRISA register are maintained set, when using them as analog inputs. 3. H
.8.2
PORTB AND THE TRISB REGISTER
PORTB is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= '1') will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= '0') will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin). Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset. Four of the PORTB pins (RB7:RB4) have an interrupt-on-change feature. Only pins configured as inputs can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the interrupt -on-change comparison). The input pins (of RB7:RB4) are compared with the old value latched on the last read of PORTB. The "mismatch" outputs of RB7:RB4 are
ORed together to generate the RB Port Change Interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the device from SLEEP. The user, in the Interrupt Service Routine, can clear the interrupt in the following manner: a) Any read or write of PORTB. This will end the mismatch condition. b) Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF Reading PORTB will end the mismatch condition and allow flag bit RBIF to be cleared. The interrupt-on-change feature is recommended for wake-up on key depression operation operation and operations where where PORTB is only used for the interrupt -onchange feature. Polling of PORTB is not recommended while using the interrupt-on-change feature. This interrupt on mismatch feature, together with software configurable pull-ups on these four pins, allow easy interface to a keypad and make it possible for wake-up on key depression.RB0/INT is an external interrupt input pin and is configured using the INT EDG bit (OPTION_REG<6>).RB0 (OPTION_REG<6>).RB0/INT. /INT. 3. I
.8.3
PORTC AND THE TRISC REGISTER
PORTC is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= '1') will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISC bit (= '0') will make the corresponding PORTC pin an output (i.e., put the contents of the output latch on the selected pin).PORTC is multiplexed with several peripheral functions .PORTC pins have Schmitt Trigger Trigger input buffers. When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals ov erride the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify-write instructions (BSF, BCF, and XORWF) with TRISC as destination should be avoided.
3. P
.9 TIMER0 MODULE
The Timer0 module timer/counter has the following features: 8-bit timer/counter Readable and writable 8-bit software programmable prescaler Internal or external clock select Interrupt on overflow from FFh to 00h Edge select for external clock Timer0 operation is controlled through the OPTION_REG register. Timer mode is selected by clearing bit T0CS (OPTION_REG<5>). In Timer mode, the Timer0 module will increment every instruction cycle (without prescaler).If the TMR0 register is written, the increment is inhibited for the following two instruction cycles. The user can work around this by writing an adjusted value to the TMR0 register. Counter mode is selected by setting bit T0CS (OPTION_REG<5>). In Counter mode, Timer0 will increment, either on every rising or falling edge of pin RA4/T0CKI. The incrementing edge is determined by the Timer0 Source Edge Select bit T0SE (OPTION_REG<4>). Clearing bit T0SE selects the rising edge. The prescaler is mutually exclusively shared between the Timer0 module and the Watchdog Timer. The prescaler is not readable or writable.
3. Q
.10
TIMER1 MODULE
The Timer1 module is a 16-bit timer/counter consisting of two 8-bit registers (TMR1H and TMR1L), which are readable and writable. The TMR1 Register pair (TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. The TMR1 Interrupt, if enabled, is generated on overflow, which is latched in interrupt flag bit TMR1IF (PIR1<0>). This interrupt can be enabled/disabled by setting/clearing TMR1 interrupt enable bit TMR1IE (PIE1<0>).
Timer1 can operate in one of two modes: As a timer As a counter The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>).In Timer mode, Timer1 increments every instruction cycle. In Counter mode, it increments on every rising edge of the external clock input.Timer1 can be enabled/disabled by setting/clearing control bit TMR1ON (T1CON<0>).Timer1 also has an internal "RESET input. This RESET can be generated by either of the two CCP modules as the special event trigger. When the Timer1 oscillator is enabled (T1OSCEN is set), the RC1/T1OSI/CCP2 and RC0/T1OSO/T1CKI pins become inputs. That is, the TRISC<1:0> value is ignored and these pins read as '0'.
3. R
.11
TIMER2 MODULE
Timer2 is an 8-bit 8-bit timer with a prescaler and a postscaler. It can be used a s the PWM time-base for t he PWM mode of the CCP module(s). The TMR2 register is readable and writable, and is cleared on any device RESET.The input clock (FOSC/4) has a prescale option of 1:1,1:4 or 1:16, selected by control bits T2CKPS1:T2CKPS0 T2CKPS1:T2CKPS0 (T2CON<1:0>).The (T2CON<1:0>).The Timer2 module has an 8-bit period register, PR2.Timer2 increments from 00h until it matches PR2 and then resets to 00h on the next increment cycle. PR2 is a readable and writable register. The PR2 register is initialized to FFh upon RESET. The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2 interrupt (latched in flag bit TMR2IF, (PIR1<1>)).Timer2 (PIR1<1>)).Timer2 can be shut-off by clearing control bit TMR2ON (T2CON<2>) to minimize power consumption. CAPTURE/COMPARE/PWM MODULES(CCP):
Each Capture/Compare/PWM (CCP) module contains a 16-bit r egister which can operate as a:
16-bit Capture register 16-bit Compare register PWM Master/Slave Duty Cycle register Both the CCP1 and CCP2 modules are identical in operation, with the exception being the operation of the special event trigger.In trigger.In the following sections, the operation of a CCP module is described with respect to CCP1. CCP2 operates the same as CCP1, except where noted. CCP1 Module
Capture/Compare/PWM Register1 (CCPR1) is comprised of two 8-bit registers: CCPR1L (low byte) and CCPR1H (high byte). The CCP1CON register controls the operation of CCP1. The special event trigger is generated by a compare match and will clear both TMR1H and TMR1L registers. CCP2 Module
Capture/Compare/PWM Register1 (CCPR1) is comprised of two 8-bit registers: CCPR1L (low byte) and CCPR1H (high byte). The CCP2CON register controls the operation of CCP2. The special event trigger is generated by a compare match; it will clear both TMR1H and TMR1L registers, and start an A/D conversion (if the A/D module is enabled).
SSP Module
The Synchronous Serial Port (SSP) module is a serial interface useful for communicating with other peripheral or microcontroller devices. These peripheral devices may be Serial EEPROMs, shift registers, display drivers, A/D converters, etc. The SSP module can operate in one of two modes: Serial Peripheral Interface (SPI) Inter-Integrated Circuit (I2C)
SPI Mode
SPI mode allows 8 bits of data to be synchronously transmitted and received simultaneously. To accomplish communication, typically three pins are used: Serial Data Out (SDO) RC5/SDO Serial Data In (SDI) RC4/SDI/SDA Serial Clock (SCK) RC3/SCK/SCL Additionally, a fourth pin may be used when in a Slave mode of operation: Slave Select (SS) RA5/SS/AN4 When initializing the SPI, several options need to be specified. This is done by programming the appropriate control bits in the SSPCON r egister (SSPCON<5:0>) and SSPSTAT<7:6>. These control bits allow the following to be specified: Master mode (SCK is the clock output) Slave mode (SCK is the clock input) Clock Polarity (IDLE state of SCK) Clock edge (output data on rising/falling edge of SCK) Clock Rate (Master mode only) Slave Select mode (Slave mode only ) SSP I2 C Operation
The SSP module in I2C mode, fully implements all slave
functions, except general call support, and provides interrupts on START and STOP bits in hardware to facilitate firmware fir mware implementations of the master functions. The SSP module implements the standard mode specifications as well as 7-bit 7-bit and 10-bit addressing a ddressing.Two .Two pins are used for data tra nsfer. These are the RC3/SCK/SCL pin, pin, which is the clock (SCL), and the RC4/SDI/SDA pin, which is the data (SDA). The user must configure these pins as inputs or outputs through the TRISC<4:3> bits. The SSP module functions are enabled by setting SSP enable bit SSPEN (SSPCON<5>).The SSPCON register allows control of the I2C operation. Four mode selection bits (SSPCON<3:0>) allow one of the following I2C modes to be selected: I2C Slave mode (7-bit address) I2C Slave mode (10-bit address) I2C Slave mode (7-bit address), with START a nd STOP bit interrupts enabled to support Firmware Master mode I2C Slave mode (10-bit address), with START and STOP bit interrupts enabled to support Firmware Master mode I2C START and STOP bit interrupts enabled to support Firmware Master mode, Slave is IDLE Selection of any I2C mode with the SSPEN bit set, forces the SCL and SDA pins to be open drain, provide these pins are progra mmed to inputs by setting the appropriate TRISC bits. Pull-up resistors must be provided externally to the SCL a nd SDA pins for proper operation of the I2C module. Universal Synchronous Asynchronous Receiver Transmitter(USART):
The Universal S ynchronous ynchronous Asynchrono As ynchronous us Receiver Transmitter (USART) module is one of the two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI.) The USART can be configured as a full duplex asynchronous asynchronous system that t hat can communicate with peripheral devices, such as CRT CRT terminals and personal computers, or it can be configured as a half duplex synchronous synchronous system that can communicate with peripheral devices, such as A/D or D/A integrated
circuits, serial EEPROMs, etc. The USART can be configured in the following modes: Asynchronous (full duplex) Synchronous - Master (half (ha lf duplex) Synchronous - Slave (half duplex) Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure pins RC6/TX/CK and RC7/R X/DT as the t he Universal Synchronous Synchronous Asynchronous Receiver Transmitte Tra nsmitter. r.
USART Asynchronous Mode:
In this mode, the USART uses standard non-return-to-zero (NRZ) format (one START bit, eight or nine data bits, and one STOP bit). The most common data format is 8-bits. An on-chip, dedicated, 8-bit 8-bit baud rate generator can ca n be used to derive standard baud rate frequencies from the oscillator. The USART transmits and receives the LSb first. The USART's transmitter and rec eiver are functionally independent, but use the same data format and baud rate. The baud rate generator produces a clock, either x16 or x64 of the bit shift rate, depending on bit BRGH (TXSTA<2>). Parity is not supported by the hardware, but can be i mplemented in software (and stored as the ninth data bit). Asynchronous mode is stopped during SLEEP. Asynchronous mode is selected by clearing bit SYNC (TXSTA<4>). The USART Asynchronous module consists of the following important elements: Baud Rate Generator Sampling Circuit
Asynchronous Asynchronous Transmitter Asynchronous Receiver USART Synchronous Master Mode:
In Synchronous Master mode, the data is transmitted in a half-duplex manner (i.e., transmission and reception do not occur at the same time). When transmitting data,the reception is inhibited and vice versa. Synchronous mode is entered by setting bit SYNC (TXSTA<4>). In addition, enable bit SPEN (RCSTA<7>) is set in order to configure the RC6/TX/CK and RC7/RX/DT I/O pins to CK (clock) and DT (data) lines, respectively. The Master mode indicates that the processor transmits the master clock on the CK line. line. The Master mode is entered by setting bit CSRC(TXSTA<7>). CSRC(TXSTA<7>). USART Synchronous Slave Mode:
Synchronous Slave mode differs from the Master mode, in that the shift clock is supplied externally at the RC6/TX/CK pin (instead of being supplied internally in Master mode). This allows the device to transfer or receive data while in SLEEP mode. Slave mode is entered by clearing bit CSRC (TXSTA<7>).
Analog to Digital Converter(A/D) Module:
The 8-bit analog-to-digital (A/D) converter module has five inputs for the PIC16f73.The A/D allows conversion of an analog input signal to a corresponding 8-bit digital number.The output of the sample and hold is the input into the converter, which generates the result via successive approximation.The analog reference reference voltage is software selectable to either the device's positive supply voltage (VDD), or the voltage level on the RA3/AN3/VREF pin.The A/D converter has a unique feature of being able to operate while the device is in SLEEP mode. To operate in SLEEP, the A/D conversion clock must be derived from the A/D's internal RC oscillator. The A/D module has three registers. These registers are: A/D Result Register ((ADRES) A/D Control Register 0 (ADCON0)
A/D Control Register 1 ((ADCON1) The ADCON0 register controls the operation of the A/D module. The ADCON1 r egister, configures the functions of the port pins. The port pins can be configured as analog inputs (RA3 can also be a voltage reference), or as digital I/O.
Instruction Set:
The PIC16 instruction set is highly orthogonal and is comprised of three basic categories: Byte-oriented operations Bit-oriented operations
Literal and control operations
Each PIC16 instruction is a 14-bit word divided into an opcode, which specifies the instruction type and one or more operands, which further specify the operation of the instruction. For byte-oriented instructions, 'f' represents a file register designator and 'd' represents a destination designator.The file register designator specifies which file register is to be used by the instruction.The destination designator specifies where the result of the operation is to be placed. If 'd' is zero, the result is placed in the W register. If 'd' is one, the result is placed in the file register regist er specified in the instruction. For bit-oriented instructions, 'b' represents a bit field designator, which selects the bit affected by the operation,while 'f' represents the address of the file in which the bit is located. For literal and control operations, 'k' represents an eight- or eleven-bit constant or literal value One instruction cycle consists of four oscillator periods;for an oscillator frequency of 4 MHz, this gives a normal instruction execution time of 1 s. All instructions are executed within a single instruction cycle, unless a conditional test is true, or
t
program count count r i r i changed as a result resu lt of an inst nstructi ruction. on. When this occurs, the executi execution on
takes t o inst nstructi ruction on cycl cycles, wit with h the second cycl cycle execut executed as a NOP.All NOP.All inst nstructi ruction on exampl examples use the format forma t '0xhh' to represent represent a hexadeci hexadecimal mal number, where 'h' si s igni gnif ies a hexadeci hexadec imal mal digit. it. For exampl examp le, a "cl "clrf POR POR B" inst nstructi ruction on will will read POR POR B, cl c lear all a ll the dat data bit bits, s, then wr ite ite the result resu lt back t back to POR POR B. Thi This exampl example woul would have the uni unintended result result that hat the conditi condition on that hat set sets the RB F f lag woul would be cl cleared for pi p ins conf igured as input nputs and usi us ing the POR POR TB int errupt errupt on-change feat fea ture
CRYST AL OSCILL ATOR Jump to: na nav vigation igation,, se sear arcch
A miniature miniature 4 MHz quartz crys ystal tal enclose losed d in a herm rme eti ticcall ally y se seal ale ed HC-49 HC-49//US pac package kage, use used d as as the the resonator esonator in a crystal ystal osc oscillator. illator.
A crystal oscillator is an elec ecttron roniic oscill oscillaator or ccircuit rcu it that hat uses the mechani mechanical cal resonance of a vi brati brating ng crys crysttal of pi piezoe ezoellec ecttr ic mat mater ial to creat create an el elect ectr ical cal signal gnal with ith a very preci prec ise frequency frequency.. Thi This frequency is commonl commonly used to keep track of ti of time me (as in quar tz wr istwa wattches ches), ), to provi provide a st stabl ab le clock si signa gnall for d for digit itaal integra egratted ci circu rcuit itss, and to st stabili abilize ze frequenci frequencies for rad for radiio transm ransmitt itters ers and rece receiivers vers.. The most most
common type of piezoelectric resonator used is t he quartz crystal, crystal, so oscillator circuits designed around them became known as "crystal oscillators." oscillators. " Quartz crystals are manufactured for frequencies from a few t ens of kilohertz of kilohertz to tens of 9 megahertz. More than two t wo billion (2×10 ) crystals are manufactured annually. Most are used for consumer devices such as wristwatches wristwatches,, clocks clocks,, radios radios,, computers computers,, and cellphones cellphones.. Quartz crystals are also found inside test and a nd measurement equipment, such as counters, signal generators,, and oscilloscopes generators oscilloscopes..
Operation A crystal is a solid in which the constituent atoms atoms,, molecules molecules,, or ions or ions are packed in a regularly ordered, repeating pattern ext ending in all three spatial dimensions. Almost any object made of an elastic material could be used like a crystal, with appropriate transducers,, since all objects have natural resonant frequencies of vibration transducers of vibration.. For example, steel is very elastic and has a high speed of sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size, shap e, elasticity elasticity,, and the speed of sound in the material. High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork . For applications not needing very precise ti ming, a low-cost ceramic resonator is resonator is often used in place of a quartz crystal. When a crystal of quartz of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity.. When the field is removed, the quartz will generate an electric field as it piezoelectricity returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor , capacitor capacitor and and resistor , with a precise resonant frequency. (See RLC circuit.) circuit .) Quartz has the further advantage that its elastic constants and its size change in such a way that the frequency dependence on temperature ca n be very low. The specific characteristics will depend on the mode of vibration and the angle at which the quartz is cut (relative to its [7] crystallographic axes). Therefore, the resonant frequency of the plate, which depends on its size, will not change much, either. This means that a quartz clock, filter or oscillator will remain accurate. For critical applications the quartz oscillator is mounted in a temperaturetemperaturecontrolled container, called a crystal oven, oven, and can also be mounted on shock absorbers to prevent perturbation by external mecha nical vibrations.
E l c ric l mo d l S
T
U
Elec ectroni tronicc
S
symbol sy mbol for a pie piezoe zoelectri ectricc crystal ystal res resonator onator
Sch Schematic matic symbol symbol and equiv quivale alent circ ircuit for a quartz crystal ystal in an osc oscillator illator
A quar tz cryst crystal can be model modeled as an el elect ectr ical cal net network wit with h a lowi ow impedance (ser ies) and a high impedance (parall (para lleel) resonance poi point spaced cl closel osely toget ogether. Mathemati hema tica call lly y (usi (using the Lapllace transform Lap ransform)) the impedance of t of this net network can be wr itten itten as: as:
or,
s = j), s is the ser ies resonant where s is the compl complex frequency ( s resonant frequency in rad radiians per second and an d p is the parall paralleel resonant resonan t frequency in radi radians per second.
Addi Adding additi additiona onall capac capacit itance ance across a cryst crystal will cause the parall paralleel resonance to shi shif t downward. Thi This can be used to ad jus justt the frequency at a t whi which a cryst crystal oscill oscillaates. Cryst rystal manufact manufacturers normall norma lly y cut cut and tr im thei heir cryst crystals to have a speci spec if ied resonance frequency with ith a known 'l ' load' capacit capacitance ance added to the cryst crystal. For exampl examp le, a cryst crystal int ended for a 6 pF load has its its speci specif ied parall para lleel resonance frequency when a 6.0pF capac capacit itor or iis pl placed across it. it. Wit Withou houtt this capacit capacitance, ance, the resonance frequency is hi higher. Tem per
W
V
ure effec
W
X
A cryst crystal's frequency charact charact er istic tic depends on the shape or 'cut 'cu t' of t of the cryst crystal. A tuni uning fork cryst crystal is usuall usua lly y cut cut such that hat its its frequency over t over temperat empera ture is a paraboli parabolicc curve cent centered around 25 °C °C. Thi This means that hat a tuni uning fork cryst crys tal oscill oscillaator will will resonat resona te cl close to its target arget frequency at a t room temperat emperature, but but will slow down when the temperat emperature eit either her iincreases or decreases from room temperat emperature. A common paraboli parabolicc coeff icient ent for a 32kHz tuni uning fork cryst crystal is í0.04 ppm/ ppm/°C². C².
In
a real rea l appli applica cati tion, on, this means that hat a cl clock built built usi using a regul regu lar 32 kHz tuni uning fork cryst crys tal will keep good time time at at room t emperat emperature, lose 2 mi minut nutes per year at a t 10 degrees C elsius above (or bel below) room temperat emperature and lose 8 mi minut nutes per year at a t 20 degrees C elsius above (or bel below) room temperat emperature due to the quar tz cryst crystal.
Commonll u ed cr Common Y
`
Y
`
a
b
l f req equ uen enci cies es
Main artic article: Cr Crys ystal tal osc oscillator illator fre fr equ que encies
Cryst rystal oscill oscillaator ci c ircuit rcuitss are of ten desi designed around rel relative tivelly few st standard frequenci frequenc ies, such as 3.579545 MHz, 4.433619 MHz, 10 MHz, 14.318182 MHz, 17.734475 MHz, 20 MHz, 33.33 MHz, and 40 MHz. The popul popu lar ity ity of t of the 3.579545 MHz cryst crystals is due to low cost cost since they are used for NTSC NTSC col color t or telev eviision recei receivers. Usi Us ing frequency di dividers ders,, frequency multi mu lti pli pliers ers and phase and phase locked loop circuit rcu its, s, it is practi practica call to der ive a wi wide range of frequenci frequenc ies from one reference frequency. 14.318182 MHz (four ti (four times mes 3.579545 MHz) is used in comput computer vi video di displ splays to generat generate a b a bit itmapped mapped video di displ splay for NTSC NTSC col color monit monitors, ors, such as the C A used wit with h the or iginal nal IBM PC. (The IBM PC used 14.318182 MHz, divided by three, as its its 4.77 MHz cl clock source, usi us ing one cryst crystal for t for two purposes.) The 4.433619 MHz and 17.734475 MHz val values are used in PAL col color t or televi evision equi equi pment pment and devi devices intended to produce PAL si s ignal gnals. Cryst rystals can be manufact manufac tured for oscill osc illaation tion over a wi wide range of frequenci frequenc ies, from a few k iloher iloher tz up to several severa l hundred megaher tz. Many appli applica cati tions ons call ca ll for a cryst crystal oscill oscillaator frequency conveni convenientl ently y rel related to some ot other desi des ired frequency, so hundreds of st s tandard cryst crystal frequenci frequenc ies are made in large quantiti quantities es and st stocked by el elect ectroni ronics di distr i but butors.
SEN ENS SOR ORS S 1. LIGHT DEPEN END DENT RES RESISTOR 2. IN INF FR A ARE RED D SEN ENS SOR (IR SEN ENS SOR OR))
LIGHT DEPEN END DENT RES RESISTOR :
[1]
The The symbol symbol for a photores photoresiistor
A light de depende ndent res resiistor
A photores (LDR ) is a res resiistor or whose whose res resiistance decreases photores istor or light dep dependent res istor (LDR with ith increasi ncreas ing inci ncident dent ligh lightt intensit ensity. y. It can al a lso be referred to as a photoconductor photoconductor. A phot photoresi oresistor i or is made of a hi high resi resistance sem semiiconduc conducttor . If li f ligh ghtt falli falling ng on the devi device is of high enough frequency frequency,, pho phottons absorbed by the semi semiconduct conduc tor gi give bounde bound elec ecttrons enough energy to jump jump into the conduc conducti tion on band. band. The resulti resu lting ng free el elect ectron (and its its ho holle par tner) conduct conduct elect ectr icity, ity, thereby lower ing res resiistance ance.. A phot photoel oelect ectr ic devi device can be eit either her iintr insi nsic or ext ex tr insi nsic. An intr insi nsic semi semiconduct conductor has its its own charge carr iers and is not not an eff icient ent semi semiconduct conduc tor, e.g. sili s ilicon. con. In intr insi nsic devi devices the onl only avail ava ilab ablle el elect ectrons are in the va vallence band, band, and hence the phot photon must must have enough energy to excit excitee the el elect ectron across the enti entire re bandgap bandgap.. Ext Extr insi nsic devi devices have impur ities, ities, also call ca lled ed dopan dopantts, added whose ground st s tate energy is cl closer t oser to the conducti conduction on band; band; since the el elect ectrons do not no t have as far t far to jump, jump, lower energy phot photons (i (i.e., longer wavel wavelengt engths and lower frequenci frequencies) are suff icient ent to tr igger t gger the devi device. If a sampl samp le of sili silicon con has some of it of itss
atoms replaced by phosphorus atoms (impurities), there will be extra electrons available for conduction. conduction. This is an a n example of an extrinsic semicondu sem iconductor. ctor.
Applications Photoresistors come in many different types. Inexpensive cadmium sulfide cells can be found in many consumer items such as camera light meters, street lights, clock radios, alarms alarms,, and outdoor clocks. They are also used in some dynamic compressors together with a small incandescent lamp or light emitting diode to control gain r eduction. Lead sulfide (PbS) and indium antimonide (InSb) LDRs (light dependent resistor) are used for the mid infrared spectral region. Ge Ge::Cu photoconductors photoconductors are ar e among the best far- infrared detectors available, and are used for infrared for infrared astronom astr onomy y and infrared spectroscopy. spectroscopy.
INFRARED SENSOR (IR SENSOR):
LIGHT EMITTING DIODE (LED) : LED is very useful for electronics pr oducts. It is used as an indicator for power availability, indicator for success execution of any proc esses, indicator for any alarm or failure and so on. Without LED, electronics products cannot infor m user for any action that need to be take and ca nnot inform any successful execution.
LED has variety of size and color. Red, blue, green and yellow LED is the most common. The shape also varies from square, recta ngle and circular. LED is normally being interface with microcontroller. 5 volt is required to turn on LED and normally 220 ohm resistor is required as a safety to avoid the LED blown.
LED consi consists of t of two legs. One of t of the legs wit with h f lag must must be connect connect ed to ground and the other must must be connect connected to 5 volt volt..
LEDs are surel surely one of t of the most most commonl commonly used el e lement ements in el elect ectroni ronics. LED is an abbrevi abbreviation tion for 'Li 'Light ght Emitti Emitting ng Di Diode'. When choosi choos ing a LED, several severa l paramet parameters shoul shou ld be looked at: at: diamet ameter, whi which is usuall usua lly y 3 or 5 mm (milli (m illime mett ers), work ing current current whi which is usuall usua lly y about about 10mA (It can be as low as 2mA for LEDs wit w ith h hi high eff iciency - high ligh lightt out out put put), and col color of course, whi wh ich can be red or green though ther he re are al a lso orange, bl b lue, yell yellow.. ow..
LEDs must must be connect connected around the correct correct way, in order t order to emit emit ligh lightt and the current current-lim limiting iting resi resistor must must be the correct correct val value so that hat the LED is not not damaged damag ed or burn out out (overheat (overheated). The positi pos itive ve of t of the suppl supply is taken to the anode, and the cat cathode goes to the negati negative ve or ground of t of the pro jec jectt (ci (circuit rcu it). ). In order t order to identi dentify fy each lead, the cat cathode is the shor ter l er lead and the LED "bul "bu l b" b" usuall usua lly y has a cut cu t or "f lat" on the cat cathode si side. Di Diodes will will emit emit ligh lightt onl only if current current is f lowi owing from anode to cat cathode. Ot Otherwi herwise, its its PN j PN junc uncti tio on is reverse bi b iased and current current won't won't f low. In order t order to connect connect a LED correctl correc tly, y, a resi res istor must must be added in ser ies that hat to lim limit the amount amount of current current through the di diode, so that hat it does not not burn out out. The val va lue of t of the resi resistor i or is det determi ermined by the amount amount of current current you want want to f low through the LED. Maxi aximum current current f low trough LED was def ined by manufact manufacturer. To det determi ermine the val va lue of t of the dropper-resi dropper-res istor, we need to know the val va lue of t of the suppl supply volt voltage. age. From this we subt subtract ract the charact character istic tic volt voltage age drop dr op of a LED. Thi This val value will will range from 1.2v to 1.6v dependi depending on the col color of t of the LED. The answer i answer is the val va lue of Ur. Usi Using this val value and the current current we want want to f low through the LED (0.002A to 0.01A) we can work out ou t the val va lue of the resi resistor from the formul formula R=Ur/ . LEDs are connect connec ted to a mi microcont crocontroll roller er iin two ways. One is to swit switch ch them on wit with h logi ogic zero, and ot other t her to swit switch ch them on wit with h logi ogic one. The f irst rst is call called ed NEGATIVE logi ogic and the other i her is call called ed POSITIVE logi ogic. The next next diagram shows how to connect connect POSITIVE logi ogic. Since POSITIVE logi ogic provi provides a volt voltage age of +5 V to the di diode and dropper resi res istor, it will
emit light each time a pin of port B is provided with a logic 1. The other way is to connect all anodes to +5V and to deliver logical zero to cathodes.
CUSTOM COMPUTER SERVICE(CCS) CCS Compiler Screen Shot
Compiler Screen Shot while Compilation
Programmer software screen shot
Progarmmer software screen shot while chip select
How to Load Hex File into PIC Controller
Once the C program code has been compiled, the hex file will be generated in the same folder as the C code. This hex file is needed to be loaded into the PIC using PIC programmer. Topwin is one of the programmers available in the market at a very cheap cost.
To use the Topwin programmer we need software from Microchip called MPLAB. MPLAB is
free software from Microchip. This software can be downloaded from Microchip web site.
After MPLAB install ion on the PC, open the MPLAB application by double click on the MPLAB icon. From the MPLAB menu on the top find select programmer and choose Topwin. Click on Enable Programmer. MPLAB will activate Topwin. However make sure Topwin programmer already connected to the serial COM1 on the PC and its power turn on before running MPLAB software.
Go to setting and select device. Choose PIC controller number as a device say for example PIC16F72. Then select configuration. Choose HS for the Oscillator.
Now go to file and import the hex file to be downloaded into the PIC. Place the PIC chip into the programmer socket and click on WRITE at the Topwin task. The hex file will be downloaded into the PIC chip. The MPLAB IDE will respond with SUCCESFUL LOADED HEX FILE.
Now the PIC controller can be transferred into the real circuit board for testing.
CODE :