Department of Electrical and Electronics

PROJECT REPORT

Nidhi T 1NH12EE030 Pooja Rani 1NH12EE034 Priyanka Agarwal 1NH12EE036

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 1

INTRODUCTION

The main aim of any electric power supply in the world is to provide uninterrupted power supply at all times to all its consumers. Although, in developing countries, the electric power generated to meet the demands of the growing consumers of electricity is insufficient, hence power instability or outage occurs. Power instability and outage in general does not promote development in the public and private sector of the country‘s economy. The investors do not feel secure to come into a country with constant power failure. These limit the development of industries , in addition, there are processes that cannot be interrupted because of their importance for instance, surgery operation in hospitals, transfer of money between banks and lots more. Power instability and outage creates a need for alternative source of power to backup the mains supply. A microcontroller-based automatic power switching or changeover finds a wide application scope wherever the reliability of electrical supply from the utilities is low and it is used in areas wherever continuity of power supply is necessary, for switching to an alternative source from main supply and vice versa.

Figure 1.1 Electric Supply Lines

Unlike a linear power supply, the pass transistor of a switching-mode supply continually switches between low-dissipation, full-on and full-off states, and spends very little time in the high dissipation transitions, which minimizes wasted energy. Ideally, a switched-mode power supply dissipates no power. Voltage regulation is achieved by varying the ratio of on-

DEPT. OF EEE, NHCE Page 1

Modelling of automatic power switching control using ARM Microcontroller to-off time. In contrast, a linear power supply regulates the output voltage by continually dissipating power in the pass transistor. This higher power conversion efficiency is an important advantage of a switched-mode power supply. Switched-mode power supplies may also be substantially smaller and lighter than a linear supply due to the smaller transformer size and weight. Switching regulators are used as replacements for linear regulators when higher efficiency, smaller size or lighter weight are required. They are, however, more complicated; their switching currents can cause electrical noise problems if not carefully suppressed, and simple designs may have a poor power factor.

1.1 Existing system

Mains power can be lost due to downed lines, malfunctions at a substation, inclement to ensure the continuity of power supply, many commercial industrial facilities depend on both utility service and onsite generation (generator set). Because of the growing complexity of electrical systems, it becomes imperative to give attention to power supply reliability and stability. Over the years many approaches have been adopted but current existing system is:

Manually Controlled Changeover

Figure 1.2 Manually Controlled Changeover

DEPT. OF EEE, NHCE Page 2

Modelling of automatic power switching control using ARM Microcontroller

1.1.1 Manually controlled change over system

Manual changeover switch system still remains the oldest changeover switch box used by majority of the electricity consumers. The switching obtainable from the changeover switch is usually manual, that is the user has to move a lever to change from one source to another. This is usually associated with time wasting as well as some health hazards like electric shock and trauma. This is usually accompanied by a loud noise and electrical sparks. Manual changeover switch box separates the source between a generator and public supply. Whenever there is power failure, change-over is done manually by an individual and the same happens when the public power is restored.

1.1.2 Limitations of manual change over system

i. Manual changeover is time wasting whenever there is power failure. ii. It is strenuous to operate because a lot of energy is required. iii. It causes device process or product damage. iv. It has the potential to cause fire outbreak. v. It is usually accompanied by a lot of noise which may sometimes be psychologically destabilizing. vi. Maintenance is more frequent because the changeover action causes tear and wear.

Figure 1.3 Electric shock

DEPT. OF EEE, NHCE Page 3

Modelling of automatic power switching control using ARM Microcontroller

1.2 Proposed system

In view of the limitation of above previous changeover systems, this project proposes and implements a power switching system that drastically reduced the shortcomings, the noise, arching, tear and wear, stress and time wasting associated with manual switch box. Also ARM LPC2148 microcontroller was also incorporated to help improve the speed of automation. The proposed system could efficiently and effectively manage energy consumption. The system can be used to avoid energy waste and saving energy consumption by a maximum of 68% in switching control during typical days[1].The system is controlled by a software program embedded in the microcontroller. Economically, this project is of affordable cost because of the use of integrated circuits (ICs) in place of discrete components. The major aim of this work is to exploit the ubiquitous microcontroller facilities in bringing about automation of the switching (changeover) process. One of the most critical needs of embedded systems is to reduce power consumption, space and time and this is achieved in this work. This system is designed to provide solution to the shortcomings of the already existing manual changeovers by performing power swap from mains power to solar panel generation automatically and vice versa.

Figure 1.4 Automatic Power Supply switch

DEPT. OF EEE, NHCE Page 4

Modelling of automatic power switching control using ARM Microcontroller

The system is controlled by microcontroller used so there is accuracy in switching actions and there would not be over usage of light when not required. Around 65%-70% reduction in power consumption is achieved with this proposed system[2].The basic problem to be addressed here is how to connect two different sources of electrical power simultaneously to a single unit (automatic power changeover switch) that can serve as a link between these power sources and the load. Moreover, preference is given to the power source such that one source supplies the load at a time and when the first (mains) source fails, the link immediately connects the second (solar panel generation) source to the load. Constructing an automatic power switching system with a microcontroller that can toggle automatically will reduce the time and energy spent in changing over the switch box from time to time. This will allow the user to enjoy long term steady and uninterrupted supply of power. It has the following advantages:

It minimizes damages on lives and equipments since it has its own monitoring system and its switching requires no human contact with the switch, thus eliminating human error and stress. It reduces its changeover timing to the minimum due to its fast response to power outage.

1.3 Significance of the work

This work serves the purpose of saving the electrical appliances in a household and offices from power fluctuation-related damages which could be occasioned by overloading of unprotected changeover switches. Such a device protects electrical appliances from possible harmful effects of voltage sag. It provides an average user the comfort of enjoying the use of electrical appliances at home and offices without the interruption of work and switching over between the public power source and alternative power source. Convenience of not having to walk all the way to the alternative power supply source to turn it off or on is also provided.

It can also create entrepreneurship opportunity for our teeming unemployed youths of the country owing to the large number of people that use alternative power supply that seek automatic switching(changeover) from the public power supply to the alternative power supply.

DEPT. OF EEE, NHCE Page 5

Modelling of automatic power switching control using ARM Microcontroller

1.4 Literature Survey

Power supply instability in developing countries creates a need for automation of electrical power generation or alternative sources of power to back up the utility supply. This automation becomes necessary as the rate of power outage becomes predominantly high. Most industries and commercial processes are partly dependent on generators and public power supply which is epileptic especially in tropical African countries where Nigeria forms a part. Therefore, if the processes of power change-over between these two power supplying sources are manual, human error during change-over connections may occur; leading to machine damage, electric shock/electrocution as well as increased down time consequently introducing massive losses. However, if the starting of the generator is automatically done by a relay which switches the battery voltage to ignition coil of the generator while the main power relay switches the load to either public supply or generator, the down time would greatly be reduced thereby maintaining the tempo of production in such industries.

The first light switch employing "quick-break technology" was invented by John Henry Holmes in 1884 in the shield field district of Newcastle upon Tyne. The "quick-break" switch overcame the problem of a switch's contacts developing electric arcing whenever the circuit was opened or closed. In 1875 Henry Woodward patents an bulb. In 1876 invents the Yablochkov , the first practical carbon , for public street in . In 1879 Thomas Edison and Joseph Wilson Swan patent the carbon-thread incandescent lamp.

Invented by Humphry Davy around 1805, the carbon arc was the first practical electric light. They were used commercially beginning in the 1870s for large building and street lighting until they were superseded in the early 20th century by the incandescent light.

In the 1920s the use of electricity for home lighting increased. By the mid-1930selectrical appliances were standard in the homes of the better-off. After the Second World War they became common in all households. Today we may find it inconvenient to walk through a darkened room and reach up to find a pendant light with a turn key. This remained, however, standard fare until the 1920s in many homes.

DEPT. OF EEE, NHCE Page 6

Modelling of automatic power switching control using ARM Microcontroller

The search in the dark was a paradigm for gas or kerosene lighting. Unless the home owner had elaborate electric igniters on gas fixtures, each light was lit by hand. At least before electricity, you had a match to see what you were doing. Electricity‘s built in convenience of remote control was not exploited for years in most homes.

Switches on the wall at an entrance were considered a luxury. Wiring books of the time considered them ―the most expensive option‖ for controlling lights. Early switches surface mounted to the wall. They had a porcelain base and a key-shaped handle that turned with a twist. Many times exposed wiring would run down the wall from the lights to the switch.

Before jumping to such an expensive option as a wall switch, wiring manuals suggested a pendent switch or a pull switch as a step up from the key switch on a pendent light. The pull switch was mounted to the ceiling and to the exposed wiring. It had a long chain or cord that extended to within reach. A pull would turn on an entire circuit of lights. This provided a certain comfort level to the cautious user since all electricity was far away on the ceiling.

Figure 1.5 Different Types of Mechanical Switches

Eventually pendent switches, ceiling switches, and surface mounted twist switches gave way to recessed wall switches protected by electrical boxes like we use today. As people found more uses for electricity, many rooms looked like Maypoles, with wires stretching out from the central light to fans, toasters, and eventually, radio.

DEPT. OF EEE, NHCE Page 7

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 2

PROJECT DESCRIPTION

2.1 Block Diagram

KEB

Figure 2.1 Block Diagram

2.2 Block diagram description

The demand for electricity is increasing everyday and frequent power cuts is causing many problems in various areas. An alternative arrangement for power source is a must. The main objective of this project is to provide uninterrupted power supply to a load by selecting the supply from any source out of mains or solar. A battery is used which gets charged from mains or solar. A voltage divider is used to reduce the high voltage level to low voltage level. An ADC is used to convert analog signal to digital ones. Output of the microcontroller is given to LCD and relay board. This board switches appropriate relay to maintain uninterrupted supply to the load. An inverter is used to convert DC into AC.The output shall be observed using a lamp. The current status, as to which source supplies the load is also displayed on the LCD.Net Metering is a new concept which facilitates the connection of

DEPT. OF EEE, NHCE Page 8

Modelling of automatic power switching control using ARM Microcontroller small, renewable energy generating systems to the power grid. The energy (in units) which is fed back to the grid will be displayed on the LCD.

This project is a model or prototype of a microcontroller-based automatic power switching which finds a wide application scope wherever the reliability of electrical supply from the utilities is low and it is used in areas wherever continuity of power supply is necessary, for switching to an alternative source from main supply and vice versa. The processing unit include microcontroller programming. A battery is used which gets charged from mains or solar. Output of the microcontroller is given to display unit and relay board. This board switches appropriate relay to maintain uninterrupted supply to the load. The output can be obtained on a home appliance such as a lamp. Net Metering is a new concept which tells how much energy (in units) is fed back to the grid. This energy will be displayed on the display unit. An IR sensor is used which detects the motion. Output of IR sensor is given to the microcontroller. A fire sensor is also used to detect and respond to the presence of flame or fire. Output of this sensor is given to microcontroller.

DEPT. OF EEE, NHCE Page 9

Modelling of automatic power switching control using ARM Microcontroller

2.3 Circuit Diagram

Figure 2.2 Circuit Diagram

DEPT. OF EEE, NHCE Page 10

Modelling of automatic power switching control using ARM Microcontroller

2.4 Circuit Diagram Explanation

Initially a step down transformer 1A is used to step down the voltage from 230V to 12V.This AC voltage will be given to a rectifier which will convert the AC into DC. Now this DC voltage will be given to a battery .An inverter circuit is used to convert DC voltage from battery into AC. This AC voltage can be given to the load (home and KEB bulb).Another 500mA step down transformer is used for charging and switching purpose. Relay board is connected to microcontroller and inverter circuit. It is also connected to the loads (home and KEB).LCD, LDR circuit, IR sensor, fire sensor and voltage divider circuit is also connected to the microcontroller. Mains supply is connected to both the transformers. Solar panel is connected to the inverter circuit. Inbuilt ADC of the microcontroller will be connected to voltage divider circuit.

2.5 Connections to ARM Microcontroller

The LPC2148 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with real-time emulation and embedded trace support, that combines the microcontroller with embedded high speed flash memory ranging from 32 KB to 512 KB. A 128-bit wide memory interface and a unique accelerator architecture enable 32-bit code execution at the maximum clock rate. For critical code size applications, the alternative 16 bit thumb mode reduces code by more than 30 % with minimal performance penalty. Due to their tiny size and low power consumption, LPC2148 are ideal for many important applications where miniaturization is a key requirement, such as access control and also the point-of-sale. The output of LDR is connected to Port0, pin0 of microcontroller.IR sensor is connected to Port0, pin1 of the controller. Fire sensor is connected to port0, pin2 of microcontroller. Voltage divider circuit is connected to Port0,pin 3and pin 30.It is also connected to 3.3V in the microcontroller.LCD is connected to Port0,pin 15,16,17 of microcontroller. Pin 15,16,17 represents Rs,Rw,EN function.Port0,pin 18,19,20,21 of microcontroller is connected to data lines(D4,D5,D6,D7) of LCD. In relay board, relay1 is connected to Port1, pin16.Relay2 is connected to Port1, pin17.Relay3 is connected to port1, pin18.

DEPT. OF EEE, NHCE Page 11

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 3

HARDWARE DESCRIPTION

3.1 Introduction

This chapter deals with complete hardware components used in our project. This chapter also describes the design specification of each component along with their working. The components used in the project are as follows:

3.2 Transformer

Transformer is a static device which convert AC electricity from one voltage to another with a little loss of power but the frequency remains the same. It works on the principle of faraday‘s laws of electromagnetic induction and mutual induction between two coils. It can raise or lower the voltage in the circuit, but with a corresponding decrease or increase in current. Most power supplies use a step-down transformer to reduce the dangerously high voltage to a safer low voltage.

Figure 3.1 A Typical Transformer The winding which takes power from the source is known as the primary winding and the winding which gives the desired output voltage is called the secondary winding. There is no electrical connection between the two coils, instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. DEPT. OF EEE, NHCE Page 12

Modelling of automatic power switching control using ARM Microcontroller

The ratio of the number of turns on each coil, called the turn‘s ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply and a small number of turns on its secondary (output) coil to give a low output voltage. TURNS RATIO = (Vp / Vs) = ( Np / Ns ) Where, Vp = primary (input) voltage. Vs = secondary (output) voltage Np = number of turns on primary coil Ns = number of turns on secondary coil Ip = primary (input) current Is = secondary (output) current. In this project, two step down transformers are used. Specification: (I) Type:step down Input voltage:220-230V AC Output voltage:12-0-12V AC Current:1A (II) Type:step down Input voltage:220-230V AC Output voltage:12-0-12V AC Current:500 mA

DEPT. OF EEE, NHCE Page 13

Modelling of automatic power switching control using ARM Microcontroller

3.3 Rectifier

Figure 3.2 Rectifier

A rectifier is an electrical device that converts (AC), which periodically reverses direction, to (DC), which flows in only one direction. This process is known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of vacuum tube diodes, mercury arc valves, semiconductor diodes and other silicon based semiconductor switches. The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. In positive half cycle only two diodes (1 set of parallel diodes) will conduct, in negative half cycle remaining two diodes will conduct and they will conduct only in forward bias only. Rectifiers have many uses, they are found serving as components of power supplies for radio, television and computer equipment. In gas heating systems flame rectification is used to detect presence of a flame. Rectifier efficiency is defined as the ratio of DC output power to the input power from the AC supply. Efficiency is reduced by losses in transformer windings and power dissipation in the rectifier element itself. Efficiency can be improved with the use of smoothing circuits which reduce the ripple. In this project we are using a bride rectifier (W10, 1000V, 1A) which is more efficient than half wave rectifier and much more cost effective than full wave rectifier.

DEPT. OF EEE, NHCE Page 14

Modelling of automatic power switching control using ARM Microcontroller

Figure 3.3 Rectifier wave form

3.4 Relay

Relay is an electromechanical switch used as a protecting device and also as a controlling device for various circuits, equipments, and electrical networks in a power system. The relay which are energized by electrical supply and performs a mechanical action (on or off) to make or break a circuit are called as electromechanical relays. The electromechanical relay can be defined as an electrically operated switch that completes or interrupts a circuit by physical movement of electrical contacts into contact with each other. The flow of current through an electrical conductor causes a magnetic field at right angles to the current flow direction. If this conductor is wrapped to form a coil, then the magnetic field produced gets oriented along the length of the coil. If the current flowing through the conductor increases, then the magnetic field strength also increases in electromechanical relay construction the magnetic field produced in coil is used to exert mechanical force on magnetic objects. This is similar to permanent magnets used to attract magnetic objects, but here the magnetic field can be turned on or off by regulating current flow through the coil. Thus, we can say that the electromechanical relay operation is dependent on the current flowing through the coil. The electromechanical relay consists of various parts such as movable armature, movable contact & stationary contact or fixed contact, spring, electromagnet (coil), the wire wrapped as coil with its terminals represented as ‗C‘ If there is no supply given to the coil

DEPT. OF EEE, NHCE Page 15

Modelling of automatic power switching control using ARM Microcontroller terminals, then the relay remains in the off condition the load connected to relay also remains turned.

Figure 3.4 Relay circuit Figure 3.5 PCB mounted Relay cube

Figure 3.6 Relay Board . Low power devices such as microcontrollers can drive relays to control electrical loads beyond their direct drive capability. Transistors are used as relay drivers. 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 most have double throw (changeover) switch contacts as shown in the diagram.

DEPT. OF EEE, NHCE Page 16

Modelling of automatic power switching control using ARM Microcontroller

Specifications: Current Range: 7A-10A (AC) 10A-12A (DC) Voltage Range: 125V – 250 V (AC) 28V – 120 V (DC)

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. Relays 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. The figure shows a 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.

Figure 3.7 Relay logic control

DEPT. OF EEE, NHCE Page 17

Modelling of automatic power switching control using ARM Microcontroller

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 labelled 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.

Applications of relays

Relays are used to and for:

Control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio amplifiers. Control a high-current circuit with a low-current signal, as in the starter solenoid of an automobile. Detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers.

3.5 Liquid Crystal Display

This is the interfacing example for the Parallel Port. It however doesn't show the use of the Status Port as an input for a 16 Character x 2 Line LCD Module to the Parallel Port. These LCD Modules are very common these days, and are quite simple to work with, as all the logic required running them is on board. A liquid crystal display (LCD) is flat panel display or electronic visual display that uses light modulating properties of liquid crystals. LCDs are used in a wide range of applications including computer monitors, televisions, aircraft cockpit displays etc. They are common in consumer devices such as DVD players, clocks, watches, calculators and telephones, and have replaced cathode ray tube (CRT) displays in most applications. Its low electrical power consumption enables it to be used in battery-powered electronic equipment.

DEPT. OF EEE, NHCE Page 18

Modelling of automatic power switching control using ARM Microcontroller

3.5.1 LCD Background

Frequently, an ARM program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to microcontroller is a LCD display. Some of the most common LCDs connected to the microcontroller are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively. Operating voltage is 5V.

Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the ARM) and communicates directly with the LCD.

Figure 3.8 LCD

3.5.2 44780 LCD Background

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).

DEPT. OF EEE, NHCE Page 19

Modelling of automatic power switching control using ARM Microcontroller

Figure 3.9 LCD circuit

The three control lines are referred to as EN, RS, and RW[4].

The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low .Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

DEPT. OF EEE, NHCE Page 20

Modelling of automatic power switching control using ARM Microcontroller

3.6 Capacitors

Figure 3.10 Capacitors A capacitor is a passive two-terminal electrical component used to store energy in the form of an electrostatic field between its plates. The forms of practical capacitors vary widely, but all contain at least two electrical conductors (plates) separated by a dielectric. The dielectric acts to increase the capacitor‘s charge capacity. Capacitors are widely used as parts of electrical circuits in many common electrical devices. Shunt capacitor banks are used to improve the quality of the electrical supply and the efficient operation of the power system. Shunt capacitor banks are relatively inexpensive and can be easily installed anywhere on the network.

3.7 LED

A light emitting diode (LED) is a two lead semiconductor device that resemble a basic PN-junction diode, except that an LED also emits light. Like transistors and other diodes, LEDs are made out of silicon. What makes an LED give off light are the small amounts of chemical impurities that are added to the silicon, such as gallium, arsenide, indium, and nitride. When current passes through the LED, it emits photons as a byproduct. This effect is called . Normal light bulbs produce light by heating a metal filament until it becomes white hot. LEDs produce photons directly and not via heat, so they are far more

DEPT. OF EEE, NHCE Page 21

Modelling of automatic power switching control using ARM Microcontroller efficient than incandescent bulbs. LED is often small in area (less than 1mm^2) and its operating voltage is 5V.

Figure 3.11 Typical LED Figure 3.12 Circuit Symbol

Early LEDs were often used as indicators on dashboards or electronic equipment. But recent advances have made LEDs bright enough to rival traditional lighting technologies. Modern LEDs can replace incandescent bulbs in almost any application. LEDs have many advantages over incandescent light sources including lower energy consumption, longer life, improved robustness, smaller size and faster switching. LEDs are now used in , traffic signals ,camera flashes and mining operations as cap lamps to provide light for miners.

3.7.1 Types of LED’S LEDs are produced in an array of shapes and sizes. The 5 mm cylindrical package is the most common, estimated at 80% of world production. The color of the plastic lens is often the same as the actual color of light emitted, but not always. For instance, purple plastic is often used for infrared LEDs. There are also LEDs in extremely tiny packages, such as those found on blinkers and on cell phone keypads. The main types of LEDs are miniature, high power devices and custom designs such as alphanumeric or multi-color.

Figure 3.13 Different types of LEDs

DEPT. OF EEE, NHCE Page 22

Modelling of automatic power switching control using ARM Microcontroller

3.7.2 White LED’S Light Emitting Diodes (LED) have recently become available that are white and bright, so bright that they seriously compete with incandescent lamps in lighting applications. They are still pretty expensive as compared to a GOW lamp but draw much less current and project a fairly well focused beam. LEDs are monochromatic (one color) devices. The wavelength of the light emitted and its color depends on the band gap of the semiconductor used to make them. Red, green, yellow and blue LEDs are fairly common. White light contains all colors and cannot be directly created by a single LED. The most common form of "white" LED really isn't white. It is a Gallium Nitride blue LED coated with a phosphor that, when excited by the blue LED light, emits a broad range spectrum that in addition to the blue emission, makes a fairly white light. There are two primary ways of producing high intensity white-light using LED‘S. One is to use individual LED‘S that emit three primary colors—red, green, and blue—and then mix all the colors to form white light. The other is to use a phosphor material to convert monochromatic light from a blue or UV LED to broad- spectrum white light, much in the same way a fluorescent light bulb works.

3.8 Diode 1N4007 Diodes are used to convert AC into DC these are used as half wave rectifier or full wave rectifier. Three points must be kept in mind while using any type of diode: 1. Maximum forward current capacity 2. Maximum reverse voltage capacity 3. Maximum forward voltage capacity

Figure 3.14 Diode 1N4007

DEPT. OF EEE, NHCE Page 23

Modelling of automatic power switching control using ARM Microcontroller

Figure 3.15 Diode Characteristics

The number and voltage capacity of some of the important diodes available in the market are as follows: Diodes of number 1N4001, 1N4002, 1N4003, 1N4004, 1N4005, 1N4006 and 1N4007 have maximum reverse bias voltage capacity of 50V and maximum forward current capacity of 1 Amp. Diode of same capacities can be used in place of one another. Besides this diode of more capacity can be used in place of diode of low capacity but diode of low capacity cannot be used in place of diode of high capacity. For example, in place of 1N4002; 1N4001 or 1N4007 can be used but 1N4001 or 1N4002 cannot be used in place of 1N4007. The diode BY 127 made by company BEL is equivalent to diode 1N4007.

3.8.1 P-N Junction Operation

Now that you are familiar with P and N-type materials, how these materials are joined together to form a diode, and the function of the diode, let us continue our discussion with the operation of the PN junction. But before we can understand how the PN junction works, we must first consider current flow in the materials that make up the junction and what happens initially within the junction when these two materials are joined together.

DEPT. OF EEE, NHCE Page 24

Modelling of automatic power switching control using ARM Microcontroller

3.8.2 Current Flow in the N-Type Material

Conduction in the N-type semiconductor, or crystal, is similar to conduction in a copper wire. That is, with voltage applied across the material, electrons will move through the crystal just as current would flow in a copper wire.The positive potential of the battery will attract the free electrons in the crystal. These electrons will leave the crystal and flow into the positive terminal of the battery. As an electron leaves the crystal, an electron from the negative terminal of the battery will enter the crystal, thus completing the current path. Therefore, the majority current carriers in the N-type material (electrons) are repelled by the negative side of the battery and move through the crystal toward the positive side of the battery.

3.8.3 Current Flow in the P-Type Material Current flow through the P-type material is illustrated. Conduction in the P material is by positive holes, instead of negative electrons. A hole moves from the positive terminal of the P material to the negative terminal. Electrons from the external circuit enter the negative terminal of the material and fill holes in the vicinity of this terminal. At the positive terminal, electrons are removed from the covalent bonds, thus creating new holes. This process continues as the steady stream of holes (hole current) moves toward the negative terminal.

3.9 Diode 1N4148

The 1N4148 is a standard small signal silicon diode used in signal processing. Its name follows the JEDEC nomenclature. The 1N4148 is generally available in a DO-35 glass package and is very useful at high frequencies with a reverse recovery time of no more than 4ns. This permits rectification and detection of radio frequency signals very effectively, as long as their amplitude is above the forward conduction threshold of silicon (around 0.7V) or the diode is biased.

DEPT. OF EEE, NHCE Page 25

Modelling of automatic power switching control using ARM Microcontroller

Figure 3.16 Diode 1N4148

3.9.1 Specifications

VRRM = 100V (Maximum Repetitive Reverse Voltage)

IO = 200mA (Average Rectified Forward Current)

IF = 300mA (DC Forward Current)

IFSM = 1.0 A (Pulse Width = 1 sec), 4.0 A (Pulse Width = 1 usec) (Non-Repetitive Peak Forward Surge Current)

PD = 500 mW (power Dissipation)

TRR < 4ns (reverse recovery time) 3.9.2 Applications

High-speed switching

3.9.3 Features Glass sealed envelope (GSD) High speed. High Reliability

3.9.4 Construction Silicon epitaxial planar

3.10 Resistors A resistor is a passive two-terminal electrical component which implements electrical resistance as a circuit element. Resistors act to reduce current flow and at the same time, act to lower voltage levels within circuits. In electronic circuits resistors are used to limit current flow, to adjust signal levels, bias active elements, terminate transmission lines among other

DEPT. OF EEE, NHCE Page 26

Modelling of automatic power switching control using ARM Microcontroller uses. High power resistors that can dissipate many watts of electrical power as heat may be used as a part of motor controls, in power distribution systems, or as test loads for generators. Fixed resistors have resistances that only change slightly with temperature, time or operating voltage. When a voltage V is applied across the terminals of a resistor, a current I will flow through the resistor in direct proportion to that voltage as given by Ohm‘s law :

Figure 3.17 Resistors Resistors are common elements of electrical networks and electronic circuits.Practical resistors as discrete components can be composed of various compounds and forms. The primary characteristics of resistors are their resistance and the power they can dissipate. Other characteristics include temperature coefficient, noise, and inductance. Resistors can be integrated into hybrid and printed circuits and can also be implemented within integrated circuits. Size and position of leads (or terminals) are relevant to equipment designers. Resistors must be physically large enough not to overheat when dissipating their power.

3.10.1Unit of resistance The ohm (symbol: Ω) is the SI unit of electrical resistance, named after Georg Simon Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and manufactured over a very large range of values, the derived units of milliohm (1 mΩ = 10−3 Ω), kilo ohm (1 kΩ = 103 Ω), and mega ohm (1 MΩ = 106 Ω) are also in common usage.

DEPT. OF EEE, NHCE Page 27

Modelling of automatic power switching control using ARM Microcontroller

The reciprocal of resistance R is called conductance G = 1/R and is measured in Siemens (SI unit), sometimes referred to as a mho.Thus a Siemens is the reciprocal of an ohm S = Ω − 1. But practical resistors are always specified in terms of their resistance (ohms) rather than conductance.

3.11 Potentiometers

Figure 3.18 Potentiometer

A common element in electronic devices is a three-terminal resistor with a continuously adjustable tapping point controlled by rotation of a shaft or knob. These variable resistors are known as potentiometers when all three terminals are present, since they act as a continuously adjustable voltage divider. A common example is a volume controls on audio equipment. Accurate, high-resolution panel-mounted potentiometers (or "pots") have resistance elements typically wire wound, although some include a conductive-plastic resistance coating over the wire to improve resolution. These typically offer ten turns of their shafts to cover their full range. They are usually set with dials that include a simple turns counter and a graduated dial. Potentiometers operated by a mechanism can be used as position transducers. Electronic analog computers used them in quantity for setting coefficients, and delayed-sweep oscilloscopes of recent decades included one on their panels.

DEPT. OF EEE, NHCE Page 28

Modelling of automatic power switching control using ARM Microcontroller

3.12 Voltage Divider Circuit

Figure 3.19 Voltage divider

It is a passive linear circuit that produces an output voltage that is a fraction of its input voltage. Voltage division is the result of distributing the input voltage among the components of the divider. A simple example of a voltage divider is two resistors connected in series, with the input voltage applied across the resistor pair and the output voltage emerging from the connection between them. Resistor voltage dividers are commonly used to create reference voltages, or to reduce the magnitude of a voltage so it can be measured and may also be used as signal attenuators at low frequencies. Voltage dividers are used for adjusting the level of a signal, or bias of active devices in amplifiers, and for measurement of voltages. A Wheatstone bridge and a multimeter both include voltage dividers. Voltage dividers can be used to allow a microcontroller to measure the resistance of a sensor. The microcontroller‘s analog-to-digital converter is connected to the centre tap of the divider so that it can measure tap voltage and compute the sensor resistance.

DEPT. OF EEE, NHCE Page 29

Modelling of automatic power switching control using ARM Microcontroller

3.13 Solar Panel

Figure 3.20 Solar Panel

Solar panel refers to a panel designed to absorb the sun's rays as a source of energy for generating electricity or heating.

A photovoltaic (in short PV) module is a packaged, connected assembly of typically 6×10 solar cells. Solar Photovoltaic panels constitute the solar array of a photovoltaic system that generates and supplies solar electricity in commercial and residential applications. Each module is rated by its DC output power under standard test conditions, and typically ranges from 100 to 365 watts. The efficiency of a module determines the area of a module. A single solar module can produce only a limited amount of power; most installations contain multiple modules. Solar modules use light energy (photons) from the sun to generate electricity through the photovoltaic effect. The majority of modules use wafer-based crystalline silicon cells or thin film cells based on cadmium telluride or silicon. Cells must also be protected from mechanical damage and moisture. Most solar modules are rigid, but semi-flexible ones are available, based on thin-film cells.

Electrical connections are made in series to achieve a desired output voltage and/or in parallel to provide a desired current capability. Bypass diodes may be incorporated or used externally, in case of partial module shading, to maximize the output of module sections still illuminated. Depending on construction, photovoltaic modules can produce electricity from a range of frequencies of light, but usually cannot cover the entire solar range (specifically, ultraviolet, infrared and low or diffused light). Hence, much of the incident sunlight energy is wasted by solar modules, and they can give far higher efficiencies if illuminated with monochromatic light. Solar panel conversion efficiency, typically in the 20 percent range, is reduced by dust, grime, pollen, and other particulates that accumulate on the

DEPT. OF EEE, NHCE Page 30

Modelling of automatic power switching control using ARM Microcontroller solar panel. On average, panels lost a little less than 0.05 percent of their overall efficiency per day. The solar panel which is used in this project has the following specifications:

Rated Maximum Power (Pmax) : 1.3W

Voltage at Pmax (Vmp) : 7.5V

Dimensions : 180*90mm

Solar Cells Array : 1*17 pcs Solar Module Weight : ≈0.2kg Operating Temperature : 5- 40° C

3.14 Battery

Figure 3.21 Battery An electric battery is a device consisting of one or more electro chemical cells with external connections provided to power electrical devices. A discharging battery has a positive terminal or cathode and a negative terminal or anode. The terminal marked negative is the source of electrons which when connected to an external circuit will flow and deliver energy to an external device. When a battery is connected to an external circuit, electrolytes are able to move as ions. It is the movement of those ions within the battery which allows current to flow out of the battery to perform work. Secondary (rechargeable batteries) can be discharged and recharged multiple times. The original composition of the electrodes can be

DEPT. OF EEE, NHCE Page 31

Modelling of automatic power switching control using ARM Microcontroller restored by reverse current. Examples include the lead-acid batteries used in vehicles and lithium-ion batteries used for portable electronics.

Batteries come in many shapes and sizes, from miniature cells used to power hearing aids and wristwatches to battery banks the size of rooms that provide standby power for telephone exchanges and computer data centres. Secondary batteries, also known as rechargeable batteries, must be charged before first use; they are usually assembled with active materials in the discharged state. Rechargeable batteries are charged by applying electric current, which reverses the chemical reactions that occur during discharge/use. Devices to supply the appropriate current are called chargers.

The oldest form of rechargeable battery is the lead acid battery. The lead–acid battery is relatively heavy for the amount of electrical energy it can supply. Its low manufacturing cost and its high surge current levels make it common where its capacity (over approximately 10 Ah) is more important than weight and handling issues. A common application is the modern car battery, which can, in general, deliver a peak current of 450 amperes. A battery's capacity is the amount of electric charge it can deliver at the rated voltage. The more electrode material contained in the cell the greater its capacity. Capacity is measured in units such as amp hour (A·h). The higher the discharge rate, the lower the capacity. Internal energy losses and limitations on the rate that ions pass through the electrolyte cause battery efficiency to vary. Battery life has two meanings for rechargeable batteries. For rechargeable, it can mean :

1) The length of time a device can run on a fully charged battery or

2) The number of charge/discharge cycles possible before the cells fail to operate satisfactorily.

The main benefit of the lead–acid battery is its low cost. Its main drawbacks are large size and weight for a given capacity and voltage. Lead–acid batteries should never be discharged to below 20% of their capacity, because internal resistance will cause heat and damage when they are recharged. The battery used in our project is a rechargeable sealed lead acid battery and its specifications are :

Working voltage : 12V , Battery capacity : 7.2Ah

DEPT. OF EEE, NHCE Page 32

Modelling of automatic power switching control using ARM Microcontroller

3.15 LDR

Figure 3.22 LDR A photoresistor (or light-dependent resistor, LDR) is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in light-sensitive detector circuits and light and dark-activated switching circuits.

A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can have a resistance as high as several mega ohms (MΩ), while in the light, a photoresistor can have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds a certain frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band.The resulting free electrons (and their hole partners) conduct electricity, thereby lowering resistance. The resistance range and sensitivity of a photoresistor can substantially differ among dissimilar devices. Photoresistors are less light- sensitive devices than photodiodes or phototransistors.The two latter components are true semiconductor devices, while a photoresistor is a passive component and does not have a PN-junction. The photoresistivity of any photoresistor may vary widely depending on ambient temperature, making them unsuitable for applications requiring precise measurement of or sensitivity to light. Photoresistors come in many types. Inexpensive cadmium sulphide cells can be found in many consumer items such as camera light meters, clock radios, alarm devices (as the detector for a light beam), , outdoor clocks, solar street lamps and solar road studs etc.

Photoresistors can be placed in streetlights to control when the light is on. Ambient light falling on the photoresistor causes the streetlight to turn off. Thus energy is saved by ensuring the light is only on during hours of darkness.Its operating voltage is 5V.

DEPT. OF EEE, NHCE Page 33

Modelling of automatic power switching control using ARM Microcontroller

3.16 IR Sensor

Figure 3.23 IR sensor A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can have a resistance as high as several mega ohms (MΩ), while in the light, a photoresistor can have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds a certain frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band. The resulting free electrons (and their hole partners) conduct electricity, thereby lowering resistance. Usually in the infrared spectrum, all the objects radiate some form of thermal radiations. These types of radiations are invisible to our eyes, that can be detected by an infrared sensor.The emitter is simply an IR LED (Light Emitting Diode) and the detector is simply an IR photodiode which is sensitive to IR light of the same wavelength as that emitted by the IR LED. When IR light falls on the photodiode, the resistances and these output voltages change in proportion to the magnitude of the IR light received.

This circuit comprises of the following components

LM358 IC 2 IR transmitter and receiver pair Resistors of the range of kilo ohms Variable resistors LED (Light Emitting Diode)

DEPT. OF EEE, NHCE Page 34

Modelling of automatic power switching control using ARM Microcontroller

Figure 3.24 Working of IR sensor

The transmitter section includes an IR sensor, which transmits continuous IR rays to be received by an IR receiver module. An IR output terminal of the receiver varies depending upon its receiving of IR rays, this output can be fed to a comparator circuit. When the IR receiver does not receive a signal, the potential at the inverting input goes higher than that non-inverting input of the comparator .Thus the output of the comparator goes low, but the LED does not glow. When the IR receiver module receives signal to the potential at the inverting input goes low. Thus the output of the comparator (LM 339) goes high and the LED starts glowing. IR sensors are used in radiation thermometers to measure the DEPT. OF EEE, NHCE Page 35

Modelling of automatic power switching control using ARM Microcontroller temperature depend upon the temperature and the material of the object IR sensors are used in gas analyzers which use absorption characteristics of gases in the IR region.IR sensors are used in moisture analyzers which use wavelengths that are absorbed by the moisture in the IR region.Its operating voltage is 5V.

3.17 Fire Sensor

Figure 3.25 Fire sensor A flame detector is a sensor designed to detect and respond to the presence of a flame or fire. Responses to a detected flame depend on the installation, but can include sounding an alarm, deactivating a fuel line (such as a propane or a natural gas line), and activating a fire suppression system. When used in applications such as industrial furnaces, their role is to provide confirmation that the furnace is properly lit; in these cases they take no direct action beyond notifying the operator or control system. A flame detector can often respond faster and more accurately than a smoke or heat detector due to the mechanisms it uses to detect the flame. Operating voltage is 5v. Thus, by using the fire sensor, we can avoid financial loss and also save people from dangerous fire accidents. flame detectors are used in:

Hydrogen stations Gas-fueled cookers Industrial heating and drying systems Domestic heating systems Industrial gas turbines

DEPT. OF EEE, NHCE Page 36

Modelling of automatic power switching control using ARM Microcontroller

3.18 Transistor (BC547)

Figure 3.26 Transistor A BC547 transistor is a negative-positive-negative (NPN) transistor having three terminals that is used for many purposes. Like all other NPN transistors, this type has an emitter terminal, a base or control terminal, and a collector terminal. In a typical configuration, the current flowing from the base to the emitter controls the collector current. A short vertical line, which is the base, can indicate the transistor schematic for an NPN transistor, and the emitter, which is a diagonal line connecting to the base, is an arrowhead pointing away from the base. There are various types of transistors, and the BC547 is a bipolar junction transistor (BJT). The negative (N)-type material inside an NPN transistor has an excess of electrons, while the positive (P)-type material has a lack of electrons, both due to a contamination process called doping. The BC547 transistor comes in one package.

3.19 Resistive Loads

Figure 3.27 A resistive load

Resistive loads are typically used to convert current into forms of energy such as heat. Unlike inductive loads, resistive loads generate no magnetic fields. Common examples include most electrical heaters, and traditional incandescent lighting loads.

DEPT. OF EEE, NHCE Page 37

Modelling of automatic power switching control using ARM Microcontroller

3.19.1 Characteristics of a Resistive Load

Resistive loads consume the electrical energy in a sinusoidal manner. In a resistive load, the current is in phase with the voltage – the current rises immediately to its steady-state value, without first rising to a higher value. Resistive loads can therefore be said to have little in rush current.

3.19.2 Optimal Use of Resistive Loads

Since resistive loads are designed to optimally convert current into energy at specific voltages, resistive loads can benefit from voltage optimization, in order to conserve power and extend the life of electronics.

Voltage optimization provides resistive loads such as light bulbs and large-scale heaters with the optimal operating voltage, and ensures a consistent supply of quality power – in order to prevent the effects of potentially harmful brownouts (a drop in the voltage coming from the electrical power supply) and power surges (―spikes‖ from a power supply, also known as over voltages) that can damage increasingly sensitive equipment.

3.20 Inverter

Figure 3.28 Inverter circuit

DEPT. OF EEE, NHCE Page 38

Modelling of automatic power switching control using ARM Microcontroller

An inverter converts the DC electricity from sources such as batteries or fuel cells to AC electricity. The electricity can be at any required voltage; in particular it can operate AC equipment designed for mains operation, or rectified to produce DC at any desired voltage. CFL inverters are small portable inverters for home and small commercial applications. They offer a constant and effective power supply whenever there is a power cut or failure. CFL inverters have been in use since a long time and are constantly evolving in pace with the advances in technology. Apart from lighting up CFL bulbs, the latest CFL inverters can also light up LED lights. They are aesthetically designed and have multi-functional features. Most of the CFL inverters are transformer based, however, the technology is now shifting towards microcontroller based designs. These inverters are a complete unit working on a single PCB, which is very convenient during servicing. Most of the CFL inverters avoid excessive charging of the battery, thus preventing battery drainage, which in turn enhances battery life.

3.21 Voltage Regulator (LM317)

Figure 3.29 Voltage regulator The LM317 is a popular adjustable linear voltage regulator. a linear regulator is a system used to maintain a steady voltage. The resistance of the regulator varies in accordance with the load resulting in a constant output voltage. The regulating device is made to act like a variable resistor, continuously adjusting a voltage divider network to maintain a constant output voltage, and continually dissipating the difference between the input and regulated voltages as waste heat. Linear regulators inherently waste as much current as they supply. When this current is multiplied by the voltage difference between input and output, a significant amount of heat results. Therefore the use of an LM317 commonly also requires a heat sink. For large voltage differences, the energy lost as heat can ultimately be greater than that provided to the circuit. This is the trade-off for using linear regulators which are a simple way to provide a stable voltage with few additional components.

DEPT. OF EEE, NHCE Page 39

Modelling of automatic power switching control using ARM Microcontroller

The LM317 has three pins: Input, Output, and Adjustment. The device is conceptually an op amp with a relatively high output current capacity.

Figure 3.30 Voltage regulator circuit

3.22 ARM Microcontroller LPC2148

Figure 3.31 ARM Microcontroller LPC2148

The LPC2148 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with real- time emulation and embedded trace support, that combines the microcontroller with embedded high speed flash memory ranging from 32 KB to 512 KB.A 128-bit wide memory interface and a unique accelerator architecture enable 32-bit code execution at the maximum clock

DEPT. OF EEE, NHCE Page 40

Modelling of automatic power switching control using ARM Microcontroller rate. For critical code size applications, the alternative 16-bit Thumb mode reduces code by more than 30 % with minimal performance penalty[3]. Due to their tiny size and low power consumption, LPC2148 are ideal for applications where miniaturization is a key requirement, such as access control and point-of-sale. A blend of serial communications interfaces ranging from a USB 2.0 Full Speed device, multiple UARTs, SPI, SSP to I2Cs, and on-chip SRAM of 8 KB up to 40 KB, make these devices very well suited for communication gateways and protocol converters, soft modems, voice recognition and low end imaging, providing both large buffer size and high processing power. Various 32-bit timers, single or dual 10-bit ADC(s),10-bit DAC, PWM channels and 45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these microcontrollers particularly suitable for industrial control and medical systems.Its operating voltage is 3.3V.

3.22.1 ARM7TDMI-S processor

The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high performance and very low power consumption. The ARM architecture is based on Reduced Instruction Set Computer (RISC) principles and the instruction set and related decode mechanism are much simpler than those of microprogrammed Complex Instruction Set Computers. This simplicity results in a high instruction throughput and impressive real-time interrupt response from a small and cost-effective processor core. Pipeline techniques are employed so that all parts of the processing and memory systems can operate continuously. Typically, while one instruction is being executed, its successor is being decoded, and a third instruction is being fetched from memory. The ARM7TDMI-S processor also employs a unique architectural strategy known as THUMB, which makes it ideally suited to high-volume applications with memory restrictions, or applications where code density is an issue. The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the ARM7TDMI-S processor has two instruction sets: • The standard 32-bit ARM instruction set. • A 16-bit THUMB instruction set. The THUMB set‘s 16-bit instruction length allows it to approach twice the density of standard ARM code while retaining most of the ARM‘s performance advantage over a DEPT. OF EEE, NHCE Page 41

Modelling of automatic power switching control using ARM Microcontroller traditional 16-bit processor using 16-bit registers. This is possible because THUMB code operates on the same 32-bit register set as ARM code. THUMB code is able to provide up to 65% of the code size of ARM, and 160% of the performance of an equivalent ARM processor connected to a 16-bit memory system.

3.22.2 Features

• 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package. • 8 to 40 KB of on-chip static RAM and 32 to 512 KB of on-chip flash program memory, 128 bit wide interface/accelerator enables high speed 60 MHz operation. • In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software. Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms. • Embedded ICE RT and Embedded Trace interfaces offer real-time debugging with the on-chip real monitor software and high speed tracing of instruction execution. • USB 2.0 full speed compliant device controller with 2 kB of endpoint RAM. In addition, the LPC2148 provide 8 KB of on-chip RAM accessible to USB by DMA. • One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of 6/14 analog inputs, with conversion times as low as 2.44 ms per channel. • Single 10-bit D/A converter provides variable analog output. • Two 32-bit timers/external event counters (with four capture and four compare channels each), PWM unit (six outputs) and watchdog. • Low power real-time clock with independent power and dedicated 32 kHz clock input. • Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 kbit/s), SPI and SSP with buffering and variable data length capabilities. • Vectored interrupt controller with configurable priorities and vector addresses. • Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package. • Up to nine edge or level sensitive external interrupt pins available. • 60 MHz maximum CPU clock available from programmable on-chip PLL with settling time of 100 ms. • On-chip integrated oscillator operates with an external crystal in range from 1 MHz to 30 MHz and with an external oscillator up to 50 MHz. • Power saving modes include idle and Power-down.

DEPT. OF EEE, NHCE Page 42

Modelling of automatic power switching control using ARM Microcontroller

• Individual enable/disable of peripheral functions as well as peripheral clock scaling for additional power optimization. • Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out Detect (BOD) or Real-Time Clock (RTC). • Single power supply chip with Power-On Reset (POR) and BOD circuits: • CPU operating voltage range of 3.0 V to 3.6 V (usually 3.3V) with 5 V tolerant I/O pads.

3.22.3Applications

• Industrial control • Medical systems • Access control • Point-of-sale • Communication gateway • Embedded soft modem • General purpose applications

3.22.4 Power control The LPC2148 supports two reduced power modes: Idle mode and Power-down mode. In Idle mode, execution of instructions is suspended until either a Reset or interrupt occurs. Peripheral functions continue operation during Idle mode and may generate interrupts to cause the processor to resume execution. Idle mode eliminates power used by the processor itself, memory systems and related controllers, and internal buses. In Power-down mode, the oscillator is shut down and the chip receives no internal clocks. The processor state and registers, peripheral registers, and internal SRAM values are preserved throughout Power- down mode and the logic levels of chip pins remain static. The Power-down mode can be terminated and normal operation resumed by either .Since all dynamic operation of the chip is suspended, Power-down mode reduces the chip power consumption to nearly zero.

DEPT. OF EEE, NHCE Page 43

Modelling of automatic power switching control using ARM Microcontroller

3.22.5 PIN SUMMARY

Figure 3.32 : Pin description of ARM LPC 2148

RESET pin : Here pin direction is input A low on this pin resets the chip, causing I/O ports and peripherals to take on their default states, and processor to begin execution at address 0x0000 0000. PORT 0(P0.0 to P0.31) : It is a 32 bit I/O port with individual direction controls for each bit. Total of 28 pins of Port 0 can be used as general purpose bi- directional digital I/Os while P0.31 provides digital output functions only. The operation of port 0 pins depends upon the pin function selected via the pin connect block. Pins P0.24,P0.26,P0.27 are not available.

DEPT. OF EEE, NHCE Page 44

Modelling of automatic power switching control using ARM Microcontroller

PORT 1 (P1.0 to P1.31): Port1 is a 32-bit bi-directional I/O port with individual direction controls for each pin. The operation of port 1 pins depends upon the pin function selected via the pin connect block. Pins 0 through 15 of port 1 are not available. Ground (Vss): 0 V reference(pin 6,18,25,42,50). 3.3 V Power Supply: This is the power supply voltage for the core and I/O ports (pin 23,43,51). PIN SEL1: It is pin function select register1 used for read/write purpose. Its address is 0xE002 C004.

GPIO REGISTERS:

IO PIN: GPIO Port Pin value register. The current state of the GPIO configured port pins can always be read from this register, regardless of pin direction. IO SET: GPIO Port Output Set register. This register controls the state of output pins in conjunction with IOCLR register. Writing ones produces highs at the corresponding port pins. Writing zeroes has no effect. IO DIR: GPIO Port Direction control register. This register individually controls the direction of each port pin. IO CLR: GPIO Port Output Clear register. This register controls the state of output pins. Writing ones produces lows at the corresponding port pins and clears the corresponding bits in the IO SET register. Writing zeroes has no effect.

DEPT. OF EEE, NHCE Page 45

Modelling of automatic power switching control using ARM Microcontroller

3.23 Working Principle Initially main supply will be available in the house but person will not be present in the house.When the person is present in the house then the IR sensor will detect the motion of the person and it will switch on home appliance(load).Now when all appliances are functioning properly and the person is present in the house and suddenly some fire incident takes place then the fire sensor will sense the fire and it will automatically switch off all the appliances. Bigger solar panel can produce sufficient energy but from project point of view it is practically not possible to put up that because of their higher cost. As we know that the intensity of the sun is intermittent so we have put up a LDR which will detect the light rays and show that we are getting the energy from solar panel. When the generation of solar panel is more than the person‘s requirements then this extra energy can be sent to grid. When the voltage is above 12V then this extra energy will be sent to grid.LCD will display the no. of units sent to grid. When the voltage is below 12V and the person is present in the house then home appliances will work but extra energy will not be sent to grid. When mains is not available and solar is also not available then supply will switch to generator or inverter mode and if the person is present in the house then IR sensor will detect the motion of person and it will switch on home appliances.

DEPT. OF EEE, NHCE Page 46

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 4

SOFTWARE REQUIREMENTS

4.1 Introduction to Embedded Systems

An Embedded System is a combination of computer hardware and software, and perhaps additional mechanical or other parts, designed to perform a specific function. An embedded system is a microcontroller-based, software driven, reliable, real-time control system, autonomous, or human or network interactive, operating on diverse physical variables and in diverse environments and sold into a competitive and cost conscious market.

An embedded system is not a computer system that is used primarily for processing, not a software system on PC or UNIX, not a traditional business or scientific application. High-end embedded & lower end embedded systems. High-end embedded system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit Controllers used with an minimal operating systems and hardware layout designed for the specific purpose.

4.1.1 System Design Calls

Figure 4.1 Embedded system design calls

DEPT. OF EEE, NHCE Page 47

Modelling of automatic power switching control using ARM Microcontroller

Figure 4.2 Embedded System Design Cycle

4.1.2 Characteristics of Embedded System • An embedded system is any computer system hidden inside a product other than a computer. • They will encounter a number of difficulties when writing embedded system software in addition to those we encounter when we write applications – Throughput – Our system may need to handle a lot of data in a short period of time. – Response–Our system may need to react to events quickly – Testability–Setting up equipment to test embedded software can be difficult – Debugability–Without a screen or a keyboard, finding out what the software is doing wrong (other than not working) is a troublesome problem – Reliability – embedded systems must be able to handle any situation without human intervention – Memory space – Memory is limited on embedded systems, and you must make the software and the data fit into whatever memory exists – Program installation – you will need special tools to get your software into embedded systems – Power consumption – Portable systems must run on battery power, and the software in these systems must conserve power

DEPT. OF EEE, NHCE Page 48

Modelling of automatic power switching control using ARM Microcontroller

– Processor hogs – computing that requires large amounts of CPU time can complicate the response problem – Cost – Reducing the cost of the hardware is a concern in many embedded system projects; software often operates on hardware that is barely adequate for the job. Embedded systems have a microprocessor/ microcontroller and a memory. Some have a serial port or a network connection. They usually do not have keyboards, screens or disk drives.

4.1.3 Applications 1) Military and aerospace embedded software applications 2) Communication Applications 3) Industrial automation and process control software 4) Mastering the complexity of applications. 5) Reduction of product design time. 6) Real time processing of ever increasing amounts of data. 7) Intelligent, autonomous sensors.

4.1.4 Classification Real Time Systems. RTS is one which has to respond to events within a specified deadline. A right answer after the dead line is a wrong answer. RTS Classification Hard Real Time Systems Soft Real Time System Hard Real Time System "Hard" real-time systems have very narrow response time. Example: Nuclear power system, Cardiac pacemaker. Soft Real Time System "Soft" real-time systems have reduced constrains on "lateness" but still must operate very quickly and repeatable.

DEPT. OF EEE, NHCE Page 49

Modelling of automatic power switching control using ARM Microcontroller

4.2 Introduction to Keil Micro Vision (IDE)

Figure 4.3 Keil software window Keil an ARM Company makes C compilers, macro assemblers, real-time kernels, debuggers, simulators, integrated environments, evaluation boards, and emulators for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families. Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development. When starting a new project, simply select the microcontroller you use from the Device Database and the µVision IDE sets all compiler, assembler, linker, and memory options for you. Keil is a cross compiler. So first we have to understand the concept of compilers and cross compilers. After that we shall learn how to work with Keil.

4.2.1 Concept of Compiler Compilers are programs used to convert a High Level Language to object code. Desktop compilers produce an output object code for the underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the HLL like ‗C‘ will compile the code to run on the system for a particular processor like x86 (underlying microprocessor in the computer). For example compilers for DOS platform is different from the Compilers DEPT. OF EEE, NHCE Page 50

Modelling of automatic power switching control using ARM Microcontroller for Unix platform. So if one wants to define a compiler then compiler is a program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instruction. See there is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program at a time while compiler analyses and execute each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Secondly programs produced by compilers run much faster than the same programs executed by an interpreter. However compilers require some time before an executable program emerges. Now as compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language.

4.2.2 Keil C Cross Compiler Keil is a German based software development company. It provides several development tools like • IDE (Integrated Development environment) • Project Manager • Simulator • Debugger • C Cross Compiler, Cross Assembler, Locator/Linker The Keil ARM tool kit includes three main tools, assembler, compiler and linker. An assembler is used to assemble the ARM assembly program. A compiler is used to compile the C source code into an object file. A linker is used to create an absolute object module suitable for our in-circuit emulator.

4.2.3 Building an Application in µVision To build (compile, assemble, and link) an application in µVision, you must: 1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2). 2. Select Project - Rebuild all target files or Build target.µVision compiles, assembles, and links the files in your project.

DEPT. OF EEE, NHCE Page 51

Modelling of automatic power switching control using ARM Microcontroller

4.2.4 Creating Your Own Application in µVision To create a new project in µVision, you must: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device Database™. 4. Create source files to add to the project. 5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add the source files to the project. 6. Select Project - Options and set the tool options. Note when you select the target device from the Device Database™ all special options are set automatically. You typically only need to configure the memory map of your target hardware. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target.

4.2.5 Debugging an Application in µVision To debug an application created using µVision, you must: 1. Select Debug - Start/Stop Debug Session. 2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function. 3. Open the Serial Window using the Serial #1 button on the toolbar. 4. Debug your program using standard options like Step, Go, Break, and so on.

4.2.6 Starting µVision and Creating a Project µVision is a standard Windows application and started by clicking on the program icon. To create a new project file select from the µVision menu Project – New Project. This opens a standard Windows dialog that asks you for the new project file name. We suggest that you use a separate folder for each project. You can simply use the icon Create New Folder in this dialog to get a new empty folder. Then select this folder and enter the file name for the new project, i.e. Project1. µVision creates a new project file with the name

DEPT. OF EEE, NHCE Page 52

Modelling of automatic power switching control using ARM Microcontroller

PROJECT1.UV2 which contains a default target and file group name. You can see these names in the Project.

4.2.7 Window – Files Now use from the menu Project – Select Device for Target and select a CPU for your project. The Select Device dialog box shows the µVision device data base. Just select the microcontroller you use. We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary tool Options for the 80C51RD+ device and simplifies the tool configuration.

4.2.8 Building Projects and Creating a HEX Files Typical, the tool settings under Options – Target are all you need to start a new application. You may translate all source files and line the application with a click on the Build Target toolbar icon. When you build an application with syntax errors, µVision will display errors and warning messages in the Output Window – Build page. A double click on a message line opens the source file on the correct location in a µVision editor window. Once you have successfully generated your application you can start debugging. After you have tested your application, it is required to create an Intel HEX file to download the software into an EPROM programmer or simulator. µVision creates HEX files with each build process when Create HEX files under Options for Target – Output is enabled. You may start your PROM programming utility after the make process when you specify the program under the option Run User Program #1.

4.2.9 CPU Simulation µVision simulates up to 16 MB of memory from which areas can be mapped for read, write, or code execution access. The µVision simulator traps and reports illegal memory accesses. In addition to memory mapping, the simulator also provides support for the integrated peripherals of the various 8051 derivatives. The on-chip peripherals of the CPU you have selected are configured from the Device.

DEPT. OF EEE, NHCE Page 53

Modelling of automatic power switching control using ARM Microcontroller

4.2.10 Start Debugging You start the debug mode of µVision with the Debug – Start/Stop Debug Session Command. Depending on the Options for Target – Debug Configuration, µVision will load the application program and run the startup code µVision saves the editor screen layout and restores the screen layout of the last debug session. If the program execution stops, µVision opens an editor window with the source text or shows CPU instructions in the disassembly window. The next executable statement is marked with a yellow arrow. During debugging, most editor features are still available. For example, you can use the find command or correct program errors. Program source text of your application is shown in the same windows. The µVision debug mode differs from the edit mode in the following aspects: The ―Debug Menu and Debug Commands‖ are available. The additional debug windows are discussed. The project structure or tool parameters cannot be modified. All build commands are disabled.

4.2.11 Disassembly Window The Disassembly window shows your target program as mixed source and assembly program or just assembly code. A trace history of previously executed instructions may be displayed with Debug – View Trace Records. To enable the trace history, set Debug – Enable/Disable Trace Recording. If you select the Disassembly Window as the active window all program step commands work on CPU instruction level rather than program source lines. You can select a text line and set or modify code breakpoints using toolbar buttons or the context menu commands. You may use the dialog Debug – Inline Assembly to modify the CPU instructions. This allows you to correct mistakes or to make temporary changes to the target program you are debugging. Numerous example programs are included to help you get started with the most popular embedded 8051 devices. The Keil µVision Debugger accurately simulates on-chip peripherals (I²C,UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your ARM device. DEPT. OF EEE, NHCE Page 54

Modelling of automatic power switching control using ARM Microcontroller

4.3 SOURCE CODE 1. Click on the Keil Vision Icon on Desktop. 2. The following fig will appear

Figure 4.4 Keil window 3. Click on the Project menu from the title bar. 4. Then Click on New Project.

Figure 4.5 Keil New project

DEPT. OF EEE, NHCE Page 55

Modelling of automatic power switching control using ARM Microcontroller

5. Then give file name and click on save button above. 6. Select the component for your project. i.e. ARM 7. Click on the + Symbol beside of ARM

Figure 4.6 Keil ARM selection

8. Select LPC2148 and click OK.

9. Then copy the standard ARM code to project folder and add file to project. 10. Now double click on the Target1, you would get another option ―Source group 1‖.

Figure 4.7 Keil source group DEPT. OF EEE, NHCE Page 56

Modelling of automatic power switching control using ARM Microcontroller

11. Click on the file option from menu bar and select ―new‖and start writing the program in ―EMBEDDED C‖ or ―ASM‖.

Figure 4.8 Saving file in .ASM / Embedded C 12. Now right click on Source group 1 and click on ―Add files to Group Source‖.

Figure 4.9 Adding files to group 13. Now Press function key F7 to compile. Any error will appear if so happen.

DEPT. OF EEE, NHCE Page 57

Modelling of automatic power switching control using ARM Microcontroller

14. If the file contains no error, then press Control+F5 simultaneously. 15. Now click on the Peripherals from menu bar, and check your required port as shown in fig below.

Figure 4.10 Selecting port 16. Drag the port a side and click in the program file.

Figure 4.11 Selecting port and pin

17. Now keep Pressing function key ―F11‖ slowly and observe. 18. You are running your program successfully.

DEPT. OF EEE, NHCE Page 58

Modelling of automatic power switching control using ARM Microcontroller

4.4 CODING //------HEADER FILES------#include "LPC214x.H" #include "type.h" #include "irq.h" #include "uart.h" #include "target.h" #include "lcd.h" #include "Serial.h" #include "stdlib.h" #include "string.h" #include "adc.h" #include //------UART DECLERATION------extern DWORD UART0Count; extern BYTE UART0Buffer[BUFSIZE]; extern DWORD UART1Count; extern BYTE UART1Buffer[BUFSIZE]; #define UART0_HOST_BAUD 9600 #define UART1_HOST_BAUD 9600 #define default_value 100 #define relay_1 (1 << 16) #define relay_2 (1 << 17) #define relay_3 (1 << 18) #define main_detect (0 << 3) #define day_night (0 << 0) #define ir_sense (0 << 1) #define fir_sense (0 << 2) unsigned int measure_voltage(void); void check_solar(void); void check_mains(void); void solar_mode_fun(void); DEPT. OF EEE, NHCE Page 59

Modelling of automatic power switching control using ARM Microcontroller

void mains_fun(void); void ir_fire_detect (void); unsigned char buf[128],buf1[10]; int status=0; int status2=0; int status3=1; int status4=1; float req_val=12.500;

void putSLcd(unsigned char *st) { for( ;*st ;lcd_putchar(*st++) ); } ////***************************** main code ***********************************************************************// int main (void) { IO1CLR|=relay_1; IO1CLR|=relay_2; IO1CLR|=relay_3; IO1DIR|=(relay_1|relay_2|relay_3); IO0DIR &=~(day_night|ir_sense|fir_sense|main_detect);

init_lcd(); init_adc0(); //IO1SET|=relay_1; lcd_command_write(1); // lcd_putstring(0,0,"GSM INT"); // delay(1000); // intGsm(); lcd_command_write(1); lcd_putstring(0,0,"POWER MANAGEMENT");

DEPT. OF EEE, NHCE Page 60

Modelling of automatic power switching control using ARM Microcontroller

lcd_putstring(1,4,"SYSTEM"); delay(1000); while(1) { lcd_command_write(1); check_solar(); if(status)solar_mode_fun(); else mains_fun(); ir_fire_detect (); } } //*************************************** auto_control_mode sub routine *******************************************// unsigned int measure_voltage(void) { unsigned int adc_value,ax,bx,i; float volts=0.0,temp=0.0; for(i=0;i<10000;i++) { ax=adc_read(ADC0, CHANNEL_3); //ADC0 PIN P0.30 // bx=bx+ax; } adc_value=bx/10000; volts=((adc_value*3.3))/1023; temp=volts*10; if(temp>=req_val) { status3=0; req_val=12.000; } else status3=1; sprintf((char *)buf,"V:%.3fv ",temp);

DEPT. OF EEE, NHCE Page 61

Modelling of automatic power switching control using ARM Microcontroller

lcd_putstring(0,0,buf); // delay(1000);

} //******************************************* check for mains subroutine ***************************************// void check_mains(void) { delay(10000); if(!(IO0PIN&main_detect))status2=1; else status2=0; } //******************************************* check for solar subroutine ***************************************//

void check_solar(void) { lcd_command_write(1); lcd_putstring(0,0,"CHECKING SOLAR...."); delay(10000); if(!(IO0PIN&day_night))status=1; else status=0; } //********************************************** solar mode function************************************************//

void solar_mode_fun(void) { char i=0,j=0; unsigned int UNIT=0; lcd_command_write(1); lcd_putstring(0,0,"SOLAR AVAILABLE");

DEPT. OF EEE, NHCE Page 62

Modelling of automatic power switching control using ARM Microcontroller

lcd_putstring(1,0,"BATTERY CHARGING"); delay(10000); IO1SET|=relay_1;

while(!(IO0PIN&day_night)) { i++; measure_voltage(); if(!status3) { IO1SET|=relay_2; j=1; } else { IO1CLR|=relay_2; j=0; } ir_fire_detect ();

if(j==1) { if(i>200) { UNIT++; i=0; }

}

sprintf(buf1,"UNIT:%d ",UNIT); lcd_putstring(1,0,buf1);

DEPT. OF EEE, NHCE Page 63

Modelling of automatic power switching control using ARM Microcontroller

}

} //************************************************* mains mode function******************************************// void mains_fun(void)

{ IO1CLR|=relay_1; lcd_command_write(1); lcd_putstring(0,0,"NO SOLAR"); lcd_putstring(1,0,"CHECKING MAINS...."); check_mains(); lcd_command_write(1);

if(status2) { lcd_putstring(0,0,"MAINS AVAILABLE"); lcd_putstring(1,0,"SWITCH TO MAINS "); delay(10000);

} else { lcd_command_write(1); lcd_putstring(0,0,"NO MAINS"); lcd_putstring(1,0,"SWITCH TO GEN "); delay(10000); } ir_fire_detect(); }

DEPT. OF EEE, NHCE Page 64

Modelling of automatic power switching control using ARM Microcontroller

void ir_fire_detect (void) { if(IO0PIN&ir_sense) { if(status4) { lcd_putstring(0,0,"IR DETECTED..."); delay(10000); IO1SET|=relay_3; delay(20000); status4=0; } } else { IO1CLR|=relay_3; status4=1; } if(!(IO0PIN&fir_sense)) { lcd_putstring(0,0,"FIRE DETECTED..."); IO1CLR|=relay_3; delay(1000);

} }

DEPT. OF EEE, NHCE Page 65

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 5 NET METERING CONCEPT

Figure 5.1 Net Metering Concept Net metering is the concept which records net energy between export of generated energy and import of Discom energy for a billing month. Alternatively, the meter, having the feature of recording both the import and export values, besides other parameters notified by CEA metering regulations and Discom procedures in vogue, shall also be allowed for arriving net energy for the billing period.

5.1 Solar PV Power Generation

Sunlight is converted to electricity directly when made to fall on solar photovoltaic (SPV) modules. Systems/devices are made for various applications based on SPV modules connected with suitably designed power conditioning units for meeting electricity requirements

5.2 Grid connected roof top solar PV system In recent years solar PV systems became viable and attractive. Utility scale plants are being set up worldwide with promotional mechanisms which are set up on ground surface. Available roof-top area on the buildings can also be used for setting up solar PV power plants, and thus dispensing with the requirement of free land area. The electricity

DEPT. OF EEE, NHCE Page 66

Modelling of automatic power switching control using ARM Microcontroller generated from SPV systems can also be fed to the distribution or transmission grid after conditioning to suit grid integration.

The roof-top solar PV systems

are easy to install and maintain have long life of 25 years are modular in nature, capacity can be enhanced in future to meet increased requirement of electricity.

5.3 How does it work

Based on available roof area solar PV panels will be installed on the roof of the building. The output of the panels (DC electricity) connect to the power conditioning unit / inverter which converts DC to AC. The inverter output will be connected to the control panel or distribution board of the building to utilise the power. The inverter synchronises with grid and also with any backup power source to produce smooth power to power the loads with preference of consuming solar power first. If the solar power is more than the load requirement, the excess power is automatically fed to the grid. For larger capacity systems connection through step up transformer and switch yard may be required to feed the power to grid.

5.4 Operation and Maintenance Requirements There are no moving parts in the system and it requires only minimal attention. Depending upon the dust level, the system requires periodic cleaning.

5.5 Advantages The grid connected roof top solar PV system would fulfill the partial / full power needs of large scale buildings. The following are some of the benefits of roof top SPV systems:

Generation of environmentally clean energy. Consumer becomes generator for his own electricity requirements. Reduction in electricity consumption from the grid. Reduction in diesel consumption wherever DG backup is provided. Feeding excess power to the grid.

DEPT. OF EEE, NHCE Page 67

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 6 ADVANTAGES AND DISADVANTAGES

6.1 Advantages

1)Reduces Electricity Bills : How much you save on your bill will be dependent on the size of the solar system and your electricity or heat usage. Moreover, not only will you be saving on the electricity bill, but if you generate more electricity than you use, the surplus will be exported back to the grid and you will receive bonus payments for that amount (considering that your solar panel system is connected to the grid). Savings can further grow if you sell excess electricity at high rates during the day and then buy electricity from the grid during the evening when the rates are lower. 2)Low maintenance costs :Solar energy systems generally don‘t require a lot of maintenance. You only need to keep them relatively clean, so cleaning them a couple of times per year will do the job. Most reliable solar panel manufacturers give 20-25 years warranty. Also, as there are no moving parts, there is no wear and tear. The inverter is usually the only part that needs to be changed after 5-10 years because it is continuously working to convert solar energy into electricity and heat .So, after covering the initial cost of the solar system, you can expect very little spending on maintenance and repair work.

3)Diverse Applications :Solar energy can be used for diverse purposes. You can generate electricity (photovoltaics) or heat (solar thermal). Solar energy can be used to produce electricity in areas without access to the energy grid, to distill water in regions with limited clean water supplies and to power satellites in space. Solar energy can also be integrated in the materials used for buildings. Not long ago Sharp introduced transparent solar energy windows.

4)Easy Installation :Solar panels are easy to install and does not require any wires, cords or power sources. Unlike wind and geothermal power stations which require them to be tied with drilling machines, solar panels does not require them and can be installed on the rooftops which means no new space is needed and each home or business user can generate their own electricity. Moreover, they can be installed in distributed fashion which means no large scale installations are needed. With the advancement in the technology and increase in

DEPT. OF EEE, NHCE Page 68

Modelling of automatic power switching control using ARM Microcontroller the production, the cost of solar panels have come down slightly. Areas where cost of electricity is high, payback times can be even lower.

5)Long Lasting Solar Cells :Solar cells make no noise at all and there are no moving parts in solar cells which makes them long lasting and require very little maintenance. Solar energy provides cost effective solutions to energy problems where there is no electricity at all.

6)Sometimes people forget to switch of their lights and fans (or any other home appliance) When they go out of the house .As IR sensor detects the motion of the person ,home appliances switch on only when person is present in the house ,thereby saving the electricity. 7) If some fire accident takes place, fire detector will automatically switch off all the home appliance, thereby reducing the damage to the appliance.

8) Solar energy is environmental friendly and free of cost.

6.2 Disadvantages

1) Cost The initial cost for purchasing a solar system is fairly high. Although the UK government has introduced some schemes for encouraging the adoption of renewable energy sources, for example the Feed-in Tariff, you still have to cover the upfront costs. This includes paying for solar panels, inverter, batteries,wiring and for the installation. Nevertheless, solar technologies are constantly developing, so it is safe to assume that prices will go down in the future.

2) Weather Dependent Although solar energy can still be collected during cloudy and rainy days, the efficiency of the solar system drops. Solar panels are dependent on sunlight to effectively gather solar energy. Therefore, a few cloudy, rainy days can have a noticeable effect on the energy system. You should also take into account that solar energy cannot be collected during the night.

DEPT. OF EEE, NHCE Page 69

Modelling of automatic power switching control using ARM Microcontroller

3) Solar Energy Storage Is Expensive Solar energy has to be used right away, or it can be stored in large batteries. These batteries, used in off-the-grid solar systems, can be charged during the day so that the energy is used at night. This is good solution for using solar energy all day long but it is also quite expensive. In most cases it is smarter to just use solar energy during the day and take energy from the grid during the night (you can only do this if your system is connected to the grid). Luckily our energy demand is usually higher during the day so we can meet most of it with solar energy.

4)Uses a Lot of Space The more electricity you want to produce, the more solar panels you will need, because you want to collect as much sunlight as possible. Solar panels require a lot of space and some roofs are not big enough to fit the number of solar panels that you would like to have. An alternative is to install some of the panels in your yard but they need to have access to sunlight. Anyways, If you don‘t have the space for all the panels that you wanted, you can just get a fewer and they will still be satisfying some of your energy needs.

6.3 Applications

1) Can be implemented in industries houses hospitals which prevents causing damage to the machine from sudden power cut.

2) Excess power can be transmitted to the mains as a result electric bill can be reduced to a greater extend.

DEPT. OF EEE, NHCE Page 70

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 7 RESULTS

Result I: Intially solar is checked for its availablility .

Figure 7.1 Checking for solar

Result II: If Solar is available , battery charges instantly.

Figure 7.2 Battery charging

DEPT. OF EEE, NHCE Page 71

Modelling of automatic power switching control using ARM Microcontroller

Result III: When extra energy is produced , it is sent to the grid

Figure 7.3 Extra power sent to grid

Result IV: If solar is unavailable the controller checks for the next available source ie mains.

Figure 7.4 Checking for mains

DEPT. OF EEE, NHCE Page 72

Modelling of automatic power switching control using ARM Microcontroller

Result V: If mains are available the controller switches to mains.

Figure 7.5 Switching to mains

Result VI: IR sensors detects the presence of human in house. If there is no presence of human , electric power is switched off, hence a large amount of energy is saved by switching off the power supply.

Figure 7.6 IR detected

DEPT. OF EEE, NHCE Page 73

Modelling of automatic power switching control using ARM Microcontroller

CHAPTER 8 FUTURE SCOPE AND CONCLUSION

This project can be further enhanced by using other sources like wind power also and then taking into consideration for using the best possible power whose tariff remains lowest at that moment. The project ―Modelling of automatic power switching control using ARM Microcontroller‖ has been explained with all its features and details. The significance of this project lies in its various advantages and wide places of applications where this project can be used efficiently. 8.1 CATALOGUE (Bills of materials)

S.NO. DESCRIPTIO QUANTITY RATE AMOUNT N OF MATERIAL

1 Transformer 2 250 500

2 Rectifier 1 500 500

3 Battery 1 2000 2000

4 Inverter circuit 1 2500 2500

5 Resistive loads 2 100 200

6 Relay Board 1 1500 1500

7 Mini ARM 1 3500 3500 LPC2148 board

8 LCD 1 750 750

9 Voltage Divider 1 300 300 Circuit

10 IR Sensor 1 350 350

11 Fire Sensor 1 350 350

12 Solar Panel 1 1500 1500

13 LDR Circuit 1 300 300

DEPT. OF EEE, NHCE Page 74

Modelling of automatic power switching control using ARM Microcontroller

14 Wires As required 300 300

15 Nuts and bolts As required 300 300

16 Soldering work As required 1000 1000

17 Drilling work As needed 750 750

18 Wooden board 1 1500 1500

19 Main Switch 1 300 300

20 Adapter 1 500 500

21 Small boards As required 1000 1000

TOTAL= Rs.20,000

DEPT. OF EEE, NHCE Page 75

Modelling of automatic power switching control using ARM Microcontroller

BIBLIOGRAPHY

[1] Siriporn Bannamas,―Intelligent lighting energy management system for commercial and residential buildings‖, ieeeexplore, ISGT ASIA,Nov 2015,pg 1-6

[2] Payal Rodi, ―Energy conservation using automatic lighting system‖,ieeeexplore,ICGET,Nov.2015,pg 1-3 [3] ARM LPC2148 User Manual and Data Sheets.

[4] ―The 8051 Microcontroller and Embedded systems‖ by Muhammad Ali Mazidi and Janice Gillispie Mazidi , Pearson Education.

WEB REFERENCES

www.wikipedia.org

www.howstuffworks.com

www.alldatasheets.com

www.IEEE Spectrum.com

www.powersupply.com

DEPT. OF EEE, NHCE Page 76

Modelling of automatic power switching control using ARM Microcontroller

APPENDIX-A

DATA SHEETS

1) LM 317 Regulator

DEPT. OF EEE, NHCE Page 77

Modelling of automatic power switching control using ARM Microcontroller

2) BC547 NPN Transistor

DEPT. OF EEE, NHCE Page 78

Modelling of automatic power switching control using ARM Microcontroller

3) W10M Rectifier

DEPT. OF EEE, NHCE Page 79