Sie sind auf Seite 1von 45

COMPANY PROFILE

Its important that the technology we implement is the most secure and as secure as possible.RAD continually explores and remains knowledgeable in the latest technologies available in the industry.RAD is a company of qualified & committed professionals who are working with a vision of developing technical excellence in young engineers and technocrats. India is a powerhouse of technical workforce and has acquired a lead in providing technical manpower worldwide. However, to become competent enough for global technical challenges, our engineers need to develop experience of real projects and products. At RAD we help people develop sharp technical skills and professional attitude to stay ahead even in the most challenging circumstances. However, to become competent enough for global technical challenges, our engineers need to develop experience of real projects and products. In RAD,emphasis is given on spending more time in lab to gain hands-on experience in various interfacing techniques that can be useful in the construction of an embedded system. We are offering training programs for Electronics/Electrical/Computers/Mechanical/Biomedical fields.

CHAPTER-1 EMBEDDED SYSTEM 1.1 INTRODUCTION TO EMBEDDED SYSTEM


Now a days electronics have developed at very fast rate. It plays a major role in the life of human being and makes it very easy and comfortable. Electronics circuits are designed to obtain a particular function. For this purpose a no of electronic component are suitably connected. Embedded systems have proved changing face of today's industrial scenario. An embedded system is a system is a specialpurpose computer system designed to perform one or a few dedicated functions often with real-time computing constraints or embedded system employs a combination of software & hardware to perform a specific function. It is a part of a larger system which may not be a computer Works in a reactive & time constrained environment. Any electronic system that uses a CPU chip, but that is not a general-purpose workstation, desktop or laptop computer is known as embedded system. Such systems generally use microprocessors; microcontroller or they may use custom-designed chips or both. They are used in automobiles, planes, trains, space vehicles, machine tools, cameras, consumer and office appliances, cell phones, PDAs and other handhelds as well as robots and toys. The uses are endless, and billions of microprocessors are shipped every year for a myriad of applications. In embedded systems, the software is permanently set into a read-only memory such as a ROM or flash memory chip, in contrast to a general-purpose computer that loads its programs into RAM each time. Sometimes, single board and rack mounted general-purpose computers are called "embedded computers" if used to control.

We are living in the Embedded World. You are surrounded with many embedded products and your daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in your kitchen, Card readers, Access Controllers, Palm devices of
2

your work space enable you to do many of your tasks very effectively. Apart from all these, many controllers embedded in your car take care of car operations between the bumpers and most of the times you tend to ignore all these controllers. In recent days, you are showered with variety of information about these embedded controllers in many places. All kinds of magazines and journals regularly dish out details about latest technologies, new devices; fast applications which make you believe that your basic survival is controlled by these embedded products. Now you can agree to the fact that These embedded products have successfully invaded into our world. You must be wondering about these embedded controllers or systems. What is this Embedded System? The computer you use to compose your mails, or create a document or analyze the database is known as the standard desktop computer. These desktop computers are manufactured to serve many purposes and applications. You need to install the relevant software to get the required processing facility. So, these desktop computers can do many things. In contrast, embedded controllers carryout a specific work for which they are designed. Most of the time, engineers design these embedded controllers with a specific goal in mind. So these controllers cannot be used in any other place. Theoretically, an embedded controller is a combination of a piece of microprocessor based hardware and the suitable software to undertake a specific task. These days designers have many choices in microprocessors/microcontrollers. Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced designer. Selecting a right microprocessor may turn out as a most difficult first step and it is getting complicated as new devices continue to pop-up very often.

1.2 EMBEDDED APPLICATIONS


1.2.1 AUTOMOBILES: i) ii) Automatic Parking Tyre Pressure Monitoring
3

iii) Keyless Entry iv) Collision Avoidance System v) Driver Information & Navigation System Light vi) Door & Seat Control

Figure 1.1 Embedded System in a car

1.2.2 BUSINESS APPLICATIONS: Vending Machine, Scanners , Printers 1.2.3MEDICAL ELECTRONICS: i) ii) iii) iv) v) vi) Patient Monitoring Blood Pressure Monitor Clinical Treatment : Dialysis Machine Diagnostic Imaging : MRI , CT Scan Hospital Networking and Information System

Figure 1.2 Blood Pressure Monitor 1.2.4 CONSUMER ELECTRONICS: i) ii) iii) iv) v) vi) vii) Microwave Oven Air Conditioning System Home-security & burglar alarm Audio / Music system DVD(Digital Versatile Disk),Video Player Mobile , Modem Washing Machine

Figure 1.3: Consumer Electronics

1.2.5 INDUSTRIAL AUTOMATION APPLICATION: i)Process Control: Control of chemical plant , oil refinery etc. ii)SCADA(Supervisory Control & Data Acquisition) : PC control &monitor smaller controllers mounted in field . iii) Plant automation: Computer numeric control machines , robots for manufacturing iv) Safety Interlocks: Safety systems to avoid life and material hazard , like plant shutdown if gas leaks.

Figure 1.4 Fabrication equipment

1.2.6 DEFENCE APPLICATIONS: RADARs, SONARs (for suvellience) , Guided Missiles System and many more

1.2.7 ROBOTICS: Embedded systems are used for making robots.

Figure 1.5: Robot

CHAPTER-2 MICROCONTROLLER 2.1 INTRODUCTION


Microcontroller are widely used in Embedded System products. An Embedded product uses the microprocessor(or microcontroller) to do one task & one task only. A printer is an example of Embedded system since the processor inside it perform one task only namely getting the data and printing it. Contrast this with Pentium based PC. A PC can be used for any no. of applications such as word processor, print server, bank teller terminal, video game player, network server or internet terminal. Software for variety of applications can be loaded and run. Of course the reason a PC can perform multiple task is that it has RAM memory and an operating system that loads the application software into RAM & lets the CPU run it. In and Embedded system there is only one application software that is typically burn into ROM. An x86PC Contain or its connected to various Embedded Products such as keyboard, printer, modem, Disc controller, Sound card, CD-Rom Driver, Mouse & so on. Each one of these peripherals as a microcontroller inside it that performs only one task. Although microcontroller are preferred choice for many Embedded systems, There are times that a microcontroller is inadequate for the task. For this reason in recent years many manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD & Cyrix have targeted their microprocessors for the high end of Embedded market. While INTEL, AMD, Cyrix push their x86 processors for both the embedded and desktop pc market, Motorolla is determined to keep the 68000 families alive by targeting it mainly for high end of embedded system. One of the most critical needs of
7

the embedded system is to decrease power consumptions and space. This can be achieved by integrating more functions into the CPU chips. All the embedded processors based on the x86 and 680x0 have low power consumptions in additions to some forms of I/O, Com port & ROM all on a single chip. In higher performance Embedded system the trend is to integrate more & more function on the CPU chip & let the designer decide which feature he/she wants to use.

2.2 DEFINITION
Microcontroller, as the name suggests, are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys ... etc, where automation is needed.

2.3 HISTORY
Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this controller had 128 bytes of RAM, 4k bytes of on chip ROM, two timers, one serial port, and four ports all are on single chip. The 8051 is an 8 bit processor, meaning that the CPU can work on only 8 bit data at a time. Data larger than 8 bits broken into 8- bit pieces to be processed by CPU. It has for I/O 8 bit wide.

2.4 FEATURES
FEATURE ROM RAM Timer I/O pins Serial port Interrupt sources QUANTITY 4K bytes 128 bytes 2 32 1 6
8

2.5 CHOOSING CRITERIA


a) Meeting the computing needs of the task efficiently and cost effectively i) Speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption i) easy to upgrade iii) cost per unit b) Availability of software development tools -assemblers, debuggers, C compilers, emulator, simulator, technical support c) Wide availability and reliable sources of the microcontrollers.

2.6 8051 ARCHITECTURE OVERVIEW


The 8051 family is one of the most common microcontroller architectures used worldwide. 8051 based microcontrollers are offered in hundreds of variants from many different silicon manufacturers. The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU, optimized for control applications with extensive Boolean processing (single-bit logic capabilities), 64K program and data memory address space and various on-chip peripherals. The 8051 microcontroller family offers developers a wide variety of high-integration and cost-effective solutions for virtually every basic embedded control application. From traffic control equipment to input devices and computer networking products, 8051 u.c deliver high performance together with a choice of configurations and options matched to the special needs of each application. Whether it's low power operation, higher frequency performance, expanded on-chip RAM, or an applicationspecific requirement, there's a version of the 8051 microcontroller that's right for the job. When it's time to upgrade product features and functionality, the 8051 architecture
9

puts you on the first step of a smooth and cost-effective upgrade path - to the enhanced performance of the 151 and 251 microcontrollers. TYPES OF ARCHITECTURE I.
II.

Von Neumann Architecture Harvard Architecture

TABLE 2.1: VON NEUMANN & HARVARD ARCHITECTURE:

Von Neumann

Harvard

Doesnt distinguish between data and Instructions and data have different instructions. Both are stored in same memory spaces , with separate address , memory and has same word size. data and control buses for each memory space . Concurrent instruction and data fetch. Size of instruction is independent of data word size.

II.7

BLOCK DIAGRAM OF MICROCONTROLLER:

10

Fig-2.1-Block diagram of MICROCONTROLLER

2.8 DIP 40 PIN CONFIGURATIONS:

11

Figure 2.2: Pin description

1.VCC: - PIN (40) - This pin is used to supply voltage to the micro controller. Generally +5V is provided to microcontroller. 2.GND: - PIN (20) - This pin is used for ground. 3.RST: - (PIN 9) It is a Reset Input. When this pin is given a high for the two continuous machine cycles while the oscillator is running, the device gets resets. Logical one on this pin stops microcontrollers operating and erases the contents of most registers. By applying logical zero to this pin, the program starts execution from the beginning. In other words, a positive voltage pulse on this pin resets the microcontroller. 4. ALE: - (PIN 30): - It is an Address latch enable. With the bit set the ALE is enabled during the MOVX or MOVC instruction. Prior to each reading from external memory, the microcontroller will set the lower address byte (A0-A7) on P0 and immediately after that activates the output ALE. Upon receiving signal from the ALE pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded ) memorizes the state of P0 and uses it as an address for memory chip. In the second part of the microcontrollers machine cycle, a signal on this pin stops being emitted and P0 is used now for data transmission (Data Bus). In this way, by means of only one additional (and cheap) integrated circuit, data multiplexing from the port is performed. This port at the same time used for data and address transmission. 5. PSEN : - (PIN 29): - Program Store Enabled is the read strobe to external program memory. When the AT89C51 is executing code from external memory, This pin is activated during each machine cycle, except that two activation are skipped during each access to external data memory. If external ROM is used for storing program then it has a logic-0 value every time the microcontroller reads a byte from memory.

12

6. EA / VPP: - (PIN 31): - External access enabled. EA must be strapped to ground in order to enable the device to fetch code from external program memory location starting at 0000H to FFFFH. EA should be strapped to VCC for internal program execution. This pin also receives the 12 -Volt programming enabled voltage during Flash Programming, for parts that require 12-volt VPP. Where VPP is a peak to peak voltage. 7. 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. That means that even there is a program written to the microcontroller, it will not be executed, the program written to external ROM will be used instead. Otherwise, by applying logic one to the EA pin, the microcontroller will use both memories, first internal and afterwards external (if it exists), up to end of address spaced to VCC for internal program execution. This pin also receives the 12 -Volt programming enabled voltage during Flash Programming, for parts that require 12-volt VPP. Where VPP is a peak to peak voltage. 8. PORT 0 AS INPUT: With resistors connected to port 0, in order to make it an input, the port must be programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an input port by writing 1's to it, and then data is received from the port and sent to P1.

13

Fig-2.3-P0 port with pull up resistors Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. When connecting an 8051/31 to an external memory, port 0 provides both address and data. The 8051 multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. When ALE = 0, it provides data D0-D7, but when ALE =1 it has address and data with the help of a 74LS373 latch. 9. PORT 1 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. For
14

example, the following code will continuously send out to port1 the alternating values 55h & AAh

9.1 PORT 1 AS INPUT To make port1 an input port, it must be programmed as such by writing 1 to all its bits. In the following code port1 is configured first as an input port by writing 1s to it, then data is received from the port and saved in R7 ,R6 & R5.

10. PORT 2 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. For example, the following code will send out continuously to port 2 the alternating values 55h and AAH. That is all the bits of port 2 toggle continuously.

10.1 PORT 2 AS INPUT To make port 2 an input, it must programmed as such by writing 1 to all its bits. In the following code, port 2 is configured first as an input port by writing 1s to it. Then data is received from that port and is sent to P1 continuously.

DUAL ROLE OF PORT 2 In systems based on the 8751, 8951, and DS5000, P2 is used as simple I/O. However, in 8031-based systems, port 2 must be used along with P0 to provide the 16-bit address for the external memory. As shown in pin configuration 8051, port 2 is also designed as A8-A15, indicating the dual function. Since an 8031 is capable of accessing 64K bytes of external memory, it needs a path for the 16 bits of the address. While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A815

A15 of the address. In other words, when 8031 is connected to external memory, P2 is used for the upper 8 bits of the 16 bit address, and it cannot be used for I/O.

11. PORT 3 Port 3 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. There functions are as follows:Table 2.2: PORT 3 functions Port Pins P3.0 Alternate Functions RXD ( serial input port)- This is used in serial communication at receivers side P3.1 TXD (serial output port)- This is used in serial communication at transmitters side P3.2 INT0 (external interrupt 0) - This pin is used for providing the interrupts. P3.3 INT1 (external interrupt 1) - This pin is used for providing the interrupts. P3.4 P3.5 P3.6 T0 (timer 0 external input) - This pin is used for providing the timers. T1 (timer 1 external input) - This pin is used for providing the timers. WR (external data memory write strobe) - This pin is used when we have to perform a write operation. P3.7 RD (external data memory read strobe) - This pin is used when we have to perform a write operation.

P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2 and P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0
16

and 1. Finally P3.6 and P3.7 are used to provide the WR and RD signals of external memories connected in 8031 based systems. 12. ALE/PROG Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/ 6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. 13.PSE Program Store Enable is the read strobe to external program memory. When the AT89S8252 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

14. External Access Enable EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected.

15. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
17

16. XTAL2 Output from the inverting oscillator amplifier. 17. OSCILLATOR CRYSTAL XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which 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. 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.

2.9 SPECIAL PURPOSE REGISTERS:


SFRs are a kind of control table used for running and monitoring microcontrollers operating. Each of these registers, even each bit they include, has its name, address in the scope of RAM and clearly defined purpose ( for example: timer control, interrupt, serial connection etc.). Even though there are 128 free memory locations intended for their storage, the basic core, shared by all types of 8051 controllers, has only 21 such registers. Rest of locations are intentionally left free in order to enable the producers to further improved models keeping at the same time compatibility with the previous versions. It also enables the use of programs written a long time ago for the microcontrollers which are out of production now.

2.9.1 CPU Registers:


a) ACCUMULATOR: - It is an 8 bit register and used as working register for the Arithmetic, Logical instructions. All the calculations are performed using this register. It can also be used as General purpose register. It is very necessary for some instructions. It is denoted by A. A number (an operand) should be added to the accumulator prior to execute an instruction upon it. Once an arithmetical operation is performed by the ALU, the result is placed into the accumulator. If a data should be transferred from one register to another, it must go through accumulator. For such
18

universal purpose, this is the most commonly used register that none microcontroller can be imagined without (more than a half 8051 microcontroller's instructions used use the accumulator in some way). b) B REGISTER: - It also an 8 bit register and can be used as General Purpose register. It is very necessary for the multiplication and division operations which can be performed only upon numbers stored in the A and B registers ,without it the operations are not accomplished. All other instructions in the program can use this register as a spare accumulator (A).

2.10 PSW-PROGRAM STATUS WORD (BIT ADDRESSABLE)

Fig-2.4-PROGRAM STATUS WORD This is one of the most important SFRs. The Program Status Word (PSW) contains several status bits that reflect the current state of the CPU. This register contains: Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit, and user-definable status flag. The ALU automatically changes some of registers bits, which is usually used in regulation of the program performing. P - Parity bit: If a number in accumulator is even then this bit will be automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmission and receiving via serial communication. Bit 1: This bit is intended for the future versions of the microcontrollers, so it is not supposed to be here. OV Overflow:
19

Sets when the result of arithmetical operation is greater than 255 (deci mal), so that it cannot be stored in one register. In that case, this bit will be set (1). If there is no overflow, this bit will be cleared (0). RS0, RS1 - Register bank select bits: These two bits are used to select one of the four register banks in RAM. By writing zeroes and ones to these bits, a group of registers R0-R7 is stored in one of four banks in RAM. TABLE-2.3 DIFFERENT COMBINATIONS OF RS0 AND RS1: RS1 0 0 1 1 F0 - Flag 0: This is a general-purpose bit available to the user. AC - Auxiliary Carry Flag: It is used for BCD operations only. CY - Carry Flag: It is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions. The above table shows that RS0 and RS1 are responsible for selecting the particular Register bank i.e. by using the different combinations of RS0 and RS1 the Register Banks are selected. RS2 0 1 0 1 SPACE IN RAM Bank 0 (00h-07h) Bank 1 (08h-0Fh) Bank 2 (10h-17h) Bank 3 (18h-1Fh)

20

CHAPTER-3 MICROPROCESSOR 3.1 INTRODUCTION


A microprocessor is a general-purpose digital computer central processing (CPU). Although popularly known as a computer on a chip is in no which contains an arithmetic and logical unit (ALU), a a stack pointer (SP),some working registers, a clock circuits. unit sense a

complete digital computer . The block diagram of a microprocessor CPU is shown, program counter (PC), timing circuit, and interrupt

Fig-3.1-BLOCK DIAGRAM OF A MICROPROCESSOR


21

3.2

COMPARISON

BETWEEN

MICROPROCESSORS

&

MICROCONTROLLERS
The microprocessor must have many additional parts to be operational as a computer whereas microcontroller requires no additional external digital parts. 1.The prime use of microprocessor is to read data, perform extensive calculations on that data and store them in the mass storage device or display it. The prime functions of microcontroller is to read data, perform limited calculations on it, control its environment based on these data. Thus the microprocessor is said to be generalpurpose digital computers whereas the microcontroller are intend to be special purpose digital controller. 2.Microprocessor is concerned with the rapid movement of the code and data from the external addresses to the chip, microcontroller is concerned with the rapid movement of the bits within the chip. Lastly, the microprocessor design accomplishes the goal of flexibility in the hardware configuration by enabling large amounts of memory and I/O that could be connected to the address and data pins on the IC package. The microcontroller design uses much more limited set of single and double byte instructions to move code and data from internal memory to ALU.

22

CHAPTER-4 PERIPHERAL INTERFACING WITH 8051

4.1

LED INTERFACING

LED can be interface with micro-controller as shown in the fig. 2.7. Here the common anode configuration is used, in which common end is connected to power supply of +5V. When the port, to which LEDs are interfaced, have logic 0 on it, LEDs will glow. The color of emitted light depends on the composition and condition of the semiconductor material used, and can be infrared, visible or nearly ultra-violet. An LED can be used as a regular home light source. Resistor is used to control flow of current through LEDs and EA pin is always connected to +Vcc in case of 8051 microcontroller. USE A LED can be used as an indicator in ac circuit. The LEDs in a seven segment display may be connected in common anode or in common-cathode configuration.

Figure 4.1: LED interfacing with 8051 microcontroller

4.2 SEVEN SEGMENT INTERFACING:


23

The Light Emitting Diode (LED), finds its place in many applications in this modern electronic fields. One of them is the Seven Segment Display. Seven-segment displays contains the arrangement of the LEDs in Eight (8) passion, and a Dot (.) with a common electrode, lead (Anode or Cathode). The purpose of arranging it in that passion is that we can make any number out of that by switching ON and OFF the particular LEDs. Here is the block diagram of the Seven Segment LED arrangement. Pin configuration of a seven segment display:

Fig-4.2-Seven-Segment Display

Seven Segments are basically of two types:


1. Common

Cathode(CC)

All the 8 anode legs uses only one cathode, which is common. 2. Common Anode (CA)

The common leg for all the cathode is of Anode type.

24

Figure 4.3: Circuit diagram for Common Cathode 7-Segment Display

LCD INTERFACING : 16x2 LCD Description

Fig 4.4-LCD diagram with pins description

LCD pin description:The LCD discuss in this section has the most common
connector used for the Hitatchi 44780 based LCD is 14 pins in a row and modes of operation and how to program and interface with microcontroller is describes in this section.
25

The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling LCD contrast. Variable voltage between Ground and Vcc is used to specify the contrast (or "darkness") of the characters on the LCD screen. RS (register select) There are two important registers inside the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction command code register is selected, then allowing to user to send a command such as clear display, cursor at home etc.. If RS=1, the data register is selected, allowing the user to send data to be displayed on the LCD. R/W (read/write) The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and R/W=0, when it writing.

26

Fig 4.4-LCD Pin Description Diagram EN (enable) The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high power, a high-to-low pulse must be applied to this pin in order to for the LCD to latch in the data presented at the data pins. D0-D7 (data lines) The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCDs internal registers. To displays the letters and numbers, we send ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making RS
27

=1. There are also command codes that can be sent to clear the display or force the cursor to the home position or blink the cursor. We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the information. The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking care of internal operations and will not accept any information. When D7 =0, the LCD is ready to receive new information. Interfacing of micro controller with LCD display In most applications, the "R/W" line is grounded. This simplifies the application because when data is read back, the microcontroller I/O pins have to be alternated between input and output modes. In this case, "R/W" to ground and just wait the maximum amount of time for each instruction (4.1 msecs for clearing the display or moving the cursor/display to the "home position", 160 usecs for all other commands) and also the application software is simpler, it also frees up a

Fig 4.5-Interfacing of Microcontroller with LCD microcontroller pin for other uses. Different LCD execute instructions at different rates and to avoid problems later on (such as if the LCD is changed to a slower unit). Before sending commands or data to the LCD module, the Module must be
28

initialized. Once the initialization is complete, the LCD can be written to with data or instructions as required. Each character to display is written like the control bytes, except that the "RS" line is set. During initialization, by setting the "S/C" bit during the "Move Cursor/Shift Display" command, after each character is sent to the LCD, the cursor built into the LCD will increment to the next position (either right or left). Normally, the "S/C" bit is set (equal to "1").

4.5 STEPPER MOTOR INTERFACING


Stepper motors can be used in various areas of your microcontroller projects such as making robots, robotic arm, automatic door lock system etc. The construction of stepper motors (unipolar and bipolar stepper motors ), basic pricipal, different controlling types (Half step and Full step), Interfacing Techniques

(using

L293D

or

ULN2003).

There are actually many ways you can interface a stepper motor to your controller, out of them the most used interfaces are: 1. Interface using L293D - H-Bridge Motor Driver 2. Interface using ULN2003/2004 - Darlington Arrays We will dicuss both connection techniques one by one. The above mentioned methods need 4 controller pins for interface.

29

Figure 4.6: Stepper motor interfacing with microcontroller Here in this circuit too the four pins "Controller pin 1",2,3 and 4 will control the motion and direction of the stepper motor according to the step sequence sent by the controller. Why to use ULN2003? It is a driver IC. ULN IC are basically current amplifiers that are used to interface motor or LED's to controller. Motor needs more current to drive the rotor. The current at port pins are very less around 25Ma which is amplified to 500ma for motor operation. So we use current amplifier to drive the motor.

30

CHAPTER-5

PROJECT COVERED

31

PASSWORD BASED DOOR LOCKING SYSTEM

5.1 INTRODUCTION
Security is a prime concern in our day-today life. Everyone wants to be as much secure as possible. An access control for doors forms a vital link in a security chain. The microcontroller based Door locker is an access control system that allows only authorized persons to access a restricted area. The system is fully controlled by the 8 bit microcontroller AT89C2051 which has a 2Kbytes of ROM for the program memory. The password is stored in the EPROM so that we can change it at any time. The system has a Keypad by which the password can be entered through it. When the entered password equals with the password stored in the memory then the relay gets
32

on and so that the door is opened .If we entered a wrong password then the alarm will be switched on.

5.2 Design Strategy


This console project is intended to be a low-end and low-cost system that will focus mainly on affordability and simplicity rather than connectivity or even ease-of-use. Hence this will be a stand-alone system that will not need a special communications interface. These limit the design phase to four sub-systems: keypad, controller, and visual/mechanical interface.

5.3 Main Modules of the System


LCD (Liquid Crystal Display) The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. Stepper Motor

Stepper motors can be used in various areas of your microcontroller projects such as making robots, robotic arm, automatic door lock system etc. The construction of stepper motors (unipolar and bipolar stepper motors ), basic pricipal, different controlling types (Half step and Full step), Interfacing Techniques (using L293D or ULN2003). Power Supply: The +5 volt supply is useful for both analog and digital circuits. DTL, TTL, and CMOS ICs will all operate nicely from a +5 volt supply. In addition, the +5 volt supply is useful for circuits that use both analog and digital signals in various ways.

33

Figure 5.1: Power supply ULN2003 It is a driver IC. ULN IC are basically current amplifiers that are used to interface motor or LED's to controller. Motor needs more current to drive the rotor. The current at port pins are very less around 25Ma which is amplified to 500ma for motor operation. So we use current amplifier to drive the motor.

Fig-5.2-pin diagram of ULN2003 PROGRAM:


$include(mod51) org 0000h r1, r2, r3, p0, lcdon lcdenterpass a, cmdw delay checkpw delay 34 #0c4h #0ffh #0ffh #0ffh #0ffh mov mov mov main1: lcall lcall mov lcall lcall lcall lcall main: mov

lcall ljmp lcdon: mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall ret lcdenterpass:

delay main a, cmdw delay a, cmdW delay a, cmdw delay a, cmdw delay a, cmdw delay mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, #'P' 35 #' ' #'r' #'e' #'t' #'n' #'E' #80h #06h #01h #0Eh #38h

lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall ret checkpw: jb mov ljmp savedata1: jb mov ljmp savedata3: jb mov ljmp savedata4: jb mov ljmp savedata5: jb

datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay p2.7, r0, p2.6, r0, p1.7, r0, p1.0, r0, p1.6, savedata1 #00h savedata3 #01h savedata4 #02h savedata5 #03h savedata6 36 #'d' #'r' #'o' #'w' #'s' #'s' #'a'

savedata

savedata

savedata

savedata

mov ljmp savedata6: jb mov ljmp savedata7: jb mov ljmp savedata8: jb mov ljmp savedata9: jb mov ljmp savedata10: savedata: jb mov lcall lcall mov cjne mov mov ljmp save1: mov cjne mov mov ljmp save2: mov cjne mov mov ljmp compare: mov cjne mov cjne

r0, p1.5, r0, p1.4, r0, p1.3, r0, p1.2, r0, p1.1, r0, star delay a, a, a, r1, a, a, a, r2, a, a, a, r3, a, a, a, a,

#04h savedata7 #05h savedata8 #06h savedata9 #07h savedata10 #08h checkpw #09h

savedata

savedata

savedata

savedata

savedata

r1 #0ffh, save1 r0 a r2 #0ffh, save2 r0 a r3 #0ffh, checkpw r0 a r1 #03h, r2 #05h, lcdinvalid 37 lcdinvalid

checkpw

checkpw

checkpw

mov cjne ret lcdinvalid: mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov

a, a, a, cmdw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a,

r3 #01h, #80h lcdinvalid

#'I'

#'n'

#'v'

#'a'

#'l'

#'i'

#'d'

#' '

#'P'

#'a'

#'s' 38

lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall setb lcall lcall lcall clr ret vpss: mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall

datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay p0.7 delayb delayb delayb p0.7 a, cmdw delay a, datw delay a, datw delay a, datw delay a, datw 39 #'i' #'l' #'a' #'v' #80h #'d' #'r' #'o' #'w' #'s'

lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall mov lcall lcall smotor: mov mtrf: r6, mov lcall mov lcall mov

delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay a, datw delay #03h p0, delayn p0, delayn p0, #06h 40 #0ch #09h #'d' #'r' #'o' #'w' #'s' #'s' #'a' #'P' #' ' #'d'

lcall mov lcall djnz lcall lcall lcall mov mtrr: mov lcall mov lcall mov lcall mov lcall djnz mov lcall ret star: mov lcall lcall ret cmdw: mov clr clr setb lcall clr ret datw: mov setb clr setb lcall clr p1, p2.3 p2.4 p2.5 delay p2.5 p1, p2.3 p2.4 p2.5 delay p2.5

delayn p0, delayn r6, delayb delayb delayb r6, p0, delayn p0, delayn p0, delayn p0, delayn r6, p0, delay a, datw delayb a #'*' mtrr #00h #09h #0ch #06h #03h #03h mtrf #03h

41

ret delayb: back13: mov back11: mov back12: djnz mov r4, r5, r5, djnz djnz ret delay: back1: back: mov mov djnz djnz ret delayn: bac: ba: mov mov djnz djnz ret end r4, r5, r5, r4, #0ffh #0ffh ba bac r4, r5, r5, r4, #22h #0ffh back back1 r7, #0ffh #0ffh back12 r4, r7, back11 back13 #05h

5.4 CIRCUIT DIAGRAM

42

Fig-5.3-circuit diagram of password based door locking system

5.5 Applications
Home: Home security is top priority of all concerned. Today there are plenty of home security products to ensure your familys security completely. Home security is the most significant one for every homeowner either in an individual house or an apartment. To get the absolute peace of mind whether you are at first time home or out of home you must ensure that your home is installed with the perfect home security monitoring system. Home security system using PASSWORD PROTECTED DOOR LOCKING SYSTEM is the best way to protect your family and your belongings. People engaged in business and often going on a business or personal trip is at the maximum need. Safes: A security system without a high security safe is not a complete theft prevention system. Throughout history there has been an enduring need to protect irreplaceable possessions from theft . In the Middle Ages merchants constructed treasury safes made of oak conjoined with iron as a repository of security. With technological advances, today's safes have tempered steel walls with fire-retardant material interspersed within the walls, affording a deterrent to theft , unimaginable just a century ago. Only safes can provide a superior level of protection for documents, jewelry, guns and personal items. A security safe PROTECTED DOOR LOCKING SYSTEM an essential protection against theft. Vehicles: Nine-out-of-ten cars are hot-wired and driven away. Mechanical devices such as steering wheel bars and pedal locks are only a minor inconvenience for the professional. Although they may work as a deterrent, car alarms can be "hot wired"
43

based on PASSWORD

designed for specific needs can meet

the varied necessities of home, business and office requirements. Security safes are

around. The professional thief simply cuts or jumps the alarm wires and he is gone. Tracking devices used by police to locate stolen cars do not STOP the vehicle from being hot-wired and driven away. They depend on early notification of authorities by the owner. A car that is taken at 2 a.m. can be dismantled miles away before the owner even realizes it is gone. Although the PASSWORD PROTECTED DOOR LOCKING SYSTEM can defeat most tactical attempts made by the thief and can be regarded as the safest means of security.

5.6 CONCLUSION
PASSWORD PROTECTED DOOR LOCKING SYSTEM is an access control system that allows only authorized person to access the restricted area. This provides us with intense safety and security at various levels of livelihood. Some of them include houses, offices, institutions, car locking system, safes. Some of its important features are a) Easily affordable means of security b) Low power consumption c) Easy to install d) Easily compatible product.

44

REFERENCES
1. www.8051projects.net 2. www.datasheet.in 3. www.microchip.com

45

Das könnte Ihnen auch gefallen