model document

78
  CHAPTER – 1  INTRODUCTION 1.1 Objective: The objective of this project is to control Robot movement and direction for an application as per the instruction given to microcontroller through wireless keypad using RF communication. As well as, it detects the leakage of g as and intimates through alarm. In this project wireless control section consists of keypad, encoder and RF transmitter. The keypad consi sts of sever al buttons represent ing the one operation such as forwa rd, reverse moveme nt and lef t, right dir ect ion. The keypad enter ed signa l is encoded and given to RF transmitter in which the signal is modulated with carrier freuency. After the modulation the encoded signal is transmitted through RF transmitter.  The receiver section consists of RF receiver, !ecoder, "icrocontroller and Robot model. The received signal is demodulated in the RF receiver in which the carrier signal is removed then given to decoder. In the decoder the encoded signal is decoded into original signal as per transmitted from the control section. Then the signal is given to microcontroller. A long with that, our robot is having the capability to detect the gas leakage. 1.2 Embedded System: An embedded system is a special#purpose computer system designed to perform one or a few dedicated functions, sometimes with real#time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general#  purpose computer, such as a personal computer, can do many different tasks depending on  programming. $mbedded systems have become very important today as they control many of the common devices we use.

Upload: aravind-mike

Post on 07-Oct-2015

18 views

Category:

Documents


0 download

DESCRIPTION

model

TRANSCRIPT

CHAPTER 1 INTRODUCTION

1.1 Objective:The objective of this project is to control Robot movement and direction for an application as per the instruction given to microcontroller through wireless keypad using RF communication. As well as, it detects the leakage of gas and intimates through alarm.In this project wireless control section consists of keypad, encoder and RF transmitter. The keypad consists of several buttons representing the one operation such as forward, reverse movement and left, right direction. The keypad entered signal is encoded and given to RF transmitter in which the signal is modulated with carrier frequency. After the modulation the encoded signal is transmitted through RF transmitter. The receiver section consists of RF receiver, Decoder, Microcontroller and Robot model. The received signal is demodulated in the RF receiver in which the carrier signal is removed then given to decoder. In the decoder the encoded signal is decoded into original signal as per transmitted from the control section. Then the signal is given to microcontroller. Along with that, our robot is having the capability to detect the gas leakage.1.2 Embedded System:An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, sometimes with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems have become very important today as they control many of the common devices we use.Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale.Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure.In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected.An embedded system is some combination of computer hardware and software, either fixed in capability or programmable, that is specifically designed for a particular kind of application device. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system. Embedded systems that are programmable are provided with a programming interface, and embedded systems programming is a specialized occupation. Certain operating systems or language platforms are tailored for the embedded market, such as Embedded Java and Windows XP Embedded. However, some low-end consumer products use very inexpensive microprocessors and limited storage, with the application and operating system both part of a single program. The program is written permanently into the system's memory in this case, rather than being loaded into RAM (Random Access Memory), as programs on a personal computer.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. 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.3 Basic Blocks of Embedded System:Now, the details of the various building blocks of the hardware of an embedded system as shown in Fig 1.1 are. Central Processing Unit (CPU) Memory (Read-only Memory and Random Access Memory) Input Devices Output devices Communication interfaces Application-specific circuitryCentral Processing Unit (CPU):The Central Processing Unit (processor, in short) can be any of the following: microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-cost processor. Its main attraction is that on the chip itself, there will be many other components such as memory, serial communication interface, analog-to digital converter etc. So, for small applications, a micro-controller is the best choice as the number of external components required will be very less. On the other hand, microprocessors are more powerful, but you need to use many external components with them. DSP is used mainly for applications in which signal processing is involved such as audio and video processing.

Figure.1.1: Block Diagram of Embedded System Memory: The memory is categorized as Random Access Memory (RAM) and Read Only Memory (ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas ROM retains the contents even if the power is switched off. So, the firmware is stored in the ROM. When power is switched on, the processor reads the ROM; the program is executed. Input devices: Unlike the desktops, the input devices to an embedded system have very limited capability. There will be no keyboard or a mouse, and hence interacting with the embedded system is not an easy task. Many embedded systems will have a small keypad-you press one key to give a specific command. A keypad may be used to input only the digits. Many embedded systems used in process control do not have any input device for user interaction; they take inputs from sensors or transducers and produce electrical signals that are in turn fed to other systems. Output devices: The output devices of the embedded systems also have very limited capability. Some embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of the system modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD) may also be used to display some important parameters.Communication interfaces: The embedded systems may need to, interact with other embedded systems at they may have to transmit data to a desktop. To facilitate this, the embedded systems are provided with one or a few communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB), and IEEE 1394, Ethernet etc. Application-specific circuitry: Sensors, transducers, special processing and control circuitry may be required for an embedded system, depending on its application. This circuitry interacts with the processor to carry out the necessary work. The entire hardware has to be given power supply either through the 230 volts main supply or through a battery. The hardware has to design in such a way that the power consumption is minimized.Security is the condition of being protected against danger or loss. In the general sense, security is a concept similar to safety. The nuance between the two is an added emphasis on being protected from dangers that originate from outside. Individuals or actions that encroach upon the condition of protection are responsible for the breach of security. The word "security" in general usage is synonymous with "safety," but as a technical term "security" means that something not only is secure but that it has been secured. One of the best options for providing good security is by using a technology named EMBEDDED SYSTEMS.1.4 Microcontroller:In the Literature discussing microprocessors, we often see the term Embedded System. Microprocessors and Microcontrollers are widely used in embedded system products. An embedded system product uses a microprocessor (or Microcontroller) to do one task only. A printer is an example of embedded system since the processor inside it performs one task only, namely getting the data and printing it. Contrast this with a Pentium based PC can be used for any number of applications such as word processor, print-server, bank teller terminal, Video game, network server, or Internet terminal. Software for a variety of applications can be loaded and run. Of course the reason a pc can perform myriad tasks is that it has RAM memory and an operating system that loads the application software into RAM memory and lets the CPU run it.In an Embedded system, there is only one application software that is typically burned into ROM. An x86 PC contains or is connectedto various embedded products such as keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each one of these peripherals has a Microcontroller inside it that performs only one task. For example, inside every mouse there is a Microcontroller to perform the task of finding the mouse position and sending it to the PC.Application AreasNearly 99 per cent of the processors manufactured end up in embedded systems. The embedded system market is one of the highest growth areas as these systems are used in very market segment- consumer electronics, office automation, industrial automation, biomedical engineering, wireless communication, data communication, telecommunications, transportation, military and so on.Consumer appliances: At home we use a number of embedded systems which include digital camera, digital diary, DVD player, video recorders etc.Office automation: The office automation products using embedded systems are copying machine, fax machine, key telephone, modem, printer, scanner etcIndustrial automation: Today a lot of industries use embedded systems for process control. In hazardous industrial environment, where human presence has to be avoided, robots are used, which are programmed to do specific jobs. Medical electronics: Almost every medical equipment in the hospital is an embedded system. These equipments include diagnostic aids such as ECG, EEG, blood pressure measuring devices, radiation, colonoscopy, endoscopy etc.Computer networking: Computer networking products such as bridges, routers, Integrated Services Digital Networks (ISDN), Asynchronous Transfer Mode (ATM), X.25 and frame relay switches are embedded systems which implement the necessary data communication protocolsTelecommunications: In the field of telecommunications, the embedded systems can be categorized as subscriber terminals and network equipment. The subscriber terminals such as key telephones, ISDN phones, terminal adapters, web cameras are embedded systems. The network equipment includes multiplexers, multiple access systems, Packet Assemblers Dissemblers (PADs), sate11ite modems etc. Security: Security of persons and information has always been a major issue. We need to protect our homes and offices; and also the information we transmit and store. Developing embedded systems for devices at homes, offices, airports etc. for authentication and verification are embedded systems security applications is one of the most lucrative businesses nowadays.Microprocessors Vs Microcontrollers: Microprocessors are single-chip CPUs used in microcomputers. Microcontrollers and microprocessors are different in 3 main aspects: hardware architecture, applications, and instruction set features. Hardware architecture: A microprocessor is a single chip CPU while a microcontroller is a single IC contains a CPU and much of remaining circuitry of a complete computer (e.g., RAM, ROM, serial interface, parallel interface, timer, interrupt handling circuit). Applications: Microprocessors are commonly used as a CPU in computers while microcontrollers are found in small, minimum component designs performing control oriented activities. Microprocessor instruction sets are processing Intensive. Their instructions operate on nibbles, bytes, words, or even double words. Addressing modes provide access to large arrays of data using pointers and offsets. They have instructions to set and clear individual bits and perform bit operations. They have instructions for input/output operations, event timing, enabling and setting priority levels for interrupts caused by external stimuli. Processing power of a microcontroller is much less than a microprocessor.Difference between 8051 and 8052:The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful microcontroller, sporting a number of additional features which the developer may make use of: 256 bytes of Internal RAM (compared to 128 in the standard 8051). A third 16-bit timer, capable of a number of new operation modes and 16-bit reloads. Additional SFRs to support the functionality offered by the third timer. 8051 Architecture:The generic 8051 architecture supports a Harvard architecture, which contains two separate buses for both program and data. So, it has two distinctive memory spaces of 64K X 8 size for both programmed and data. It is based on an 8 bit central processing unit with an 8 bit Accumulator and another 8 bit B register as main processing blocks. Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit memory locations. Each 8051 device has some amount of data RAM built in the device for internal processing. This area is used for stack operations and temporary storage of data. This bus architecture is supported with on-chip peripheral functions like I/O ports, timers/counters, versatile serial communication port. So it is clear that this 8051 architecture was designed to cater many real time embedded needs. Figure.1.2: Block Diagram of the 8051 microcontroller Now we may be wondering about the non-mentioning of memory space meant for the program storage, the most important part of any embedded controller. Originally this 8051 architecture was introduced with on-chip, one time programmable version of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051) with users program fused inside the device. The memory portion was mapped at the lower end of the Program Memory area. But, after getting devices, customers couldnt change anything in their program code, which was already made available inside during device fabrication.

So, very soon Intel introduced the 8051 devices with re-programmable type of Program Memory using built-in EPROM of size 4K X 8. Like a regular EPROM, this memory can be re-programmed many times. Later on Intel started manufacturing these 8031 devices without any on chip Program Memory.The major Features of 8-bit Micro controller ATMEL 89S52: 8 Bit CPU optimized for control applications Extensive Boolean processing (Single - bit Logic ) Capabilities. On - Chip Flash Program Memory On - Chip Data RAM Bi-directional and Individually Addressable I/O Lines Multiple 16-Bit Timer/Counters Full Duplex UART Multiple Source / Vector / Priority Interrupt Structure On - Chip Oscillator and Clock circuitry. On - Chip EEPROM SPI Serial Bus Interface

1.5 Circuit Diagram:Figure 1.3:S

CHAPTER-2 MICROCONTROLLER AT89C51 The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured using Atmel is high density nonvolatile memory technology and is compatible with the industry standard MCS-51 instruction set and pinout. PIN OUT DIAGRAM OF THE 8051 Figure 2.1:pin diagram of 8051

The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications

2.1 Pin Description2.1.1 VCCIt is a 5v supply voltage.2.1.2 GNDIt is a ground pin.2.1.3 Port 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull-ups are required during program verification.2.1.4 Port 1Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order address bytes during Flash programming and verification.2.1.5 Port 2Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. 2.1.6 Port 3Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C51 as listed below:

Table 2.1: Alternate functions of port3Port 3 also receives some control signals for Flash programming and verification.2.1.7 RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets the device.2.1.8 ALE/PROGAddress Latch Enable 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. 2.1.9 PSENProgram Store Enable is the read strobe to external program memory. When the AT89C51 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.2.1.10 EA/VPPExternal 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, for parts that require 12-volt VPP.2.1.11 XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.2.1.12 XTAL2Output from the inverting oscillator amplifier. It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.2.2. OSCILLATOR AND CLOCK CIRCUITSThe heart of the 8051 is the circuitry that generates the clock pulse by which all internal operations are synchronized. Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator. The crystal frequency is the basic internal clock frequency of the microcontroller. The manufactures make available 8051 designs that can run at specified maximum and minimum frequencies, typically 1 megahertz to 24 megahertz. Minimum frequencies imply that some internal memories are dynamic and must always operate above a minimum frequency or data will be lost. Serial data communication needs often state the frequency of the oscillator because of the requirement that internal counters must divide the basic clock frequency is not divisible without a remainder, and then the resulting communication frequency is not standard. Ceramic resonators may be used as low-cost alternative to crystal resonators. However, decreases in frequency stability data accuracy make the ceramic resonator a poor choice if high-speed serial data communication with the systems, or critical timing, is to be done. The oscillator formed by the crystal, capacitors, and an on-chip inverter microcontroller, called the pulse, P, time. The smallest interval of time to accomplish any simple instruction, or part of a complex instruction, however, is the machine cycle. The machine cycle is itself made up of six states. A state is the basic time interval for discrete operations of the microcontroller such as fetching an opcode byte, decoding an opcode, executing an opcode, or writing a data byte. Two oscillator pulses define each state. Program instructions may require one, two, or four machine cycles to the executed, depending on the type of instruction. Instructions are fetched and executed by the microcontroller automatically, beginning with the instruction located by the microcontroller automatically; beginning with the instruction located at ROM memory address 0000h at the time the microcontroller is first reset. To calculate the time any particular instruction will take to be executed, find the number of cycles, C, The time to execute that instruction is then found by multiplying C by 12 and dividing the product by the crystal frequency: C x 12T inst = -------------------------------------------- ------------------(2.1)Crystal frequency For example, if the crystal frequency is 16 megahertz, then the time to execute an ADD A, R1 one-cycle instructions is .75 microseconds. A 12-megahertz crystal yields the convenient time of 1 microsecond per cycle.Oscillator frequency (f)

P1P2P2P2P1P1P2P2P2P2P1P1P1

State 1State 6State 5State 4State 3State 2

One machine cycle

Address Latch Enable (ALE)8051 Timing

Figure 2.2: Oscillator frequency (f) &ALE pulse per machine cycle There are two ALE pulse per machine cycle. The ALE pulse, which is primarily used as a timing pulse for external memory access, indicates when every instruction byte is fetched. Two bytes of a single instruction may thus be fetched, and executed, in one machine cycle. Single byte instructions are nor executed in a half cycle, however, Single-byte instructions "throw-away" the second byte (which is the first byte of the next instruction.)

2.3 IDLE MODE: The CPU is turned off while the RAM and other on - chip peripherals continue operating. Inn this mode current draw is reduced to about 15 percent of the current drawn when the device is fully active.2.4POWER DOWN MODE: All on-chip activities are suspended while the on chip RAM continues to hold its data. In this mode, the device typically draws less than 15 Micro Amps and can be as low as 0.6 Micro Amps2.5POWER ON RESET: When power is turned on, the circuit holds the RST pin high for an amount of time that depends on the capacitor value and the rate at which it charges.To ensure a valid reset, the RST pin must be held high long enough to allow the oscillator to start up plus two machine cycles. On power up, VCC should rise within approximately 10ms. The oscillator start-up time depends on the oscillator frequency. For a 10 MHz crystal, the start-up time is typically 1ms.With the given circuit, reducing VCC quickly to 0 causes the RST pin voltage to momentarily fall below 0V. How ever, this voltage is internally l limited and will not harm the device.2. 6 CPU REGISTERS The 8051 contain 34 general-purpose, or working, registers. Two of these, registers A and B hold results of many instructions, particularly for arithmetical and logical operations. The other 32 are arranged as part of internal RAM in four banks, Bank0-Bank3, of eight registers each. 2.6.1 PROGRAM COUNTER (PC) The 8051 contain two 16-bit registers: the program counter (PC) and the data pointer (DPTR). Each is used to hold the address of a word in memory. Program instruction bytes are fetched from locations in memory that are addressed by the PC. Program ROM may be on the chip at addresses 000h to FFFh, external to the chip for address that exceed FFFh, or totally external for all address from 0000h to FFFFh. The PC is automatically incremented after every instruction byte is fetched and may also be altered by certain instructions. The PC is the only register that does not have an internal address. The Program Counter (PC) is a 2-byte address that tells the 8051 where the next instruction to execute is found in memory. When the 8051 is initialized PC always starts at 0000h and is incremented each time an instruction is executed. It is important to note that PC isnt always incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by 2 or 3 in these cases. There is no way to directly modify its value. The Program Counter is special in that. That is to say, you cant do something like PC=2430h. On the other hand, if you execute LJMP 2340h youve effectively accomplished the same thing. It is also interesting to note that while you may change the value of PC (by executing a jump instruction, etc.) there is no way to read the value of PC. That is to say, there is no way to ask the 8051 "What address are you about to org 00h2.6.2 DATA POINTER (DPTR) The DPTR register is made up of two 8-bit registers, named DPH and DPL, which are used to furnish memory addresses for internal and external code access and external data access. The DPTR is under the control of program instructions name, DPH and DPL. DPTR does not have a single internal address; DPH and DPL are each assigned an address.The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. DPTR, as the name suggests, is used to point to address something like HL register pair in 8085 microprocessor. It is used by a number of commands that allow the 8051 to access external memory and internal memory. While DPTR is most often used to point to data in external memory, many programmers often take advantage of the fact that its the only true 16-bit register available. It is often used to store 2-byte values that have nothing to do with memory locations. 2.6.3 PROGRAM STATUS WORD (PSW) Flags are 1-bit registers provided to store the results of certain program instructions. Other instructions can test the condition of the flags and make decisions based on the flag states. In order that the flags may be conveniently addressed, they are grouped inside the program status word (PSW) and the power control (PCON) registers. The 8051 have four math flags that respond automatically to the outcomes of math operations and three general-purpose user flags that can be set to 1 or cleared to 0 by the programmer as desired. The math flags include Carry (CY), Auxiliary Carry (AC), Overflow (OV), and Parity (P). User flag is named F0; this general-purpose flags that may be used by the programmer to record some event in the program. Register bank selection may be done by the use of RS0 and RS1 Note that all of the flags can be set and cleared by the programmer at will. The math flags, however, are also affected by math operations. The program status word is shown below. The PSW contains the math flags, user program flag F0, and the register select bits RS0, RS1 that identify which of the four general-purpose register banks is currently in use by the program. Program Status Word (PSW) Register:Fig 2.3: PSW Register FormatPSW register is one of the most important SFRs. It contains several status bits that reflect the current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit and user-definable status flag.P - Parity bit: If a number stored in the accumulator is even then this bit will be automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via serial communication.Bit 1. This bit is intended to be used in the future versions of microcontrollers.OV Overflow: occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0).RS0, RS1 - Register bank select bits. These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM.RS1RS2Space in RAM

00Bank0 00h-07h

01Bank1 08h-0Fh

10Bank2 10h-17h

11Bank3 18h-1Fh

Table.2.2: Register formats of PSWF0 - Flag 0: This is a general-purpose bit available for use.AC - Auxiliary Carry Flag: This is used for BCD operations only.CY - Carry Flag: Is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions.2.6.4 THE STACK AND THE STACK POINTER The stack refers to an area of internal RAM that is used in conjunction with certain opcodes to store and retrieve data quickly. The 8-bit Stack Pointer (SP) register is used by the 8051 to hold an internal RAM addresses that is called the top of the stack. The address held in the SP register is the location in internal RAM where the last byte of data was stored by a stack operation. When data is to be placed on the stack, the SP increments before storing data on the stack so that the stack grows up as data is stored. As data is retrieved from the stack, the byte is read from the stack, and then the SP decrements to point to the next available byte of stored data. The stack is limited in height to the size of the internal RAM. The stack has the potential (if the programmer is not careful to limit its growth) to over write valuable data in the register banks, bit-addressable RAM, and general purpose (scratchpad) RAM areas. The programmer is responsible for making sure the stack does not grow beyond predefined bounds! The stack is normally placed high in internal RAM, by an appropriate choice of the number placed in the SP register, to avoid conflict with the register, bit and scratch-pad internal RAM areas. The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate where the next value to be removed from the stack should be taken from. When you push a value onto the stack, the 8051 first increments the value of SP and then stores the value at the resulting memory location. When you pop a value off the stack, the 8051 returns the value from the memory location indicated by SP, and then decrements the value of SP. That is last in first out method (LIFO) This order of operation is important. When the 8051 is initialized SP will be initialized to 07h. If you immediately push a value onto the stack, the value will be stored in Internal RAM address 08h. This makes sense taking into account what were mentioned two paragraphs above: First the 8051 will increment the value of SP (from 07h to 08h) and then will store the pushed value at that memory address (08h). SP is modified directly by the 8051 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI. It is also used intrinsically whenever an interrupt is triggered. (More on interrupts later).

2.7 THIRTY-TWO INPUT / OUTPUT PINS All four ports in the 8051 are bi-directional each contains a latch, an output driver and input buffer. The output drivers of port0 and 2, and the input buffers of port 0 are used in access to external memory. In this application port 0 is used as a lower byte of the external memory address multiplexed with data bus and port 2 is used as a higher byte of the external memory address when address is sixteen bit wide. Otherwise it can be used as general purpose I/O2.8 INTERNAL MEMORY A functioning computer must have memory for program codes, commonly in ROM, and RAM memory for variable data that can be altered as the program runs. The 8051 has internal RAM and ROM memory for these functions. Additional memory can be added externally using suitable circuits. Unlike Microcontrollers with Von Neumann architectures, which can use a single memory address for either program code or data, but not for both, the 8051 has a Harvard architecture, which uses the same address, in different memories, for code and data. Internal circuitry accesses the correct memory based on the nature of the operation in progress. Harvard architecture uses separate buses to fetch the data and the address2.8.1 INTERNAL ROM The 8051 is organized so that data memory and program code memory can be in two entirely different physical memory entities. Each has the same address range. The structure of the internal RAM will be discussed later. Generally 8051 microcontroller is available with 4Kilo Bytes internal ROM. A corresponding block of internal program code, contained in an internal ROM, occupies code address space 000h to FFFh. The Program Counter is ordinarily used to address program code bytes from address 0000h to FFFFh. Program addresses higher than 0FFFh, which exceed the internal ROM capacity, will cause the 8051 to automatically fetch code bytes from external program memory. Code bytes can also be fetched exclusively from an external memory, address 0000h to FFFFh, by connecting the external access pin (EA pin no 31 on the DIP) to ground. The PC does not care where the code is, the circuit designer decides whether the code is found totally in internal ROM, totally in external ROM, or in a combination of internal and external ROM.Each register bank address areBank 000h-07h Bank 108h-0fh Bank 210h-17h Bank 3 18h-1fh8051 microcontroller has 16-bit address bus and 8 bit data bus, with 16-bit address bus we can address maximum of 64Kilobytes of external memory that is from 0000h to FFFF. 8051 is available with 4kilobytes of internal ROM its derivatives 8751, 8951 are available with EPROM, FLASH ROM respectively with 4kilobytes capacity.2.8.2 INTERNAL RAM OF 128BYTES : As mentioned at the beginning of this chapter, the 8051 includes a certain amount of on-chip memory. On-chip memory is really one of two types: Internal RAM and Special Function Register (SFR) memory. The layout of the 8051's internal RAM is presented. As is illustrated in this map, the 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is switched off this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". By manipulating certain SFRs, a program may choose to use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in addresses 08h through 1Fh. So the registers are part of internal RAM.Figure 2.4: INTERNAL RAM ORGANIZATION

7FR6R71F

R4R50F102FFBank 3Bank 2Bank 1Bank 00807181700

R2R3

R1R0

R6R7

R4R5

R2R3

R0R1

77 707F 78R7R6

67 606F 68R2R4R5

5F 5857 50R3

47 404F 48R1R0

3F 38R6R7

37 302F 28R5

1F 1827 20R3

0F 0817 1030R4R2R1

2007 00R0 Bit Memory also lives and is part of internal RAM. Bit memory actually resides in internal RAM, from addresses 20h through 2Fh. It can be bit addressed from 00h to 7fh (totally 128 bits) The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack.This fact severely limits the 8051s stack since, as illustrated in the memory map, the area reserved for the stack is only 80 bytes and usually it is less since these 80 bytes has to be shared between the stack and user variables.REGISTER BANKS The 8051 use 8 "R" registers, which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7). These registers are generally used to assist in manipulating values and moving data from one memory location to another. For example, to add the value of R4 to the Accumulator, we would execute the following instruction: ADD A, R4 Thus if the Accumulator (A) contained the value 3 and R4 contained the value 3, the Accumulator would contain the value 6 after this instruction was executed. However, as the memory map shows, the "R" Register R4 is really part of Internal RAM. Specifically, R4 is address 04h. Thus the above instruction accomplishes the same thing as the following operation: ADD A, 04h This instruction adds the value found in Internal RAM address 04h to the value of the Accumulator, leaving the result in the Accumulator. Since R4 is really Internal RAM 04h, the above instruction effectively accomplished the same thing. But watch out! As the memory map shows, the 8051 has four distinct register banks. When the 8051 is first booted up, register bank 0 (addresses 00h through 07h) is used by default. However, your program may instruct the 8051 to use one of the alternate register banks; i.e., register banks 1, 2, or 3. In this case, R4 will no longer be the same as Internal RAM address 04h. For example, if your program instructs the 8051 to use register bank 3, "R" register R4 will now be synonymous with Internal RAM address 1Ch. The concept of register banks adds a great level of flexibility to the 8051, especially when dealing with interrupts (we'll talk about interrupts later). However, always remember that the register banks really reside in the first 32 bytes of Internal RAM. Register banks can be selected with the help of RS0, RS1 bits in the program status word (PSW).If you only use the first register bank (i.e. bank 0), you may use Internal RAM locations 08h through 1Fh for your own use. But if you plan to use register banks 1, 2, or 3, be very careful about using addresses below 20h as you may end up overwriting the value of your "R" registers! 2.9 INTERRUPTS An interrupt is a special feature, which allows the 8051 to provide the illusion of "multi-tasking," although in reality the 8051 is only doing one thing at a time. The word "interrupt" can often be substituted with the word "event." An interrupt is triggered whenever a corresponding event occurs. When the event occurs, the 8051 temporarily puts "on hold" the normal execution of the program and executes a special section of code referred to as an interrupt handler. The interrupt handler performs whatever special functions are required to handle the event and then returns control to the 8051 at which point program execution continues as if it had never been interrupted. Five interrupts are provided in the 8051. Three of these are generated automatically by internal operations: Timer flag 0, Timer flag 1, and the serial port interrupt (RI or TI). Two interrupts are triggered by external signals provided by circuitry that is connected to pins INT0 and INT1 (port pins P3.2 and P3.3)After the Interrupt has been handled by the interrupt subroutine, which is placed by the programmer at the interrupt location in program memory, the interrupt program must resume operation at the instruction where the interrupt took place. Program resumption is done by storing the interrupted PC address on the stack in RAM before changing the PC to the interrupt address in ROM. The PC address will be restored from the stack after an RETI instruction is executed at the end of the interrupt subroutine.CHAPTER-3Basic electronic, electrical, Sensing & wireless transmitting and receiving elements3.1 Transformer A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductorsthe transformer's coils. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core and thus a varying magnetic field through the secondary winding. This varying magnetic field induces a varying electromotive force (EMF), or "voltage", in the secondary winding. This effect is called inductive coupling. If a load is connected to the secondary, current will flow in the secondary winding, and electrical energy will be transferred from the primary circuit through the transformer to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the primary voltage (Vp) and is given by the ratio of the number of turns in the secondary (Ns) to the number of turns in the primary (Np) as follows: ----------------------(3.1) (ideal transformer equation)By appropriate selection of the ratio of turns, a transformer thus enables an alternating current (AC) voltage to be "stepped up" by making Ns greater than Np, or "stepped down" by making Ns less than Np.In the vast majority of transformers, the windings are coils wound around a ferromagnetic core, air-core transformers being a notable exception.Transformers range in size from a thumbnail-sized coupling transformer hidden inside a stage microphone to huge units weighing hundreds of tons used to interconnect portions of power grids. All operate on the same basic principles, although the range of designs is wide. While new technologies have eliminated the need for transformers in some electronic circuits, transformers are still found in nearly all electronic devices designed for household ("mains") voltage. Transformers are essential for high-voltage electric power transmission, which makes long-distance transmission economically practical.Basic principles

Figure:3.1 An ideal transformer. The secondary current arises from the action of the secondary EMF on the (not shown) load impedance.The transformer is based on two principles: first, that an electric current can produce a magnetic field (electromagnetism) and second that a changing magnetic field within a coil of wire induces a voltage across the ends of the coil (electromagnetic induction). Changing the current in the primary coil changes the magnetic flux that is developed. The changing magnetic flux induces a voltage in the secondary coil.An ideal transformer is shown in the adjacent figure. Current passing through the primary coil creates a magnetic field. The primary and secondary coils are wrapped around a core of very high magnetic permeability, such as iron, so that most of the magnetic flux passes through both the primary and secondary coils. If a load is connected to the secondary winding, the load current and voltage will be in the directions indicated, given the primary current and voltage in the directions indicated (each will be alternating current in practice). Induction lawThe voltage induced across the secondary coil may be calculated from Faraday's law of induction, which states that:

where Vs is the instantaneous voltage, Ns is the number of turns in the secondary coil and is the magnetic flux through one turn of the coil. If the turns of the coil are oriented perpendicularly to the magnetic field lines, the flux is the product of the magnetic flux density B and the area A through which it cuts. The area is constant, being equal to the cross-sectional area of the transformer core, whereas the magnetic field varies with time according to the excitation of the primary. Since the same magnetic flux passes through both the primary and secondary coils in an ideal transformer,[28] the instantaneous voltage across the primary winding equals

Taking the ratio of the two equations for Vs and Vp gives the basic equation[29] for stepping up or stepping down the voltage

Np/Ns is known as the turns ratio, and is the primary functional characteristic of any transformer. In the case of step-up transformers, this may sometimes be stated as the reciprocal, Ns/Np. Turns ratio is commonly expressed as an irreducible fraction or ratio: for example, a transformer with primary and secondary windings of, respectively, 100 and 150 turns is said to have a turns ratio of 2:3 rather than 0.667 or 100:150.Ideal power equation

Figure 3.2 The ideal transformer as a circuit elementIf the secondary coil is attached to a load that allows current to flow, electrical power is transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly efficient. All the incoming energy is transformed from the primary circuit to the magnetic field and into the secondary circuit. If this condition is met, the input electric power must equal the output power:

giving the ideal transformer equation

Transformers normally have high efficiency, so this formula is a reasonable approximation.If the voltage is increased, then the current is decreased by the same factor. The impedance in one circuit is transformed by the square of the turns ratio.[28] For example, if an impedance Zs is attached across the terminals of the secondary coil, it appears to the primary circuit to have an impedance of (Np/Ns)2Zs. This relationship is reciprocal, so that the impedance Zp of the primary circuit appears to the secondary to be (Ns/Np)2Zp.3.2 RectifiersA rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), which flows in only one direction. The process is known as rectification. Physically, rectifiers take a number of forms, including vacuum tube diodes, mercury-arc valves, solid-state diodes, silicon-controlled rectifiers and other silicon-based semiconductor switches.Rectifier devicesBefore the development of silicon semiconductor rectifiers, vacuum tube diodes and copper(I) oxide or selenium rectifier stacks were used. High power rectifiers, such as are used in high-voltage direct current power transmission, now uniformly employ silicon semiconductor devices of various types. These are thyristors or other controlled switching solid-state switches which effectively function as diodes to pass current in only one direction. Half-wave rectificationIn half wave rectification, either the positive or negative half of the AC wave is passed, while the other half is blocked. Because only one half of the input waveform reaches the output, it is very inefficient if used for power transfer.

Figure3.3 Half-wave rectifierHalf-wave rectification can be achieved with a single diode in a one-phase supply, or with three diodes in a three-phase supply. Half wave rectifiers yield a unidirectional but pulsating direct current.The output DC voltage of a half wave rectifier can be calculated with the following two ideal equations-------------------------------(3.2)------------------------------------(3.3)Full-wave rectificationA full-wave rectifier converts the whole of the input waveform to one of constant polarity (positive or negative) at its output. Full-wave rectification converts both polarities of the input waveform to DC (direct current), and is more efficient. However, in a circuit with a non-center tapped transformer, four diodes are required instead of the one needed for half-wave rectification (see semiconductors and diode). Four diodes arranged this way are called a diode bridge or bridge rectifier.

Figure 3.4 Graetz bridge rectifier: a full-wave rectifier using 4 diodes.3.3 Transistor A transistor is a semiconductor device used to amplify and switch electronic signals and power. It is composed of a semiconductor material with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor's terminals changes the current flowing through another pair of terminals. Because the controlled (output) power can be much more than the controlling (input) power, a transistor can amplify a signal. Today, some transistors are packaged individually, but many more are found embedded in integrated circuits. The transistor is the fundamental building block of modern electronic devices, and is ubiquitous in modern electronic systems. Following its release in the early 1950s the transistor revolutionized the field of electronics, and paved the way for smaller and cheaper radios, calculators, and computers, among other things. Figure 3.5:Basic transister Transistor as a switch Transistors are commonly used as electronic switches, both for high-power applications such as switched-mode power supplies and for low-power applications such as logic gates.In a grounded-emitter transistor circuit, such as the light-switch circuit shown, as the base voltage rises, the base and collector current rise exponentially. The collector voltage drops because of the collector load resistance (in this example, the resistance of the light bulb). If the collector voltage was zero, the collector current would be limited only by the light bulb resistance and the supply voltage. The transistor is then said to be saturated - it will have a very small voltage from collector to emitter. Providing sufficient base drive current is a key problem in the use of bipolar transistors as switches. The transistor provides current gain, allowing a relatively large current in the collector to be switched by a much smaller current into the base terminal. The ratio of these currents varies depending on the type of transistor, and even for a particular type, varies depending on the collector current. In the example light-switch circuit shown, the resistor is chosen to provide enough base current to ensure the transistor will be saturated.In any switching circuit, values of input voltage would be chosen such that the output is either completely off,[21] or completely on. The transistor is acting as a switch, and this type of operation is common in digital circuits where only "on" and "off" values are relevant.Transistor as an amplifier The common-emitter amplifier is designed so that a small change in voltage in (Vin) changes the small current through the base of the transistor; the transistor's current amplification combined with the properties of the circuit mean that small swings in Vin produce large changes in Vout.

Figure 3.6:Amplifier circuit, common-emitter configuration.Various configurations of single transistor amplifier are possible, with some providing current gain, some voltage gain, and some both.From mobile phones to televisions, vast numbers of products include amplifiers for sound reproduction, radio transmission, and signal processing. The first discrete transistor audio amplifiers barely supplied a few hundred milliwatts, but power and audio fidelity gradually increased as better transistors became available and amplifier architecture evolved.Modern transistor audio amplifiers of up to a few hundred watts are common and relatively inexpensive.

3.4 Relay

Figure 3.7: Realay circuit diagramA relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits; the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Figure 3.8: practical relaysRelays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. The animated picture shows a working relay with its coil and switch contacts. You can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them, making the relay DPDT.

The relay's switch connections are usually labeled COM, NC and NO: COM = Common, always connect to this, it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on.

Circuit description: This circuit is designed to control the load. The load may be motor or any other load. The load is turned ON and OFF through relay. The relay ON and OFF is controlled by the pair of switching transistors (BC 547). The relay is connected in the Q2 transistor collector terminal. A Relay is nothing but electromagnetic switching device which consists of three pins. They are Common, Normally close (NC) and Normally open (NO). The relay common pin is connected to supply voltage. The normally open (NO) pin connected to load. When high pulse signal is given to base of the Q1 transistors, the transistor is conducting and shorts the collector and emitter terminal and zero signals is given to base of the Q2 transistor. So the relay is turned OFF state. When low pulse is given to base of transistor Q1 transistor, the transistor is turned OFF. Now 12v is given to base of Q2 transistor so the transistor is conducting and relay is turned ON. Hence the common terminal and NO terminal of relay are shorted. Now load gets the supply voltage through relay.

Voltage Signal from Transistor Q1 Transistor Q2 Relay Microcontroller or PC 1 on off off 0 off on on

3.5 DC Motors The direct current (DC) motor is one of the first machines devised to convert electrical power into mechanical power. Permanent magnet (PM) direct current converts electrical energy into mechanical energy through the interaction of two magnetic fields.

Figure 3.9: Dc motor One field is produced by a permanent magnet assembly; the other field is produced by an electrical current flowing in the motor windings. These two fields result in a torque which tends to rotate the rotor. As the rotor turns, the current in the windings is commutated to produce a continuous torque output. The stationary electromagnetic field of the motor can also be wire-wound like the armature (called a wound-field motor) or can be made up of permanent magnets (called a permanent magnet motor). In either style (wound-field or permanent magnet) the commutator. acts as half of a mechanical switch and rotates with the armature as it turns. The commutator is composed of conductive segments (called bars), usually made of copper, which represent the termination of individual coils of wire distributed around the armature. The second half of the mechanical switch is completed by the brushes. These brushes typically remain stationary with the motor's housing but ride (or brush) on the rotating commutator. As electrical energy is passed through the brushes and consequently through the armature a torsional force is generated as a reaction between the motor's field and the armature causing the motor's armature to turn. As the armature turns, the brushes switch to adjacent bars on the commutator. This switching action transfers the electrical energy to an adjacent winding on the armature which in turn perpetuates the torsional motion of the armature. Permanent magnet (PM) motors are probably the most commonly used DC motors, but there are also some other type of DC motors(types which use coils to make the permanent magnetic field also) .DC motors operate from a direct current power source. Movement of the magnetic field is achieved by switching current between coils within the motor. This action is called "commutation". Very many DC motors (brush-type) have built-in commutation, meaning that as the motor rotates, mechanical brushes automatically commutate coils on the rotor. You can use dc-brush motors in a variety of applications. A simple, permanent-magnet dc motor is an essential element in a variety of products, such as toys, servo mechanisms, valve actuators, robots, and automotive electronics. There are several typical advantages of a PM motor. When compared to AC or wound field DC motors, PM motors are usually physically smaller in overall size and lighter for a given power rating. Furthermore, since the motor's field, created by the permanent magnet, is constant, the relationship between torque and speed is very linear. A PM motor can provide relatively high torque at low speeds and PM field provides some inherent self-braking when power to the motor is shutoff. There are several disadvantages through, those being mostly being high current during a stall condition and during instantaneous reversal. Those can damage some motors or be problematic to control circuitry. Furthermore, some magnet materials can be damaged when subjected to excessive heat and some loose field strength if the motor is disassembled. High-volume everyday items, such as hand drills and kitchen appliances, use a dc servomotor known as a universal motor. Those universal motors are series-wound DC motors, where the stationary and rotating coils are wires in series. Those motors can work well on both AC and DC power. One of the drawbacks/precautions about series-wound DC motors is that if they are unloaded, the only thing limiting their speed is the windage and friction losses. Some can literally tear themselves apart if run unloaded. A brushless motor operates much in the same way as a traditional brush motor. However, as the name implies there are no brushes (and no commutator). The mechanical switching function, implemented by the brush and commutator combination in a brush-type motor, is replaced by electronic switching in a brushless motor. In a typical brushless motor the electromagnetic field, created by permanent magnets, is the rotating member of the motor and is called a rotor. The rotating magnetic field is generated with a number of electromagnets commutatated with electronics switches (typically transistors or FETs) in a right order at right speed. In a brushless motor, the trick becomes to know when to switch the electrical energy in the windings to perpetuate the rotating motion. This is typically accomplished in a brushless-type motor by some feedback means designed to provide an indication of the position of the magnet poles on the rotor relative to the windings. A hall effect device (HED) is a commonly used means for providing this positional feedback. In some applications brushless motors are commutated without sensors or with the use of an encoder for positional feedback. A brushless motor is often used when high reliability, long life and high speeds are required. The bearings in a brushless motor usually become the only parts to wear out. In applications where high speeds are required (usually above 30,000 RPM) a brushless motor is considered a better choice (because as motor speed increases so does the wear of the brushes on traditional motors). A brushless motor's commutation control can easily be separated and integrated into other required electronics, thereby improving the effective power-to-weight and/or power-to-volume ratio. A brushless motor package (motor and commutation controller) will usually cost more than a brush-type, yet the cost can often be made up in other advantages. For example, in applications where sophisticated control of the motor's operation is required. Brushless motors are seen nowadays in very many computer application, they for example rotate normal PC fans,hard disks and disk drives. Sometimes the rotation direction needs to be changed. In normal permanent magnet motors, this rotation is changed by changing the polarity of operating power (for example by switching from negative power supply to positive or by inter-changing the power terminals going to power supply). This direction changing is typically implemented using relay or a circuit called an H bridge. There are some typical characteristics on "brush-type" DC motors. When a DC motor is straight to a battery (with no controller), it draws a large surge current when connected up. The surge is caused because the motor, when it is turning, acts as a generator. The generated voltage is directly proportional to the speed of the motor. The current through the motor is controlled by the difference between the battery voltage and the motor's generated voltage (otherwise called back EMF). When the motor is first connected up to the battery (with no motor speed controller) there is no back EMF. So the current is controlled only by the battery voltage, motor resistance (and inductance) and the battery leads. Without any back emf the motor, before it starts to turn, therefore draws the large surge current. When a motor speed controller is used, it varies the voltage fed to the motor. Initially, at zero speed, the controller will feed no voltage to the motor, so no current flows. As the motor speed controller's output voltage increases, the motor will start to turn. At first the voltage fed to the motor is small, so the current is also small, and as the motor speed controller's voltage rises, so too does the motor's back EMF. The result is that the initial current surge is removed, acceleration is smooth and fully under control.

Motor speed control of DC motor is nothing new. A simplest method to control the rotation speed of a DC motor is to control it's driving voltage. The higher the voltage is, the higher speed the motor tries to reach. In many applications a simple voltage regulation would cause lots of power loss on control circuit, so a pulse width modulation method (PWM)is used in many DC motor controlling applications. In the basic Pulse Width Modulation (PWM) method, the operating power to the motors is turned on and off to modulate the current to the motor. The ratio of "on" time to "off" time is what determines the speed of the motor. When doing PWM controlling, keep in mind that a motor is a low pass device. The reason is that a motor is mainly a large inductor. It is not capable of passing high frequency energy, and hence will not perform well using high frequencies. Reasonably low frequencies are required, and then PWM techniques will work. Lower frequencies are generally better than higher frequencies, but PWM stops being effective at too low a frequency. The idea that a lower frequency PWM works better simply reflects that the "on" cycle needs to be pretty wide before the motor will draw any current (because of motor inductance). A higher PWM frequency will work fine if you hang a large capacitor across the motor or short the motor out on the "off" cycle (e.g. power/brake pwm) The reason for this is that short pulses will not allow much current to flow before being cut off. Then the current that did flow is dissipated as an inductive kick - probably as heat through the fly-back diodes. The capacitor integrates the pulse and provides a longer, but lower, current flow through the motor after the driver is cut off. There is not inductive kick either, since the current flow isn't being cut off. Knowing the low pass roll-off frequency of the motor helps to determine an optimum frequency for operating PWM. Try testing your motor with a square duty cycle using a variable frequency, and then observe the drop in torque as the frequency is increased. This technique can help determine the roll off point as far as power efficiency is concerned.3.6 IC voltage regulatorsVoltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set voltage. The regulators can be selected for operation with load currents from hundreds of milli amperes to tens of amperes, corresponding to power ratings from milli watts to tens of watts. A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated dc output voltage, Vo, from a second terminal, with the third terminal connected to ground.The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated voltages from 5 to 24 volts.

THREE-TERMINAL VOLTAGE REGULATORS:Fig shows the basic connection of a three-terminal voltage regulator IC to a load. The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated output dc voltage, Vo, from a second terminal, with the third terminal connected to ground. For a selected regulator, IC device specifications list a voltage range over which the input voltage can vary to maintain a regulated output voltage over a range of load current. The specifications also list the amount of output voltage change resulting from a change in load current (load regulation) or in input voltage (line regulation).Figure 3.10 Fixed Positive Voltage Regulators:

IN OUT 7805 GND

FromTransformersecondry

GND The series 78 regulators provide fixed regulated voltages from 5 to 24 V. Figure 3.1 shows how one such IC, a 7812, is connected to provide voltage regulation with output from this unit of +12V dc. An unregulated input voltage Vi is filtered by capacitor C1 and connected to the ICs IN terminal. The ICs OUT terminal provides a regulated + 12V which is filtered by capacitor C2 (mostly for any high-frequency noise). The third IC terminal is connected to ground (GND). While the input voltage may vary over some permissible voltage range, and the output load may vary over some acceptable range, the output voltage remains constant within specified voltage variation limits.Table 3.1. Positive Voltage Regulators in 7800 seriesIC PartOutput Voltage (V)Minimum Vi (V)

7805+57.3

7806+68.3

7808 +810.5

7810+1012.5

7812+1214.6

7815+1517.7

7818+1821.0

7824+2427.1

These limitations are spelled out in the manufacturers specification sheets. A table of positive voltage regulated ICs is provided in table 3.1.

3.7 Gas sensor

Figure 3.11 Gas sensor 3.7.1 Gas Sensor: Ideal sensor for use to detect the presence of a dangerous LPG leak in your car or in a service station, storage tank environment. This unit can be easily incorporated into an alarm unit, to sound an alarm or give a visual indication of the LPG concentration. The sensor has excellent sensitivity combined with a quick response time. The sensor can also sense iso-butane, propane, LNG and cigarette smoke. Features: High Sensitivity Detection Range: 100 - 10,000 ppm iso-butane propane Fast Response Time: