You are on page 1of 94

UNJAB TECHNICAL UNIVERSITY ALANDHARING/PROJECT REPORT ON

EMBEDDED SYSTEM DESIGN


A Project report submitted in partial fulfillment of the requirement for the award of Bachelor of Technology in Electronics and Communication Engineering Submitted by:
MUKESH KUMAR ROLL NO: 7008040469

Under the guidance of BHUPINDER SINGH (H.O.D) Dept. of Electronics & Communication Engineering LOVELY INSTITUTE OF TECHNOLOGY Six weeks training carried out at ADVANCED TECHNOLOGY CHANDIGARH SCO-160, SEC-24D

~1~

(12 JUNE 2008-26JULY 2008)

2008
EMBEDDED SYSTEM DESIGN

SUBMITTED TO: MR. BHUPINDER VERMA H.O.D, E.C.E L.I.T CHEHRU (KPT.)

MUKESH KUMAR E.C.E V SEM 3/8/2008

TRAINING/PROJECT REPORT ON EMBEDDED SYSTEM DESIGN Submitted to partial full filament of the requirement for the course of four years B-tech in Electronics & communication Engineering of Punjab Technical University. UNDER THE GUIDANCE OF Mrs Asha Rani. Lecturer in LIT SUBMITTED TO: Department Of Electronics & Communication Engineering SUBMITTED BY: Mukesh Kumar Roll no 7008040469 LOVELY INSTITUTE OF TECHNOLOGY CHEHERU (DIST. KAPURTHALA)

CERTIFICATE This to certify that Training/Project Work after 4th semester E.C.E. TRAINING/PROJECT ON EMBEDDED SYSTEM DESIGN Has Been Successfully Completed By Mukesh Kumar Roll no: 7008040469

IN PARTIAL FULFILLMENT FOR THE B-TECH OF ELECTRONICS & COMMUNICATION ENGINEERING AWARDED BY Punjab Technical University Jalandhar.

~4~

ACKNOWLEDGEMENT

t the outset I wish to express my gratitude to various people for their assistance and support without which it would have been impossible for us to complete my training/project. Firstly, I would like to express my gratitude and appreciation to Mr. BHUPINDER SINGH who is Head Of Department Of Electronics & Communication Engineering in Lovely Institute Of Technology and Mrs. ASHA RANI Lecture in ECE Department. I consider it my foremost duty to express our deepest sense of our respect and gratitude to my guide MR. SUMEET. I want to express my heart felt thank to MR. PARDEEP KUMAR Head of Production Department and MISS. SHWETA KAK Head of Training Department in Advanced Technology being a source of guidance for me. Without them I was not able to complete the training/ project. I would like to special thanks MRS. SUMAN, MR RAJESH, MR SUNIL, MR RAKESH who are the members of Production Department, which help me in each and every step of my project to improve my performance in building the project. At lastly i acknowledge our indebtedness to my classmates and friends for their acknowledgement and sincere suggestion.

~5~

PREFACE

s a part of my B-tech program I have to go under "INDUSTRIAL TRAINING" for six week in some Industry after completing fourth semester for learning practical work. The Industrial training occupies a significant place during B-TECH. In Industrial training one is brought in close touch with real Industry life programs for away from classroom culture and is require to bend theory into practical. The total training was carefully allotted to me in such a way that I shall acquire useful information regarding PSPICE,PCB DESIGNING. I spent my all six weeks of training in INSTITUTE OF SCIENCE AND TECNOLOGY KLAWAD and learnt all about HARD WAER IMPLIMENTATION.

dvance Technology established in the year 1999, is an embedded design house. It provides out-of-the-box solution from concept to reality. It is registered with Small Scale Industries with Chandigarh Administration. Arvind Dixit, the architect of the advance technology is a self made man and a man of vision. His foresight & 15 years of experience maintaining high quality standards, as a sure way of success and flourished rapidly. Advance Technology consists of a group of talented and experienced business professionals who are dedicated to maintaining a standard of excellence, while providing personalized services and the highest quality of products at the lowest price as possible as in the market place. The company is one of the innovations, dedication and diversification with 15 years of experience in the field of Embedded, VLSI, DSP and Wireless. The company has built a resource of base of high innovate professionals and state-of-art manufacturing in a very short time.

LIST OF CONTENTS 1). Embedded System Design. Introduction Applications 2). Microcontroller 8051. Introduction History Definition of a Microcontroller Microcontrollers vs. Microprocessors Types of microcontroller Architectures Difference between CISC & RISC 8051 core architecture Pin description of 8051 Memory Unit Central Processing Unit Bus Input Output Unit Serial Communication Timer Unit Analog to Digital Converter

3). Microcontroller Application Board (MAB).

Introduction MAB Components P89C51RD2 Power Supply Section

Seven Segment Section LED Section Relay Section ADC 0808/0809 Section Buzzer Section Stepper Motor Section Switch Section LCD Section How to program MCS51 How to use Keil VISION How to use Flash Magic

4). Interfacing & Experiments on MCS51. LED interfacing LCD interfacing Seven Segment Display Interfacing ADC interfacing Relay Interfacing Serial communication [b/w PC & Microcontroller] Stepper Motor Interfacing DIP switch interfacing Buzzer interfacing

EMBEDDED SYSTEM DESIGN INTRODUCTION 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. Figure: A basic Embedded System 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 generalpurpose 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 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. EMBEDDED APPLICATIONS AUTOMOBILES: Fuel Injection control (for fuel efficiency), Air bags and Automatic braking (for safety), and car entertainment systems.

MEDICAL ELECTRONICS: Many sophisticated medical instruments (Body Scanners, Heart rate monitors, Pacemaker etc) Industrial Control: such as CNC machines are example embedded systems.

BUSINESS APPLICATIONS: Vending machines, scanners, printers. CONSUMER ELECTRONICS: Cameras, Toys, Cellular Phones, Washing Machines

AVIONICS: Airplanes, Satellite Stations

DEFENSE: RADARs, SONARs (for suvellience ), Guided Missile Systems

COMPONENTS OF EMBEDDED SYSTEM

HARDWARE

Processor

Memory User Interface Displays Input/Output Other Electrical Components Examples include Power Supply, Data Converters, Electric Filters Components of Embedded System

SOFTWARE

Control Software :Responsible for managing and synchronizing Computation Extensive Software Device Drivers which control System's Peripheral User Interface for collecting user inputs Operating System (optional) : Operating System is a software which manages the different resources (CPU, Memory, Peripherals) of a system

MICROCONTROLLER 8051
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 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.
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.

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

DEFINITION OF A MICROCONTROLLER 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. THE KEY FEATURES OF MICROCONTROLLERS INCLUDE: High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have on-chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry. Field Programmability, Flexibility Microcontrollers often use EEPROM or EPROM as their storage device to allow field programmability so they are flexible to use. Once the program is tested to be correct then large quantities of microcontrollers can be programmed to be used in embedded systems. Easy to Use Assembly language is often used in microcontrollers and since they usually follow RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries.

~ 18 ~

MOST MICROCONTROLLERS WILL ALSO COMBINE OTHER DEVICES SUCH AS:

A Timer module to allow the microcontroller to perform tasks for certain time periods. A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller. An ADC to allow the microcontroller to accept analogue input data for processing.

Figure: Showing a typical microcontroller device and its different subunits The heart of the microcontroller is the CPU core. In the past this has traditionally been based on an 8-bit microprocessor unit. MICROCONTROLLERS VERSUS MICROPROCESSORS Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices. TYPES OF MICROCONTROLLER ARCHITECTURE: There are two types of Microcontroller architecture designed for embedded system development. These are: 1)RISC- Reduced instruction set computer 2)CISC- Complex instruction set computer

~ 19 ~

DIFFERENCE BETWEEN CISC AND RISC CISC stands for Complex Instruction Set Computer. Most PC's use CPU based on this architecture. For instance Intel and AMD CPU's are based on CISC architectures. Typically CISC chips have a large amount of different and complex instructions. In common CISC chips are relatively slow (compared to RISC chips) per instruction, but use little (less than RISC) instructions. MCS-51 family microcontrollers based on CISC architecture. RICS stands for Reduced Instruction Set Computer. The philosophy behind it is that almost no one uses complex assembly language instructions as used by CISC, and people mostly use compilers which never use complex instructions. Therefore fewer, simpler and faster instructions would be better, than the large, complex and slower CISC instructions. However, more instructions are needed to accomplish a task. Atmells AVR microcontroller based on RISC architecture. 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 application-specific 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 puts you on the first step of a smooth and costeffective upgrade path - to the enhanced performance of the 151 and 251 microcontrollers.

~ 20 ~

BLOCK DIAGRAM OF 8051

Figure: Internal Architecture of 8051 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. PORT 0 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. For example, the following code will continuously send out to port 0 the alternating values 55H and AAH

Figure: Pin Configuration Of 8051 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.

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.

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 pullup resistors internally. Upon reset, Port 1 is configured as an output port. For example, the following code will continuously send out to port1 the alternating values 55h & AAh 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. 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. 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 A8-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. 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:-

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 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. 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. PSEN 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. EA/VPP 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 12volt programming is selected.

XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. Oscillator Characters: 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.

Figure: 11.0592MHZ Crystal

MEMORY UNIT Memory is part of the microcontroller whose function is to store data. The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose that we marked the drawers in such a way that they can not be confused, any of their contents will then be easily accessible. It is enough to know the designation of the drawer and so its contents will be known to us for sure.

Figure: Simplified model of a memory unit

Memory components are exactly like that. For a certain input we get the contents of a certain addressed memory location and that's all. Two new concepts are brought to us: addressing and memory location. Memory consists of all memory locations, and addressing is nothing but selecting one of them. This means that we need to select the desired memory location on one hand, and on the other hand we need to wait for the contents of that location. Besides reading from a memory location, memory must also provide for writing onto it. This is done by supplying an additional line called control line. We will designate this line as R/W (read/write). Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory location. Memory is the first element, and we need a few operation of our microcontroller. The amount of memory contained within a microcontroller varies between different microcontrollers. Some may not even have any integrated memory (e.g. Hitachi 6503, now discontinued). However, most modern microcontrollers will have integrated memory. The memory will be divided up into ROM and RAM, with typically more ROM than RAM. Typically, the amount of ROM type memory will vary between around 512 bytes and 4096 bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as 128 Kbytes of ROM type memory. ROM type memory, as has already been mentioned, is used to store the program code. ROM memory can be ROM (as in One Time Programmable memory), EPROM, or EEPROM. The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes to 4 Kbytes. RAM is used for data storage and stack

management tasks. It is also used for register stacks (as in the microchip PIC range of microcontrollers).

Figure: Memory Organization LOGICAL SEPARATION OF PROGRAM DATA MEMORY All Atmel Flash microcontrollers have separate address spaces for program and data memory. The logical separation of program and data memory allows the data memory to be accessed by 8-bit addresses, which can be more quickly stored and manipulated by an 8- bit CPU. Nevertheless, 16-bit data memory addresses can also be generated through the DPTR register. Program memory can only be read. There can be up to 64K bytes of directly addressable program memory. The read strobe for external program memory is the Program Store Enable signal (PSEN). Data memory occupies a separate address space from program memory. Up to 64K bytes of external memory can be directly addressed in the external data memory space. The CPU generates read and write signals, RD and WR, during external data memory accesses. External program memory and external data memory can be combined by applying the RD and PSEN signals to the input of an AND gate and using the output of the gate as the read strobe to the external program/data memory.

PROGRAM MEMORY After reset, the CPU begins execution from location 0000H. each interrupt is assigned a fixed location in program memory. The interrupt causes the CPU to jump to that location, where it executes the service routine. External Interrupt 0, for example, is assigned to location 0003H. If External Interrupt 0 is used, its service routine must begin at location 0003H. If the interrupt is not used, its service location is available as general purpose program memory. The interrupt service locations are spaced at 8-byte intervals:

0003H for External Interrupt 0, 000BH for Timer 0, 0013H for External Interrupt 1, 001BH for Timer 1,and so on. If an interrupt service routine is short enough (as is often the case in control applications), it can reside entirely within that 8-byte interval. Longer service routines can use a jump instruction to skip over subsequent interrupt locations, if other interrupts are in use. The lowest addresses of program memory can be either in the on-chip Flash or in an external memory. To make this selection, strap the External Access (EA) pin to either VCC or GND. For example, in the AT89C51 with 4K bytes of on-chip Flash, if the EA pin is strapped to VCC, program fetches to addresses 0000H through 0FFFH are directed to the internal Flash. Program fetches to addresses 1000H through FFFFH are directed to external memory. In the AT89C52 (8K bytes Flash), EA = VCC selects addresses 0000H through 1FFFH to be internal and addresses 2000H through FFFFH to be external. If the EA pin is strapped to GND, all program fetches are directed to external memory. The read strobe to external memory, PSEN, is used for all external program fetches. Internal program fetches do not activate PSEN. The hardware configuration for external program execution. Note that 16 I/O lines (Ports 0 and 2) are dedicated to bus functions during external program memory fetches. Port 0 serves as a multiplexed address/data bus. It emits the low byte of the Program Counter (PCL) as an address and then goes into a float state while waiting for the arrival of the code byte from the program memory. During the time that the low byte of the Program Counter is valid on P0, the signal ALE (Address Latch Enable) clocks this byte into an address latch. Meanwhile, Port 2 emits the high byte of the Program Counter (PCH). Then PSEN strobes the external memory, and the microcontroller reads the code byte. Program memory addresses are always 16 bits wide, even though the actual amount of program memory used may be less than 64K bytes. External program execution sacrifices two of the 8-bit ports, P0 and P2, to the function of addressing the program memory.

DATA MEMORY The right half of the internal and external data memory spaces available on Atmels Flash Microcontrollers. Hardware configuration for accessing up to 2K bytes of external RAM. In this case, the CPU executes from internal Flash. Port 0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2 are used to page the RAM. The CPU generates RD and WR signals as needed during external RAM accesses. You can assign up to 64K bytes of external data memory. External data memory addresses can be either 1 or 2 bytes wide. One-byte addresses are often used in conjunction with one or more other I/O lines to page the RAM. Two-byte addresses can also be used, in which case the high address byte is emitted at Port 2. Internal data memory addresses are always 1 byte wide, which implies an address space of only 256 bytes. However, the addressing modes for internal RAM can in fact accommodate 384 bytes. Direct addresses higher than 7FH access one memory space and indirect addresses higher than 7FH access a different memory space. Thus, the Upper 128 and SFR space occupying the same block of addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7. Two bits in the Program Status Word (PSW) select which register bank is in use. This architecture allows more efficient use of code space, since register instructions are shorter than instructions that use direct addressing.

PROGRAM STATUS WORD The Program Status Word (PSW) contains status bits that reflect the current state of the CPU. The PSW, shown in Figure 11, resides in SFR space. The PSW contains the Carry bit, the Auxiliary Carry (for BCD operations), the two register bank select bits, the Overflow flag, a Parity bit, and two user-definable status flags. The Carry bit, in addition to serving as a Carry bit in arithmetic operations, also serves as the Accumulator for a number of Boolean operations. The bits RS0 and RS1 select one of the four register banks shown in Figure 8. A number of instructions refer to these RAM locations as R0 through R7. The status of the RS0 and RS1 bits at execution time determines which of the four banks is selected. The Parity bit reflects the number of 1s in the Accumulator: P=1 if the Accumulator contains an odd number of 1s, and P=0 if the Accumulator contains an even number of 1s. Thus, the number of 1s in the Accumulator plus P is always even. Two bits in the PSW are uncommitted and can be used as general purpose status flags. CENTRAL PROCESSING UNIT Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

~ 30 ~

Figure:

Simplified central processing unit with three registers

Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another. BUS That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires. There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

Figure:

Showing connection between memory and central unit using buses

As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component. INPUT-OUTPUT UNIT Those locations we've just added are called "ports". There are several types of ports: input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

Figure:

Simplified input-output unit communicating with external world

When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller. SERIAL COMMUNICATION Beside stated above we've added to the already existing unit the possibility of communication with an outside world. However, this way of communicating has its drawbacks. One of the basic drawbacks is the number of lines which need to be used in order to transfer data. What if it is being transferred to a distance of several kilometers? The number of lines times number of kilometers doesn't promise the economy of the project. It leaves us having to reduce the number of lines in such a way that we don't lessen its functionality. Suppose we are working with three lines only, and that one line is used for sending data, other for receiving, and the third one is used as a reference line for both the input and the output side. In order for this to work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is therefore defined in advance so there wouldn't be any misunderstanding between the sides that are communicating with each other. For example, if one man is speaking in French, and the other in English, it is highly unlikely that they will quickly and effectively understand

each other. Let's suppose we have the following protocol. The logical unit "1" is set up on the transmitting line until transfer begins. Once the transfer starts, we lower the transmission line to logical "0" for a period of time (which we will designate as T), so the receiving side will know that it is receiving data, and so it will activate its mechanism for reception. Let's go back now to the transmission side and start putting logic zeros and ones onto the transmitter line in the order from a bit of the lowest value to a bit of the highest value. Let each bit stay on line for a time period which is equal to T, and in the end, or after the 8th bit, let us bring the logical unit "1" back on the line which will mark the end of the transmission of one data. The protocol we've just described is called in professional literature NRZ (Non-Return to Zero).

Figure:

Serial unit sending data through three lines only

As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time. So called full-duplex mode block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol. TIMER UNIT Since in the serial communication we can receive, send and process data. However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer block which is significant to us because it can give us information about time, duration, protocol etc.

Figure:

Timer unit generating signals in regular time intervals

The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1 and T2 and on the basis of their difference we can determine how much time has elapsed. This is a very important part of the microcontroller whose understanding requires most of our time. ANALOG TO DIGITAL CONVERTER As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an ADC. This block is responsible for converting an information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it.

Figure:

Block for converting an analog input to digital output

Finally, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside.

Figure:

Physical configuration of the interior of a microcontroller

Thin lines which lead from the center towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following page represents the center section of a microcontroller.

Figure:

Microcontroller outline with basic elements and internal connections

For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a program that would be executed, and a few more elements which make up interface logic towards the elements of regulation

MICROCONTROLLER APPLICATION BOARD INTRODUCTION AT-51 has on board ADC section. AC section. RTC & EEPROM section. DISPLAY (LCD, LED, & 7-SEG) section. INPUT SWITCHES section. RELAY section. BUZZER section RS-232 (FOR SERIAL INTERFACE) section.

CENTRAL PROCESSOR Micro controller: - P89C51RD2 Crystal frequency: - 11.0592MHz Internal Memory: - 64K MEMORY 4K memory which can be upgradeable to 516k is provided in EEPROM section. PERIPHERALS Part No. ADC0809CCN DAC0808LCN DS1307 24C04 LCD BUZZER RELAY Specifications 8-BIT 8-CHANNEL, 100s. 8-BIT, 150ns. 64X8, SERIAL I2C Real Time Clock. 4K serial EEPROM. 16 x 2 character LCD 5V 5A/250V AC

POWER SUPPLY REQUIREMENTS

Voltage +/- 5 V +/- 12V

Current 1A 1A

CONFIGURATION AND INSTALLATION MAB-51 is a versatile kit with no manufacture restrictions i.e. there is no predefined settings, which are required to obey. STEP WISE INSTALLATION PROCEDURE 1. Connect the power supply lead to JP7 of power supply section. (Supply should be switched off here). 2. Connect serial cable with one end at the COM 1 or COM 2 port of COMPUTER and other end to the kit. 3. Install the evaluation version of KEIL provided to you with this kit. 4. Install the FLASH MAGIC provided to you with this kit. HOW TO PROGRAM THE MICRO CONTROLLER ON THE KIT (1) Make the required code using KEIL. (2) Make the HEX file from the code file. (3) Open FLASH MAGIC. a) Browse for the location of file. b) Click START. c) Wait for the message FINISHED d) Press reset button on kit make program to run in stand-alone mode. MAB COMPONENTS P89C51RD2 Features On-chip Flash Program Memory with ISP and In-Application Programming capability Boot ROM contains low-level Flash programming routines for downloading via the UART Can be programmed by the end-user application (IAP) Parallel programming with 87C51 compatible hardware interface to programmer Supports 6-clock/12-clock mode via parallel programmer (default clock mode after Chip Erase is 12- clock) 6-clock/12-clock mode Flash bit erasable and programmable via ISP 6-clock/12-clock mode programmable on-the-fly by SFR bit

~ 39 ~

Peripherals (PCA, timers, UART) may use either 6CLK or 12CLK mode while the CPU is in 6-CLK mode Speed up to 20 MHz with 6-clock cycles per machine cycle (40 MHz equivalent performance); up to 33 MHz with 12 clocks per machine cycle Fully static operation RAM expandable externally to 64 Kbytes Four interrupt priority levels Seven interrupt sources Four 8-bit I/O ports Full-duplex enhanced UART -Framing error detection -Automatic address recognition Power control modes -Clock can be stopped and resumed -Idle mode -Power down mode Programmable clock-out pin Second DPTR register Asynchronous port reset Low EMI (inhibit ALE) Programmable Counter Array (PCA) -PWM -Capture/compare

VARIOUS SECTIONS OF MAB KIT

DAUGHTER CARD

ADC(ANALOG TO DIGITAL CONVERTER) SECTION

SEVEN SEGMENT SECTION

RELAY SECTION

STEPPER MOTOR SECTION

LCD SECTION

LED SECTION

BUZZER&SWITCH SECTION

VARIOUS MAB SECTION ON GENERAL POURPOSE PCB

MCS51 SECTION

SWITCH SECTION

SEVEN SEGMENT SECTION

LED SECTION

RELAY SECTION

MAX232 SECTION

POWRE SUPPLY SECTION

LCD SECTION

HOW TO USE KEILs VISION SOFTWARE

The Keil development tools for the 8051 offer numerous features and advantages that help you quickly and successfully develop embedded applications. They are easy to use and are guaranteed to help you achieve your design goals. Vision2 Integrated Development Environment Vision2 IDE is Windows-based software development platforms that combines a robust editor, project manager, and make facility. Vision2 supports all of the Keil tools for the 8051 including the C compiler, macro assembler, linker/locator, and object-HEX converter. Vision2 helps expedite the development process of your embedded applications by providing the following: _ Full-featured source code editor, _ Device database for configuring the development tool setting, _ Project manager for creating and maintaining your projects, _ Integrated make facility for assembling, compiling, and linking your embedded applications, _ Dialogs for all development tool settings, _ True integrated source-level Debugger with high-speed CPU and peripheral simulator, _ Advanced GDI interface for software debugging in the target hardware and for connection to Monitor-51, _ Links to development tools manuals, device datasheets & users guides. 3 The Vision2 screen provides you with a menu bar for command entry, a tool bar where you can rapidly select command buttons, and windows for source files, dialog boxes, and information displays.

STEPS TO ACCESS VISION: 3 1. Double Click on the icon present on the desktop. 2. The following window will be popped-up

3. click on project and select new project 4. Create a new folder of your project name.

~ 44 ~

5. Select New from File menu. 6. And save file as file_name.c i.e. save file with .c extension.

7. Select device for target as shown in figure below.

8. Configure Device and select clock 11.0592MHZ.

9.Create HEX. File.

~ 46 ~

10. Press right click and select INSERT #include<REGF51.H>.

11. Type the application code and after compiling, saving the code burn it into controller using Flash Mazic.

~ 47 ~

HOW TO USE FLASH-MAGIC

1. Double Click on the icon present on the desktop. 2. The following window will be popped-up Press cancel to continue.

3.

Configuration Click options and then click Advanced options

now set the parameters as shown below

4. After selection of the chip (P89C51RDHxx) , Port (Com1), Osc.Mhz(11.0592) we can see the window as below:

Select the blocks to erase, browse for the hex file to be loaded. Press Start 5. Within 5-6 seconds the message will be displayed FINISHED.

PCB DESIGN STEPS IN OrCad 10.5 ENTRY OF SCHEMATIC DIAGRAM: Schematic diagram provides the functional flow and the graphical representation of an electronic circuit. The entry of schematic diagram is the first step in PCB design using OrCad. A schematic diagram consists of:-

Electrical connections(nets) Junctions Integrated circuits symbols Discrete components symbols like resistors, capacitors etc. Input / output connectors Power and ground symbols Buses No connection symbols Components reference names Text
THE SCHEMATIC PAGE EDITOR The schematic page editor is used to display and edit schematic pages. So that one can parts; wires; buses and draw graphics. The schematic page editor has a tool palette that you can use to draw and place everything you need to create a schematic page. One can print from within the schematic page editor, or from the project window.

~ 50 ~

THE PART EDITOR The part editor is used to create and edit parts. From the view menu of the part editor you can choose either part or package. In part view one can: Create and edit parts and symbols, then store in new or existing libraries. Create and edit power and ground symbols, off-page connector symbols, and title block Use the tool palettes electrical tools to place pins on parts, and its drawing tools to draw parts and symbols. THE SESSION LOG The session log lists the events that have occurred during the current Capture session, includes message resulting from using captures tools. To display context-sensitive help for an error message, put the cursor in the error message line in the session log press F1. The ruler along the top appears in either inches or mill meters, depending on which measurement system is selected in the window panel. Your tab setting are saved and used each time you start capture.

One can search for information in the session log using the find command on the Edit menu. You can also save the contents of the of the session log to a file, which is useful when working with Orcads technical support to solve technical problems. The default filename is SESSION.TXT.

~ 51 ~

THE TOOLBAR Captures toolbar is dock able (that means you can select and drag the toolbar to new location) as well as resizable, and displays tool tips for each tool; by choosing a tool button you can quickly perform a task. If tool button is dimmed, you cant perform that task in the current situation.

Some of the tools operate only on what you have selected, while others give you a choice of either operating on what is selected or expanding the scope to entire project. You can hide the toolbar, then display it again when u need it. For hiding select from the schematic page editors view menu, choose TOOLBAR. THE TOOL PALETTE Capture has two tool palettes: one for the schematic page editor and one for the part editor. Both tool palettes are dock able and resizable. They can also display tool tips that identify each tool. The drawing tools on the two tool palettes are identical, however, each tool palette has different electrical tools after you choose a tool, and you press the right mouse button to display a context- sensitive pop-up menu. The first group of tools on the tool palette is electrical tools, used to place electrical connectivity objects. The second group of tools is Drawing tools, used to create graphical objects without electrical connectivity.

The first group of tools on the part palette is electrical tools, used to place pins and symbols. They have been already explained above within the schematic page editor tools. The second group of tools is drawing tools, used to create graphical objects without objects any electrical connectivity and is described: Pin Tools: Place pins on part Pin Array: Place multiple pins on part SELECTING AND DESELECTING OF OBJECTS Once one selects an object, one can perform operations on it, include moving, copying, cutting, mirroring, rotating, resizing, or editing. One can also select multiple, objects and edit them, or group them in to a single object. Grouping objects maintain relation ship among them while one moves them to another location.

~ 52 ~

INTERFACING & EXPERIMENTS ON MCS51

/*********************************************************************/ /* LED INTERFACING WITH MCS51 */ /********************************************************************/

#include <REG51F.H> void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { while(1) { P2=0x00; delay(50); P2=0xFF; delay(50); } }

/*********************************************************************/ /* LCD INTERFACING WITH MCS51 */ /*********************************************************************/ #include <REG51F.H> unsigned int a[5]={0x38,0x01,0x06,0x85}; unsigned int b[6]={'M','U','K','E','S','H'}; sbit RS= P3^0; sbit E= P3^1; void delay(unsigned int t) { unsigned int p,q; for(p=0;p<t;p++) for(q=0;q<1275;q++); } void CommandRoutine() { RS=0; E=1; E=0; } void DataRoutine() { RS=1; E=1; E=0; } void main (void) { unsigned char i,j; for(i=0;i<=3;++i) { P1=a[i]; CommandRoutine(); delay(50); } for(j=0;j<=5;++j) { P1=b[j]; DataRoutine(); delay(50); } }

/*********************************************************************/ /* SEVEN SEGMENT DISPLAY INTERFACING WITH MCS51 */ /********************************************************************/ #include <REG51F.H> unsigned int a[10]={0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xE7}; unsigned int b[10]={0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xE7}; void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { unsigned int i,j; while(1) { for(i=0;i<=9;++i) { for(j=0;j<=9;++j) { P1=0x01; P2=b[j]; delay(4); P1=0x02; P2=a[i]; delay(4); } } } }

/*********************************************************************/ /* ADC INTERFACING WITH MCS51 */ /********************************************************************/ #include <REG51F.H> unsigned int l[6]={0x38,0x01,0x06,0x0E,0xC0,0x82}; sbit RS=P2^0; sbit E=P2^1; sbit OE=P1^0; sbit SC=P1^1; sbit ALE=P1^2; sbit EOC=P1^3; sbit a=P1^4; sbit b=P1^5; sbit c=P1^6; sbit clk=P1^7; void delay(unsigned int t) { unsigned int a,b; for(a=0;a<t;a++) for(b=0;b<=1275;++b); } void cmd(void) { RS=0; E=1; E=0; } void datwrt(void) { RS=1; E=1; E=0; } void convert(unsigned int value) { unsigned char d1,d2,d3,d4; d1=value/10; d2=value%10; d3=d1%10; d4=d1/10; P0=d4|0x30;; datwrt(); delay(10); P0=d3|0x30;; datwrt(); delay(10); P0=d2|0x30;; datwrt(); delay(10); }

void timer0()interrupt 1 { clk=~clk; } void initialzelcd() { unsigned int p; for(p=0;p<=5;++p) { P0=l[p]; cmd(); delay(10); } } void main(void) { unsigned int m; P3=0xFF; IE=0x82; TMOD=0x02; TH0=0x00; ALE=0; SC=0; OE=0; EOC=1; TR0=1; while(1) { a=1; b=1; c=1; ALE=1; delay(10); SC=1; delay(10); ALE=0; delay(10); SC=0; delay(10); while(EOC==1); while(EOC==0); initialzelcd(); OE=1; delay(10); m= P3; datwrt(); delay(10); convert(m); OE=0; } }

/*********************************************************************/ /* RELAY INTERFACING WITH MCS51 */ /********************************************************************/ #include <REG51F.H> void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { P1=0x00; delay(50); P1=0xFF; delay(50); }

/*********************************************************************/ /*SERIAL COMMUNICATION [B/W PC & MICROCONTROLLER]WITH 8051 */ /*********************************************************************/ #include <REGX51.H> sbit RS=P0^0; sbit E=P0^1; unsigned int m[5]={0x38,0x01,0x06,0x0E,0x80}; void command() { RS=0; E=1; E=0; } void dataroute() { RS=1; E=1; E=0; } void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { unsigned char i; SCON=0x50; TMOD=0x20; TH1=-3; TR1=1; for(i=0;i<=4;++i) { P2=m[i]; command(); delay(10); } while(1) { while(RI==0); P2=SBUF; dataroute(); delay(10); RI=0; } }

/*********************************************************************/ /* STEPPER MOTOR INTERFACING WITH MCS51 */ /********************************************************************/ #include <REG51F.H> void delay(unsigned int t) { int i,j; for(j=0;j<=t;++j) for(i=0;i<=1275;i++); } void main(void) { while(1) { P0=0x10; delay(100); P0=0x30; delay(100); P0=0x20; delay(100); P0=0x60; delay(100); P0=0x40; delay(100); P0=0xC0; delay(100); P0=0x80; delay(100); P0=0x90; delay(100); P0=0x80; delay(100); P0=0xC0; delay(100); P0=0x40; delay(100); P0=0x60; delay(100); P0=0x20; delay(100); P0=0x30; delay(100); } }

/*********************************************************************/ /* DIP SWITCH INTERFACING WITH MCS51 */ /********************************************************************/ #include <REG51F.H> void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { while(1) { unsigned int c; P1=0xFF; c=P1; c=c&0x03; switch(c) { case 0: P2=0x00; delay(50); P2=0xFF; delay(50); break; case 1: P2=0x55; delay(50); P2=0xAA; delay(50); break; case 2: P2=24; delay(50); P2=36; delay(50); P2=66; delay(50); P2=129; delay(50); break; default: break; } } }

/*********************************************************************/ /* BUZZER INTERFACING WITH MCS51 */ /*********************************************************************/ #include <REG51F.H> void delay(unsigned int t) { unsigned int a,b; for(a=0;a<=t;++a) for(b=0;b<=1275;++b); } void main(void) { while(1) { P1=0x00; delay(30); P1=0xFF; delay(30); } }

INDUSTRIAL APPLIANCES CONTROL SYSTEM WITH SERIAL COMMUNICATION INTRODUCTION Industrial Appliances Control System with Serial Communication controls four industrial appliances connected to 23010% AC Volts through PC (IBM Personal Computer), connected with my project through RS232 as a control for appliances. This project is an example of Industrial Automation. Automation (ancient Greek: = self dictated), roboticization or industrial automation or numerical control is the use of control systems such as computers to control industrial machinery and processes, reducing the need for human intervention. In the scope of industrialization, automation is a step beyond mechanization. Whereas mechanization provided human operators with machinery to assist them with the physical requirements of work, automation greatly reduces the need for human sensory and mental requirements as well. Processes and systems can also be automated. Automation plays an increasingly important role in the global economy and in daily experience. Engineers strive to combine automated devices with mathematical and organizational tools to create complex systems for a rapidly expanding range of applications and human activities. Many roles for humans in industrial processes presently lie beyond the scope of automation. Human-level pattern recognition, language recognition, and language production ability are well beyond the capabilities of modern mechanical and computer systems. Tasks requiring subjective assessment or synthesis of complex sensory data, such as scents and sounds, as well as high-level tasks such as strategic planning, currently require human expertise. In many cases, the use of humans is more cost-effective than mechanical approaches even where automation of industrial tasks is possible. Specialized hardened computers, referred to as programmable logic controllers (PLCs), are frequently used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events. This leads to precisely controlled actions that permit a tight control of almost any industrial process. Humanmachine interfaces (HMI) or computer human interfaces (CHI), formerly known as man-machine interfaces, are usually employed to communicate with PLCs and other computers, such as entering and monitoring temperatures or pressures for further automated control or emergency response. Service personnel who monitor and control these interfaces are often referred to as stationary engineers.

Automation has had a notable impact in a wide range of highly visible industries beyond manufacturing. Once-ubiquitous telephone operators have been replaced largely by automated telephone switchboards and answering machines. Medical processes such as primary screening in electrocardiography or radiography and laboratory analysis of human genes, sera, cells, and tissues are carried out at much greater speed and accuracy by automated systems. Automated teller machines have reduced the need for bank visits to obtain cash and carry out transactions. In general, automation has been responsible for the shift in the world economy from agrarian to industrial in the 19th century and from industrial to services in the 20th century

BLOCK DIAGRAM The block diagram of Industrial Appliances Control System is as shown below. It consists of six sections i.e. 1. PC (Personal Computer). 2. MCS51 SECTION. 3. MAX232 SECTION. 4. LCD SECTION. 5. RELAY SECTION. 6. POWER SUPPLY.

Figure: Basic Block Diagram of Industrial Appliances Control System

PC (Personal Computer) In Industrial Appliances Control System PC is used as remote control of devices. Using numeric pad of IBMs QWERTY 108 keys keyboards keys 1,2,3,4 is acting as switch in this project. To interface PC with MCS51, MAX232 is used. The type of communication between PC and MCS51 is serial communication (bit by bit data is sending from Tx to Rx). The platform in computer on which this whole of process is done i.e. HYPER TERMINAL. The HyperTerminal is a program that you can use to connect to other computers, Telnet sites, bulletin board systems (BBSs), online services, and host computers, using either your modem or a null modem cable.

Figure: Function of PC MCS51 SECTION This section is major part of this project. As shown in the schematics microcontroller 8051 is main element of this section.

Figure: MCS51 Section.

A microcontroller is an entire computer manufactured on a single chip. Microcontrollers are usually dedicated devices embedded within an application. The architecture of the 8051 family of microcontrollers is referred to as the MCS-51 architecture, or sometimes simply as MCS-51. The microcontrollers have an 8-bit data bus. They are capable of addressing 64K of program memory and a separate 64K 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: MCS51 Section

MAX232 SECTION When communicating with various micro processors one needs to convert the RS232 levels down to lower levels, typically 3.3 or 5.0 Volts. Here is a cheap and simple way to do that. Serial RS-232 (V.24) communication works with voltages -15V to +15V for high and low. On the other hand, TTL logic operates between 0V and +5V . Modern low power consumption logic operates in the range of 0V and +3.3V or even lower.

Thus the RS-232 signal levels are far too high TTL electronics, and the negative RS232 voltage for high cant be handled at all by computer logic. To receive serial data from an RS-232 interface the voltage has to be reduced. Also the low and high voltage level has to be inverted. This level converter uses a Max232 and five capacitors. The max232 is quite cheap (less than 5 dollars) or if youre lucky you can get a free sample from Maxim. The MAX232 from Maxim was the first IC which in one package contains the necessary drivers and receivers to adapt the RS-232 signal voltage levels to TTL logic. It became popular, because it just needs one voltage (+5V or +3.3V) and generates the necessary RS-232 voltage levels.

SCHEMATICS

The required parts:


1 x female serial port connector 1 x max 232 4 x 1uF capacitor 1 x 10uF capacitor

LCD SECTION LCD stands for Liquid Crystal Display. The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters.

PIN DESCRIPTION Most LCDs with two controllers has 16 Pins. The function of each of the connections is shown in the table below:PIN NO. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 NAME Vss Vdd Vee RS R/W E D0 D1 D2 D3 D4 D5 D6 D7 FUNCTION Ground +ve supply contrast Register select Read/Write Enable Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7

Figure: Pin description of the LCD Pins 1 & 2 are the power supply lines, Vss & Vdd. The Vdd pin should be connected to the positive supply & Vss to the 0V supply or ground. Although the LCD module data sheets specify 5V D.C. supply (at only a few milliamps), supplies of 6V & 4.5V both work well, and even 3V is sufficient for some modules. Consequently, these modules can be effectively and economically powered by batteries. Pin 3 is a control pin, Vee, which is used to alter the contrast of the display. Ideally, these pin should be connected to a variable voltage supply. A preset potentiometer connected between the power supply lines, with its wiper connected to the contrast pin is suitable in many cases, but be aware that some modules may require a negative potential; as low as 7V in some cases. For absolute simplicity, connecting this pin to 0V will often suffice. Pin 4 is register select (RS) line. Three command control inputs. When this line is low, data bytes transferred to the display are treated as commands, and data bytes read from the

display indicate its status. By setting the RS line high, character data can be transferred to and from the module. Pin 5 is (R/W) line. This line is pulled low in order to write commands or character data to the module, or pulled high to read character data or status information from its registers. Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of commands or character data between the module and the data lines. When writing to the display, data is transferred only on the high to low transition of this signal. However, when reading from the display, data will become available shortly after the low to high transition and remain available until the signal falls low again. Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to and from the display, either as a single 8-bit byte or as two 4-bit nibbles. In the latter case, only the upper four data lines (D4 to D7) are used. This $ bit mode is beneficial when using a microcontroller, as fewer I/O lines are required.

SENDING COMMANDS TO LCD To send commands we simply need to select the command register. Everything is same as we have done in the initialization routine. But we will summarize the common steps and put them in a single subroutine. Following are the steps: Move data to LCD port Select command register Select write operation Send enable signal Wait for LCD to process the command COMMANDS AND INSTRUCTION SET There are also instructions command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor. Table below lists the instruction command codes. We also use RS = 0 to check the busy flag bit to see if the LCD is ready to receive information. The busy flag is D7 and can be read when R/W =1 and RS = 0, as follows: if R/W =1, RS =0. When D7 = 1(busy flag = 1), the LCD busy taking care of internal operations and will not accept any new information. When D7 = 0, the LCD is ready to receive new information. Note: It is recommended to check the busy flag before writing any data to the LCD.

Code (hex) Command to LCD Instruction Register 1 Clear display screen 2 Return home 4 Shift cursor to left 5 Shift display right 6 Shift cursor to right 7 Shift display left 8 Display off, Cursor off A Display off, Cursor on C Display on, cursor off E Display on, cursor blinking F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to beginning of 1st line C0 Force cursor to beginning of 2nd line 38 2 lines and 5x7 matrix Figure: Command\ Instruction Set SCHEMATICS

RELAY SECTION A relay is a simple electromechanical switch made up of an electromagnet and a set of contacts. Relays are found hidden in all sorts of devices. In fact, some of the first computers ever built used relays to implement Boolean gates.

RELAY CONSTRUCTION Relays are amazingly simple devices. There are four parts in every relay:

Electromagnet Armature that can be attracted by the electromagnet Spring Set of electrical contacts

The following figure shows these four parts in action:

Figure: Parts of Relay In this figure, you can see that a relay consists of two separate and completely independent circuits. The first is at the bottom and drives the electromagnet. In this circuit, a switch is controlling power to the electromagnet. When the switch is on, the electromagnet is on, and it attracts the armature (blue). The armature is acting as a switch in the second circuit. When the electromagnet is energized, the armature completes the second circuit and the light is on. When the electromagnet is not energized, the spring pulls the armature away and the circuit is not complete. In that case, the light is dark.

Figure: Function of Relay

When you purchase relays, you generally have control over several variables: The voltage and current that is needed to activate the armature The maximum voltage and current that can run through the armature and the armature contacts The number of armatures (generally one or two) The number of contacts for the armature (generally one or two -- the relay shown here has two, one of which is unused) Whether the contact (if only one contact is provided) is normally open (NO) or normally closed (NC)

Figure: Protection from back emf

SCHEMATICS

Figure: Schematics of Relay Section

POWER SUPPLY SECTION Power supply (PSU) is the device that transfers electric power from a source to a load using electronic circuits. A typical application of power supplies is to convert utility's AC input power into regulated DC voltage(s) required for electronic equipment. In this project we need +12V and +5V DC which is regulated by IC7812 (+12V) & IC7805 (+5V) respectively, as shown in figure:

Figure: Power Supply Schematics Depending on the mode of operation of power semiconductors PSU can be linear or switching (SMPS). What is SMPS? SMPS stands for switch mode power supply. In this supply power handling electronic components are continuously switching on and off with high frequency in order to provide the transfer of electric power via energy storage components (inductors and capacitors). By varying duty cycle, frequency or a relative phase of these transitions average value of output voltage or current is controlled. The frequency range of an SMPS is from 20 kHz to several MHz Low pass EMI filter reduces high frequency currents getting from PSU into the AC line to an acceptable level. It is necessary to prevent the PSU from causing interference on the mains wiring. There is a number of standards (such as EN55022 for Information technology equipment) that govern the maximum level of EMI caused by PSU. The filter is followed by the bridge rectifier- the circuit that converts bipolar AC voltage to unipolar pulsating voltage. It uses four diodes in a bridge arrangement to provide the same polarity of output voltage for both polarities of input voltage.

Figure: Power Supply Schematics

PROJECT REQUIREMENTS ICS USED: P89C51RD2XX (MICROCONTROLLER) MAX232 (VOLTAGE TRANSLATER) MCT2E (OPTOCOUPLER) 7805 (5 VOLT REGULATOR) 7812 (12 VOLT REGULATOR) 1 1 4 1 1

ACTIVE COMPONENTS: BC547 (TRANSISTOR) CRYSTAL 11.0592MHZ LED LCD 16X2 4 1 8 1

PASSIVE COMPONENTS: R1 1K R2 10K R5 560 R6 4.7K R7 10K POT C1 .1F C2 33PF C3 10F TRANSFORMER 12-0-12 RELAYS 12VOLTS MICROSWITCHE POWER SUPPLY: 5VOLTS 12VOLTS 3VOLTS 6 8 8 8 1 4 2 4 1 4 1

RF COMMUNICATION BASED HOME AUTOMATION INTRODUTION Can I switch on or off my electrical gadgets like microwave oven, washing machine, dish washer, lights and all other appliances though a remote? How many times have questions like these passed through the human mind and one has wished that technology would provide us a quick solution as it has done in almost all walks of life. Technology has indeed provided us an answer with the advent of Home Appliances Control System. This technology allows controlling many home appliances through a remote with a RF link. A vital ingredient in enhancing the quality of life, home networking has come a long way in making these smart devices and smart homes a part and parcel of our lives. A user will be able to switch on or off the appliances remotely through remote. Example the monitors, refrigerator or microwave oven. The Project Long Range Remote Control can be used to remotely control a number of Electrical or Electronic Gadgets connected to it. Unlike Infra Red remote control, this Project employs AM transmission and Reception, and hence it can be used for comparatively longer range. Any gadget can be switched on/off by keying the number allocated to it. The Receiver is made up of the famous 8 bit Microcontroller from Atmel. The Microcontroller is used as the Master in the receiver end which is used to control all the devices. It decodes the Signal from the transmitter and controls the relays according to the signal. For transmission we are using frequency modulation at the frequency of 433.92 MHzs. Radio-frequency (RF) communication is based on electromagnetic waves. One of the most important challenges in RF communications devices is antenna size. To optimize transmission and reception, an antenna should be at least /4, where is the wavelength of the carrier frequency. Assuming a sensor node radio with a quarter of wavelength to be 1 mm, the RF carrier frequency would have to be 75 GHz, which is slightly out of the range of modern low power RF electronics. It is also necessary to reduce energy consumption with modulation, filtering, Demodulation etc. RF communication advantages are its ease of use, integrality, and well established in the commercial market place, which make it an ideal testing platform for sensor node. Several aspects affect the power consumption of a radio, including the type of modulation, scheme used, data rate, transmit power. Also the most important advantage of radio transmission over cable transmission is that it does not require any physical medium. Radio systems are quick to install and because no digging of cable into the ground is required, the investment costs are much lower.

BLOCK DIAGRAM The block diagram consists of consists of tow main functional blocks Transmitter and Receiver.

Figure: Block Diagram Of Rf Based Home Automation Using Mcs51 TRANSMITTER The block diagram of transmitter section is as shown in the figure shown below:

Figure: Block Diagram of Transmitter Section It consists of four sections: i) ii) iii) iv) POWER SUPPLY 5VOLTS. CONTROL SWITCHES. ENCODER HT12-E. RF ANTENNA(A434).

TRANSMITTER REMOTE

Figure: Transmitter Schematics

POWER SUPPLY SECTION Transmitter section requires 5volts-12volts to do all work. For this 9volt battery connected with IC7805 regulator that will provide constant 5volts to transmitter section. CONTROL SWITCHES Through Control switches we can switch on or off appliances as we desire. There are four switches sw1, sw2, and sw3, sw4, with these four switches we can switch on or off appliances in sixteen combinations. ENCODER HT12-E HT12-E is used as parallel to serial converter IC. It receives parallel data from the control switches and encodes it with the local address set through DIP switches and converts these bits into serial data to be RF transmitter antenna circuit. The 212 encoders are a series of CMOS LSIs for remote control system applications. They are capable of encoding information which consists of N address bits and 12_N data bits. Each address/data input can be set to one of the two logic states. The programmed addresses/data are transmitted together with the header bits via an RF or an infrared transmission medium upon receipt of a trigger signal. The capability to select a TE trigger on the HT12E or a DATA trigger on the HT12A further enhances the application flexibility of the 212 series of encoders. The HT12A additionally provides a 38 kHz carrier for infrared systems.

Figure: Block Diagram Of Ht12-E FEATURES Operating voltage 2.4V~12V for the HT12E Low power and high noise immunity CMOS technology Low standby current: 0.1_A (typ.) at VDD=5V HT12A with a 38kHz carrier for infrared transmission medium Minimum transmission word Four words for the HT12E Built-in oscillator needs only 5% resistor Data code has positive polarity Minimal external components Pair with Holtek_s 212 series of decoders 18-pin DIP, 20-pin SOP package

ELECTRICAL CHARACTERISTICS

PIN DIAGRAM

Figure: Pin Diagram of Ht12-E

PIN DISCRIPTION:

Figure: Pin Description of Ht12-E IC

ADDRESS/DATA PROGRAMMING (PRESET) The status of each address/data pin can be individually pre-set to logic _high_ or _low_. If a transmission-enable signal is applied, the encoder scans and transmits the status of the 12 bits of address/data serially in the order A0 to AD11 for the HT12E encoder and A0 to D11 for the HT12A encoder. During information transmission these bits are transmitted with a preceding synchronization bit. If the trigger signal is not applied, the chip enters the standby mode and consumes a reduced current of less than 1_A for a supply voltage of 5V. Usual applications preset the address pins with individual security codes using DIP switches or PCB wiring, while the data is selected by push buttons or electronic switches. APPROXIMATE CIRCUIT

Figure: approximate practical circuit.

AM/ASK TRANSMITTER CIRCUIT The AM/ASK transmitter circuit facilitate design remote control application in shortest way. Low power consumption and wide operating voltage makes the circuit ideal for battery operated low power application and it is small enough to fit in almost any cabinet.

Figure: Ask Transmitter Circuit(A434)

FEATURES 5V -12V Single supply operation. OOK/ASK Data Format. Up to 9.6kbps data rate +9dbm output power SAW based architecture Vertical/Horizontal mount Low power consumption. Direct Plug and use. No external component required.

PIN CONFIGURATION *Pin1 GND *Pin2 DATA IN *Pin3 VCC *Pin4 ANTENNA

RECEIVER The block diagram of receiver section is as shown in the figure(12).

Figure: Block Diagram Of Receiver Section It consists of four sections: i) ii) iii) iv) RF ANTENNA.(A434). DECODER HT12-E.D. OUTPUT SECTION POWER SUPPLY 5VOLTS.

RF RECEIVER ANTENNA (A434) This module facilitates the designers to design their applications in remote in the quickest way. The circuit is designed with SMD components and the module size is small enough to be able fitted in many remote control applications.

Figure: Am/Ask Receiver Circuit(A434)

FEATURES 5V -12V Single supply operation. Wide operating range. Low power consumption. Improved data transmission. No alignment required. Vertical/Horizontal mount Direct Plug and use. No external component required.

PIN CONFIGURATION *Pin1 GND *Pin2 DATA OUT *Pin3 LINEAR OUT *Pin4 VCC5V *Pin5 VCC5V *Pin6 GND *Pin7 GND *Pin8 ANTINNA

NOTE: * Use 17-20cm antenna wire *Do not feed more than 5V to the receiver. *Do not mount the receiver in side a metal box. *Place antenna at out side if metal box is used.

DECODER HT12-D The 212 decoders are a series of CMOS LSIs for remote control system applications. For proper operation, a pair of encoder/decoder with the same number of addresses and data format should be chosen. The decoders receive serial addresses and data from a programmed 212 series of encoders that are transmitted by a carrier using an RF or an IR transmission medium. They compare the serial input data three times continuously with their local addresses. If no error or unmatched codes are found, the input data codes are decoded and then transferred to the output pins. The VT pin also goes high to indicate a valid transmission. The 212 series of decoders are capable of decoding informations that consist of N bits of address and 12_N bits of data. Of this series, the HT12D is arranged to provide 8 address bits and 4 data bits, and HT12F is used to decode 12 bits of address information.

Figure: Block Diagram of HT12-D Features: Operating voltage: 2.4V~12V Low power and high noise immunity CMOS technology Low standby current Capable of decoding 12 bits of information Binary address setting Received codes are checked 3 times Address/Data number combination HT12D: 8 address bits and 4 data bits Built-in oscillator needs only 5% resistor Valid transmission indicator Easy interface with an RF or an infrared transmission medium Minimal external components Pair with Holtek_s 212 series of encoders 18-pin DIP, 20-pin SOP package

ELECTRICAL CHARACTERICTICS

PIN DIAGRAM

Figure: Pin Diagram Of Ht12-D PIN DISCRIPTION

Figure: PIN DISCRIPTION OF HT12-D IC

OUTPUT SECTION In the output section four relays ate connected with four sockets in which our devices to be connected. As shown in figure below:

Figure: Relay Section POWER SUPPLY SECTION This project requires +5 volts as well as +12 volt DC, which is getting through regulators IC7805 and IC7812, as shown in figure below:

Figure: Power Supply Section

PROJECT REQUIREMENTS ICS USED: ATMEL89S51 (MICROCONTROLLER) HT12E (ENCODER) HT12D (DECODER) 3021 (OPTOCOUPLER) ACTIVE COMPONENTS: 7805 (5 VOLT REGULATOR) 7812 (12 VOLT REGULATOR) 369P35 (TRANSISTOR) CRYSTAL 11.0592MHZ LED PASSIVE COMPONENTS: R1 1K R2 10K R3 68K R4 56K R5 100 R6 4.7K C1 .1F C2 33PF C3 10F TRANSFORMER 12-0-12 RELAYS 12VOLTS MICROSWITCHES ANTEENA RF MODULE (A434) RX&TX POWER SUPPLY: 5VOLTS 12VOLTS 3VOLTS 1 6 8 1 1 4 1 4 2 4 1 4 4 1 1 4 1 7 1 1 1 4

You might also like