You are on page 1of 49

JAWAHARLAL NEHRU TECHNOLOGY UNIVERSITY

A Mini project report On

ELECTRONIC LOCKING SYSTEM FOR CAR


Submitted in partial fulfillment of the requirements for the award of

BACHELOR OF TECHNOLOGY IN ELECTRONICS & COMMUNICATION ENGINEERING


Submitted by Pavani P.Navya rani Manasa Teja (08RP1A0441) (08RP1A0436) (08RP1A0430) (08RP1A0479)

Under the esteemed guidance of

MR.D.PRASHANTH
Associate professor, Department of ECE.

MEGHA INSTITUTE OF ENGINEERING & TECHNOLOGY FOR WOMEN


(Affiliated to JNTU, Hyderabad, AP) Edulabad (v), Ghatkesar (M), R.R, Dist

MEGHA INSTITUTE OF ENGINEERING & TECHNOLOGY FOR WOMEN


(Affiliated to JNTU, Hyderabad, AP) Edulabad (v), Ghatkesar (M), R.R, Dist

CERTIFICATE

This is to certified that Mini project work entitled ELECTRONIC LOCKING SYSTEM FOR CAR Is a bonifide work carried out by Pavani (08RP1A0441), P.Navya rani (08RP1A0436), Manasa (08RP1A0479), Teja (08RP1A0479) , In partial fulfillment of the requirements for the degree BACHELOR OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING by Jawaharlal Nehru technological university, Hyderabad ,during the academic year 2008-2012. The results embodies in this report have not been submitted to any other university or institution for the award of any degree.

Internal supervisor MS.S.PRIYADARSHINI Associate professor Department of ECE M.I.E.T

Head of the Department MS.S.PRIYADARSHINI Professor & HOD Department of ECE M.I.E.T

ACKNOWLEDGEMENT

We would like to thank our management for providing all the facilities to carry out our project work successfully. We would like to thank our honorable principal MR.G.V.SUBBA RAO, who had inspired a lot through their speeches and for providing this opportunity to carry out the present project work.

For valuable suggestions in the accomplishment the constant patronage and encouragement received from Prof.S.PRIYADARSHINI M.TECH, professor, HOD OF ECE, M.I.ET, has been of great help in carrying the present work and is acknowledge with reverential thanks.

We also wish to acknowledge our internal guide MS.S.PRIYADARSHINI , M.TECH for his co-operation in completion of our project successfully

We would like to express gratitude to all faculty members of Department of ECE, M.I.ET, Hyderabad for their intellectual support throughout the course of this work.

Finally, we indebted to all whom so ever have contributed in this project work and friendly stay at M.I.ET, Hyderabad.

Pavani P.Navya rani Manasa Teja

(08RP1A0441) (08RP1A0436) (08RP1A0430) (08RP1A0479)

INDEX
Page no: LIST OF FIGURES LIST OF TABLES LIST OF ABBREVATIONS i ii iii

ABSTRACT CHAPTER 1: INTRODUCTION 1.1 OBJECTIVE 1.2 HISTORY OF THE PROJECT BLOCK DIAGRAM SCHEMATIC DIAGRAM CHAPTER 2: EMBEDEDDED SYSTEMS 2.1 INTRODUCTION OF EMBEDDED SYSTEMS 2.2 EMBEDDED SYSTEMS CHAPTER 3: HARDWARE IMPLEMENTATION 3.1 POWER SUPPLY 3.1.1 RECTIFIER 3.1.2 FILTERS 3.1.3 DC POWER SUPPLY 3.1.4 AC POWER SUPPLY 3.1.5 TRANSFORMER 3.1.6 7805 REGULATOR 3.1.7 7805 DESCRIPTION 3.1.8 CAPACITOR 3.1.9 RESISTANCE 3.2 MICROCONTROLLER SYSTEM 3.2.1 SELECTION OF MICROCONTROLLER FOR A DESIGN 3.2.2 HOW DOSE THE MICROCONTROLLER POPERATES? 3.2.3 WHAT IS MICROCONTROLLER? 3.2.4 MICROCONTROLLER HAS 7 MAIN COMPONENTS 3.2.5 THE 8051 MICROCONTROLLER FAMILY ARCHITECTURE a. READ ONLY MEMORY (ROM) b. RANDOM ACCESS MEMORY (RAM) c. ELETRICAL ERASABLE PROGRAMMABLE ROM (EEPROM) d. SPECIAL FUNTIONS OF REGISTERS (SPRs) e. PROGRAM COUNTER (PC) f. CENTRAL PROCESSOR UNIT (CPU) 3.2.6 PIN OUT DESCRIPTION a. PORT-0 b. PORT-1 c. PORT-2 d. PORT-3 3.2.7 8051 PORTS STRUCTURE AND OPERATION 3.2.8 INSTRUCTIONS OF 8051 3.2.9 TYPES OF INSTRUCTIONS 3.2.10 MEMORY ORGANISATION OF 8051 a. TIMERS-8051 MICROCONTROLLER b. TIMERS SFRs

iv

3.3 LIQUID CRYSTAL DISPLAY 3.3.1 LCD PINS 3.3.2 LCD SCREEN 3.3.3 LCD INITIALIZATION 3.4 MM74C922 ENCODER 3.5 STEPPER MOTOR 3.6 BUZZER CHAPTER 4: SOFTWARE 4.1 ABOUT SOFTWARE 4.1.1 KEIL VISION3 4.1.2 WHAT IS VISION3 4.2 EMBEDDED C 4.2.1 EMBEDDED C DATA TYPES 4.3 STEPS TO WRITE PROGRAM IN KEIL SOFTWARE CHAPTER 5: 5.1 APPLICATIONS 5.2 ADVANTAGES 5.3 CONCLUSION 5.4 BIBLIOGRAPHY 5.4.1 NAME OF WEBSITES 5.4.2 REFERENCES

LIST OF FIGURES Figure 1: Power supply Figure 2: Transformer Figure 3: Three pin regulator-7805 Figure 4: 7805 Regulator circuit Figure 5: 7805 Voltage regulator pin out Figure 6: Capacitor Figure 7: Resistance Figure 8: Architecture of microcontroller Figure 9: Architecture of 8051 Figure 10: Pin diagram of 8051 Figure 11: Oscillator circuit Figure 12: Memory organization of ROM

Pg no. 14 16 16 18 18 19 20 23 26 29 30 34

Figure 13: Port0 input/output registers Figure 14: LCD display Figure 15: LCD Interfacing with micro controller Figure 16: LCD connections Figure 24: Gear of the motor Figure 25: Buzzer

35 36 39 46 47

LIST OF TABLES Table 1: Various blocks of microcontroller Table 2: Comparison of various 8051 family members Table 3: SFRs relating timers Table 4: LCD pin functions Table 5: Pins in LCD display

pg no. 21 25 37 38 39

LIST OF ABBREVIATIONS LED LCD IC - light emitting diode - liquid crystal display - Integrated circuit

ABSTRACT

Electronic locking systems are one of the most difficult locking mechanism to by pass due to their complex

nature. Each type of electronic lock may have a different release as a electronic car lock can be opened with a key fob. If you verification before realizing lock unlike the standard pass word electric lock. Normal two factor authentication systems require something like a card or fob as well as a password or pin to open the lock.

needed a secure lock you would be best to use a two factor authentication system. This kind of locking system needs two of

A combination lock is a type in which a sequence of numbers or symbols is used to open the lock. The sequence may be entered using a single rotating dial which interacts with several rotating disks with inscribed numerals which directly combination lock is a misnomer. In mathematics the term combination represents a set of symbols that can be in any order:1-2-3 is the same combination as 3-2-1,2-3-1 and 1-3-2. However, the symbols or numbers for lock must be entered in the correct sequence:1-2-3 will not open a lock set to 3-2-1. The correct mathematical term for a set of symbols that must be entered in a specific sequence is a permutation.

interact with the locking mechanism or through an electronic or mechanical keypad. From a mathematical standpoint,

CHAPTER 1

1.1 INTRODUCTION A combination lock is a type in which a sequence of numbers or symbols is used to open the lock. The sequence may be entered using a single rotating dial which interacts with several rotating disks with inscribed numerals which directly interact with the locking mechanism or through an electronic or mechanical keypad.

OBJECTIVE The main objective of our project ELECTRONIC LOCKING SYSTEM FOR CAR . Each type of electronic determine the lock sequence by viewing several successful accesses,Allow many valid

lock may have a different release as a electronic car lock can be opened with a key fob. The advantage that Easy to

combinations, changing one person's access has no effect on other users,These are popular the attacks on their mechanical counterparts .

for safe and vault doors, The "secret" is encoded in an electronic microcontroller,Safe from

1.3 HISTORY OF THE PROJECT

CHAPTER 2

2.1 INTRODUCTION OF EMBEDDED SYSTEM:

In general, "embedded system" is not a strictly definable term, as most systems have some element of extensibility or programmability. For example, handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them, but they allow different applications to be loaded and peripherals to be connected or a few dedicated functions", and is thus appropriate to call "embedded". Moreover, even systems which don't expose programmability as a primary feature generally need to support software updates. On a continuum from "general purpose" to "embedded", large application systems will have subcomponents at most points even if the system as a whole is "designed to perform one or a few dedicated functions", and is thus appropriate to call "embedded".

2.2 EMBEDDED SYSTEMS An embedded system is a special purpose computer system designed to perform one or a few dedicated functions, often with real time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Embedded systems span all aspects of modern life. Characteristics:

Embedded systems are designed to do some specific task, rather than be a general-purpose computer for multiple tasks. Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. Applications: Telecommunications Consumer electronics like PDAs, mp3 players, mobile phones, digital cameras, DVD's, ovens, washing machine, to control lights, to provide security, climate, etc.. User Interface: Embedded systems range from no user interface at all dedicated only to one task to complex graphical user interfaces that resemble modern computer desktop operating systems. Simple embedded devices use buttons, LEDs, graphic or character LCDs (for example popular HD44780 LCD) with a simple menu system. A more sophisticated devices use graphical screen with touch sensing or screen-edge buttons provide flexibility while minimizing space used: the meaning of the buttons can change with the screen, and selection involves the natural behavior of pointing at what's desired

Advantages of Embedded Systems: 1. They are designed to do a specific task and have real time performance constraints which must be met. 2. They allow the system hardware to be simplified so costs are reduced. 3. They are usually in the form of small computerized parts in larger devices which serve a general purpose. 4. The program instructions for embedded systems run with limited computer hardware resources, little memory and small or even non-existent keyboard or screen. Overview of Embedded System : Embedded system means the processor is embedded into that application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Example: printer, keyboard, video game player.

CHAPTER 3
Hardware Implementation This chapter briefly explains about the Hardware Implementation of the project. It discusses the design and working of the design with the help of block diagram and circuit diagram and explanation of circuit diagram in detail.

3.1 Power Supply

A Power Supply is a device that supplies electrical energy to one or more electric loads. The term is most commonly applied to devices that convert one form of electrical energy to another, though it may also refer to devices that convert another form of energy (e.g., mechanical, chemical, solar) to electrical energy. A regulated power supply is one that controls the output voltage or current to a specific value; the controlled value is held nearly constant despite variations in either load current or the voltage supplied by the power supply's energy source. Ste p do wn T/F Bridg e Rectifi er

Filter Circ uit

Regul ator

Power supply to all sections

3.1.1 RECTIFIER:

The primary application of rectifiers is to derive usable DC power from an AC supply. Virtually all electronics except simple motor circuits such as fans require a DC supply but mains power is AC so rectifiers find uses inside the power supplies of virtually all electronic equipment.

3.1.2 FILTERS:

Electronic filters are electronic circuits which perform signal processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both. 3.1.3DC power supply:

An AC powered unregulated power supply usually uses a transformer to convert the voltage from the wall outlet (mains) to a different, nowadays usually lower, voltage. If it is used to produce DC, a rectifier is used to convert alternating voltage to a pulsating direct voltage, followed by a filter, comprising one or more capacitors, resistors, and sometimes inductors, to filter out (smooth) most of the pulsation. A small remaining unwanted alternating voltage component at mains or twice mains power frequency (depending upon whether half- or full-wave rectification is used)rippleis unavoidably superimposed on the direct output voltage. For purposes such as charging batteries the ripple is not a problem, and the simplest unregulated mains-powered DC power supply circuit consists of a transformer driving a single diode in series with a resistor.

Before the introduction of solid-state electronics equipment used valves (vacuum tubes) which required high voltages; power supplies used step-up transformers, rectifiers, and filters to generate one or more direct voltages of some hundreds of volts, and a low alternating voltage for filaments. Only the most advanced equipment used expensive and bulky regulated power supplies. 3.1.4 AC power supply:

An AC power supply typically takes the voltage from a wall outlet (mains supply, often 230v in Europe) and lowers it to the desired voltage (eg : 9V ac). As well as lowering the voltage some filtering may take place.

3.1.5 TRANSFORMER:

A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductorsthe transformer's coils. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core and thus a varying magnetic field through the secondary winding. 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, an electric current will flow in the secondary winding and electrical energy will be transferred from the primary circuit through the transformer to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the primary voltage (Vp), and is given by the ratio of the number of turns in the secondary (Ns) to the number of turns in the primary (Np) as follows:

By appropriate selection of the ratio of turns, a transformer thus allows an alternating current (AC) voltage to be "stepped up" by making Ns greater than Np , or "stepped down" by making Ns less than Np.

In the vast majority of transformers, the windings are coils wound around a ferromagnetic core, air-core transformers being a notable exception.

Transformers range in size from a thumbnail-sized coupling transformer hidden inside a stage microphone to huge units weighing hundreds of tons used to interconnect portions of power grids. All operate with the same basic principles, although the range of designs is wide. While new technologies have eliminated the need for transformers in some electronic circuits, transformers are still found in nearly all electronic devices designed for household ("mains") voltage. Transformers are essential for high voltage power transmission, which makes long distance transmission economically practical.

Figure: 2.Transformer

3.1.6: 7805 Regulator The 7805 voltage regulators employ built-in current limiting, thermal shutdown, and safe-operating area protection which makes them virtually immune to damage from output overloads

Figure :3.Three pin regulator-7805

3.1.7: 7805 Regulator Description The 7805 voltage regulators employ built-in current limiting, thermal shutdown, and safe-operating area protection which makes them virtually immune to damage from output overloads. 7805 is a three-terminal positive voltage regulator. With adequate heat sinking, it can deliver in excess of 0.5A output current. Typical applications would include local (oncard) regulators which can eliminate the noise and degraded performance associated with single-point regulation. 7805 regulator comes from the 78xx family of self-contained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular choice for many electronic circuits which require a regulated power supply, due to their ease of use and relative cheapness. When specifying individual ICs within this family, the xx is replaced with a two-digit number, which indicates the output voltage the particular device is designed to provide (for example, the 7805 voltage regulator has a 5 volt output, while the 7812 produces 12 volts). The 78xx line are positive voltage regulators, meaning that they are designed to produce a voltage that is positive relative to a common ground. There is a related line of 79xx devices which are complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to provide both positive and negative supply voltages in the same circuit, if necessary. 7805 ICs have three terminals and are most commonly found in the TO220 form factor, although smaller surface-mount and larger TO3 packages are also available from some manufacturers. These devices typically support an input voltage which can be anywhere from a couple of volts over the intended output voltage, up to a maximum of 35 or 40 volts, and can typically provide up to around 1 or 1.5 amps of current (though smaller or larger packages may have a lower or higher current rating). The 7805 series has several key advantages over many other voltage regulator circuits which have resulted in its popularity:

7805 series ICs do not require any additional components to provide a constant, regulated source of power, making them easy to use, as well as economical, and also efficient uses of circuit board real estate. By contrast, most other voltage regulators require several additional components to set the output voltage level, or to assist in the regulation process. Some other designs (such as a switching power supply) can require not only a large number of components but also substantial engineering expertise to implement correctly as well. 7805 series ICs have built-in protection against a circuit drawing too much power. They also have protection against overheating and short-circuits, making them quite robust in most applications. In some cases, the current-limiting features of the 7805 devices can provide protection not only for the 7805 itself, but also for other parts of the circuit it is used in, preventing other components from being damaged as well.

Figure: 4. 7805 Regulator Circuit

Figure: 5. 7805 Voltage Regulator Pin out

3.1.8 Capacitor

A capacitor (formerly known as condenser) is a device for storing electric charge. The forms of practical capacitors vary widely, but all contain at least two conductors separated by a non conductor. Capacitors used as parts of electrical systems, for example, consist of metal foils separated by a layer of insulating film

A capacitor is a passive electronic component consisting of a pair of conductors separated by a dielectric (insulator). When there is potential (voltage) across the conductors, a static electric field develops across the dielectric, causing positive charge to collect on one plate and negative charge on the other plate. Energy is stored in the electrostatic field. An ideal capacitor is characterized by a single constant value, capacitance, measured in farads. This is the ratio of the electric charge on each conductor to the potential difference between them.

Capacitors are widely used in electronic circuits for blocking direct current while allowing alternating current to pass, in filter networks, for smoothing the output of power supplies, in the resonant circuits that tune radios to particular frequencies and for many other purposes.The capacitance is greatest when there is a narrow separation between large areas of conductor, hence capacitor conductors are often called "plates," referring to an early means of construction. In practice the dielectric between the plates passes a small amount of leakage and also has an electric field strength limit, resulting in a breakdown voltage, while the conductors and leads introduce an undesired inductance and resistance.

Figure: 6. Capacitor

. capacitor block DC (constant) signals, capacitors easily pass AC (changing) signals.


3.1.9 Resistor:

A resistor is a device which opposes the flow of current. The electrical resistance of an electrical element measures its opposition to the passage of an electric current; the inverse quantity is electrical conductance, measuring how easily electricity flows along a certain path. Electrical resistance shares some conceptual parallels with the mechanical notion of friction. The SI unit of electrical resistance is the ohm (), while electrical conductance is measured in Siemens(S).

An object of uniform cross section has a resistance proportional to its resistivity and length and inversely proportional to its cross-sectional area. All materials show some resistance, except for superconductors, which have a resistance of zero. The resistance of an object is defined as the ratio of voltage across it to current through it:

For a wide variety of materials and conditions, the electrical resistance R is constant for a given temperature; it does not depend on the amount of current through or the potential difference (voltage) across the object. Such materials are called Ohmic materials. For objects made of ohmic materials the definition of the resistance, with R being a constant for that resistor, is known as Ohm's law

Figure: 7. Resistor

3.2 Microcontrollers Systems: CPU RAM ROM


Table: 1.Various blocks of microcontroller

A digital computer typically consists of three major components: the Central Processing Unit (CPU), program and data memory, and an Input/output (I/O) system. The CPU controls the flow of information among the components of the computer. It also processes the data by performing digital operations. Most of the processing is done in the ArithmeticLogic Unit (ALU) within the CPU is called a minicomputer. A microprocessor is a CPU that is compacted into a single-chip semiconductor device. Microprocessors are general-purpose devices, suitable for many applications. A computer built around a microprocessor is called a microcomputer. The choice of I/O and memory devices of a microcomputer depends on the specific application. For example, most personal computers contain a keyboard and monitor as standard input and output devices.

A microcontroller is an entire computer manufactured on a single chip. Microcontrollers are usually dedicated devices embedded within an application. For example, microcontrollers are used as engine controllers in automobiles and as exposure and focus controllers in cameras. In order to serve these applications, they have a high concentration of on-chip facilities such as serial ports, parallel input-output ports, timers, counters, interrupt control, analog-to-digital converters, random-access memory, read only memory, etc. The I/O, memory, and on-chip peripherals of a microcontroller are selected depending on the specifics of the target application. Since microcontrollers are powerful digital processors, the degree of control and programmability they provide significantly enhances the effectiveness of the application.Embedded control applications also distinguish the microcontroller from its relative, the general-purpose microprocessor.Embedded systems often require real-. Real-time operation and multitasking capabilities refers to the fact that the embedded controller must be able to the environment must not wait for the controller. In other words, the embedded controller should not be a bottleneck in the operation of the system. Multitasking is the capability to perform many functions in a simultaneous or quasisimultaneous manner. The embedded controller is often responsible of monitoring several aspects of a system and responding accordingly when the need arises receive and process the signals from its environment as they are received. That is, the environment must not wait for the controller to become available. Similarly, the controller must perform fast enough to output control signals to its environment when they are needed. again,.

3.2.1 Selection of Micro controller for a Design: There are four major 8 bit micro controllers. They are free scales 6811, Intels 8051, zilog Z8 and PIC 16 X from micro chip technology. Each of these micro controller has a unique instruction set and register set, therefore they are micro controllers made by various chip makers. With all these different micro controllers, what criteria do designers consider in choosing microcontroller are as follows meeting the computing needs of task at hand efficiently and cost effectively availability of software development tool such as compilers ,assembler and debuggers Wide availability and reliable source of micro controllers 3.2.2 How does the microcontroller operate? Even though there is a large number of different types of microcontrollers and even more programs created for their use only, all of them have many things in common. Thus, if you learn to handle one of them you will be able to handle them all. A typical scenario on the basis of which it all functions is as follows:

1. Power supply is turned off and everything is stillthe program is loaded into the microcontroller, nothing indicates what is about to come 2. Power supply is turned on and everything starts to happen at high speed! The control logic unit keeps everything under control. It disables all other circuits except quartz crystal to operate. While the preparations are in progress, the first milliseconds go by. 3. Power supply voltage reaches its maximum and oscillator frequency becomes stable. SFRs are being filled with bits reflecting the state of all circuits within the microcontroller. All pins are configured as inputs. The overall electronics starts operation in rhythm with pulse sequence. From now on the time is measured in micro and nanoseconds. 4. Program Counter is set to zero. Instruction from that address is sent to instruction decoder which recognizes it, after which it is executed with immediate effect. 5. The value of the Program Counter is incremented by 1 and the whole process is repeated...several million times per second.

Figure: 8. Architecture of Microcontroller

3.2.3 What is a Microcontroller?

Microcontroller is a single chip, self-contained computer which incorporates all the basic components of a personal computer on a much smaller scale. Microcontrollers are often referred to as single chip devices or single chip computers. The main consequence of the microcontrollers small size is that its resources are far more limited than those of a desktop personal computer. In functional terms, a microcontroller is a programmable single chip which controls a process or system. Microcontrollers are typically used as embedded controllers where they control part of a larger system such as an appliance, Automobile, scientific instrument or a computer peripheral. Microcontrollers are designed to be low cost solutions; therefore using them can drastically reduce part and design costs for a project. Physically, a microcontroller is an integrated circuit with pins along each side. The pins presented by a microcontroller are used for power, ground, oscillator, I/O ports, interrupt request signals, reset and control. In contrast, the pins exposed by a microprocessor are most often memory bus signals (rather than I/O ports). A microcontroller is not the same as a microprocessor. A microprocessor is a single chip CPU used within other computer systems. A microcontroller is itself a single chip computer system. Personal computers are used as development platforms for microcontroller projects. Development computers, usually personal or workstation computers, use a microprocessor as their principle computing engine. Microprocessors depend upon a variety of subsidiary chips and devices to provide the resources not available on the microprocessor. 3.2.3 Microcontroller has seven main components: Central processing unit (CPU) ROM RAM Input and Output Timer Interrupt circuitry Buses

Various microcontrollers:

There are two members in the 8051 family of microcontrollers. They are 8052 and 8031and their version are AT89S51, 8751, DS5000 8052 micro controller: The 8052 is another member of 8051 family .the 8052 has all the standard features of the 8051 as well as an extra 128 bytes of RAM and extra timer. In other words, the 8052 has 256bytes instead of 4k bytes .All programs written for 8051 will be run on 8052 but the reverse is not possible

8031 micro controller: Another member of the 8051 family is the 8031 chip. This is often referred to as ROM-less 8051 since it has 0k bytes of on chip ROM. To use this chip you must add external ROM to it. This external ROM contains the

program that the 8031 will fetch and execute. Contrast that to the 8051 in which the on-chip contain the program to be as large as 64k bytes of code. The ROM containing the program attached to the 8031, you loose two ports that leaves only ports (0f the 4 ports) for I/O operations. To solve this problem, you can add external I/O to 8031.inerfacing the 8031 with memory and I/O ports such as the 8255

Comparison of various 8051 family members: Features 8051 ROM(bytes) 4k RAM(bytes) 128 TIMERS 2 I/O pins 32 Serial ports Interrupt sources 1 6

8052 8k 256 3 32 1 8

8031 0k 128 2 32 1 6

Table: 2. Comparison of Various 8051 Family Members

3.2.4 : The 8051 Microcontroller Family Architecture:

The 8051 is the first microcontroller of the MCS-51 family introduced by Intel Corporation at the end of the 1970s. The architecture of the 8051 family of microcontrollers is referred to as the MCS-51architecture, or sometimes simply as MCS51. The microcontrollers have an 8-bitdata bus. They are capable of addressing 64K of program memory and a separate64K of data memory. The 8051 has 4K of code memory implemented as on-chip Read Only Memory (ROM). The 8051 has 128 bytes of internal Random Access Memory (RAM). The 8051 has two timer/counters, a serial port, 4 general purpose parallel input/output ports, and interrupt control logic with five sources of interrupts. Besides internal RAM, the 8051 has various Special Function Registers (SFR), which are the control and data registers for on-chip facilities. The SFRs also include the accumulator, the B register, and the Program Status Word (PSW), which contains the CPU flags. Programming the various internal hardware facilities of the 8051 is achieved by placing the appropriate control words into the corresponding SFRs.

Figure: 9. Architecture of 8051

As seen in figure above, the 8051 microcontroller has nothing impressive in appearance: Features: 4K Bytes of In-System Reprogrammable Flash Memory 128 x 8-bit Internal RAM 4 ports having in total of 32 input/output Two 16-bit Timer/Counters Six Interrupt Sources Serial port The whole configuration is obviously thought of as to satisfy the needs of most programmers working on development of automation devices. One of its advantages is that nothing is missing and nothing is too much. In other words, it is created exactly in accordance to the average users taste and needs. Another advantage is RAM organization, the operation of Central Processor Unit (CPU) and ports which completely use all recourses and enable further upgrade.

a. Read Only Memory (ROM)

Read Only Memory (ROM) is a type of memory used to permanently save the program being executed. The size of the program that can be written depends on the size of this memory. ROM can be built in the microcontroller or added as an external chip, which depends on the type of the microcontroller. Both options have some disadvantages. If ROM is added as

an external chip, the microcontroller is cheaper and the program can be considerably longer. At the same time, a number of available pins is reduced as the microcontroller uses its own input/output ports for connection to the chip. The internal ROM is usually smaller and more expensive, but leaves more pins available for connecting to peripheral environment. The size of ROM ranges from 512B to 64KB. b. Random Access Memory (RAM):

Random Access Memory (RAM) is a type of memory used for temporary storing data and intermediate results created and used during the operation of the microcontrollers. The content of this memory is cleared once the power supply is off. For example, if the program performs an addition, it is necessary to have a register standing for what in everyday life is called the sum. For that purpose, one of the registers in RAM is called the "sum" and used for storing results of addition. The size of RAM goes up to a few KBs. c. Electrically Erasable Programmable ROM (EEPROM):

The EEPROM is a special type of memory not contained in all microcontrollers. Its contents may be changed during program execution (similar to RAM), but remains permanently saved even after the loss of power (similar to ROM). It is often used to store values, created and used during operation (such as calibration values, codes, values to count up to etc.), which must be saved after turning the power supply off. A disadvantage of this memory is that the process of programming is relatively slow. It is measured in milliseconds.

d. Special Function Registers (SFR): Special function registers are part of RAM memory. Their purpose is predefined by the manufacturer and cannot be changed therefore. Since their bits are physically connected to particular circuits within the microcontroller, such as A/D converter, serial communication module etc., any change of their state directly affects the operation of the microcontroller or some of the circuits. For example, writing zero or one to the SFR controlling an input/output port causes the appropriate port pin to be configured as input or output. In other words, each bit of this register controls the function of one single pin.

e. Program Counter (PC):

Program Counter is an engine running the program and points to the memory address containing the next instruction to execute. After each instruction execution, the value of the counter is incremented by 1. For this reason, the program executes only one instruction at a time just as it is written. Howeverthe value of the program counter can be changed at any moment, which causes a jump to a new memory location. This is how subroutines and branch instructions are executed.

f. Central Processor Unit (CPU): As its name suggests, this is a unit which monitors and controls all processes within the microcontroller and the user cannot affect its work. It consists of several smaller subunits, of which the most important are:

Instruction decoder is a part of the electronics which recognizes program instructions and runs other circuits on the basis of that. The abilities of this circuit are expressed in the "instruction set" which is different for each microcontroller family. Arithmetical Logical Unit (ALU) performs all mathematical and logical operations upon data. Accumulator is an SFR closely related to the operation of ALU. It is a kind of working desk used for storing all data upon which some operations should be executed (addition, shift etc.). It also stores the results ready for use in further processing. One of the SFRs, called the Status Register, is closely related to the accumulator, showing at any given time the "status" of a number stored in the accumulator (the number is greater or less than zero etc.).

Figure: 10. Pin Diagram of 8051

3.2.5: Pin out Description: Pin 1-8 port 1: Each of these pins can be configured as an input or an output. Pin 9 RS a logic one on this pin disables the microcontroller and clears the contents of most registers. In other words, the positive voltage on this pin resets the microcontroller. By applying logic zero to this pin, the program starts execution from the beginning. Pin 10-17 port 3: Similar to port 1, each of these pins can serve as general input or output. Besides, all of them have alternative functions: Pin 10 RXD: Serial asynchronous communication input or Serial synchronous communication output. Pin 11 TXD: Serial asynchronous communication output or Serial synchronous communication clock output. Pin 12INT0: Interrupt 0 inputs. PIN13 INT1: Interrupt 1 input. Pin 14 T0: Counter 0 clock input. Pin 15 T1: Counter 1 clock input. Pin 16 WR: Write to external (additional) RAM. Pin 17 RD: Read from external RAM. Pin 18, 19 X2, and X1: Internal oscillator input and output. A quartz crystal which specifies operating frequency is usually connected to these pins. Instead of it, miniature ceramics resonators can also be used for frequency stability. Later versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz. XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in the below figure. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

Figure:11. Oscillatory Circuit

Pin 20 GND: Ground. Pin 21-28 port 2: If there is no intention to use external memory then these port pins are configured as general inputs/outputs. In case external memory is used, the higher address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is not used, which means that not all eight port bits are used for its addressing, the rest of them are not available as inputs/outputs. Pin 29 PSEN: If external ROM is used for storing program then a logic zero (0) appears on it every time the microcontroller reads a byte from memory. Pin 30 ALE: Prior to reading from external memory, the microcontroller puts the lower address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by means of only one additional (and cheap) integrated circuit. In other words, this port is used for both data and address transmission. Pin31 EA: By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. It means that even there is a program written to the microcontroller, it will not be executed. Instead, the program written to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will use both memories, first internal then external (if exists). Pin 32-39 port 0: Similar to P2, if external memory is not used, these pins can be used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0). Pin 40: VCC+5V power supply. 3.2.6: 8051 Ports Structures and Operations

There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as output, ready to be used as output ports. To use any of these ports as an input port, it must be programmed. A logic state (voltage) on any pin can be changed or read at any moment. A logic zero (0) and logic one (1) are not equal. A logic one (0) represents almost short circuit to ground. Such a pin is configured as output.

A logic one (1) is loosely connected to voltage power supply through resistors of high resistance. Since this voltage can be easily pulled down by an external signal, such a pin is configured as input.

PORT 0--occupies a total of 8 pins (pins 32-39) .It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected externally to a 10K ohm pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.Open drain is a term used for MOS chips in the same way that open collector is used for TTL chips. With external pull-up resistors connected upon reset, port 0 is configured as an output port

PORT 1--occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In contrast to port 0, this port does not need any pull-up resistors since it already has pull-up resistors internally. Upon reset, Port 1 is configured as an output port. This is a true I/O port, because there are no role assigning as it is the case with P0. Since it has embedded pull up resistors is completely compatible with TTL circuits. PORT 2--Similar to P0, when using external memory, lines on this port occupy addresses intended for external memory chip. This time it is the higher address byte with addresses A8-A15. When there is no additional memory, this port can be used as universal input-output port similar by its features to the port 1. Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output. Just like P1, P2 does not need any pull-up resistors since it already has pull-up resistors internally. Upon reset, Port 2 is configured as an output port.

PORT 3--Even though all pins on this port can be used as universal I/O port, they also have an alternative function. Occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3 does not need any pull-up resistors, the same as P1 and P2 did not. Although port 3 is configured as an output port upon reset. Port 3 has the additional function of providing some extremely important signals such as interrupts. This information applies both 8051 and 8031 chips system.

3.2.7 Instructions of 8051:

The process of writing program for the microcontroller mainly consists of giving instructions (commands) in the specific order in which they should be executed in order to carry out a specific task. As electronics cannot understand what for example an instruction if the push button is pressed- turn the light on means, then a certain number of simpler and precisely defined orders that decoder can recognize must be used. All commands are known as INSTRUCTION SET. All microcontrollers compatible with the 8051 have in total of 255 instructions, i.e. 255 different words available for program writing.

At first sight, it is imposing number of odd signs that must be known by heart. However, It is not so complicated as it looks like. Many instructions are considered to be different, even though they perform the same operation, so there are only 111 truly different commands. For example: ADD A, R0, ADD A, R1... ADD A, R7 are instructions that perform the same operation (addition of the accumulator and register). Since there are 8 such registers, each instruction is counted separately. Taking into account that all instructions perform only 53 operations (addition, subtraction, copy etc.) and most of them are rarely used in practice, there are actually 20-30 abbreviations to be learned, which is acceptable.

3.2.8 Types of instructions: Depending on operation they perform, all instructions are in several groups:

Arithmetic Instructions Branch Instructions Data Transfer Instructions Logic Instructions Bit-oriented Instructions

The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copy, addition, logic operation etc.). Mnemonics are abbreviations of the name of operation being executed. For example:

INC R1- Means: Increment register R1 (increment register R1); LJMP LAB5 - Means: Long Jump LAB5 (long jump to the address marked as LAB5); JNZ LOOP - Means: Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to the address marked as LOOP);

The other part of instruction, called OPERAND is separated from mnemonic by at least one whitespace and defines data being processed by instructions. Some of the instructions have no operand, while some of them have one, two or three. If there is more than one operand in an instruction, they are separated by a comma. For example: RET return from JZ TEMP - if the number in the accumulator is not 0, jump to the ADD A,R3 add R3 CJNE A,#20,LOOP - compare accumulator with 20. If they are not equal, jump to 3.2.9 Memory Organization OF 8051:

a subroutine; address marked as TEMP; and accumulator; the address marked as LOOP;

The 8051 has two types of memory and these are Program Memory and Data Memory. Program Memory (ROM) is used to permanently save the program being executed, while Data Memory (RAM) is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Depending on the model in use (we are still talking about the 8051 microcontroller family in general) at most a few Kb of ROM and 128 or 256 bytes of RAM is used. However All 8051 microcontrollers have a 16-bit addressing bus and are capable of addressing 64 kb memory.

Figure:12. Memory Organization of ROM

How does the microcontroller handle external memory depend on the EA pin logic state? EA=0 in this case, the microcontroller completely ignores internal program memory and executes only the program stored in external memory.

EA=1 in this case, the microcontroller executes first the program from built-in ROM, and then the program stored in external memory.

In both cases, P0 and P2 are not available for use since being used for data and address transmission. Besides, the ALE and PSEN pins are also used.

P0, P1, P2, P3 - Input/output Registers:

Figure: 13.Port-0 input/output registers

If neither external memory nor serial communication system are used then 4 ports with in total of 32 input/output pins are available for connection to peripheral environment. Each bit within these ports affects the state and performance of appropriate pin of the microcontroller. Thus, bit logic state is reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on a pin reflects the state of appropriate port bit.

As mentioned, port bit state affects performance of port pins, i.e. whether they will be configured as inputs or outputs. If a bit is cleared (0), the appropriate pin will be configured as an output, while if it is set (1), the appropriate pin will be configured as an input. Upon reset and power-on, all port bits are set (1), which means that all appropriate pins will be configured as inputs.

NOTE: I/O ports are directly connected to the microcontroller pins. Accordingly, logic state of these registers can be checked by voltmeter and vice versa, voltage on the pins can be checked by inspecting their bits.

a. TIMERS - 8051 MICROCONTROLLER :

The AT89S51 comes equipped with two timers, both of which may be controlled, set, read, and configured individually. T AT89S51 timers have three general functions: 1) Keeping time and/or calculating the amount of time between events 2) Counting the events themselves 3) Generating baud rates for the serial port. The three timer uses are distinct so we will talk about each of them separately. The first two uses will be discussed in chapter while the use of timers for baud rate generation will be discussed in the chapter relating to serial ports.

b. TIMERS SFRs:

As mentioned before, the 8051 has two timers which each function essentially the same way. One timer is TIMER0 and the other is TIMER1. The two timers share two SFRs (TMOD and TCON) which control the timers, and each timer also has two SFRs dedicated solely to itself (TH0/TL0 and TH1/TL1).Weve given SFRs names to make it easier to refer to them, but in reality an SFR has a numeric The SFRs relating to timers are: SFR Name TH0 TL0 TH1 TL1 TCON TMOD Description Timer 0 High Byte Timer 0 Low Byte Timer 1 High Byte Timer 1 Low Byte Timer Control Timer Mode SFR Address 8Ch 8Ah 8Dh 8Bh 88h 89h

Table:3.SFRs relating to timers

3.3 LIQUID CRYSTAL DISPLAY (LCD): An LCD display is specifically manufactured to be used with microcontrollers, which means that it cannot be activated by standard IC circuits. It is used for displaying different messages on a miniature liquid crystal display.

Figure 14: LCD Display

The model described here is for its low price and great capabilities most frequently used in practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages in two lines with 16 characters each. It displays all the letters of alphabet, Greek letters, punctuation marks, mathematical symbols etc. In addition, it is possible to display symbols made up by the user. Other useful features include automatic message shift (left and right), cursor appearance, LED backlight etc.

Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. These LCD's are very simple to interface with the controller as well as are cost effective. The most commonly used ALPHANUMERIC displays are 1x16 (Single Line & 16 characters) 2x16 (Double Line & 16 character per line) 4x20 (Four lines & twenty characters per line) The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines + 3 control lines i.e. total 11 lines are required. And if operated in 4-bit mode then 4 data lines + 3 control lines i.e. 7 lines are required. How do we decide which mode to use? Its simple if you have sufficient data lines you can go for 8 bit mode & if there is a time constrain i.e. display should be faster then we have to use 8-bit mode because basically 4-bit mode takes twice as more time as compared to 8-bit mode. Pin 1 2 Symbol Vss Vdd Function Ground Supply Voltage

3 4 5 6 7-14 15 16

Vo RS R/W En DB0-DB7 A/Vee K

Contrast Setting Register Select Read/Write Select Chip Enable Signal Data Lines Gnd for the backlight Vcc for backlight

Table: 4.LCD pin functions

3.3.1 LCD Pins:

There are pins along one side of a small printed board. These are used for connecting to the microcontroller. There are in total of 14 pins marked with numbers (16 if it has backlight). Their function is described in the table bellow : Function Ground Power supply Contrast Pin Number 1 2 3 4 Control operating of 5 Name Vss Vdd Vee RS R/W Logic State 0 1 0 1 Description 0V +5V 0 - Vdd D0 D7 are interpreted as commands D0 D7 are interpreted as data Write data (from controller to LCD) Read data (from LCD to controller) Access to LCD disabled 0 Normal operating 1 Data/commands are transferred to From 1 to 0 LCD 0/1 Bit 0 LSB 0/1 Bit 1 0/1 Bit 2 0/1 Bit 3 0/1 Bit 4 0/1 Bit 5 0/1 Bit 6 0/1 Bit 7 MSB

6 7 8 9 10 11 12 13 14

E D0 D1 D2 D3 D4 D5 D6 D7

Data / commands

Table: 5.Pins in LCD Display

When RS is low (0), the data is to be treated as a command. When RS is high (1), the data being sent is considered as text data which should be displayed on the screen. When R/W is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively reading from the LCD. Most of the times there is no need to read from the LCD so this line can directly be connected to Ground thus saving one controller line The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed.

Figure: 15.LCD Interfacing with Microcontroller

For Contrast setting a 10K pot should be used as shown in the figure. Display Data Ram (DDRAM) stores the display data. So when we have to display a character on LCD we basically write it into DDRAM. For a 2x16 LCD the DDRAM address for first line is from 80h to 8fh & for second line is 0c0h to 0cfh. So if we want to display 'H' on the 7th position of the first line then we will write it at location 87h. Now as you have noticed two types of data is given to the LCD data to be displayed, command or special instruction. So now let us write a subroutine for both the type of data The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed. 3.3.2 LCD Screen: LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built in backlight (blue or green diodes). When used during operating, a resistor for current limitation should be used (like with any LE diode).

Figure: 16. LCD Connections

3.3.3 LCD Initialization: Once the power supply is turned on, LCD is automatically cleared. This process lasts for approximately 15mS. After that, display is ready to operate. The mode of operating is set by default. This means that: 1. Display is cleared 2. Mode DL = 1 Communication through 8-bit interface N = 0 Messages are displayed in one line F = 0 Character font 5 x 8 dots 3. Display/Cursor on/off D = 0 Display off U = 0 Cursor off B = 0 Cursor blink off 4. Character entry ID = 1 Addresses on display are automatically incremented by 1 S = 0 Display shift off

Automatic reset is mainly performed without any problems. Mainly but not always! If for any reason power supply voltage does not reach full value in the course of 10mS, display will start perform completely unpredictable? If voltage supply unit cannot meet this condition or if it is needed to provide completely safe operating, the process of initialization by which a new reset enabling display to operate normally must be applied.

Algorithm according to the initialization is being performed depends on whether connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after that is to give basic commands and of course- to display messages. 3.4: MM74C922 Encoder General Description The MM74C922 CMOS key encoders provide all the necessary logic to fully encode an array of SPST switches. The keyboard scan can be implemented by either an external clock or external capacitor. These encoders also have on-chip pull-up devices which permit switches with up to 50 kon resistance to be used. No diodes in the switch array are needed to eliminate ghost switches. The internal debounce circuit needs only a single external capacitor and can be defeated by omitting the capacitor. A Data Available output goes to a high level when a valid keyboard entry has been made. The Data Available output returns to a low level when the entered key is released, even if another key is depressed. The Data Available will return high to indicate acceptance of the new key after a normal debounce period; this two-key roll-over is provided between any two switches. An internal register remembers the last key pressed even after the key is released. The 3-STATE outputs provide for easy expansion and bus operation and are LPTTL compatible. Features _ 50 kmaximum switch on resistance _ On or off chip clock _ On-chip row pull-up devices _ 2 key roll-over _ Keybounce elimination with single capacitor _ Last key register at outputs _ 3-STATE output LPTTL compatible _ Wide supply range: 3V to 15V _ Low power consumption

3.5:STEPPER MOTOR 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.

Figure 1 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.

Figure 2 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 multipole motor can be seen in Figure 3. In position 1, the north pole of the rotor's perminant magnet is aligned with the south pole of the stator's electromagnet. Note that multiple positions are alligned 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.

Figure 3 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.

Figure 5 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 reistance between the center-tap wire and each end lead, and 26 ohms between the two end leads. Wires originating from seperate coils are not connected, and therefore would not read on the ohm meter.

3.5.1 INTERNAL CIRCUIT: Figure 4 is the schematic of our first test circuit. The PIC's output lines are first buffered by a 4050 hex buffer chip, and are then connected to an NPN transistor. The transistor used, TIP120, is actually a NPN Darlington (it is shown as a standard NPN). The TIP120's act like switches, activating one stepper motor coil at a time.

Figure 4 Due to a inductive surge created when a coil is toggled, a standard 1N4001 diode is usually placed across each transistor as shown in the figure, providing a safe way of dispersing the reverse current without damaging the transistor. Sometimes called a snubbing diode. The TIP120 transistors do not need an external snubbing diode becasue they have a built in diode. So the diodes shown in the drawing are the internal diodes in the TIP120 transistors. The simplest way to operate a stepper motor with a PIC is with the full step pattern shown in Table 1. Each part of the sequence turns on only one transistor at a time, one after the other. After the sequence is completed, it repeats infinitly until power is removed.

Q1 +

Q2 -

Q3 -

Q4 -

+ Table 1

+ -

I purposly made this first program as small as possible, simply to demonstrate how easy it is to control a stepper motor. Also note the use of high and low commands to control the output lines, rather than peek and poke routines. For our purposes, high and low are sufficent.

3.6: Buzzer
A buzzer or beeper is an audio signaling device, which may be mechanical, electromechanical, or Piezoelectric. Typical uses of buzzers and beepers include alarms, timers and confirmation of user input such as a mouse click or keystroke

Figure: 25.Buzzer

CHAPTER 4

SOFTWARE 4.1 ABOUT SOFTWARE: Software used is: *Keil software for C programming.

Keil compiler is software used where the machine language code is written and compiled. After compilation, the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Keil compiler also supports C language code. 4.1.1 KEIL Vision3: What's New in Vision3? Vision3 adds many new features to the Editor like Text Templates, Quick Function Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and debugger setup. Vision3 is fully compatible to Vision2 and can be used in parallel with Vision2. 4.1.2 What is Vision3? Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components: A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

4.2 EMBEDDED C:

The programming Language used here in this project is an Embedded C Language. This Embedded C Language is different from the generic C language in few things like a) Data types b) Access over the architecture addresses. The Embedded C Programming Language forms the user friendly language with access over Port addresses, SFR Register addresses etc.

CHAPTER5
5.1 APPLICATIONS Multiple-dial locks often seen in low-security bicycle locks and in briefcases.

Combination locks found on padlocks or safes may use a single dial which interacts with several parallel discs or cams. Testing the mechanism to open the lock does not modify the state of the lock, multiple combinations can be tried sequentially, drastically reducing the brute force search time.

Early combination padlocks made by Master Lock could be cracked by pulling on the shackle of the lock and turning the dial until it stopped.

5.2 ADVANTAGES Easy to determine the lock sequence by viewing several successful accesses. Allow many valid combinations, changing one person's access has no effect on other users. These are popular for safe and vault doors . The "secret" is encoded in an electronic microcontroller. Safe from the attacks on their mechanical counterparts

5.3 CONCLUSION 5.4 BIBLIOGRAPHY 5.4.1 Name of WEBSITES:

1. www.8051.com 2. en.wikipedia.org/wiki/Infrared sensors 3. en.wikipedia.org/wiki/Light-emitting diode 4. en.wikipedia.org/wiki/Liquid_crystal_display 5. www.alldatasheet.com/datasheet-pdf/pdf/../lm339comparator ic 6- www.alldatasheet.com/datasheet-pdf/pdf/.../l293d 7. www.alldaatsheets.com

5.4.2 References: 1. 8051-MICROCONTROLLER AND EMBEDDED SYSTEM by Mohd. Mazidi 2. TECHNOLOGY AND ENGINEERING by M.H.Rashid 3. MAGAZINES-ELECTRONICS FOR YOU -ELECTRIKINDA

You might also like