Sie sind auf Seite 1von 58

MICROCONTROLLER BASED Automated Train Signal System

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR AWARD OF THE DEGREE

OF

B.TECH (ELECTRONICS & COMMUNICATION) (2007-2011)

SUBMITTED BY:

. RAJIV KUMAR(07/EL/70)

. RAVINDER KUMAR(07/EL/74)

. SHAINKI BANSAL(07/EL/82)

Maharshi Dayanand

Universty (MDU)Rohtak

DEPARMENT OF: ELECTRONICS & COMMUNICATION ENGINEERING B.S.A.I.T.M FARIDABAD

ACKNOWLEDGMENT

THE authors gratefully acknowledgw the guidance provided by the project supervisor Mr. Deepak Arora (project coordinator) throughout the development of the project.

The authors wish to thank Mr. jaspal jindal,HOD ELECTRONICS & COMMUNICATION ENGINEERING DEPARTMENT for his consistent support, valuable suggestion and directions.

The authors also thank their batch mates for providing constant encouragement, support and suggestions during the development of the project.

. RAJIV KUMAR (07/EL/70) . RAVINDER KUMAR(07/EL/74) . SHAINKI BANSAL(07/EL/82)

CANDIDATES DECLARATION

We hereby declare that this project report titled microcontroller based code lock submitted towords the completion of major project in 8th semester of B.TECH(E.C.E) in B.S.ANANGPURIA INSTITUTE OF TECHNOLOGY AND MANAGEMENT,FARIDABAD is an authentic record of work carried out under the guidance of

Mr. JASPAL JINDAL (HOD,ECE DEPT)

Mr.DEEPAK ARORA (PROJECT COORDINATOR)

DATE:APRIL 8,2011 PLACE: FARIDABAD

CERTIFICATE

This is to certify that the declaration made by Mr. Rajiv Kumar,Ravinder Kumar,Shainki Bansal is true the best of my knowledge and belief.

DATE:APRIL 8,2011 PLACE: FARIDABAD

Mr. JASPAL JINDAL (HOD,ECE DEPT)

Abstract

Automated train signaling system project is a prototype of Indian railways signal system and also proposed a way for AUTOMATIC CONTROL FOR UNMANNED RAILWAY GATE. This use three led (red, green, yellow) controlled by microcontroller 8051 to represent train signals. Microcontroller sense the Location/position of train is done by using magnetic reed switch and control all signal and Gate. Unmanned gate is controlled by interfacing a stepper motor to microcontroller which provide fixed step to open and close the gate. This simple train signal prototype project is based on a 20-pin ATMEL microcontroller T89C2051. It employs a 4-digit sequential code with time-out security feature. In addition to the microcontroller, the circuit uses a single additional IC (ULN2003) .

INDEX 1. INTRODUCTION 2. CIRCUIT DIAGRAM 3. LAYOUT 4. EXPLANATION OF CIRCUIT DIAGRAM 5. COMPONENTS DISCRIPTION 6. INTRODUCTION TO MICROCONTROLLER 7. 8051 ARCHTECTURE 8. 8051 PIN FUNCTION 9. PROGRAMING

This diagram shows a line with three aspect of signal. The block is occupied by Train 1 is protected by the red signal at the entrance. The block behind IS Clear of train but a yellow signal is provide adavance warning of the red aspect ahead. This block provide the safe braking distance for the train 2.The next block in rear is also clear of train and shows green.

CIRCUI DIAGRAM

Circuit Description-:
As already mentioned, the project makes use of ATMEL AT89C2051 microcontroller, in 20-pin DIP package, which supports 2 kB of flash-based program memory. Signal LED are connected to the Port P3 and Port P1. Which are controlled when signal are received from magnetic reed switch. Magnetic reed switch are connected to Port P1. Mocrocontroller received the signal from reed switch and and command LED and stepper motor. A 4 pole stepper motor is connected to port P2 through a IC ULN2003 which is used to drive the Stepper motor. ADD here more about microcontroller reset,circuit, Description of power supply ******************************************

POWER SUPPLY: Power supply is a reference to a source of electrical power. A device or system that supplies Electrical or other types of energy to an output load or group of loads is called a power supply unit Or PSU. The term is most commonly applied to electrical energy supplies, less often to mechanical ones, and rarely to others. Here in our application we need a 5v DC power supply for all electronics involved in the project. This requires step down transformer, rectifier, voltage regulator, and filter circuit for generation of 5v DC power. Here a brief description of all the components is given as follows:

TRANSFORMER: A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductors the transformer's coils or "windings". Except for air-core transformers, the conductors are commonly wound around a single iron-rich core, or around separate but magnetically coupled cores. A varying current in the first or "primary" winding creates a varying magnetic field in the core (or cores) of the transformer. This varying magnetic field induces a varying electromotive force (EMF) or "voltage" in the "secondary" winding. This effect is called mutual induction.

If a load is connected to the secondary circuit, electric charge will flow in the secondary winding of the transformer and transfer energy from the primary circuit to the load connected in the secondary circuit. The secondary induced voltage VS, of an ideal transformer, is scaled from the primary VP by a factor equal to the ratio of the number of turns of wire in their respective windings: By appropriate selection of the numbers of turns, a transformer thus allows an alternating voltage to be stepped up by making NS more than NP or stepped down, by making it.

BASIC PARTS OF A TRANSFORMER In its most basic form a transformer consists of: A primary coil or winding. A secondary coil or winding. A core that supports the coils or windings.

Refer to the transformer circuit in figure as you read the following explanation: The primary winding is connected to a 60-hertz ac voltage source. The magnetic field (flux) builds up (expands) and collapses (contracts) about the primary winding. The expanding and contracting magnetic field around the primary winding cuts the secondary winding and induces an alternating voltage into the winding. This voltage causes alternating current to flow through the load. The voltage may be stepped up or down depending on the design of the primary and secondary windings.

THE COMPONENTS OF A TRANSFORMER Two coils of wire (called windings) are wound on some type of core material. In some cases the coils of wire are wound on a cylindrical or rectangular cardboard form. In effect, the core material is air and the transformer is called an AIR-CORE TRANSFORMER. Transformers used at low frequencies, such as 60 hertz and 400 hertz, require a core of low-reluctance magnetic Material usually iron. This type of transformer is called an IRON-CORE TANSFORMER. Most power transformers are of the iron-core type. The principle parts of a transformer and their functions are: The CORE, which provides a path for the magnetic lines of flux. The PRIMARY WINDING, which receives energy from the ac source. The SECONDARY WINDING, which receives energy from the primary winding and delivers it to the load. The ENCLOSURE, which protects the above components from dirt, moisture, and mechanical damage. BRIDGE RECTIFIER

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. BASIC OPERATION According to the conventional model of current flow originally established by Benjamin Franklin and still followed by most engineers today, current is assumed to flow through electrical conductors from the positive to the negative pole. In actuality, free electrons in a conductor nearly always flow from the negative to the positive pole. In the vast majority of applications, however, the actual direction of current flow is irrelevant. Therefore, in the discussion below the conventional model is retained. In the diagrams below, when the input connected to the left corner of the diamond is positive, and the input connected to the right corner is negative, current flows from the upper supply terminal to the right along the red (positive) path to the output, and returns to the lower supply terminal via the blue (negative) path.

When the input connected to the left corner is negative, and the input connected to the right corner is positive, current flows from the lower supply terminal to the right along the red path to the output, and returns to the upper supply terminal via the blue path.

In each case, the upper right output remains positive and lower right output negative. Since this is true whether the input is AC or DC, this circuit not only produces a DC output from an AC input, it can also provide what is sometimes called "reverse polarity protection". That is, it permits normal functioning of DC-powered equipment when batteries have been installed backwards, or when the leads (wires) from a DC power source have been reversed, and protects the equipment from potential damage caused by reverse polarity. Prior to availability of integrated electronics, such a bridge rectifier was always constructed from discrete components. Since about 1950, a single four-terminal component containing the four diodes connected in the bridge configuration became a standard commercial component and is now available with various voltage and current ratings. OUTPUT SMOOTHING For many applications, especially with single phase AC where the full-wave bridge serves to convert an AC input into a DC output, the addition of a capacitor may be desired because the bridge alone supplies an output of fixed polarity but continuously varying or "pulsating" magnitude (see diagram above).

The function of this capacitor, known as a reservoir capacitor (or smoothing capacitor) is to lessen the variation in (or 'smooth') the rectified AC output voltage waveform from the bridge. One explanation of 'smoothing' is that the capacitor provides a low impedance path to the AC component of the output, reducing the AC voltage across, and AC current through, the resistive load. In less technical terms, any drop in the output voltage and current of the bridge tends to be canceled by loss of charge in the capacitor. This charge flows out as additional current through the load. Thus the change of load current and voltage is reduced relative to what would occur without the capacitor. Increases of voltage correspondingly store excess charge in the capacitor,thus moderating the change in output voltage / current. The simplified circuit shown has a well-deserved reputation for being dangerous, because, in some applications, the capacitor can retain a lethal charge after the AC power source is removed. If supplying a dangerous voltage, a practical circuit should include a reliable way to safely discharge the capacitor. If the normal load cannot be guaranteed to perform this function, perhaps because it can be disconnected, the circuit should include a bleeder resistor connected as close as practical across the capacitor. This resistor should consume a current large enough to discharge the capacitor in a reasonable time, but small enough to minimize unnecessary power waste. Because a bleeder sets a minimum current drain, the regulation of the circuit, defined as percentage voltage change from minimum to maximum load, is improved. However in many cases the improvement is of insignificant magnitude. The capacitor and the load resistance have a typical time constant = RC where C and R are the capacitance and load resistance respectively. As long as the load resistor is large enough so that this time constant is much longer than the time of one ripple cycle, the above configuration will produce a smoothed DC voltage across the load. In some designs, a series resistor at the load side of the capacitor is added. The smoothing can then be improved by adding additional stages of capacitorresistor pairs, often done only for subsupplies to critical high-gain circuits that tend to be sensitive to supply voltage noise. The idealized waveforms shown above are seen for both voltage

and current when the load on the bridge is resistive. When the load includes a smoothing capacitor, both the voltage and the current waveforms will be greatly changed. While the voltage is smoothed, as described above, current will flow through the bridge only during the time when the input voltage is greater than the capacitor voltage. For example, if the load draws an average current of n Amps, and the diodes conduct for 10% of the time, the average diode current during conduction must be 10n Amps. This non-sinusoidal current leads to harmonic distortion and a poor power factor in the AC supply. In a practical circuit, when a capacitor is directly connected to the output of a bridge, the bridge diodes must be sized to withstand the current surge that occurs when the power is turned on at the peak of the AC voltage and the capacitor is fully discharged. Sometimes a small series resistor is included before the capacitor to limit this current, though in most applications the power supply transformer's resistance is already sufficient. Output can also be smoothed using a choke and second capacitor. The choke tends to keep the current (rather than the voltage) more constant. Due to the relatively high cost of an effective choke compared to a resistor and capacitor this is not employed in modern equipment. Some early console radios created the speaker's constant field with the current from the high voltage ("B +") power supply, which was then routed to the consuming circuits, (permanent magnets were then too weak for good performance) to create the speaker's constant magnetic field. The speaker field coil thus performed 2 jobs in one: it acted as a choke, filtering the power supply, and it produced the magnetic field to operate the speaker.

REGULATOR IC (78XX) It is a three pin IC used as a voltage regulator. It converts unregulated DC current into regulated DC current.

Normally we get fixed output by connecting the voltage regulator at the output of the filtered DC (see in above diagram). It can also be used in circuits to get a low DC voltage from a high DC voltage (for example we use 7805 to get 5V from 12V). There are two types of voltage regulators 1. fixed voltage regulators (78xx, 79xx) 2. variable voltage regulators (LM317) In fixed voltage regulators there is another classification 1. +ve voltage regulators 2. -ve voltage regulators POSITIVE VOLTAGE REGULATORS This include 78xx voltage regulators. The most commonly used ones are 7805 and 7812. 7805 gives fixed 5V DC voltage if input voltage is in (7.5V, 20V).

The CAPACITOR 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, lowcurrent 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. The capacitor (C1) shown in figure 4-15 is a simple filter connected across the output of the rectifier in parallel with the load.

Full-wave rectifier with a capacitor filter.

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 halfwave 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

Half-wave rectifier with and without filtering

FILTER

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. The rate of charge for the capacitor is limited only by the resistance of the conducting diode, which is relatively low. Therefore, the RC charge time of the circuit is relatively short. As a result, when the pulsating voltage is first applied to the circuit, the capacitor charges rapidly and almost reaches the peak value of the rectified voltage within the first few cycles. The capacitor attempts to charge to the peak value of the rectified voltage anytime a diode is conducting, and tends to retain its charge when the rectifier output falls to zero. (The capacitor cannot discharge immediately.) The capacitor slowly

discharges through the load resistance (RL) during the time the rectifier is nonconducting. The rate of discharge of the capacitor is determined by the value of capacitance and the value of the load resistance. If the capacitance and load-resistance values are large, the RC discharge time for the circuit is relatively long. A comparison of the waveforms shown in figure 4-16 (view A and view B) illustrates that the addition of C1 to the circuit results in an increase in the average of the output voltage (Eavg) and a reduction in the amplitude of the ripple component (Er) which is normally present across the load resistance. Now, let's consider a complete cycle of operation using a half-wave rectifier, a capacitive filter (C1), and a load resistor (RL). As shown in view A of figure 4-17, the capacitive filter (C1) is assumed to be large enough to ensure a small reactance to the pulsating rectified current. The resistance of RL is assumed to be much greater than the reactance of C1 at the input frequency. When the circuit is energized, the diode conducts on the positive half cycle and current flows through the circuit, allowing C1 to charge. C1 will charge to approximately the peak value of the input voltage. (The charge is less than the peak value because of the voltage drop across the diode (D1)). In view of the figure, the heavy solid line on the waveform indicates the charge on C1. As illustrated in view B, the diode cannot conduct on the negative half cycle because the Anode of D1 is negative with respect to the cathode. During this interval, C1 discharges through the load resistor (RL). The discharge of C1 produces the downward slope as indicated by the solid line on the waveform in view B. In contrast to the abrupt fall of the applied ac voltage from peak value to zero, the voltage across C1 (and thus across RL) during the discharge period gradually decreases until the time of the next half cycle of rectifier operation. Keep in mind that for good filtering, the filter capacitor should charge up as fast as possible and discharge as little as possible.

Figure 4-17A. - Capacitor filter circuit (positive and negative half cycles). POSITIVE HALFCYCLE

Since practical values of C1 and RL ensure a more or less gradual decrease of the discharge voltage, a substantial charge remains on the capacitor at the time of the next half cycle of operation. As a result, no current can flow through the diode until the rising ac input voltage at the anode of the diode exceeds the voltage on the charge remaining on C1. The charge on C1 is the cathode potential of the diode. When the potential on the anode exceeds the potential on the cathode (the charge on C1), the diode again conducts and C1 begins to charge to approximately the peak value of the applied voltage. After the capacitor has charged to its peak value, the diode will cut off and the capacitor will start to discharge. Since the fall of the ac input voltage on the anode is considerably more rapid than the decrease on the capacitor voltage, the cathode quickly become more positive than the anode, and the diode ceases to conduct. Operation of the simple capacitor filter using a full-wave rectifier is basically the same as that discussed for the half-wave rectifier. Referring to figure 4-18, you should notice that because one of the diodes is always conducting on. Either alternation, the filter capacitor charges and discharges during each half cycle. (Note that each diode conducts only for that portion of time when the peak secondary voltage is greater than the charge across the capacitor.) Figure 4-18. - Full-wave rectifier (with capacitor filter).

Another thing to keep in mind is that the ripple component (E r) of the output voltage is an ac voltage and the average output voltage (Eavg) is the dc component of the output. Since the filter capacitor offers relatively low impedance to ac, the majority of the ac component flow through the filter capacitor. The ac component is therefore bypassed (shunted) around the load resistance, and the entire dc component (or Eavg) flows through the load resistance. This statement can be clarified by using the formula for XC in a half-wave and full-wave rectifier. First, you must establish some values for the circuit. CIRCUIT DIAGRAM OF POWER SUPPLY

When we have to learn about a new computer we have to familiarize about the machine Capability we are using, and we can do it by studying the internal hardware design (devices Architecture), and also to know about the size, number and the size of the registers. A microcontroller is a single chip that contains the processor (the CPU), nonvolatile memory for the program (ROM or flash), volatile memory for input and output (RAM), a clock and an I/O control unit. Also called a "computer on a chip," billions of microcontroller units (MCUs) are embedded each year in a myriad of products from toys to appliances to automobiles. For example, a single vehicle can use 70 or more microcontrollers. The following picture describes a general block diagram of microcontroller

89S52: The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-stand and 80C51instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory pro-grammar. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller, which provides a highly flexible and cost-effective solution to many, embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Powerdown mode saves the RAM con-tents but freezes the oscillator, disabling all other chip

functions until the next interrupt

The hardware is driven by a set of program instructions, or software. Once familiar with hardware and software, the user can then apply the microcontroller to the problems easily. The pin diagram of the 8051 shows all of the input/output pins unique to microcontrollers: The following are some of the capabilities of 8051 microcontroller Internal

The following are some of the capabilities of 8051 microcontroller. Internal ROM and RAM I/O ports with programmable pins Timers and counters Serial data communication The 8051 architecture consists of these specific features: 16 bit PC &data pointer (DPTR) 8 bit program status word (PSW) 8 bit stack pointer (SP) Internal ROM 4k Internal RAM of 128 bytes. 4 register banks, each containing 8 registers 80 bits of general purpose data memory 32 input/output pins arranged as four 8 bit ports: P0-P3 Two 16 bit timer/counters: T0-T1 Two external and three internal interrupt sources Oscillator and Clock circuits.

RESISTOR

A resistor is a two-terminal electronic component that produces a voltage across its terminals that is proportional to the electric current through it in accordance with Ohm's law: V = IR Units The ohm (symbol: ) is the SI unit of electrical resistance, named after Georg Simon Ohm. Commonly used multiples and submultiples in electrical and electronic usage are the milliohm (1x103), kilohm (1x103), and megohm (1x106). Theory of operation Ohm's law The behavior of an ideal resistor is dictated by the relationship specified in Ohm's law: Ohm's law states that the voltage (V) across a resistor is proportional to the current (I) through it where the constant of proportionality is the resistance (R). Equivalently, Ohm's law can be stated:

This formulation of Ohm's law states that, when a voltage (V) is maintained across a resistance (R), a current (I) will flow through the resistance. This formulation is often used in practice. For example, if V is 12 volts and R is 400 ohms, a current of 12 / 400 = 0.03 amperes will flow through the resistance R. [edit]Series and parallel resistors Main article: Series and parallel circuits Resistors in a parallel configuration each have the same potential difference (voltage). To find their total equivalent resistance (Req):

The parallel property can be represented in equations by two vertical lines "||" (as in geometry) to simplify equations. For two resistors,

The current through resistors in series stays the same, but the voltage across each resistor can be different. The sum of the potential differences (voltage) is equal to the total voltage. To find their total resistance:

A resistor network that is a combination of parallel and series can be broken up into smaller parts that are either one or the other. For instance,

CAPACITOR

TYPE- PASSIVE Invented Ewald Georg von Kleist (October 1745) Electronic symbol

Theory of operation Capacitance

Charge separation in a parallel-plate capacitor causes an internal electric field. A dielectric (orange) reduces the field and increases the capacitance.

A simple demonstration of a parallel-plate capacitor A capacitor consists of two conductors separated by a non-conductive region[8] called the dielectric medium though it may be a vacuum or a semiconductor depletion region chemically identical to the conductors. A capacitor is assumed to be selfcontained and isolated, with no net electric charge and no influence from any external electric field. The conductors thus hold equal and opposite charges on their facing surfaces,[9] and the dielectric develops an electric field. In SI units, a capacitance of one farad means that one coulomb of charge on each conductor causes a voltage of one volt across the device. The capacitor is a reasonably general model for electric fields within electric circuits. An ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge Q on each conductor to the voltage V between them

Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to vary. In this case, capacitance is defined in terms of incremental changes:

Applications of capacitors Capacitors have many uses in electronic and electrical systems. They are so common that it is a rare electrical product that does not include at least one for some purpose.

Light-emitting diode Light-emitting diode

Red, green and blue LEDs of the 5mm type Type Working principle Invented Electronic symbol Passive, optoelectronic Electroluminescence Nick Holonyak Jr. (1962)

Pin configuration

Anode and Cathode

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices, and are increasingly used for lighting. Introduced as a practical

electronic component in 1962, early LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet and infrared wavelengths, with very high brightness. Advantages Efficiency: LEDs emit more light per watt than incandescent bulbs. Their efficiency is not affected by shape and size, unlike Fluorescent light bulbs or tubes. Color: LEDs can emit light of an intended color without using any color filters as traditional lighting methods need. This is more efficient and can lower initial costs. Size: LEDs can be very small (smaller than 2 mm) and are easily populated onto printed circuit boards. On/Off time: LEDs light up very quickly. A typical red indicator LED will achieve full brightness in under a microsecond. LEDs used in communications devices can have even faster response times. Lifetime: LEDs can have a relatively long useful life. One report estimates 35,000 to 50,000 hours of useful life, though time to complete failure may be longer. Fluorescent tubes typically are rated at about 10,000 to 15,000 hours, depending partly on the conditions of use, and incandescent light bulbs at 1,000 2,000 hours. Low toxicity: LEDs do not contain mercury, unlike fluorescent lamps

Disadvantages

Some Fluorescent lamps can be more efficient. High initial price: LEDs are currently more expensive, price per lumen, on an initial capital cost basis, than most conventional lighting technologies. The additional expense partially stems from the relatively low lumen output and the drive circuitry and power supplies needed. Voltage sensitivity: LEDs must be supplied with the voltage above the threshold and a current below the rating. This can involve series resistors or currentregulated power supplies.

Droop: The efficiency of LEDs tends to decrease as one increases current

Crystal oscillator A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to

keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them became known as "crystal oscillators."]

Operation A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly ordered, repeating pattern extending in all three spatial dimensions. Almost any object made of an elastic material could be used like a crystal, with appropriate transducers, since all objects have natural resonant frequencies of vibration. For example, steel is very elastic and has a high speed of sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size, shape,elasticity, and the speed of sound in the material. High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork. For

applications not needing very precise timing, a low-cost ceramic resonator is often used in place of a quartz crystal. When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency. (See RLC circuit.) Quartz has the further advantage that its elastic constants and its size change in such a way that the frequency dependence on temperature can be very low. The specific characteristics will depend on the mode of vibration and the angle at which the quartz is cut (relative to its crystallographic axes). [7] Therefore, the resonant frequency of the plate, which depends on its size, will not change much, either. This means that a quartz clock, filter or oscillator will remain accurate. For critical applications the quartz oscillator is mounted in a temperature-controlled container, called a crystal oven, and can also be mounted on shock absorbers to prevent perturbation by external mechanical vibrations.

Commonly used crystal frequencies Crystal oscillator circuits are often designed around relatively few standard frequencies, such as 3.579545 MHz, 4.433619 MHz, 10 MHz, 14.318182 MHz, 17.734475 MHz, 20 MHz, 33.33 MHz, and 40 MHz. The popularity of the 3.579545 MHz crystals is due to low cost since they are used for NTSC color television receivers. Using frequency dividers, frequency multipliers and phase locked loopcircuits, it is practical to derive a wide range of frequencies from one reference frequency. 14.318182 MHz (four times 3.579545 MHz) is used in computer video displays to generate a bitmapped video display for NTSC color monitors, such as the CGA used with the original IBM PC. (The IBM PC used 14.318182 MHz, divided by three, as its 4.77 MHz clock source, using one crystal for two purposes.) The 4.433619 MHz and 17.734475 MHz values are used in PAL color television equipment and devices intended to produce PAL signals. Crystals can be manufactured for oscillation over a wide range of frequencies, from a few kilohertz up to several hundred megahertz. Many applications call for a crystal oscillator frequency conveniently related to some other desired frequency, so hundreds

of standard crystal frequencies are made in large quantities and stocked by electronics distributors. Temperature effects A crystal's frequency characteristic depends on the shape or 'cut' of the crystal. A tuning fork crystal is usually cut such that its frequency over temperature is a parabolic curve centered around 25 C. This means that a tuning fork crystal oscillator will resonate close to its target frequency at room temperature, but will slow down when the temperature either increases or decreases from room temperature. A common parabolic coefficient for a 32 kHz tuning fork crystal is 0.04 ppm/C.

In a real application, this means that a clock built using a regular 32 kHz tuning fork crystal will keep good time at room temperature, lose 2 minutes per year at 10 degrees Celsius above (or below) room temperature and lose 8 minutes per year at 20 degrees Celsius above (or below) room temperature due to the quartz crystal.

Voltage regulator A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. A voltage regulator may be a simple "feed-forward" design or may include negative feedbackcontrol loops. It may use an electromechanical mechanism, or electronic components. Depending on the design, it may be used to regulate one or more AC or DC voltages. Electronic voltage regulators are found in devices such as computer power supplies where they stabilize the DC voltages used by the processor and other elements. In automobile alternators and central power station generator plants, voltage regulators control the output of the plant. In an electric power distribution system, voltage regulators may be installed at a substation or along distribution lines so that all customers receive steady voltage independent of how much power is drawn from the line.

Measures of regulator quality The output voltage can only be held roughly constant; the regulation is specified by two measurements:

load regulation is the change in output voltage for a given change in load current (for example: "typically 15mV, maximum 100mV for load currents between 5mA and 1.4A, at some specified temperature and input voltage"). line regulation or input regulation is the degree to which output voltage changes with input (supply) voltage changes - as a ratio of output to input change (for example "typically 13mV/V"), or the output voltage change over the entire specified input voltage range (for example "plus or minus 2% for input voltages between 90V and 260V, 50-60Hz").

Other important parameters are: Temperature coefficient of the output voltage is the change in output voltage with temperature (perhaps averaged over a given temperature range), while...

Initial accuracy of a voltage regulator (or simply "the voltage accuracy") reflects the error in output voltage for a fixed regulator without taking into account temperature or aging effects on output accuracy. Dropout voltage is the minimum difference between input voltage and output voltage for which the regulator can still supply the specified current. A Low DropOut (LDO) regulator is designed to work well even with an input supply only a Volt or so above the output voltage. Absolute maximum ratings are defined for regulator components, specifying the continuous and peak output currents that may be used (sometimes internally limited), the maximum input voltage, maximum power dissipation at a given temperature, etc. Output noise (thermal white noise) and output dynamic impedance may be specified as graphs versus frequency, while output ripple noise (mains "hum" or switch-mode "hash" noise) may be given as peak-to-peak or RMS voltages, or in terms of their spectra. Quiescent current in a regulator circuit is the current drawn internally, not available to the load, normally measured as the input current while no load is connected (and hence a source of inefficiency; some linear regulators are, surprisingly, more efficient at very low current loads than switch-mode designs because of this).

Electronic voltage regulators A simple voltage regulator can be made from a resistor in series with a diode (or series of diodes). Due to the logarithmic shape of diode V-I curves, the voltage across the diode changes only slightly due to changes in current drawn. When precise voltage control is not important, this design may work fine. Feedback voltage regulators operate by comparing the actual output voltage to some fixed reference voltage. Any difference is amplified and used to control the regulation element in such a way as to reduce the voltage error. This forms a negative feedback control loop; increasing the open-loop gain tends to increase regulation accuracy but reduce stability (avoidance of oscillation, or ringing during step changes). There will also be a trade-off between stability and the speed of the response to changes. If the output voltage is too low (perhaps due to input voltage reducing or load current increasing), the regulation element is commanded, up to a point, to produce a higher output voltageby dropping less of the input voltage (for linear series regulators and buck switching regulators), or to draw input current for longer periods (boosttype switching regulators); if the output voltage is too high, the regulation element will normally be commanded to produce a lower voltage. However, many regulators have over-current protection, so that they will entirely stop sourcing current (or limit the current in some way) if the output current is too high, and some regulators may also shut down if the input voltage is outside a given range (see also: crowbar circuits).

Microcontroller 8051

Intel P8051 microcontroller. The Intel MCS-51 is a Harvard architecture, single chip microcontroller (C) series which was developed by Intel in 1980 for use in embedded systems.[1][2]Intel's original versions were popular in the 1980s and early 1990s, but has today largely been superseded by a vast range of faster and/or functionally enhanced 8051-compatible devices manufactured by more than 20 independent manufacturers including Atmel, Infineon Technologies (formerly Siemens AG), Maxim Integrated Products (via its Dallas Semiconductor subsidiary), NXP (formerly Philips Semiconductor), Nuvoton (formerly Winbond), ST Microelectronics, Silicon Laboratories (formerly Cygnal), Texas Instruments, Ramtron International, Silicon Storage Technology, and Cypress Semiconductor. Intel's original MCS-51 family was developed using NMOS technology, but later versions, identified by a letter C in their name (e.g., 80C51) used CMOStechnology and were less power-hungry than their NMOS predecessors. This made them more suitable for battery-powered devices.

Important features and applications . The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a single package

8-bit ALU, Accumulator and 8-bit Registers; hence it is an 8-bit microcontroller 8-bit data bus It can access 8 bits of data in one operation 16-bit address bus It can access 216 memory locations 64 KB (65536 locations) each of RAM and ROM On-chip RAM 128 bytes (data memory) On-chip ROM 4 kByte (program memory) Four byte bi-directional input/output port

UART (serial port) Two 16-bit Counter/timers Two-level interrupt priority

Power saving mode (on some derivatives) ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator frequency, for external timing or clocking purposes, even when there are no accesses to external memory.

microcontroller Pin Diagram and Pin Functions EA must be externally wired low. In the EPROM devices, this pin also receives the programming supply voltage (VPP) during EPROM programming.

XTAL1: Input to the inverting oscillator amplifier. XTAL2: Output from the inverting oscillator amplifier. ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator frequency, for external timing or clocking purposes, even when there are no accesses to external memory. (However, one ALE pulse is skipped during each access to external Data Memory.) This pin is also the program pulse input (PROG) during EPROM programming. PSEN: Program Store Enable is the read strobe to external Program Memory. When the device is executing out of external Program Memory, PSEN is activated twice each machine cycle (except that two PSEN activations are skipped during accesses to external Data Memory). PSEN is not activated when the device is executing out of internal Program Memory. EA/VPP: When EA is held high the CPU executes out of internal Program Memory (unless the Program Counter exceeds 0FFFH in the 80C51). Holding EA low forces the CPU to execute out of external memory regardless of the Program Counter value. In the 80C31, EA must be externally wired low. In the EPROM devices, this pin also receives the programming supply voltage (VPP) during EPROM programming

XTAL1: Input to the inverting oscillator amplifier. XTAL2: Output from the inverting oscillator amplifier. Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open drain output port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that state will function as high impedance inputs. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pullups. Port 1 pins that have 1s written to them are pulled high by the internal pullups, and in that state can be used as inputs. As inputs, port 1 pins that are externally being pulled low will source current because of the internal pullups. Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pullups. Port 2 emits the high-order address byte during accesses to external memory that use 16-bit addresses. In this application, it uses the strong internal pullups when emitting 1s.

Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pullups. It also serves the functions of various special features of the 80C51 Family as follows:Port Pin Alternate Function

P3.0 RxD (serial input port) P3.1 TxD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe)

Programming There are various high-level programming language compilers for the 8051. Several C compilers are available for the 8051, most of which feature extensions that allow the programmer to specify where each variable should be stored in its six types of memory, and provide access to 8051 specific hardware features such as the multiple register banks and bit manipulation instructions. There are many commercial C compilers. SDCC is a popular open source C compiler. Other high level languages such as Forth, BASIC, Pascal/Object Pascal, PL/M and Modula-2 are available for the 8051, but they are less widely used than C and assembly. Educational Use In many engineering schools the 8051 microcontroller is used in introductory microcontroller courses

ULN2003 HIGH VOLTAGE AND HIGH CURRENT DARLINGTON TRANSISTOR ARRAY DESCRIPTION The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It consists of seven NPN darlington pairs that features high-voltage outputs with common-cathode clamp diode for switching inductive loads. The collector-current rating of a single darlington pair is 500mA. The darlington pairs may be parrlleled for higher current capability. Applications include relay drivers,hammer drivers, lampdrivers,display drivers(LED gas discharge),line drivers, and logic buffers. The ULN2003 has a 2.7kW series base resistor for each darlington pair for operation directly with TTL or 5V CMOS devices. FEATURES * 500mA rated collector current (Single output) * High-voltage outputs: 50V * Inputs compatible with various types of logic. * Relay driver application_

Stepper Motors Stepper motors consist of a permanent magnet rotating shaft, called the rotor, and electromagnets on the stationary portion that surrounds the motor, called the stator. Figure 1 illustrates one complete rotation of a stepper motor. At position 1, we can see that the rotor is beginning at the upper electromagnet, which is currently active (has voltage applied to it). To move the rotor clockwise (CW), the upper electromagnet is deactivated and the right electromagnet is activated, causing the rotor to move 90 degrees CW, aligning itself with the active magnet. This process is repeated in the same manner at the south and west electromagnets until we once again reach the starting position.

In the above example, we used a motor with a resolution of 90 degrees or demonstration purposes. In reality, this would not be a very practical motor for most applications. The average stepper motor's resolution -- the amount of degrees rotated per pulse -- is much higher than this. For example, a motor with a resolution of 5 degrees would move its rotor 5 degrees per step, thereby requiring 72 pulses (steps) to complete a full 360 degree rotation. You may double the resolution of some motors by a process known as "half-stepping". Instead of switching the next electromagnet in the rotation on one at a time, with half stepping you turn on both electromagnets, causing an equal attraction between, thereby doubling the resolution. As you can see in Figure 2, in the first position only the upper electromagnet is active, and the rotor is drawn completely to it. In position 2, both the top and right electromagnets are active, causing the rotor to position itself between the two active poles. Finally, in position 3, the top magnet is deactivated and the rotor is drawn all the way right. This process can then be repeated for the entire rotation.

There are several types of stepper motors. 4-wire stepper motors contain only two electromagnets; however the operation is more complicated than those with three or four magnets, because the driving circuit must be able to reverse the current after each step. For our purposes, we will be using a 6-wire motor. Unlike our example motors which rotated 90 degrees per step, real-world motors employ a series of mini-poles on the stator and rotor to increase resolution. Although this may seem to add more complexity to the process of driving the motors, the operation is identical to the simple 90 degree motor we used in our example. An example of a multiple motor can be seen in Figure 3. In position 1, the north pole of the rotor's permanent magnet is aligned with the south pole of the stator's electromagnet. Note that multiple positions are aligned at once. In position 2, the upper electromagnet is deactivated and the next one to its immediate left is activated, causing the rotor to rotate a precise amount of degrees. In this example, after eight steps the sequence repeats.

The specific stepper motor we are using for our experiments (ST-02: 5VDC, 5 degrees per step) has 6 wires coming out of the casing. If we follow Figure 5, the electrical equivalent of the stepper motor, we can see that 3 wires go to each half of the coils, and that the coil windings are connected in pairs. This is true for all four-phase stepper motors.

However, if you do not have an equivalent diagram for the motor you want to use, you can make a resistance chart to decipher the mystery connections. There is a 13 ohm resistance between the center-tap wire and each end lead, and 26 ohms between the two end leads. Wires originating from separate coils are not connected, and therefore would not read on the ohm meter.

Magnetic Reed Switch The reed switch is an electrical switch operated by an applied magnetic field. It was invented at Bell Telephone Laboratories in 1936 by W. B. Ellwood. It consists of a pair of contacts on ferrous metal reeds in a hermetically sealed glass envelope. The contacts may be normally open, closing when a magnetic field is present, or normally closed and opening when a magnetic field is applied. The switch may be actuated by a coil, making a reed relay,[1] or by bringing a magnet near to the switch. Once the magnet is pulled away from the switch, the reed switch will go back to its original position. An example of a reed switch's application is to detect the opening of a door, when used as a proximity switch for a burglar alarm. The reed switch contains a pair (or more) of magnetizable, flexible, metal reeds whose end portions are separated by a small gap when the switch is open. The reeds are hermetically sealed in opposite ends of a tubular glass envelope.

Reed switch diagrams from Ellwood's patent, U.S. Patent 2,264,746, Electromagnetic switch

A magnetic field (from an electromagnet or a permanent magnet) will cause the reeds to come together, thus completing an electrical circuit. The stiffness of the reeds causes them to separate, and open the circuit, when the magnetic field ceases. Another configuration contains a non-ferrous normally-closed contact that opens when the ferrous normally-open contact closes. Good electrical contact is assured by plating a thin layer of non-ferrous precious metal over the flat contact portions of the reeds; lowresistivity silver is more suitable than corrosion-resistant gold in the sealed envelope. There are also versions of reed switches with mercury "wetted" contacts. Such switches must be mounted in a particular orientation otherwise drops of mercury may bridge the contacts even when not activated. Since the contacts of the reed switch are sealed away from the atmosphere, they are protected against atmospheric corrosion. The hermetic sealing of a reed switch make them suitable for use in explosive atmospheres where tiny sparks from conventional switches would constitute a hazard. One important quality of the switch is its sensitivity, the amount of magnetic field necessary to actuate it. Sensitivity is measured in units of Ampere-turns, corresponding to the current in a coil multiplied by the number of turns. Typical pull-in sensitivities for commercial devices are in the 10 to 60 AT range. The lower the AT, the more sensitive the reed switch. Also, smaller reed switches, which have smaller parts, are more sensitive to magnetic fields, so the smaller the reed switch's glass envelope is, the more sensitive it is. In production, a metal reed is inserted in each end of a glass tube and the end of the tube heated so that it seals around a shank portion on the reed. Infrared-absorbing glass is used, so an infrared heat source can concentrate the heat in the small sealing zone of the glass tube. The thermal coefficient of expansion of the glass material and metal parts must be similar to prevent breaking the glass-to-metal seal. The glass used must have a high electrical resistance and must not contain volatile components such as lead oxide and fluorides. The leads of the switch must be handled carefully to prevent breaking the glass envelope. How Reed Switches are used with a Permanent Magnet Using Reed Switches in a sensing environment, one generally uses a magnet for actuation. It is important to understand this interaction clearly for proper sensor functioning. Sensors may operate in a normally open mode, a normally closed mode or a latching mode. In the normally open mode, when a magnet is brought toward the Reed Switch (or vice versa) the reed bladeswill close. When the magnet is withdrawn the reed blades will open. With the normally closed sensor, bringing a magnet to the Reed Switch the reed blades will open, and withdrawing the magnet, the reed blades will re-close. In a latching mode the reed blades may be in either an open or closed state. When a magnet is brought close to the Reed Switch the contacts will change their state. If they

were initially open, the contacts will close. Withdrawing the magnet the contacts will remain closed. When the magnet is again brought close to the Reed Switch, with a changed magnetic polarity, the contacts will now open. Withdrawing the magnet the contacts will remain open. Again, reversing the magnetic polarity, and bringing the magnet again close to the Reed Switch the contacts will again close and remain closed when the magnet is withdrawn. In this manner, one has a latching sensor or a bi-stable state sensor. In the following diagrams, we will outline the guidelines

one must be aware of when using a magnet. Please keep in mind the magnetic field is three-dimensional. A permanent magnet is the most common source for operating the Reed Switch. The methods used depend on the actual application. Some of these methods are the following: front to back motion (see Figure #19);

the use of a magnetic shield to deflect the magnetic flux flow (see Figure #22);

The complete programming


#include<REG52.H> #include <intrins.h> #define seg_data P1 #define seg_select P3

void DelayMS(unsigned char ms) { unsigned long us = 500*ms; while (us--) { _nop_(); } } sbit sbit sbit sbit sbit sbit sbit sbit sbit sbit sbit switch1=P1^0; switch2= P1^1; switch3=P1^2; switch4=P1^3; signal11=P1^4; //green signal12=P1^5;//orange signal13=P1^6; //red signal21=P1^7; //green signal22=P3^0; //orange signal23=P3^1; //red signal31=P3^2; //green //orange //red //green //orange //red

sbit signal32=P3^3; sbit signal33=P3^4; sbit signal41=P3^5; sbit signal42=P3^6; sbit signal43=P3^7;

#define motor P2 //unsigned char step[8]={0x11, 0x33, 0x22, 0x66, 0x44, 0xCC, 0x88, 0x99}; unsigned char step[8]={0xEE, 0xDD, 0xBB, 0x77, 0xEE, 0xDD, 0xBB, 0x77}; void motor_clock() { char i=0,j=0;

for(i=0; i<1; i++) { for(j=0; j<8; j++) { motor=step[j]; DelayMS(10); } }

void motor_anti() { char i= 0, j=0; for(i=0; i<1; i++) { for(j=7; j>=0; j--) { motor=step[j]; DelayMS(10); } } } *********************main loop start from here****************** main() { signal11=0; signal12=1; signal13=1; signal21=0; signal22=1; signal23=1; signal31=0; signal32=1; signal33=1; signal41=0; signal42=1; signal43=1; while(1) { if(!switch1) { DelayMS(10); signal31=0; signal32=1; signal33=1; signal11=1; signal12=1; signal13=0;

signal41=1; signal42=0; signal43=1; while(!switch1); } if(!switch2) { DelayMS(10); signal11=1; signal12=0; signal13=1; signal41=0; signal42=1; signal43=1; signal21=1; signal22=1; signal23=0; } while(!switch2);

if(!switch3) { DelayMS(10); signal21=1; signal22=0; signal23=1; signal11=0; signal12=1; signal13=1; signal31=1; signal32=1; signal33=0; motor_clock(); while(!switch3);

if(!switch4) { DelayMS(10); signal31=1; signal32=0; signal33=1; signal21=0;

signal22=1; signal23=1; signal41=1; signal42=1; signal43=0; motor_anti(); } } } while(!switch4);

*************************end of main******************************

Das könnte Ihnen auch gefallen