You are on page 1of 64

A.C Dimmer INTRODUCTION One of the earliest circuits in home electronics is the venerable incandescent AC lamp dimmer.

It is also one of the most challenging circuits to get right. In this tech-nical brief we will examine how using a microcontroller can both simplify the circuit and make it efficient. THEORY Early dimmers were very simple circuits, not much more than a high-current rheostat (variable resistor) wired in series with the lamp. For low-light conditions, it was adjusted to a high resistance, reducing the current through the lamp filament. For high-light conditions, it was adjusted for a low resistance increasing the current flow in the filament. However, because it was essentially a current limiting resistor, it typically dissipated a lot of heat, especially in the middle of its range. So the search was on for a more efficient method of dimming. With the advent of semiconductor thyristors, a new method of dimming was born. The method of dimming involved delaying the turn-on time of a triac until a controlled time after each zero crossing. Because the zero crossing resets the triac (turning it off), the delay essentially pulse width modulated the lamp, delivering only a portion of the potential current in each cycle and dimming the AC lamp. Generating the delayed triggering of the triac initially involved an RC network with a variable R, which created the required time delay. However, as simple as the circuit is for a RC gate drive, it still suffers from nonlinearity's due to the sinusoidal shape of the AC waveform. Production dimmers alleviated this problem by creating a custom potentiometer with a nonlinear resistance curve, which approximated linear dimming. But, due to the high voltages involved, there was still a significant amount of heat dissipated in the resistor. So, what about using a microcontroller to control the triac? It can generate an appropriate timing delay using a table to produce a linear dimming curve, and a microcontroller opens up a number of user interface possibilities. Unfortunately, microcontrollers do not run at AC line voltages, they need a low-voltage DC power supply to operate. Transformerless designs can supply the lower voltage, but their low efficiency would still dissipate a significant amount of heat. It is at this point that nano-Watt technology comes to the rescue. Given its extremely lowcurrent consump-tion, it is possible to reduce the heat generated in the transformerless power supply down to reasonable levels.

BLOCK DIAGRAM
TI C R A TI C RE R DV A I R

LA O D

MRCN O E I O T L R C OR L UT N I

U P KY E

ZR CO I G EORS N S DW ON KY E

A VL CO T

Block Diagram Description: There are three units in this project namely 1. 2. 3. 4. Microcontroller unit TRIAC unit Zero crossing unit Load & Switch unit

Zero crossing unit: In this unit we will use a triac with ac input that will give a zero crossing to the microcontroller unit Microcontroller unit: In this unit we will use the output of the triac zero crossing that will further converted into the positive pulses. This pulse will further fed to the TRIAC unit. We can vary the time of the pulse that will further fed to the TRIAC unit according to this pulse time the triac will passes the ac current to the load. TRIAC unit: In this unit we will use the output of the microcontroller positive pulses that will allow the triac to pass the ac pulses according to their pulse timing. Load & Switch unit: In this unit we will use two switches to increase the pulse time of the triac and decrease the pulse time. Load will drive according to this gated pulse timing. We will use an electric bulb for the load.

Components List: 1. 2. 3. 4. 5. 6. 7. 8. microcontroller capacitors registers crystal power supply Triac micro switches bulb

HARDWARE A nano-Watt microcontroller can be used to generate a feature rich dimmer design. For this design, we will be designing an AC dimmer for incandescent lamps with the following features. 1. Capable of delivering 100-200 Watts of power at 110 VAC. 2. Two user interfaces; one based on an infrared remote control system, and the second based on interruptions of the AC supply caused by the user toggling the switch for an existing in-house switched outlet. 3. Low-power dissipation, resistor-based transformerless power supply. 4. Small form factor. The first step in the design is to choose a triac for the switching circuit. In order to make an informed decision, we will need to cover a few triac basics first. A triac is essentially two Silicon Controlled Rectifiers, or SCR, cross-connected with their gate inputs tied together. Because it is SCR based, once the device begins conducting, it will continue to conduct until the current flowing through the device goes to zero. So, in operation, the triac is an open circuit between the AC supply and the lamp until the minimum gate current is either sourced or sunk through the gate pin. The triac is then latched on until the current through the device goes to zero at the next zero crossing of the AC waveform. While this description gives you a general idea of how the device works, there are a few specifics that are missing. First of all, the triac does not latch on until the minimum holding current flowing through the device is reached. Second, the two main pins of the triac are not completely interchangeable as the description implies. This is because the bias current for the triac is depen-dent, to an extent, on the direction of the bias current and the direction of the load current in the device. These combinations of current directions are referred to as the conduction quadrants for the device.

MICROCONTROLLER A microcontroller is a highly integrated chip which performs controlling functions. A microcontroller, or embedded controller, is similar to a microprocessor as used in a personal computer, but with a great deal of additional functionality combined onto the same monolithic semiconductor substrate. Microcontrollers, sometimes referred to as one-chip microcomputers, are used to control a wide range of electrical and mechanical appliances. Since they were first introduced, microcontrollers have evolved to the point where they can be used for increasingly complex applications. Some microcontrollers in use today are also programmable, expanding the number of applications in which they can be used. A modern microcontroller is basically a low-cost computer adapted to provide rapid solutions to external events after intensive computation. The microcontroller senses the happening of external events through signals received at input ports and transmits responses to the events through output ports. Modern microcontrollers are found in nearly every facet of modern life. More and more consumer and commercial products, such as for example but not limited to, appliances, telecommunications devices, automobiles, security systems, full-house instant hot water heaters, thermostats, and the like are being controlled by these integrated circuit microcontrollers. Generally, a microcontroller has a standard hardware design that is customized for a particular implementation by programming the firmware for a specific application. Microcontrollers combine relatively inexpensive, generic hardware with specialized firmware to provide cost-effective custom designs for many different applications. Microcontrollers are microprocessors integrated with peripherals on a single integrated circuit. The microcontroller is essentially a microprocessor adapted for control type applications. They are compact in size and yet retain the computational power of traditional microprocessors, allowing them to be used in a multitude of applications. The evolution of microprocessors into complex instruments and machines has led to sophisticated, fast real-time control capability. Microprocessors of 16 or 32 bit capability with associated interrupt handler chips, programmable timer chips, ROM and RAM chips, have been replaced in many control function instances by single chip I/O microcontrollers with all peripherals embedded on the same chip with the microcontroller. However, microcontrollers differ from microprocessors in many ways. Microcontrollers are independently programmable and can have a great deal of additional functionality combined on the same integrated circuit. A typical microprocessor can access from a megabyte to a gigabyte of memory, and is capable of processing 16, 32, or 64 bits of information or more with a single instruction. In contrast to the microprocessor, a microcontroller includes a central processing unit, memory and other functional elements, all on a single semiconductor substrate, or integrated circuit. In a computer, the microprocessor performs the primary or basic computing functions, and other integrated circuits such as memory and adapters provide peripheral functions such as communications, input/output (I/O), and controlling devices such as monitors or printers. In a microcontroller, many of these functions are contained within the chip itself. As compared to the relatively large external memory accessed by the microprocessor, the typical microcontroller accesses a much smaller memory. A typical microcontroller might have a core microprocessor, a memory controller, an interrupt controller, and both

asynchronous and synchronous serial interfaces. The advantage of a microcontroller as compared with a microprocessor is that the microcontroller can be used in an autonomous way. No external circuitry is needed for their operation. This is why their use is very widespread in relatively straightforward applications, such as in small electronic products. Modern microcontrollers incorporate not only a processor core and communications cores, but also include other commonly-employed device circuitry, such as blocks of memory and programmable timers. A typical microcontroller not only includes a core microprocessor, but also further includes a memory controller, a direct memory access (DMA) controller, an interrupt controller, and both asynchronous and synchronous serial interfaces. Microcontrollers have embedded logic units, memories, power sources, and other circuits. Power on reset (POR) circuits are typically used in microcontrollers to initialize stable power states, ensuring that booting is accomplished safely. Within a microcontroller a central processing unit (CPU) having an arithmetic logic unit (ALU) and a load and store unit or a combination of both is located. The CPU is coupled through a bus with a memory to provide storage capacity for program instructions and data. Program and data memory can be separate with different bus lines or embodied in a single memory unit. Other peripheral components may be coupled through the same or additional busses. The memories employed in present microcontrollers for storing the program instructions take the form of either read only memories or erasable programmable read only memories. A rewriteable flash memory is associated with the microcontroller. The flash memory is used to store application code. Microcontrollers are programmed in a machine-dependent assembler language. To program the flash memory, the microcontroller needs data addressable read/write/erase access to the flash memory. Microcontrollers typically include self-tests to verify the proper operation of the CPU and the associated peripheral devices. The self-test typically will detect illegal memory access decoding, illegal opcode execution or a simple watchdog/computer operating properly (COP) test. The architecture of specific microcontrollers can vary from manufacturer to manufacturer, and from product to product. Microcontrollers provide programmable control (through programming of the processor core) of peripheral devices connected to them. The peripheral devices embedded in a microcontroller each have their own individual registers. Typical peripheral device registers include state registers, instruction registers, address registers, status registers and data registers. On system start up, the execution unit initializes each peripheral device with device specific initial configuration data. In general, a microcontroller's operation includes a process for initializing, or beginning, its own internal logic and/or intended software application, also known as a boot method. The boot method for a microcontroller's application software is accomplished by the use of reset vector logic contained within the microprocessor, reset vectors in application memory space, application boot software and the application software itself. The application boot software typically determines if the application software is present and supplies the appropriate communication algorithms for reprogramming the application memory. The application software controls the functionality of the microcontroller by controlling the operations of the microprocessor. Resetting the microcontroller is done in

a power-on reset operation. It can also be prompted by an external reset signal, or by a reset signal coming from an internal circuit of the microcontroller called a watchdog circuit. Debugging the programming code in embedded microcontrollers is usually done during development using an in-circuit emulator (ICE) unit. Microcontrollers allow circuit designers great flexibility in design choice. However, programming the microcontroller to perform the desired functions can be an arduous task. Techniques for programming the user program into the nonvolatile memory may be characterized by use of an external programmer coupled directly to the nonvolatile memory. The programmer utilizes a control signal line to appropriately signal the nonvolatile memory (as well as associated circuitry within the microcontroller) that a programming mode is being entered. By using a block of user programmable nonvolatile memory, the microcontroller may be customized to carry out any desired function within the capabilities of the device. Microcontrollers are connected via an external bus to an external memory in which a control program and data are recorded, read out instruction code from this memory by outputting an instruction fetch request, and read or write predetermined data by outputting a data access request. Microcontrollers are used in many different applications. Microcontrollers are found in all market segments such as consumer, commercial, PC peripherals, telecommunications, automotive and industrial. Microcontrollers are used in modems for command interpretation and data transmission, in printer buffers for high speed dumping of data in preparation for driving the printer at the appropriate speed. Microcontroller embedded control are also used in copiers, cable television terminal equipment, lawn sprinkling controllers, credit card phone equipment, cellular phones, fax machines, automotive applications such as engine control modules, anti-lock braking systems, automobile suspension control, keyless entry systems, and a host of other industrial and consumer applications. In a computer storage system having multiple disk drives and multiple power supplies, an environmental monitoring unit (EMU) is controlled by a microcontroller. The EMU performs a variety of tasks including monitoring power supply voltage and currents, fan speeds, temperature of the storage system enclosure, and the status of the various disk drives in the storage system. In household appliances, microcontrollers are a part of microwave ovens, televisions, calculators, remote controls, clocks, etc. In a car, they are used in the engine control modules, the antilock braking systems, the sound systems, the airbags, and automobile suspension control modules. In antilock braking systems, the microcontroller monitors the rotational speed of the tires through sensors attached to the tires.

Control unit is the hart of the system. Here we have used ATMELS microcontroller AT89C2051 to process our program. The features of this microcontroller are listed below. This unit can take input from the user and can take decision what to do. After taking decision this unit can give output accordingly. All connections are shown in the circuit diagram.

Features

Compatible with MCS-51 roducts P 2 Kbytes of Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles 2.7 V to 6 V Operating Range Fully Static Operation: 0 Hz to 24 MHz Two-Level Program Memory Lock 128 x 8-Bit Internal RAM 15 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources Programmable Serial UART Channel Direct LED Drive Outputs On-Chip Analog Comparator

3.2 Pin description: Pin no 10: Gnd (ground) Pin no 20: +5 volt supply Pin no 1: Reset Pin no 12 to 19: port 1 P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the positive input (AIN0) and the negative input (AIN1),

Respectively. Pin no 4&5: crystal oscillator (xtal 2 & xtal 1)

Diode

Example:

Circuit symbol:

Function
Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol shows the direction in which the current can flow. Diodes are the electrical version of a valve and early diodes were actually called valves.

Forward Voltage Drop


Electricity uses up a little energy pushing its way through the diode, rather like a person pushing through a door with a spring. This means that there is a small voltage across a conducting diode, it is called the forward voltage drop and is about 0.7V for all normal diodes which are made from silicon. The forward voltage drop of a diode is almost constant whatever the current passing through the diode so they have a very steep characteristic (current-voltage graph).

Reverse Voltage
When a reverse voltage is applied a perfect diode does not conduct, but all real diodes leak a very tiny current of a few A or less. This can be ignored in most circuits because it will be very much smaller than the current flowing in the forward direction. However, all diodes have a maximum reverse voltage (usually 50V or more) and if this is exceeded the diode will fail and pass a large current in the reverse direction, this is called breakdown.

Ordinary diodes can be split into two types: Signal diodes which pass small currents of 100mA or less and Rectifier diodes which can pass large currents. In addition there are LEDs (which have their own page) and Zener diodes (at the bottom of this page).

Connecting and soldering


Diodes must be connected the correct way round, the diagram may be labelled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is marked by a line painted on the body. Diodes are labelled with their code in small print, you may need a magnifying glass to read this on small signal diodes! Small signal diodes can be damaged by heat when soldering, but the risk is small unless you are using a germanium diode (codes beginning OA...) in which case you should use a heat sink clipped to the lead between the joint and the diode body. A standard crocodile clip can be used as a heat sink. Rectifier diodes are quite robust and no special precautions are needed for soldering them.

Testing diodes
You can use a multimeter or a simple tester (battery, resistor and LED) to check that a diode conducts in one direction but not the other. A lamp may be used to test a rectifier diode, but do NOT use a lamp to test a signal diode because the large current passed by the lamp will destroy the diode!

Signal diodes (small current)


Signal diodes are used to process information (electrical signals) in circuits, so they are only required to pass small currents of up to 100mA. General purpose signal diodes such as the 1N4148 are made from silicon and have a forward voltage drop of 0.7V. Germanium diodes such as the OA90 have a lower forward voltage drop of 0.2V and this makes them suitable to use in radio circuits as detectors which extract the audio signal from the weak radio signal.

For general use, where the size of the forward voltage drop is less important, silicon diodes are better because they are less easily damaged by heat when soldering, they have a lower resistance when conducting, and they have very low leakage currents when a reverse voltage is applied.

Protection diodes for relays


Signal diodes are also used to protect transistors and ICs from the brief high voltage produced when a relay coil is switched off. The diagram shows how a protection diode is connected 'backwards' across the relay coil. Current flowing through a relay coil creates a magnetic field which collapses suddenly when the current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across the relay coil which is very likely to damage transistors and ICs. The protection diode allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. This prevents the induced voltage becoming high enough to cause damage to transistors and ICs.

Rectifier diodes (large current)


Rectifier diodes are used in power supplies to convert alternating current (AC) to direct current (DC), a process called rectification. They are also used elsewhere in circuits where a large current must pass through the diode. All rectifier diodes are made from silicon and therefore have a forward voltage drop of 0.7V. The table shows maximum current and maximum reverse voltage for some popular rectifier diodes. The 1N4001 is suitable for most low voltage circuits with a current of less than 1A.

Bridge rectifiers
There are several ways of connecting diodes to make a rectifier to convert AC to DC. The bridge rectifier is one of them and it is available in special packages containing the four diodes required. Bridge rectifiers are rated by their maximum current and maximum reverse voltage. They have four leads or terminals: the two DC outputs are labelled + and -, the two AC inputs are labelled .

The diagram shows the operation of a bridge rectifier as it converts AC to DC. Notice how alternate pairs of diodes conduct. Types of diodes

closeup, showing silicon crystal


In electronics, a diode is a component that restricts the direction of movement of charge carriers. Essentially, it allows an electric current to flow in one direction, but blocks it in the opposite direction. Thus, the diode can be thought of as an electronic version of a check valve. Circuits that require current flow in only one direction will typically include one or more diodes in the circuit design. Early diodes included "cat's whisker" crystals and vacuum tube devices (called thermionic valves in British English). Today the most common diodes are made from semiconductor materials such as silicon or germanium.

History Thermionic and solid state diodes developed in parallel. The principle of operation of thermionic diodes was discovered by Frederick Guthrie in 1873 . The principle of operation of crystal diodes was discovered in 1874 by the German scientist, Karl Ferdinand Braun . Thermionic diode principles were rediscovered by Thomas Edison on February 13, 1880 and he took out a patent in 1883 (U.S. Patent 307031 ), but developed the idea no further. Braun patented the crystal rectifier in 1899 . The first radio receiver using a crystal diode was built around 1900 by Greenleaf Whittier Pickard. The first thermionic diode was patented in Britain by John Ambrose Fleming (scientific adviser to the Marconi Company and former Edison employee) on November 16, 1904 (U.S. Patent 803684 in November 1905). Pickard received a patent for a silicon crystal detector on November 20, 1906 (U.S. Patent 836531 ). At the time of their invention such devices were known as rectifiers. In 1919 William Henry Eccles coined the term diode from Greek roots; di means 'two', and ode (from odos) means 'path'.

Thermionic or gaseous state diodes

The symbol for a vacuum tube diode. From top to bottom, the components are the anode, the cathode, and the heater.
Thermionic diodes are vacuum tube devices (also known as thermionic valves), which are arrangements of electrodes surrounded by a vacuum within a glass envelope, similar in appearance to incandescent light bulbs. In vacuum tube diodes, a current is passed through the heater filament. This indirectly heats the cathode, another filament treated with a mixture of barium and strontium oxides, which are oxides of alkaline earth metals; these substances are chosen because they have a small work function. (Some tubes use direct heating, in which the heating current is passed through the cathode itself.) The heat causes thermionic emission of electrons into the vacuum envelope. In forward operation, a surrounding metal electrode, called the anode, is positively charged, so that it electrostatically attracts the emitted electrons. However, electrons are not easily released from the unheated anode surface when the voltage polarity is reversed and hence any reverse flow is a very tiny current. For much of the 20th century vacuum tube diodes were used in analog signal applications, and as rectifiers in power supplies. Today, tube diodes are only used in niche applications, such as rectifiers in tube guitar and hi-fi amplifiers, and specialized high-voltage equipment.

Semiconductor diodes

Diode schematic symbol. Current can flow from the anode to the cathode, but not the other way around.
Most modern diodes are based on semiconductor p-n junctions. In a p-n diode, conventional current can flow from the p-type side (the anode) to the n-type side (the cathode), but not in the opposite direction. Another type of semiconductor diode, the Schottky diode, is formed from the contact between a metal and a semiconductor rather than by a p-n junction. A semiconductor diode's current-voltage, or I-V, characteristic curve is ascribed to the behavior of the so-called depletion layer or depletion zone which exists at the p-n junction between the differing semiconductors. When a p-n junction is first created, conduction band (mobile) electrons from the N-doped region diffuse into the P-doped region where there is a large population of holes (places for electrons in which no electron is present) with which the electrons "recombine". When a mobile electron recombines with a hole, the hole vanishes and the electron is no longer mobile. Thus, two charge carriers have vanished. The region around the p-n junction becomes depleted of charge carriers and thus behaves as an insulator. However, the depletion width cannot grow without limit. For each electron-hole pair that recombines, a positively-charged dopant ion is left behind in the N-doped region, and a negatively charged dopant ion is left behind in the P-doped region. As recombination proceeds and more ions are created, an increasing electric field develops through the depletion zone which acts to slow and then finally stop recombination. At this point, there is a 'built-in' potential across the depletion zone. If an external voltage is placed across the diode with the same polarity as the built-in potential, the depletion zone continues to act as an insulator preventing a significant electric current. This is the reverse bias phenomenon. However, if the polarity of the external voltage opposes the built-in potential, recombination can once again proceed resulting in substantial electric current through the p-n junction. For silicon diodes, the built-in potential is approximately 0.6 V. Thus, if an external current is passed through the diode, about 0.6 V will be developed across the diode such that the P-doped region is positive with respect to the N-doped region and the diode is said to be 'turned on' as it has a forward bias.

I-V characteristics of a P-N junction diode (not to scale).


A diode's I-V characteristic can be approximated by two regions of operation. Below a certain difference in potential between the two leads, the depletion layer has significant width, and the diode can be thought of as an open (non-conductive) circuit. As the potential difference is increased, at some stage the diode will become conductive and allow charges to flow, at which point it can be thought of as a connection with zero (or at least very low) resistance. More precisely, the transfer function is logarithmic, but so sharp that it looks like a corner on a zoomedout graph . In a normal silicon diode at rated currents, the voltage drop across a conducting diode is approximately 0.6 to 0.7 volts. The value is different for other diode types - Schottky diodes can be as low as 0.2 V and light-emitting diodes (LEDs) can be 1.4 V or more (Blue LEDs can be up to 4.0 V). Referring to the I-V characteristics image, in the reverse bias region for a normal P-N rectifier diode, the current through the device is very low (in the A range) for all reverse voltages up to a point called the peak-inverse-voltage (PIV). Beyond this point a process called reverse breakdown occurs which causes the device to be damaged along with a large increase in current. For special purpose diodes like the avalanche or zener diodes, the concept of PIV is not applicable since they have a deliberate breakdown beyond a known reverse current such that the reverse voltage is "clamped" to a known value (called the zener voltage or breakdown voltage). These devices however have a maximum limit to the current and power in the zener or avalanche region. Shockley diode equation or the diode law

The Shockley ideal diode equation (named after William Bradford Shockley) is the I-V characteristic of an ideal diode in either forward or reverse bias (or no bias). It is derived with the

assumption that the only processes giving rise to current in the diode are drift (due to electrical field), diffusion, and thermal recombination-generation. It also assumes that the recombinationgeneration (R-G) current in the depletion region is insignificant. This means that the Shockley equation doesn't account for the processes involved in reverse breakdown and photon-assisted RG. Additionally, it doesn't describe the "leveling off" of the I-V curve at high forward bias due to internal resistance, nor does it explain the practical deviation from the ideal at very low forward bias due to R-G current in the depletion region.

where

I is the diode current, IS is a scale factor called the saturation current, VD is the voltage across the diode, VT is the thermal voltage, and n is the emission coefficient.
The emission coefficient n varies from about 1 to 2 depending on the fabrication process and semiconductor material and in many cases is assumed to be approximately equal to 1 (thus omitted). The thermal voltage VT is approximately 25.2 mV at room temperature (approximately 25 C or 298 K) and is a known constant. It is defined by:

where

e is the magnitude of charge on an electron (the elementary charge), k is Boltzmann's constant, T is the absolute temperature of the p-n junction.

Types of semiconductor diode

Diode Light-emitting diode

Zener Diode Photodiode

Schottky Diode Varicap

Tunnel Diode SCR

Some diode symbols

There are several types of semiconductor junction diodes:

Normal (p-n) diodes which operate as described above. Usually made of doped silicon or, more rarely, germanium. Before the development of modern silicon power rectifier diodes, cuprous oxide and later selenium was used; its low efficiency gave it a much higher forward voltage drop (typically 1.41.7 V per "cell," with multiple cells stacked to increase the peak inverse voltage rating in high voltage rectifiers), and required a large heat sink (often an extension of the diode's metal substrate), much larger than a silicon diode of the same current ratings would require. Gold doped' diodes As a dopant, gold (or platinum) acts as recombination centers, which help a fast recombination of minority carriers. This allows the diode to operate at signal frequencies, at the expense of a higher forward voltage drop . A typical example is the 1N914. Zener diodes (Pronounced /zinr/) Diodes that can be made to conduct backwards. This effect, called Zener breakdown, occurs at a precisely defined voltage, allowing the diode to be used as a precision voltage reference. In practical voltage reference circuits Zener and switching diodes are connected in series and opposite directions to balance the temperature coefficient to near zero. Some devices labeled as high-voltage Zener diodes are actually avalanche diodes (see below). Two (equivalent) Zeners in series and in reverse order, in the same package, constitute a transient absorber (or Transorb, a registered trademark). They are named for Dr. Clarence Melvin Zener of Southern Illinois University, inventor of the device. Avalanche diodes Diodes that conduct in the reverse direction when the reverse bias voltage exceeds the breakdown voltage. These are electrically very similar to Zener diodes, and are often mistakenly called Zener diodes, but break down by a different mechanism, the avalanche effect. This occurs when the reverse electric field across the p-n junction causes a wave of ionization, reminiscent of an avalanche, leading to a large current. Avalanche diodes are designed to break down at a well-defined reverse voltage without being destroyed. The difference between the avalanche diode (which has a reverse breakdown above about 6.2 V) and the Zener is that the channel length of the former exceeds the 'mean free path' of the electrons, so there are collisions between them on the way out. The only practical difference is that the two types have temperature coefficients of opposite polarities.

Transient voltage suppression (TVS) diodes These are avalanche diodes designed specifically to protect other semiconductor devices from high-voltage transients. Their p-n junctions have a much larger cross-sectional area than those of a normal diode, allowing them to conduct large currents to ground without sustaining damage.

Electrical resistance

A 75-ohm resistor, as identified by its electronic color code. A multimeter could be used to verify this value.

Electrical resistance is a measure of the degree to which an object opposes the passage of an electric current. The SI unit of electrical resistance is the ohm. Its reciprocal quantity is electrical conductance measured in siemens. The quantity of resistance in an electric circuit determines the amount of current flowing in the circuit for any given voltage applied to the circuit.

where

R is the resistance of the object, usually measured in ohms, equivalent to Js/C2 V is the potential difference across the object, usually measured in volts I is the current passing through the object, usually measured in amperes
For a wide variety of materials and conditions, the electrical resistance does not depend on the amount of current flowing or the amount of applied voltage. V can either be measured directly across the object or calculated from a subtraction of voltages relative to a reference point. The former method is simpler for a single object and is likely to be more accurate. There may also be problems with the latter method if the voltage supply is AC and the two measurements from the reference point are not in phase with each other.

Electronic color code The electronic color code discussed here is used to indicate the values or ratings of electronic components, very commonly for resistors, but also for capacitors, inductors, and others. A separate code, the 25-pair color code, is used to identify wires in a cable or bundle. The advantage of color coding (over printed text) on physically small components is the inherent increase in marking area, which makes the values easier to read without magnification. Color coded markings are also more resistant to abrasion. A significant drawback, on the other hand, is color degradation due to aging, oxidation and overheating. In the days of classical chassis televisions, for example, overheated resistors would change their color bands, making it virtually impossible to distinguish brown from red from orange, except by circuit analysis and deduction. This could mean the difference between a 330, 3.3K or 33K resistor respectively (a factor of 100). An overheated 33K resistor often looked like 330. Dirt, unusual lighting, and color blindness can also make it difficult to read color codes. Color-coding of this form is becoming rarer. In newer equipment, most passive components come in surface mount packages. Many of these packages are unlabeled, and those that are are normally labeled with alphanumeric codes, not colors. In one popular marking method, the manufacturer prints 3 digits on components: 2 value digits followed by the power of ten multiplier. Thus the value of a resistor marked 472 is 4,700 and a capacitor marked 104 is 100 nF (100,000 pF). This can be confusing; a resistor marked 472 might seem to be a 472 unit, and we must rely upon experience to interpret markings. Another way is to use the "Kilo" or "Mega" prefixes in place of the decimal point: e.g. 1K2 = 1.2K = 1200, 4M7 = 4.7M = 4 700 000. For 1% resistors, a three-digit alphanumeric code is sometimes used, which is not obviously related to the value at all. For instance, a resistor marked 68C is 499(68) 100(C) = 49,900 ohms. It is sometimes not obvious whether a color coded component is a resistor, capacitor, or inductor, and this may be deduced by knowledge of its circuit function, physical shape or by measurement (capacitors have nearly infinite resistance; unfortunately, so do faulty open-circuit resistors and inductors). Resistors, capacitors and inductors

Resistor values are always coded in ohms, capacitors in picofarads (pF), inductors in microhenries (H), and transformers in volts.

band A is first significant figure of component value band B is the second significant figure band C is the decimal multiplier band D if present, indicates tolerance of value in percent (no color means 20%) For example, a resistor with bands of yellow, violet, red, and gold will have first digit 4 (yellow in table below), second digit 7 (violet), followed by 2 (red) zeros: 4,700 ohms. Gold signifies that the tolerance is 5%. Resistors manufactured for military use may also include a fifth band which indicates component failure rate (reliability); refer to MIL-STD-199 for further details. Tight tolerance resistors may have three bands for significant figures rather than two, and/or an additional band indicating temperature coefficient, in units of ppm/K. All coded components will have at least two value bands and a multiplier; other bands are optional (italicised below). The Standard EIA Color Code Table per EIA-RS-279 is as follows: Color Black Brown Red Orange Yellow Green Blue Violet Gray White Gold Silver None Value digit 1 Value digit 2 Value digit 3 Multiplier Tolerance Temp. Coefficient 0 0 0 100 1 1 1 101 1% (F) 100 ppm/K 2 2 2 102 2% (G) 50 ppm/K 3 3 3 3 10 15 ppm/K 4 4 4 104 25 ppm/K 5 5 5 5 10 0.5% (D) 6 6 6 106 0.25% (C) 7 7 7 7 10 0.1% (B) 8 8 8 108 0.05% (A) 9 9 9 9 10 0.1 5% (J) 0.01 10% (K) 20% (M)

Mnemonics A useful mnemonic for remembering the first ten color codes matches the first letter of the color code, by order of increasing magnitude. There are many variations:

Bright Boys Rave Over Young Girls But Veto Getting Wed B. B. R O Y of Great Britain has a Very Good Wife Better Be Right Or Your Great Big Venture Goes West Bad Beer Rots Our Young Guts, But Vodka Goes Well Bad Boys Rape Our Young Girls But Violet Gives Willingly, Get Some Now (Originally written by D. A. Gehlke[citation needed]) Bad Boys Rape Our Young Girls Behind Victory Garden Walls

Black Bastards Rape Our Young Girls But Violet Gives Willingly (Offensive, but easier to remember) Bye Bye Rosie, Off You Go, Birmingham Via Great Western Bob Brown Runs Over Your Garden, But Violet Grey Won't (Originally written by David Stothard) Black Bugs Race Over Yellow Grass Beside Violent Grey Water

Examples

From top to bottom:


Green-Blue-Black-Black-Brown o 560 1% Red-Red-Orange-Gold o 22,000 5% Yellow-Violet-Brown-Gold o 470 5%

Resistive loss When a current, I, flows through an object with resistance, R, electrical energy is converted to heat at a rate (power) equal to

where

P is the power measured in watts I is the current measured in amperes R is the resistance measured in ohms
This effect is useful in some applications such as incandescent lighting and electric heating, but is undesirable in power transmission. Common ways to combat resistive loss include using thicker wire and higher voltages. Superconducting wire is used in special applications.

Resistance of a conductor

DC resistance As long as the current density is totally uniform in the conductor, the DC resistance R of a conductor of regular cross section can be computed as

where

L is the length of the conductor, measured in meters A is the cross-sectional area, measured in square meters (Greek: rho) is the electrical resistivity (also called specific electrical resistance) of the material, measured in ohm meter. Resistivity is a measure of the material's ability to oppose the flow of electric current.
For practical reasons, almost any connections to a real conductor will almost certainly mean the current density is not totally uniform. However, this formula still provides a good approximation for long thin conductors such as wires.

AC resistance

If a wire conducts high-frequency alternating current then the effective cross sectional area of the wire is reduced. This is because of the skin effect. This formula applies to isolated conductors. In a conductor close to others, the actual resistance is higher because of the proximity effect. Causes of resistance In metals A metal consists of a lattice of atoms, each with a shell of electrons. This can also be known as positive ionic lattice. The outer electrons are free to dissociate from their parent atoms and travel through the lattice, creating a 'sea' of electrons, making the metal a conductor. When an electrical potential difference (a voltage) is applied across the metal, the electrons drift from one end of the conductor to the other under the influence of the electric field. In a metal the thermal motion of ions is the primary source of scattering of electrons (due to destructive interference of free electron wave on non-correlating potentials of ions) - thus the prime cause of metal resistance. Imperfections of lattice also contribute into resistance, although their contribution in pure metals is negligible. The larger the cross-sectional area of the conductor, the more electrons is available to carry the current, so the lower the resistance. The longer the conductor, the more scattering events occur in each electron's path through the material, so the higher the resistance.

In semiconductors and insulators In metals the fermi level lies in the conduction band giving rise to free conduction electrons. However in semiconductors the position of the fermi level is within the band gap, exactly half way between the conduction band minimum and valence band maximum for intrinsic (undoped) semiconductors. This means that at 0 Kelvin, there are no free conduction electrons and the resistance is infinite. However, as the temperature is increased, charge carriers are thermally excited to the conduction band giving rise to a non-zero resistance. The resistance will continue to decrease as the charge carrier density in the conduction band increases. In extrinsic (doped) semiconductors, dopant atoms increase the majority charge carrier by donating electrons to the conduction band or accepting holes in the valence band. For both types of donor or acceptor atoms, increasing the dopant density leads to a reduction in the resistance. Highly doped semiconductors hence behave metallic. At very high temperatures, the contribution of thermally generated carriers will dominate over the contribution from dopant atoms and the resistance will decrease exponentially with temperature.

In ionic liquids/electrolytes In electrolytes, electrical conduction happens not by band electrons or holes, but by full atomic species (ions) traveling, each carrying an electrical charge. The resistivity of ionic liquids varies

tremendously by the salt concentration - while distilled water is almost an insulator, salt water is a very efficient electrical conductor. In biological membranes, currents are carried by ionic salts. Small holes in the membranes, called ion channels, are selective to specific ions and determine the membrane resistance.

Resistance of various materials

Resistivity, ohm-meter Metals 10 - 8 Semiconductors variable Electrolytes variable Insulators 1016 Material

Band theory

Electron energy levels in an insulator.


Quantum mechanics states that the energy of an electron in an atom cannot be any arbitrary value. Rather, there are fixed energy levels which the electrons can occupy, and values in between these levels are impossible. The energy levels are grouped into two bands: the valence band and the conduction band (the latter is generally above the former). Electrons in the conduction band may move freely throughout the substance in the presence of an electrical field.

In insulators and semiconductors, the atoms in the substance influence each other so that between the valence band and the conduction band there exists a forbidden band of energy levels, which the electrons cannot occupy. In order for a current to flow, a relatively large amount of energy must be furnished to an electron for it to leap across this forbidden gap and into the conduction band. Thus, large voltages yield relatively small currents.

Differential resistance When resistance may depend on voltage and current, differential resistance, incremental resistance or slope resistance is defined as the slope of the V-I graph at a particular point, thus:

This quantity is sometimes called simply resistance, although the two definitions are equivalent only for an ohmic component such as an ideal resistor. If the V-I graph is not monotonic (i.e. it has a peak or a trough), the differential resistance will be negative for some values of voltage and current. This property is often known as negative resistance, although it is more correctly called negative differential resistance, since the absolute resistance V/I is still positive.

Temperature-dependence Near room temperature, the electric resistance of a typical metal conductor increases linearly with the temperature:

,
where a is the thermal resistance coefficient.

The electric resistance of a typical intrinsic (non doped) semiconductor decreases exponentially with the temperature:

Extrinsic (doped) semiconductors have a far more complicated temperature profile. As temperature increased starting from absolute zero they first decrease steeply in resistance as the carriers leave the donors or acceptors. After most of the donors or acceptors have lost their carriers the resistance starts to increase again slightly due to the reducing mobility of carriers (much as in a metal). At higher temperatures it will behave like intrinsic semiconductors as the carriers from the donors/acceptors become insignificant compared to the thermally generated carriers.

The electric resistance of electrolytes and insulators is highly nonlinear, and case by case dependent, therefore no generalized equations are given.

CAPACITOR We have said that an electrical current can only flow through a closed circuit. Thus, if we break or cut a wire in a circuit, that circuit is opened up, and can no longer carry a current. But we know that there will be a small electrical field between the broken ends. What if we modify the point of the break so that the area is expanded, thus providing a wide area of "not quite" contact?

The figure to the right shows two metal plates, placed close to each other but not touching. A wire is connected to each plate as shown, so that this construction may be made part of an electrical circuit. As shown here, these plates still represent nothing more than an open circuit. A wide one to be sure, but an open circuit nevertheless.

Now suppose we apply a fixed voltage across the plates of our construction, as shown to the left. The battery attempts to push electrons onto the negative plate (blue in the figure), and pull electrons from the positive plate (the red one). Because of the large surface area between the two plates, the battery is actually able to do this. This action in turn produces an electric field between the two plates, and actually distorts the motions of the electrons in the molecules of air in between the two plates. Our construction has been given an electric charge, such that it now holds a voltage equal to the battery

voltage. If we were to disconnect the battery, we would find that this structure continues to hold its charge until something comes along to connect the two plates directly together and allow the structure to discharge itself. Because this structure has the capacity to hold an electrical charge, it is known as a capacitor. How much of a charge it can hold is determined by the area of the two plates and the distance between them. Large plates close together show a high capacity; smaller plates kept further apart show a lower capacity. Even the cut ends of the wire we described at the top of this page show some capacity to hold a charge, although that capacity is so small as to be negligible for practical purposes. The electric field between capacitor plates gives this component an interesting and useful property: it resists any change in voltage applied across its terminals. It will draw or release energy in the form of an electric current, thus storing energy in its electric field, in its effort to oppose any change. As a result, the voltage across a capacitor cannot change instantaneously; it must change gradually as it overcomes this property of the capacitor.

A practical capacitor is not limited to two plates. As shown to the right, it is quite possible to place a number of plates in parallel and then connect alternate plates together. In addition, it is not necessary for the insulating material between plates to be air. Any insulating material will work, and some insulators have the effect of massively increasing the capacity of the resulting device to hold an electric charge. This ability is known generally as capacitance, and capacitors are rated according to their capacitance. It is also unnecessary for the capacitor plates to be flat. Consider the figure below, which shows two "plates" of metal foil, interleaved with pieces of waxed paper (shown in yellow). This assembly can be rolled up to form a cylinder, with the edges of the foil extending from either end so they can be connected to the actual capacitor leads. The resulting package is small, light, rugged, and easy to use. It is also typically large enough to have its

capacitance value printed on it numerically, although some small ones do still use color codes. The schematic symbol for a capacitor, shown below and to the right of the rolled foil illustration, represents the two plates. The curved line specifically represents the outer foil when the capacitor is rolled into a cylinder as most of them are. This can become important when we start dealing with stray signals which might interfere with the desired behavior of a circuit (such as the "buzz" or "hum" you often hear in an AM radio when it is placed near fluorescent lighting). In these cases, the outer foil can sometimes act as a shield against such interference.

An alternate construction for capacitors is shown to the right. We start with a disc of a ceramic material. Such discs can be manufactured to very accurate thickness and diameter, for easilycontrolled results. Both sides of the disc are coated with solder, which is compounded of tin and lead. These coatings form the plates of the capacitor. Then, wire leads are bonded to the solder plates to form the structure shown here. The completed construction is then dipped into another ceramic bath, to coat the entire structure with an insulating cover and to provide some additional mechanical protection. The capacitor ratings are then printed on one side of the ceramic coating, as shown in the example here.

Modern construction methods allow these capacitors to be made with accurate values and well-known characteristics. Also, different types of ceramic can be used in order to control such factors as how the capacitor behaves as the temperature and applied voltage change. This can be very important in critical circuits.

Physics A capacitor consists of two conductive electrodes, or plates, separated by an insulator. Capacitance

When electric charge accumulates on the plates, an electric field is created in the region between the plates that is proportional to the amount of accumulated charge. This electric field creates a potential difference V = Ed between the plates of this simple parallel-plate capacitor. The capacitor's capacitance (C) is a measure of the amount of charge (Q) stored on each plate for a given potential difference or voltage (V) which appears between the plates:

In SI units, a capacitor has a capacitance of one farad when one coulomb of charge causes a potential difference of one volt across the plates. Since the farad is a very large unit, values of capacitors are usually expressed in microfarads (F), nanofarads (nF), or picofarads (pF). The capacitance is proportional to the surface area of the conducting plate and inversely proportional to the distance between the plates. It is also proportional to the permittivity of the dielectric (that is, non-conducting) substance that separates the plates.

The capacitance of a parallel-plate capacitor is given by:

where is the permittivity of the dielectric, A is the area of the plates and d is the spacing between them. In the diagram, the rotated molecules create an opposing electric field that partially cancels the field created by the plates, a process called dielectric polarization.

Stored energy As opposite charges accumulate on the plates of a capacitor due to the separation of charge, a voltage develops across the capacitor owing to the electric field of these charges. Everincreasing work must be done against this ever-increasing electric field as more charge is separated. The energy (measured in joules, in SI) stored in a capacitor is equal to the amount of work required to establish the voltage across the capacitor, and therefore the electric field. The energy stored is given by:

where V is the voltage across the capacitor. The maximum energy that can be (safely) stored in a particular capacitor is limited by the maximum electric field that the dielectric can withstand before it breaks down. Therefore, all capacitors made with the same dielectric have about the same maximum energy density (joules of energy per cubic meter).

Hydraulic model

As electrical circuitry can be modeled by fluid flow, a capacitor can be modeled as a chamber with a flexible diaphragm separating the input from the output. As can be determined intuitively as well as mathematically, this provides the correct characteristics

The pressure difference across the unit is proportional to the integral of the current A steady state current cannot pass through it because applying too much pressure, above the maximum pressure, will destroy it. But a transient pulse or alternating current can be transmitted The capacitance of units connected in parallel is equivalent to the sum of their individual capacitances

Electrical circuits

The electrons within dielectric molecules are influenced by the electric field, causing the molecules to rotate slightly from their equilibrium positions. The air gap is shown for clarity; in a real capacitor, the dielectric is in direct contact with the plates. Capacitors also allow AC current to flow and blocks DC current.

DC sources Electrons cannot easily pass directly across the dielectric from one plate of the capacitor to the other as the dielectric is carefully chosen so that it is a good insulator. When there is a current through a capacitor, electrons accumulate on one plate and electrons are removed from the other plate. This process is commonly called 'charging' the capacitor -- even though the capacitor is at all times electrically neutral. In fact, the current through the capacitor results in the separation of electric charge, rather than the accumulation of electric charge. This separation of charge causes an electric field to develop between the plates of the capacitor giving rise to voltage across the plates. This voltage V is directly proportional to the amount of charge separated Q. Since the current I through the capacitor is the rate at which charge Q is forced through the capacitor (dQ/dt), this can be expressed mathematically as: where I is the current flowing in the conventional direction, measured in amperes, dV/dt is the time derivative of voltage, measured in volts per second, and C is the capacitance in farads. For circuits with a constant (DC) voltage source, the voltage across the capacitor cannot exceed the voltage of the source. (Unless the circuit includes a switch and an inductor, as in SMPS, or a

switch and some diodes, as in a charge pump). Thus, an equilibrium is reached where the voltage across the capacitor is constant and the current through the capacitor is zero. For this reason, it is commonly said that capacitors block DC.

AC sources The current through a capacitor due to an AC source reverses direction periodically. That is, the alternating current alternately charges the plates: first in one direction and then the other. With the exception of the instant that the current changes direction, the capacitor current is nonzero at all times during a cycle. For this reason, it is commonly said that capacitors "pass" AC. However, at no time do electrons actually cross between the plates, unless the dielectric breaks down. Such a situation would involve physical damage to the capacitor and likely to the circuit involved as well. Since the voltage across a capacitor is proportional to the integral of the current, as shown above, with sine waves in AC or signal circuits this results in a phase difference of 90 degrees, the current leading the voltage phase angle. It can be shown that the AC voltage across the capacitor is in quadrature with the alternating current through the capacitor. That is, the voltage and current are 'out-of-phase' by a quarter cycle. The amplitude of the voltage depends on the amplitude of the current divided by the product of the frequency of the current with the capacitance, C.

Impedance The ratio of the phasor voltage across a circuit element to the phasor current through that element is called the impedance Z. For a capacitor, the impedance is given by

where

is the capacitive reactance, is the angular frequency, f is the frequency), C is the capacitance in farads, and j is the imaginary unit. While this relation (between the frequency domain voltage and current associated with a capacitor) is always true, the ratio of the time domain voltage and current amplitudes is equal to XC only for sinusoidal (AC) circuits in steady state.

Hence, capacitive reactance is the negative imaginary component of impedance. The negative sign indicates that the current leads the voltage by 90 for a sinusoidal signal, as opposed to the inductor, where the current lags the voltage by 90. The impedance is analogous to the resistance of a resistor. The impedance of a capacitor is inversely proportional to the frequency -- that is, for very high-frequency alternating currents the reactance approaches zero -- so that a capacitor is nearly a short circuit to a very high frequency AC source. Conversely, for very low frequency alternating currents, the reactance increases without bound so that a capacitor is nearly an open circuit to a very low frequency AC source. This frequency dependent behaviour accounts for most uses of the capacitor (see "Applications", below). Reactance is so called because the capacitor doesn't dissipate power, but merely stores energy. In electrical circuits, as in mechanics, there are two types of load, resistive and reactive. Resistive loads (analogous to an object sliding on a rough surface) dissipate the energy delivered by the circuit, ultimately by electromagnetic emission (Black body radiation), while reactive loads (analogous to a spring or frictionless moving object) store this energy, ultimately delivering the energy back to the circuit.

Also significant is that the impedance is inversely proportional to the capacitance, unlike resistors and inductors for which impedances are linearly proportional to resistance and inductance respectively. This is why the series and shunt impedance formulae (given below) are the inverse of the resistive case. In series, impedances sum. In parallel, conductances sum.

Laplace equivalent (s-domain) When using the Laplace transform in circuit analysis, the capacitive impedance is represented in the s domain by:

where C is the capacitance, and s (= +j) is the complex frequency.

Displacement current The physicist James Clerk Maxwell invented the concept of displacement current, dD/dt, to make Ampere's law consistent with conservation of charge in cases where charge is accumulating as in a capacitor. He interpreted this as a real motion of charges, even in vacuum, where he supposed

that it corresponded to motion of dipole charges in the ether. Although this interpretation has been abandoned, Maxwell's correction to Ampere's law remains valid.

Networks

Series or parallel arrangement Capacitors in a parallel configuration each have the same potential difference (voltage). Their total capacitance (Ceq) is given by:

The reason for putting capacitors in parallel is to increase the total amount of charge stored. In other words, increasing the capacitance also increases the amount of energy that can be stored. Its expression is:

The current through capacitors in series stays the same, but the voltage across each capacitor can be different. The sum of the potential differences (voltage) is equal to the total voltage. Their total capacitance is given by:

In parallel the effective area of the combined capacitor has increased, increasing the overall capacitance. While in series, the distance between the plates has effectively been increased, reducing the overall capacitance.

In practice capacitors will be placed in series as a means of economically obtaining very high voltage capacitors, for example for smoothing ripples in a high voltage power supply. Three "600 volt maximum" capacitors in series, will increase their overall working voltage to 1800 volts. This is of course offset by the capacitance obtained being only one third of the value of the capacitors used. This can be countered by connecting 3 of these series set-ups in parallel, resulting in a 3x3 matrix of capacitors with the same overall capacitance as an individual capacitor but operable under three times the voltage. In this application, a large resistor would be connected across each capacitor to ensure that the total voltage is divided equally across each capacitor and also to discharge the capacitors for safety when the equipment is not in use. Another application is for use of polarized capacitors in alternating current circuits; the capacitors are connected in series, in reverse polarity, so that at any given time one of the capacitors is not conducting... Capacitor/inductor duality In mathematical terms, the ideal capacitor can be considered as an inverse of the ideal inductor, because the voltage-current equations of the two devices can be transformed into one another by exchanging the voltage and current terms. Just as two or more inductors can be magnetically coupled to make a transformer, two or more charged conductors can be electrostatically coupled to make a capacitor. The mutual capacitance of two conductors is defined as the current that flows in one when the voltage across the other changes by unit voltage in unit time.

Applications Capacitor symbols Polarized Variable Capacitor capacitors capacitor

Capacitors have various uses in electronic and electrical systems.

Energy storage A capacitor can store electric energy when disconnected from its charging circuit, so it can be used like a temporary battery. Capacitors are commonly used in electronic devices to maintain power supply while batteries are being changed. (This prevents loss of information in volatile memory.) Capacitors are used in power supplies where they smooth the output of a full or half wave rectifier. They can also be used in charge pump circuits as the energy storage element in the generation of higher voltages than the input voltage. Capacitors are connected in parallel with the power circuits of most electronic devices and larger systems (such as factories) to shunt away and conceal current fluctuations from the primary power source to provide a "clean" power supply for signal or control circuits. Audio equipment, for example, uses several capacitors in this way, to shunt away power line hum before it gets into the signal circuitry. The capacitors act as a local reserve for the DC power source, and bypass AC currents from the power supply. This is used in car audio applications, when a stiffening capacitor compensates for the inductance and resistance of the leads to the lead-acid car battery.

Power factor correction Capacitors are used in power factor correction. Such capacitors often come as three capacitors connected as a three phase load. Usually, the values of these capacitors are given not in farads but rather as a reactive power in volt-amperes reactive (VAr). The purpose is to counteract inductive loading from electric motors and fluorescent lighting in order to make the load appear to be mostly resistive.

Filtering Signal coupling Because capacitors pass AC but block DC signals (when charged up to the applied dc voltage), they are often used to separate the AC and DC components of a signal. This method is known as AC coupling. (Sometimes transformers are used for the same effect.) Here, a large value of capacitance, whose value need not be accurately controlled, but whose reactance is small at the signal frequency, is employed. Capacitors for this purpose designed to be fitted through a metal panel are called feed-through capacitors, and have a slightly different schematic symbol.

Noise filters, motor starters, and snubbers When an inductive circuit is opened, the current through the inductance collapses quickly, creating a large voltage across the open circuit of the switch or relay. If the inductance is large enough, the energy will generate a spark, causing the contact points to oxidize, deteriorate, or sometimes weld together, or destroying a solid-state switch. A snubber capacitor across the newly opened circuit creates a path for this impulse to bypass the contact points, thereby preserving their life; these were commonly found in contact breaker ignition systems, for instance. Similarly, in smaller scale circuits, the spark may not be enough to damage the switch but will still radiate undesirable radio frequency interference (RFI), which a filter capacitor absorbs. Snubber capacitors are usually employed with a low-value resistor in series, to dissipate energy and minimize RFI. Such resistor-capacitor combinations are available in a single package. In an inverse fashion, to initiate current quickly through an inductive circuit requires a greater voltage than required to maintain it; in uses such as large motors, this can cause undesirable startup characteristics, and a motor starting capacitor is used to increase the coil current to help start the motor. Capacitors are also used in parallel to interrupt units of a high-voltage circuit breaker in order to equally distribute the voltage between these units. In this case they are called grading capacitors. In schematic diagrams, a capacitor used primarily for DC charge storage is often drawn vertically in circuit diagrams with the lower, more negative, plate drawn as an arc. The straight plate indicates the positive terminal of the device, if it is polarized (see electrolytic capacitor). Signal processing The energy stored in a capacitor can be used to represent information, either in binary form, as in DRAMs, or in analogue form, as in analog sampled filters and CCDs. Capacitors can be used in analog circuits as components of integrators or more complex filters and in negative feedback loop stabilization. Signal processing circuits also use capacitors to integrate a current signal. Tuned circuits Capacitors and inductors are applied together in tuned circuits to select information in particular frequency bands. For example, radio receivers rely on variable capacitors to tune the station frequency. Speakers use passive analog crossovers, and analog equalizers use capacitors to select different audio bands. In a tuned circuit such as a radio receiver, the frequency selected is a function of the inductance (L) and the capacitance (C) in series, and is given by:

This is the frequency at which resonance occurs in an LC circuit.

Other applications Sensing Most capacitors are designed to maintain a fixed physical structure. However, various things can change the structure of the capacitor the resulting change in capacitance can be used to sense those things. Changing the dielectric: the effects of varying the physical and/or electrical characteristics of the dielectric can also be of use. Capacitors with an exposed and porous dielectric can be used to measure humidity in air. Changing the distance between the plates: Capacitors are used to accurately measure the fuel level in airplanes. Capacitors with a flexible plate can be used to measure strain or pressure. Capacitors are used as the sensor in condenser microphones, where one plate is moved by air pressure, relative to the fixed position of the other plate. Some accelerometers use MEMS capacitors etched on a chip to measure the magnitude and direction of the acceleration vector. They are used to detect changes in acceleration, eg. as tilt sensors or to detect free fall, as sensors triggering airbag deployment, and in many other applications. Also some fingerprint sensors.Changing the effective area of the plates: capacitive touch switches.

Pulsed power and weapons Groups of large, specially constructed, low-inductance high-voltage capacitors (capacitor banks) are used to supply huge pulses of current for many pulsed power applications. These include electromagnetic forming, Marx generator , pulsed lasers (especially TEA lasers), pulse forming networks, radar, fusion research, and particle accelerators. Large capacitor banks are used as energy sources for the exploding-bridgewire detonators or slapper detonators in nuclear weapons and other speciality weapons. Experimental work is under way using banks of capacitors as power sources for electromagnetic armour and electromagnetic railguns or coilguns.

Hazards and safety Capacitors may retain a charge long after power is removed from a circuit; this charge can cause shocks (sometimes fatal) or damage to connected equipment. For example, even a seemingly innocuous device such as a disposable camera flash unit powered by a 1.5 volt AA battery contains a capacitor which may be charged to over 300 volts. This is easily capable of delivering an extremely painful, and possibly lethal shock.

Care must be taken to ensure that any large or high-voltage capacitor is properly discharged before servicing the containing equipment. For safety purposes, all large capacitors should be discharged before handling. For board-level capacitors, this is done by placing a bleeder resistor across the terminals, whose resistance is large enough that the leakage current will not affect the circuit, but small enough to discharge the capacitor shortly after power is removed. High-voltage capacitors should be stored with the terminals shorted, since temporarily discharged capacitors can develop potentially dangerous voltages when the terminals are left open-circuited. Large oil-filled old capacitors must be disposed of properly as some contain polychlorinated biphenyls (PCBs). It is known that waste PCBs can leak into groundwater under landfills. If consumed by drinking contaminated water, PCBs are carcinogenic, even in very tiny amounts. If the capacitor is physically large it is more likely to be dangerous and may require precautions in addition to those described above. New electrical components are no longer produced with PCBs. ("PCB" in electronics usually means printed circuit board, but the above usage is an exception.) Capacitors containing PCB were labelled as containing "Askarel" and several other trade names.

High-voltage Above and beyond usual hazards associated with working with high voltage, high energy circuits, there are a number of dangers that are specific to high voltage capacitors. High voltage capacitors may catastrophically fail when subjected to voltages or currents beyond their rating, or as they reach their normal end of life. Dielectric or metal interconnection failures may create arcing within oil-filled units that vaporizes dielectric fluid, resulting in case bulging, rupture, or even an explosion that disperses flammable oil, starts fires, and damages nearby equipment. Rigid cased cylindrical glass or plastic cases are more prone to explosive rupture than rectangular cases due to an inability to easily expand under pressure. Capacitors used in RF or sustained high current applications can overheat, especially in the center of the capacitor rolls. The trapped heat may cause rapid interior heating and destruction, even though the outer case remains relatively cool. Capacitors used within high energy capacitor banks can violently explode when a fault in one capacitor causes sudden dumping of energy stored in the rest of the bank into the failing unit. And, high voltage vacuum capacitors can generate soft X-rays even during normal operation. Proper containment, fusing, and preventative maintenance can help to minimize these hazards. High voltage capacitors can benefit from a pre-charge to limit in-rush currents at power-up of HVDC circuits. This will extend the life of the component and may mitigate high voltage hazards.

History

Various types of capacitors. From left: multilayer ceramic, ceramic disc, multilayer polyester film, tubular ceramic, polystyrene (twice: axial and radial), electrolytic. Major scale divisions are cm.

Various Capacitors In October 1745, Ewald Georg von Kleist of Pomerania invented the first recorded capacitor: a glass jar coated inside and out with metal. The inner coating was connected to a rod that passed through the lid and ended in a metal sphere. By having this thin layer of glass insulation (a dielectric) between two large, closely spaced plates, von Kleist found the energy density could be increased dramatically compared with the situation with no insulator. In January 1746, before Kleist's discovery became widely known, a Dutch physicist Pieter van Musschenbroek independently invented a very similar capacitor. It was named the Leyden jar, after the University of Leyden where van Musschenbroek worked. Daniel Gralath was the first to combine several jars in parallel into a "battery" to increase the total possible stored charge. The earliest unit of capacitance was the 'jar', equivalent to about 1 nF. Early capacitors were also known as condensers, a term that is still occasionally used today. It was coined by Volta in 1782 (derived from the Italian condensatore), with reference to the device's ability to store a higher density of electric charge than a normal isolated conductor. Most non-English languages still use a word derived from "condensatore", like the French "condensateur", the German, Norwegian or Polish "Kondensator", or the Spanish "condensador".

Indicators of Capacity Many capacitors have numbers printed on their bodies to indicate their electrical characteristics. Some are indicated with XYZ K/M VOLTS V where XYZ stands for the capacitance, the letters K and M is the tolerance of 10% or 20% respectively and VOLTS V represents the work voltage. Example: A capacitor that has written on its body : 105 K 330 V is a capacitor 10^5 pF 10% with a work voltage of 330 V

A capacitor 103 M 100 V is a capacitor 10 x 10 pF 20% with a work voltage of 100 V, or 10 000 x 10-12 Farad, or .01uF (microfarad).

The rule is: XY x 10^Z pF (picoFarads) Tolerance Work voltage. TRIAC The TRIAC is a three-terminal device similar in construction and operation to the SCR. The TRIAC controls and conducts current flow during both alternations of an ac cycle, instead of only one. The schematic symbols for the SCR and the TRIAC are compared in figure 3-23. Both the SCR and the TRIAC have a gate lead. However, in the TRIAC the lead on the same side as the gate is "main terminal 1," and the lead opposite the gate is "main terminal 2." This method of lead labeling is necessary because the TRIAC is essentially two SCRs back to back, with a common gate and common terminals. Each terminal is, in effect, the anode of one SCR and the cathode of another, and either terminal can receive an input. In fact, the functions of a TRIAC can be duplicated by connecting two actual SCRs as shown in figure 3-24. The result is a three-terminal device identical to the TRIAC. The common anode-cathode connections form main terminals 1 and 2, and the common gate forms terminal 3. Figure 3-23. - Comparison of SCR and TRIAC symbols.

Figure 3-24. - Back to back SCR equivalent circuit.

The difference in current control between the SCR and the TRIAC can be seen by comparing their operation in the basic circuit shown in figure 3-25. In the circuit shown in view A, the SCR is connected in the familiar half-wave arrangement. Current will flow through the load resistor (RL) for one alternation of each input cycle. Diode CR1 is necessary to ensure a positive trigger voltage. Figure 3-25A. - Comparison of SCR and TRIAC circuits.

In the circuit shown in view B, with the TRIAC inserted in the place of the SCR, current flows through the load resistor during both alternations of the input cycle. Because either alternation will trigger the gate of the TRIAC, CR1 is not required in the circuit. Current flowing through the load will reverse direction for half of each input cycle. To clarify this difference, a comparison of the waveforms seen at the input, gate, and output points of the two devices is shown in figure 3-26.

Figure 3-25B. - Comparison of SCR and TRIAC circuits.

Figure 3-26. - Comparison of SCR and TRIAC waveforms.

A TRIAC, or TRIode for Alternating Current is an electronic component approximately equivalent to two silicon-controlled rectifiers (SCRs/thyristors) joined in inverse parallel (paralleled but with the polarity reversed) and with their gates connected together. Formal name for a TRIAC is bidirectional triode thyristor. This results in a bidirectional electronic switch which can conduct current in either direction when it is triggered (turned on). It can be triggered by either a positive or a negative voltage being applied to its gate electrode (with respect to A1, otherwise known as MT1). Once

triggered, the device continues to conduct until the current through it drops below a certain threshold value, such as at the end of a half-cycle of alternating current (AC) mains power. This makes the TRIAC a very convenient switch for AC circuits, allowing the control of very large power flows with milliampere-scale control currents. In addition, applying a trigger pulse at a controllable point in an AC cycle allows one to control the percentage of current that flows through the TRIAC to the load (so-called phase control). Low power TRIACs are used in many applications such as light dimmers, speed controls for electric fans and other electric motors, and in the modern computerized control circuits of many household small and major appliances. However, when used with inductive loads such as electric fans, care must be taken to assure that the TRIAC will turn off correctly at the end of each half-cycle of the ac power.

Triac semiconductor construction A snubber circuit is often used to assist this turn off. Snubber circuits are also used to prevent premature triggering. For higher-powered, more-demanding loads, two SCRs in inverse parallel may be used instead of one TRIAC. Because each SCR will have an entire half-cycle of reverse polarity voltage applied to it, turn-off of the SCRs is assured, no matter what the character of the load.

SCRs are unidirectional (one-way) current devices, making them useful for controlling DC only. If two SCRs are joined in back-to-back parallel fashion just like two Shockley diodes were joined together to form a DIAC, we have a new device known as the TRIAC: (Figure below)

The TRIAC SCR equivalent and, TRIAC schematic symbol Because individual SCRs are more flexible to use in advanced control systems, these are more commonly seen in circuits like motor drives; TRIACs are usually seen in simple, low-power applications like household dimmer switches. A simple lamp dimmer circuit is shown in Figure below, complete with the phase-shifting resistor-capacitor network necessary for after-peak firing.

TRIAC phase-control of power TRIACs are notorious for not firing symmetrically. This means these usually won't trigger at the exact same gate voltage level for one polarity as for the other. Generally speaking, this is undesirable, because unsymmetrical firing results in a current waveform with a greater variety of harmonic frequencies. Waveforms that are symmetrical above and below their average centerlines are comprised of only odd-numbered harmonics. Unsymmetrical waveforms, on the other hand, contain even-numbered harmonics (which may or may not be accompanied by odd-numbered harmonics as well). In the interest of reducing total harmonic content in power systems, the fewer and less diverse the harmonics, the better -- one more reason individual SCRs are favored over TRIACs for complex, high-power control circuits. One way to make the TRIAC's current waveform more symmetrical is to use a device external to the TRIAC to time the triggering pulse. A DIAC placed in series with the gate does a fair job of this: (Figure below)

DIAC improves symmetry of control

DIAC breakover voltages tend to be much more symmetrical (the same in one polarity as the other) than TRIAC triggering voltage thresholds. Since the DIAC prevents any gate current until the triggering voltage has reached a certain, repeatable level in either direction, the firing point of the TRIAC from one half-cycle to the next tends to be more consistent, and the waveform more symmetrical above and below its centerline. Practically all the characteristics and ratings of SCRs apply equally to TRIACs, except that TRIACs of course are bidirectional (can handle current in both directions). Not much more needs to be said about this device except for an important caveat concerning its terminal designations. From the equivalent circuit diagram shown earlier, one might think that main terminals 1 and 2 were interchangeable. These are not! Although it is helpful to imagine the TRIAC as being composed of two SCRs joined together, it in fact is constructed from a single piece of semiconducting material, appropriately doped and layered. The actual operating characteristics may differ slightly from that of the equivalent model. This is made most evident by contrasting two simple circuit designs, one that works and one that doesn't. The following two circuits are a variation of the lamp dimmer circuit shown earlier, the phase-shifting capacitor and DIAC removed for simplicity's sake. Although the resulting circuit lacks the fine control ability of the more complex version (with capacitor and DIAC), it does function: (Figure below)

This circuit with the gate to MT2 does function. Suppose we were to swap the two main terminals of the TRIAC around. According to the equivalent circuit diagram shown earlier in this section, the swap should make no difference. The circuit ought to work: (Figure below)

With the gate swapped to MT1, this circuit does not function. However, if this circuit is built, it will be found that it does not work! The load will receive no power, the TRIAC refusing to fire at all, no matter how low or high a resistance value the control resistor is set to. The key to successfully triggering a TRIAC is to make sure the gate receives its triggering current from the main terminal 2 side of the circuit (the main terminal on the opposite side of the TRIAC symbol from the gate terminal). Identification of the MT1 and MT2 terminals must be done via the TRIAC's part number with reference to a data sheet or book. REVIEW: A TRIAC acts much like two SCRs connected back-to-back for bidirectional (AC) operation. TRIAC controls are more often seen in simple, low-power circuits than complex, high-power circuits. In large power control circuits, multiple SCRs tend to be favored. When used to control AC power to a load, TRIACs are often accompanied by DIACs connected in series with their gate terminals. The DIAC helps the TRIAC fire more symmetrically (more consistently from one polarity to another). Main terminals 1 and 2 on a TRIAC are not interchangeable. To successfully trigger a TRIAC, gate current must come from the main terminal 2 (MT2) side of the circuit!

Power supply unit: Introduction Power supply is the most important part of any electronic circuit; we even cant imagine any electronic gadget in our life. Power supply has very vast and long history associated with it, before the invention of semiconductor there was a use of bulky and uncomfortable power supply which consumes lot of power and occupy large circuit area

which also increase the cost of device inversely. Here I have mentioned modern power supply unit which has semiconductor on it so that the circuit becomes very small and its consumes less power. The regulation of power supplies is done by incorporating circuitry to tightly control the output voltage and/or current of the power supply to a specific value. The specific value is closely maintained despite variations in the load presented to the power supply's output, or any reasonable voltage variation at the power supply's input. This kind of regulation is commonly categorized as a Stabilized power supply. Step-down Transformer A transformer is a device that transfers electrical energy from one circuit to another by magnetic coupling without requiring relative motion between its parts. It usually comprises two or more coupled windings, and, in most cases, a core to concentrate magnetic flux. An alternating voltage applied to one winding creates a time varying magnetic flux in the core, which induces a voltage in the other windings. Varying the relative number of turns between primary and secondary windings determines the ratio of the input and output voltages, thus transforming the voltage by stepping it up or down between circuits. Rectifier A simple AC powered linear power supply usually uses a transformer to convert the voltage from the wall outlet (mains) to a different, usually a lower voltage. If it is used to produce DC a rectifier circuit is employed either as a single chip, an array of diodes Sometimes called a diode bridge or Bridge Rectifier, both for full wave rectification or a single diode yielding a half wave (pulsating) output. More elaborate configurations rectify the AC voltage at first to pulsating DC. Then a capacitor smooth out part of the pulses giving a type of DC voltage. The smaller pulses remaining are known as ripple. Because of a full wave rectification they occur at twice the mains frequency (in USA it's 60 Hz doubled to 120 Hz). Finally, depending on the requirements of the load, a linear regulator may be used to reduce the ripple sometimes also allowing for adjustment of the output to the desired but a lower voltage. More elaborate versions used by circuit designers are adjustable up to 30 volts and up to 5 amperes output. These often employ

current limiting. Some can be driven by an external signal, for example, for applications requiring a pulsed output. A rectifier is an electrical device that converts alternating current to direct current, a process known as rectification. Rectifiers are used as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid state diodes, vacuum tube diodes, mercury arc valves, and other technologies. When just 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 rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting AC to DC than is possible with just a single diode. Before the development of solid state rectifiers, vacuum tube diodes and copper oxide or selenium rectifier stacks were used. Early radio receivers called crystal sets, 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". In gas heating systems flame rectification can be used to detect a flame. Two metal electrodes in the outer layer of the flame provide a current path and rectification of an applied alternating voltage, but only while the flame is present. 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.

Filter

The simple capacitor filter is the most basic type of power supply filter. The application of the simple capacitor filter is very limited. It is sometimes used on extremely highvoltage, low-current power supplies for cathode-ray and similar electron tubes, which require very little load current from the supply. The capacitor filter is also used where the power-supply ripple frequency is not critical; this frequency can be relatively high. When this filter is used, the RC charge time of the filter capacitor (C1) must be short and the RC discharge time must be long to eliminate ripple action. In other words, the capacitor must charge up fast, preferably with no discharge at all. Better filtering also results when the input frequency is high; therefore, the full-wave rectifier output is easier to filter than that of the half-wave rectifier because of its higher frequency. For you to have a better understanding of the effect that filtering has on Eavg, a comparison of a rectifier circuit with a filter and one without a filter is illustrated in views A and B of figure 4-16. The output waveforms in figure 4-16 represent the unfiltered and filtered outputs of the half-wave rectifier circuit. Current pulses flow through the load resistance (RL) each time a diode conducts. The dashed line indicates the average value of output voltage. For the half-wave rectifier, Eavg is less than half (or approximately 0.318) of the peak output voltage. This value is still much less than that of the applied voltage. With no capacitor connected across the output of the rectifier circuit, the waveform in view A has a large pulsating component (ripple) compared with the average or dc component. When a capacitor is connected across the output (view B), the average value of output voltage (Eavg) is increased due to the filtering action of capacitor C1.

UNFILTERED

The value of the capacitor is fairly large (several microfarads), thus it presents a relatively low reactance to the pulsating current and it stores a substantial charge. Regulator A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. 7805 is an integrated three-terminal positive fixed linear voltage

regulator. It supports an input voltage of 10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp although lower current models are available. Its output voltage is fixed at 5.0V. The 7805 also has a built-in current limiter as a safety feature. 7805 is manufactured by many companies, including National Semiconductors and Fairchild Semiconductors. The 7805 will automatically reduce output current if it gets too hot. It belongs to a family of three-terminal positive fixed regulators with similar specifications and differing fixed voltages from 8 to 15 volts. These are usually packaged in TO220 chip carriers, but smaller surface-mount and larger TO3 packages are also available. The last two digits represent the voltage; for instance, the 7812 is a 12-volt regulator. The 78xx series of regulators is designed to work in complement with the 79xx series of negative voltage regulators in systems that provide both positive and negative regulated voltages, since the 78xx series can't regulate negative voltages in such a system. The 7805 is one of the most common and well-known of the 78xx series regulators, as its small component count and medium power regulated 5V make it useful for powering TTL devices.

ASSEMBLER BASICS 8.1 ASSEMBLER Selecting Assemble from the Assemble menu assembles the source in the currently active editor window. The number of errors found in the source will be displayed in the Output window. If any errors are located double clicking on an error message will load the associated source code and position the cursor at the location of the line containing that error. NOTE: Some errors will generate additional errors, usually the first error is the actual offense. If you fix an error and are unable to see the problems with a subsequent error try reassembling the source. Once an error is fixed, double clicking on other listed errors will load the associated source code and position the cursor on the corresponding line If you add a new line or delete an existing line the offending line no longer has the same line number as the one in the error list. For this reason if you add or delete lines containing errors reassemble the source to regenerate an accurate error/line number list. If no errors are reported you can simulate the source.

Refer to 8051 source format, for a description of the layout of an 8031 assembly language program. 8.2 PROJECT FILE The Project option allows you to specify the main source file in a multi-file project. The project file contains include statements which list all the files in the project. This allows you to assemble your project without having to first load the main file. To specify a project file select the Project command from the Assemble menu and type in the file name or select one from the list. Use the Close Project command to clear the specified project file name. 8.3 FILE GENERATION The 8051 assembler generates a number of files when it assembles either an individual file or a project. These files have the same name as either the individual file being assembled or the name of the project being built. They will however have the following extensions HEX Intel hex format of the assembled binary code. LST List file containing line numbers, address, binary code and source lines of the file being assembled or the total project being built. SOURCE FILE FORMAT The assembler mnemonics, labels and symbols are not case sensitive. In other words LOOP is the same as loop to the assembler. Each line of the source code has the following format LABEL: OPCODE OPERANDS; COMMENT Each of these fields is defined below. LABEL: Each line of source can contain an optional label. Labels may contain letters, digits and an under score (_) character. The label must start with a alphabetic character and terminate with a colon ":". Labels can contain as many characters as you want although the assembler only recognizes the first 32. The first time a label is encountered its name along with the current value of the program counter is added to the label table. When the label is used as an operand the value of the program counter associated with that label is substituted. OPCODE: Opcodes can be either an 8051 mnemonic or an assembler directive. A list of mnemonics and their operands are given in appendix A. The following section contains a list of assembler directives. Opcodes must be separated from labels and operands by at least one blank.

OPERAND: Operands are added after a mnemonic or directive to indicate what the operation is to be performed on. For example in the instruction: MOV R1,A The operands are R1 and A. A comma, as in the example just given must separate multiple operands. COMMENT: Comments begin with a semicolon and instruct the assembler to ignore all text from the semicolon to the end of the line. SYMBOL: A symbol is a character string, which represents a specific value. For example the source line CR EQU 13 Instructs the assembler to equate the value 13 with the character sequence CR. Symbols must conform to the same requirements as labels (but they are terminated with a blank instead of a colon). EQUATIONS: The assembler has a built in equation evaluator. Opcodes requiring an immediate value or directives requiring a value can be constructed into an equation. For example in the following source line MOV A, 8*4 8 * 4 is the equation which will be evaluated. Equations can be comprised of numbers, labels, symbols, operators and parenthesized sub-equations. Numbers must start with a digit between 0 and 9. Terminating with a B, H or D respectively can specify binary, hexadecimal and decimal numbers. For example 01000001b, 041h and 65d are binary, hexadecimal and decimal representations of the same value. If the radix is not specified then decimal is assumed. Although the default assembler radix can be changed with the RADIX assembler directive. Values for ASCII characters can be specified by surrounding the character with single quotes, for example 'A' will cause the ASCII value (65) for the character to be substituted. Labels and symbols can be used if previously defined or equated to a value. Labels and symbols not defined prior to their use can be used in expressions if their value is not required on the first assembler pass. For example in the source lines DB 'hello', CR, LF CR EQU 13 LF EQU 10 The value of CR and LF are not needed on the first pass, their values can be substituted on the second pass. The only exception is the DS (Define Space) directive. An example of this is

DS BUFSIZE BUFSIZE EQU 20 This code segment will generate a phase error. On the first pass the assembler must know how many bytes to allocate for the DS (Define Space) directive in order for it to continue determining address values for subsequent labels. For this reason labels and symbols used in the DS directive must be defined prior to their use. The available operators are listed below in order of precedent () parenthesized sub-equations

High returns the high byte of an integer value/result. Example: if val is equal to 0x1234 High(val) returns 0x12 Low returns the low byte of an integer value/result. Example: if val is equal to 0x1234 Low(val) returns 0x34 HighWord Returns the high word (two-byte) of an integer value/result. Example: if val is equal to 0x12345678 HighWord(val) returns 0x1234 LowWord Returns the low word (two-byte) of an integer value/result. Example: if val is equal to 0x12345678 LowWord(val) returns 0x5678 ^ exponential * multiplication / division %, MOD modular, either type can be used. &, AND logical AND, either type can be used. |, OR logical OR, either type can be used. + addition - subtraction +, - unary operations

.n dot operator (20H.1=33, 20H.2=34, ... 20H.7=39)

ASSEMBLER DIRECTIVES The following is a list of directives supported by the 8051 Assembler: ORG: Originate. Resets the program counter (at assembly time) to a specific value. For example the source line ORG 7 resets the program counter to the value 7. DATAORG: Data Originate. Resets the data address counter used by the DS directive. For example the source code segment DATAORG 10 VAR1 DS 1 VAR2 DS 1 sets the symbols VAR1 and VAR2 to 10 and 11 respectively. EQU: Equates a value with a character string (Symbol). For example the source line LF EQU 10 adds the symbol LF to the symbol table with the associated value 10. Each time LF is used as an operand the value 10 will be substituted. A symbol can be equated only once in a project. Equated symbols are evaluated to a numeric result. The EQU directive does not perform a character substitution. SET: Like EQU, SET sets a symbol to a specific value. A symbols value can be modified at more than one location in the source file by the SET command. BIT: Equates a bit address with a character string (Symbol). For example the source line HoldPin BIT 80h adds the symbol HoldPin to the symbol table with the associated bit address 80h (128 decimal, same as bit 0 of port 0). Each time HoldPin is used as an operand the value 80h will be substituted. A symbol can be defined using the BIT operation only once in a project. Bit defined symbols are evaluated to a numeric result. The BIT directive does not perform a character substitution.

DATA: Equates an address with a character string (Symbol). For example the source line Count1 DATA 10h adds the symbol Count1 to the symbol table with the associated address 10h (16 decimal). Each time Count1 is used as an operand the value 10h will be substituted. A symbol can be defined using the DATA operation only once in a project. Defined symbols are evaluated to a numeric result. The DATA irective does not perform a character substitution. DB: Define byte. This directive places a value or string of values in program memory at the current program counter location (one per memory location). For example NUM: DB 10 MSG: DB 'HELLO WORLD',13,10 are legal usage of the DB directive. Each value (or values) will occupy one memory location. DW: Define word. This directive places a value or string of values in program memory at the current program counter location one per 2 bytes of memory. For example NUM: DW 10 MSG: DW 'HELLO WORLD', 13, 10 are legal usage of the DW directive. Each value (or values) will occupy two memory locations (in LS MS order). DS: Define space. This directive will allocated a specified number of data memory locations starting at the current data address counter location. For example BUF DS 10 Will allocate 10 bytes of memory starting at the location associated with BUF. This directive is used to allocate space in internal and external data memory. END: Instructs the assembler to stop assembling the source file (ignore any text, which follows the END directive). The END directive is not required; the assembler will stop assembling either when it reaches an END directive or the end of the text buffer.

COADING #include<reg51.h> #define ack 0 #define nack 1 #define addrtc 0xd0 sbit scl =P2^3; sbit sda= P2^7; sbit seg0=P1^0; sbit seg1=P1^0; void delay(unsigned int); void i2c_start(); void i2c_stop(); void i2c_write(unsigned char d); unsigned char i2c_read(unsigned char); void disp_clk_regs(void); void rtc_set(void); unsigned char uart_read(void); void transmit(unsigned char); unsigned char arr_seg[]={0x09,0xbd,0x4c,0x1c,0xb8,0x1a,0x0a,0x9d,0x08,0x18}; void main() { // unsigned char c; scl=1; sda=1; TMOD=0x20; TH1=0xf4; //-12 SCON=0x50; IE=0x00; TR1=1; transmit('N'); transmit(0x0a); // c=uart_read(); // if(c=='s') rtc_set(); while(1) { disp_clk_regs(); //delay(100);

} } void i2c_start() { sda=1; scl=1; scl=1; sda=0; } void i2c_stop() { sda=0;sda=0;sda=0;scl=1;scl=1;sda=1; } void i2c_write(unsigned char d) { unsigned char i; scl=0; for(i=1;i<=8;i++) { sda=(d>>7); scl=1; d=d<<1; scl=0; } sda=1; scl=0; scl=1; scl=0; } unsigned char i2c_read(unsigned char b) { unsigned char d,i; sda=1; scl=0; for(i=1;i<=8;i++) { scl=1; d=d<<1; d=d | (unsigned char)sda; scl=0; } sda=b;

scl=0; scl=1; if(b==nack) sda=1; scl=0; sda=1; return d; } void disp_clk_regs(void) { unsigned char sec,min,prv_sec=0,hr,dt,mon,dy,yr,i,j; unsigned char sec1,min1,hr1,sec2,min2,hr2,dt2,yr2,dt1,yr1,mon1,mon2; i2c_start(); i2c_write(addrtc); i2c_write(0x00); i2c_stop(); i2c_start(); i2c_write(addrtc|0x01); sec=i2c_read(ack); min=i2c_read(ack); hr=i2c_read(ack); dy=i2c_read(ack); dt=i2c_read(ack); mon=i2c_read(ack); yr=i2c_read(ack); i2c_stop(); if((hr>=0)&&(hr<=59)) { if(sec!=prv_sec) { prv_sec=sec; hr1=hr&0xf0; hr1=(hr1>>4)+0x30; transmit(hr1); hr2=(hr&0x0f)+0x30; transmit(hr2); transmit(':'); min1=min&0xf0; min1=(min1>>4)+0x30; transmit(min1); min2=(min&0x0f)+0x30; transmit(min2); transmit(':'); sec1=sec&0xf0; i=sec1>>4;

//

sec1=i+0x30; transmit(sec1); j=sec&0x0f; sec2=j+0x30; transmit(sec2); transmit(' '); seg0=1; dt1=dt&0xf0; dt1=(dt1>>4)+0x30; transmit(dt1); dt2=(dt&0x0f)+0x30; transmit(dt2); transmit('/'); mon1=mon&0xf0; mon1=(mon1>>4)+0x30; transmit(mon1); mon2=(mon&0x0f)+0x30; transmit(mon2); transmit('/'); yr1=yr&0xf0; yr1=(yr1>>4)+0x30; transmit(yr1); yr2=(yr&0x0f)+0x30; transmit(yr2); transmit(0x0d); seg1=0; P0=arr_seg[i]; delay(500); seg1=1; seg0=0; P0=arr_seg[j]; delay(50); seg0=1; } }

} void rtc_set() { /* unsigned char hr,min,sec,hr1,hr2,min1,min2,sec1,sec2; hr1=uart_read(); transmit(hr1); hr2=uart_read(); transmit(hr2); min1=uart_read(); transmit(min1);

//

min2=uart_read(); transmit(min2); sec1=uart_read(); transmit(sec1); sec2=uart_read(); transmit(sec2); hr1=hr1&0x0f; hr1<<=4; hr2=hr2&0x0f; hr=hr1|hr2; min1=min1&0x0f; min1<<=4; min2=min2&0x0f; min=min1|min2; sec1=sec1&0x0f; sec1<<=4; sec2=sec2&0x0f; sec=sec1|sec2; */ i2c_start(); i2c_write(addrtc); i2c_write(0x00); i2c_stop(); i2c_start(); i2c_write(addrtc); i2c_write(0x00); i2c_write(0x30); i2c_write(0x54); i2c_write(0x10); i2c_write(0x07); //01010000 i2c_write(0x06); i2c_write(0x01); i2c_write(0x08); i2c_stop(); delay(1000);

} void delay(unsigned int itime) { unsigned int i; for(i=0; i<itime; i++); } void transmit(unsigned char x) { SBUF=x; while(TI==0);

TI=0; } unsigned char uart_read() { unsigned char r; while(RI!=1); RI=0; r=SBUF; return r; }