Implementation of Automated Switching Circuit for Battery

download Implementation of Automated Switching Circuit for Battery

of 56

Transcript of Implementation of Automated Switching Circuit for Battery

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    1/56

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    2/56

    ii

    APRIL 2013

    SCHOOL OF ELECTRICAL & ELECTRONICS ENGINEERING

    BONAFIDE CERTIFICATE

    This is to certify that the project work entitled Implementation of automated switchingcircuit for battery charging during low light intensity in solar pumps is the bonafide workdone by Chi. SAKET,V (113005123) of VIII semester B.Tech. Degree in Electrical &Electronics Engineering during the academic year 2012-2013 in partial fulfillment of therequirements for the award of Degree of Bachelor of Technology in EEE at SASTRA university.

    _________________________ ____________________

    Internal Project Guide External Project Guide

    _____________________ _____________________

    Internal Examiner External Examiner

    Submitted for the university examination held on __________________________

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    3/56

    iii

    ____________________

    SCHOOL OF ELECTRICAL & ELECTRONICS ENGINEERING

    DECLARATION

    We / I submit this project entitledTITLE OF THE PROJECT to SASTRA University,

    in partial fulfillment of the requirement for the award ofB.Tech., Degree in ELECTRICAL

    AND ELECTRONICS ENGINEERING and we in full consciousness, declare this

    dissertation as our original and independent work carried out under the guidance of GUIDE

    NAME WITH DESIGNATION, EEE Department, SEEE, SASTRA University,

    Thanjavur.

    Date : ______________ Signature: 1. ____________________

    Place : ______________ 2. ____________________

    3. ____________________

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    4/56

    4

    ACKNOWLEDGEMENTS

    First and foremost, I would like to thank Prof R Sethuraman, Vice Chancellor, SASTRA

    University for providing all the facilities and necessary encouragement during the course of

    study. I would also like to extend our thanks to the Registrar Dr G Balachandran for giving

    us permission to undertake the four month intern in Kirloskar Brothers Limited, and also

    for all the opportunities provided by him and the management during our course.

    I would also like to thank Dr B Viswananthan, Dean School of Electrical and

    Electronics Engineering (SEEE for his moral support. I owe a debt of gratitude to Mr.

    S.Venkatesh whose encouragement and guidance helped me immensely throughout this

    project period.

    I wish to express my immense gratitude to Mr. Ajay Shirodkar, General

    Manager and Head-Solar Division, Kirloskar Brothers Limited, for guiding me throughout

    this project and allowing me to access the valuable resources at KBL. I would also like to

    thank Mr. Pradeep Sharma and Mr. Santosh Singh Pujari for their guidance on approaching

    the problem.

    Special thanks to Mr. Sham Sundar Chendake and Dr. Vijay Mehta from

    Khyatee electronics for providing me their expertise in electronic design.

    It has been an amazing experience that I had for the last three months and I

    had very good exposure on how to go about a research problem, and Kirloskar Brothers

    Limited provided me the valuable opportunity to work on this real time problem and for

    this I am grateful to KBL.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    5/56

    5

    ABSTRACT

    The idea of harnessing the energy of the sun is not a new one. In fact, way back in 7thcentury BC our ancestors were using crude magnifying glasses to focus the Suns energyand light fires. Then, fast forward to 1767, when Swiss scientist Horace de Saussure builtthe world's first solar collector. However, it would not be until 1839 that the basis of mostof our more modern solar power energy would be discovered by French scientist Edmond

    Becquerel, who named his discovery the photovoltaic effect.PV power is one of the most environmentally safe forms of energy that we have in

    use. This, plus the fact that solar power is a renewable energy source, makes PV power veryattractive for the future of our energy production. Current energy production methods suchas fossil fuels are non-renewable and greatly harmful to our environment. If we want tocontinue to lead healthy, long lives, we need to start looking to the future, and that is solarpower. The photovoltaic effect is one by which PV cells (there are many different materialswhich PV cells can be made of) convert light energy into electrical energy at the atomiclevel. Light, however, may be reflected, absorbed, or pass right through the PV cell, and itis only the absorbed light that generates electricity.

    PV power is of higher significance in rural areas of India where conventional gridsupply is intermittent and loads are heavy due to requirements of irrigation and agriculture.Hence, KIRLOSKAR BROTHERS LIMITED came up with the innovative idea of usingsolar PV cells to power three phase induction motors through an inverter to drive pumps.

    This project aims at developing an add-on circuit for this system, which canautomatically switch between battery charging and pumping operations based on the inputpower from the solar panels. This input power is dependent on the intensity of light incidenton the solar panels and thus the circuit switches according to the light intensity incident onthe solar panels.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    6/56

    6

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    7/56

    7

    LIST OF FIGURES

    2.1 SILICON SOLAR CELL..3

    2.2 ENERGY BANDS IN SOLAR CELLS4

    2.3 PV MODULES AND ARRAYS...4

    2.4 I-V CURVES AND CHARACTERISIC CURVES..6,7

    2.5 SOLAR RADIATION VS TIME CURVE...8

    2.6 LIGHT INTENSITY VS VOLTAGE CURVE...9

    2.7 GENERAL BLOCK DIAGRAM OF R5F2127..11

    2.8 PIN CONFIGURATION OF R5F2127...12

    2.9 MEMORY MAP OF R5F2127...16

    3.1 LM 338 CONNECTION DIAGRAM.18

    3.2. CIRCUIT DIAGRAM FOR SWITCHING..21

    3.3 INTERFACING WITH R5F212722

    3.4 SWITCHES AND REFERENCE VOLTAGES..23

    LIST OF TABLES

    3.1 PIN FUNCTIONS OF R5F2127..13,143.2 PIN FUNCTIONS OF LCD DISPLAY20

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    8/56

    8

    NOTATIONS AND ABBREVIATIONS

    1.KBL-Kirloskar Brothers Limited

    2.SVPWM- Space Vector Pulse Width Modulation

    3.MPPT- Maximum Power Point Tracking

    4.Wp- Watt Peak

    5.ADC- Analog to Digital Converter

    6.AM- Atmospheric Mean

    7.Vref- Reference Voltage

    8.Vout-Output Voltage

    9.Iadj- Adjustment Current

    10.P0_x-Port 0 pin x

    11.RLY1,RLY2- Relay 1 and 2

    12. SW1 and SW2- Switches 1 and 2

    13. RS- Register Select

    14.RW- Read/Write

    15.EN-Enable

    16. RxD, TxD- Receive/Transmit Data serially

    17. VocOpen Circuit Voltage

    18.VmpVolatage at maximum power

    19. Isc- Short Circuit Current

    20. Imp Current at Maximum Power

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    9/56

    9

    TABLE OF CONTENTS

    Acknowledgements iAbstract iiList of figures iiiList of Tables ivNotations and Abbreviations v

    1. Chapter 11.1 Introduction...11.2 The Concept..1

    1.3 Problem Statement.. .11.4 Objective1-21.5 Line Diagram2

    2. Chapter 2-Review of related Literature2.1 Fundamentals of solar power3-52.2 I-V Characteristics of Solar cells6-102.3 Effect of Light intensity on solar efficiency..10-132.4 Introduction to the Renesas R5F2127

    Microcontroller..13-18

    3. Chapter 3- Methods and Procedure

    3.1 Describing the elemental Design..193.2 Basic design of the circuit.193.3 Code for the microcontroller.263.4Testing the circuit...483.5 Battery sizing.49

    4. Chapter 4- Results and Summary..52

    5. References..54

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    10/56

    10

    CHAPTER 1

    1.1 INTRODUCTION

    Kirloskar brothers limited (kbl) is one of the world's leading manufacturers of pumps.

    Ranging from submersible to solar pumps, they offer a wide variety of options for its

    valued customers. KBL has recently enterred into the solar pumping business and in a shortspan of time has created revolutionising technology for its solar pumps.

    The following project in based on solar powered pumps that have been rolled out

    by Kirloskar recently.

    As we all know, solar power can be harnessed in two forms:

    Thermal form( using solar power plants).

    Photovoltaic form(using photovoltaic cells)

    The solar pumps that have been developed by KBL use the second form, i.e, they

    use an array of photovoltaic cells to harness solar energy to power the motor-pump set.

    This is done by using solar cell modules to obtain DC current and then using a patentedinverter to convert the DC power into AC power and to maximise the efficiency of the

    solar pumps. This power is then fed to a 3-phase induction motor that is used to run the

    pump set.

    1.2 THE CONCEPT

    The solar pumps at KBL use 3 phase AC induction motors to drive a pump. These are

    supplied through a large solar panel(of adequate size) and a patented solar power

    conditioning unit (SPCU) called the JALVERTER. The main function of the Jalverter is

    to convert the DC power output from solar panels into 3 phase SVPWM(Space VectorPulse Width Modulated) AC power to supply to the induction motor. It also performs

    certain optimisation functions so as to maximise the efficiency of the entire system using a

    technique called MPPT(Maximum Power Point Tracking).

    1.3 PROBLEM STATEMENT

    During morning and evening hours when the intensity of solar radiation is too low to

    supply enough power to drive the motor, the power produced (around 600Wp from a

    2400Wp module) , is wasted. We can use this power to charge a suitably sized battery

    during morning and evening hours so that the power from this battery can be used to drive

    light loads such as household loads like TV, lighting,etc.during hours when power is

    unavailable, through the Jalverter. This is useful in rural areas where the solar pumps are

    most likely to be used(for irrigation etc.) due to the absence of power supply or the erratic

    nature of supply.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    11/56

    11

    Objective:

    1.The design will require the use of a current sensor/voltage sensor that

    senses the current/voltage variations from the solar panel. The sensor is interfaced to a

    micrococontroller via an ADC .

    2.When the current/voltage is below a certain level , the controller is programmed in

    such a way that it switches ON the charging unit. When power is sufficient for the pump to

    be driven, the controller switches the pump ON and the charger OFF3.The switching action can be achieved through MOSFETs or SCRs or GTOs ,etc or

    power relays such as sugar cube relays..

    4.The battery is sized according to the power available for charging. This battery is

    connected to the Jalverter(which is basically an inverter) to provide 1-Phase power supply

    to rural households for a specified amount of time.

    1.4 LINE DIAGRAM

    During low solar intensity-

    SOLAR PANELSAuto Switch ckt.BATTERY

    During High Solar intensity-

    SOLAR PANELSJALVERTERPUMP

    During Night(No Solar Incidence)-

    BATTERYJALVERTERHOUSEHOLD

    Thus during low solar intensity hours, the power obtained from the solar modulescan be diverted to the battery instead of wasting it in supplying the losses of themotor(copper losses,iron losses,etc.). This battery is appropriately sized and can be used topower household supplies. Thus the two objectives are:

    1. Design of switching circuitry(automated).2. Appropriate sizing of battery.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    12/56

    12

    CHAPTER 2

    REVIEW OF RELATED LITERATURE

    2.1 FUNDAMENTALS OF SOLAR POWER

    As mentioned earlier, there are two methods of harnessing solar power, these are:

    1. Thermal methods(solar ponds,etc.)2. Photovoltaic method( Using solar cells).

    In this project, we have used solar cells to power the solar pumps.

    Solar Cells:

    Fig.2.1 Silicon solar cell

    The above diagram shows a typical crystalline silicon solar cell. The electrical currentgenerated in the semiconductor is extracted by contacts to the front and rear of the cell. Thetop contact structure, which must allow light to pass through, is made in the form of widelyspaced thin metal strips (usually calledfingers) that supply current to a larger bus bar. Thecell is covered with a thin layer of dielectric material - the anti-reflection coating, ARC - tominimise light reflection from the top surface.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    13/56

    13

    Fig.2.2 Energy bands in solar cells

    Solar cells are essentially semiconductor junctions under illumination. Light generateselectron-hole pairs on both sides of the junction, in the n-type emitter and in the p-typebase. The generated electrons (from the base) and holes (from the emitter) then diffuse tothe junction and are swept away by the electric field, thus producing electric current across

    the device. Note how the electric currents of the electrons and holes reinforce each othersince these particles carry opposite charges. The p-n junction therefore separates thecarriers with opposite charge, and transforms the generation current between the bands intoan electric current across the p-n junction.

    When solar cells are arranged in a series-parallel connection to obtain a desiredvoltage, the resulting structure is called a solar module.

    These modules are then connected in series to form a panel and these panels aregrouped to form arrays of solar cells.

    Fig.2.3 PV modules and arrays

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    14/56

    14

    2.2 I-V CHARACTERISTICS OF A SOLAR CELL:

    I= Is(exp(qv/kt)-1-Iph

    Iph=qaG(Lh+Le)

    On Open Circuit:

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    15/56

    15

    The current is zero hence solar cell delivers maximum voltage.Also, power= Vx I=0

    On Short Circuit:

    The voltage across the diode is zero. The solar cell delivers maximum current.Power Output= VxI=0.

    Also, on short circuit, the current

    Isc= -Iph=-qaG(Lh+Le)

    On Arbitrary Load:

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    16/56

    16

    The dashed region shows the range of external bias where power is generated.

    P=VxI

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    17/56

    17

    As shown in the above figure, the I-V curve of the solar cells has been plotted at 1sun,i.e at

    Temp=25 deg. Celsius

    AM=1.5

    Energy=1000W/m2

    Voc denotes the open circuit voltage while Isc denotes the short circuit current.Imp and Vmp denote the voltage and current at maximun power(Ump). The maximum power

    point is Pmpp and is denoted at the knee of the curve. This is the point where power obtained

    from the solar cell is maximum and the voltage and current at this point are Vmp and Imp

    respectively.

    The following figure shows the effect of decrease in the intensity of solar incidence on

    the I-V characteristics of the solar cell:

    Fig.2.4(b). Characteristic curves of a solar cell

    As seen from the above figure, if the intensity of solar radiation per sq. metre decreases,

    the Voc and the Vmp remain relatively constant but the Isc and the Imp decrease. Thus we can

    see that the output voltage of a solar panel reduces gradually with decrease the intensity of

    solar radiation but the output current decreases drastically with a decrease in the intensity

    of solar radiation.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    18/56

    18

    Also , with an increase in temperature(by around 25 degrees), both the output current

    and voltage from the solar panels tend to decrease. But since the variation of temperatures during

    day time is very less (around + or 5 degrees celsius), we consider the effect of temperature to

    be negligible.

    Concept of Peak Sun Hours:

    Solar power per unit area falling on earth normally follows a flatter at top,bell shaped curve similar to one shown below. The energy received during morning andevening hours is less than that during the period say, 11 am to 2 pm. If we add up all theenergy from just after sunrise to just before sunset (7 am to 5 pm), in India, itApproximately adds up to 5.5 kWhrs / sq.m.. In other words, this is as if 1000W solarpower is falling continuously for 5.5 hours on 1 sq.m. area kept horizontally. This 5.5hours is then called as Peak Sun Hours ( in India ) , which can be defined technicallyas the equivalent number of hours per day if solar irradiance had averaged at 1000

    W/m2 .

    Hence, the approximate power produced by a solar module is

    P=kWpx Peak sun hours

    Wp= the power produced by a solar module under test conditions i.e at 1sun.

    2.3 EFFECT OF LIGHT INTENSITY ON SOLAR EFFICIENCY

    HypothesisFor non-ideal solar cells, voltage output related to varying light intensity exhibitsdiminishing returns: that is, as light intensity increases, the increase in voltage output dropsoff.Setup

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    19/56

    19

    Materials:

    Lamp with 60W light bulbVariable transformer, 120VCardboard boxSolar cell panel (9V, 50mA)Electronic voltmeter with 0-20V rangeElectronic Light probe

    Computer with light probe software

    Procedure:1. Set up your materials as shown in picture. The lamp, solar cell panel and lightprobe should all be inside the cardboard box, to avoid light pollution by ambientlight. The light probe should be propped up at such an angle that it is directly facingthe light that the lamp is providing. Connect the lamp to the transformer, andconnect the transformer to your power source. The solar cell panel should beconnected to the voltmeter, and the light probe connected to the computer or otherdevice to interpret the readings of the light probe.2. Start by taking your baseline readings. Record the amount of light intensity in luxand amount of voltage that is output by the solar cell when there is no power to the

    lamp.3. Next, turn the transformer to 100% of its power source (to avoid artificiallydeflated lux values due to hysteresis) and record the power output by the solar cell.Also, to record the light intensity, set the light probe to get data points for fiveseconds, with five probes per second. This way you can record the fluctuating lightintensity and determine the average light intensity for that power output.4. Repeat step 3 at 90% of the transformer's power, then continue to reduce thepower at 10% intervals until reaching 0% again.5. Take off the cardboard box for about five minutes, as the temperature inside thebox builds up and might skew results.6. Repeats steps 3 through 5 two more times, to provide more data for accurateresults.

    Fig.2.5. Voltage vs Light intensity curve

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    20/56

    20

    Inference

    Our hypothesis is completely justified, given the results of our experiment. As the lightintensity increases, the increase in voltage production drops off. It took nearly 3 times asmuch light intensity to create a 10 volt output as it did to produce 7.5volts of output: a one-third increase in productiveness for a 3x increase in solarraw materials.The strengths ofour approach are many. First, the use of the electronic light probe enabled us to take 25samples for each trial for three trials, resulting in 75measures of light intensity. This helps

    reduce the margin of error for the independent variable. Second, the setup shielded the solarcell as much as possible from ambient light, and used a non-reflective surface and container(black butcher paper and cardboard box) which ensures that the cell and the probe areexposed to the same proportion of the available light. Additionally, a five-minute cool-down period between each trial was given, which limits interference from raisedtemperatures.

    Most of the limitations of the approach are related to the poor quality of theequipment used, specifically the solar cell itself. Series resistance in the structure ofthe cellis a part of what creates the diminishing returns effect, and the low quality of our cellexaggerates this tendency beyond what may be considered reasonable in one of industrial orresearch quality. Additionally, because we did not stop between each different lux value butinstead between different trials, accumulated radiant heat would deflate the voltage output

    at later values within each trial.

    Results:

    Hence we find that:1.With an increase in light intensity, the voltage output of the solar cell increases and viceversa.2. The rate of increase of voltage is linear at first then it gradually drops off and saturatesnear open circuit voltage.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    21/56

    21

    2.4 INTRODUCTION TO RENESAS R5F2127 16-BIT MICROCONTROLLER:

    GENERAL BLOCK DIAGRAM OF R5F2127

    Fig.2.6. General block diagram of R5F2127

    The Renesas R5F2127SDF microcontroller is a 16 bit microcontroller. It has the followingspecifications:Program ROM: 16KbRAM: 1KbData Flash: 1Kb x 2

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    22/56

    22

    PIN CONFIGURATION:

    Fig.2.7.Pin Configuration of R5F2127

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    23/56

    23

    TABLE OF PIN FUNCTIONS:

    Table 2.1 List of pin functions of R5F2127

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    24/56

    24

    Table 2.1(contd.)

    CENTRAL PROCESSING UNIT:

    Data Registers (R0, R1, R2, and R3)

    R0 is a 16-bit register for transfer, arithmetic, and logic operations. The same applies to R1

    to R3. R0 can be split into high-order bits (R0H) and low-order bits (R0L) to be usedseparately as 8-bit data registers. R1H and R1L are analogous to R0H and R0L. R2 can becombined with R0 and used as a 32-bit data register (R2R0). R3R1 is analogous to R2R0.

    Address Registers (A0 and A1)

    A0 is a 16-bit register for address register indirect addressing and address register relativeaddressing. It is also used for transfer, arithmetic, and logic operations. A1 is analogous toA0. A1 can be combined with A0 to be used as a 32-bit address register (A1A0).

    Frame Base Register (FB)

    FB is a 16-bit register for FB relative addressing.

    Interrupt Table Register (INTB)INTB is a 20-bit register that indicates the start address of an interrupt vector table.

    Program Counter (PC)

    PC is 20 bits wide and indicates the address of the next instruction to be executed.

    User Stack Pointer (USP) and Interrupt Stack Pointer (ISP)

    The stack pointers (SP), USP, and ISP, are each 16 bits wide. The U flag of FLG is used toswitch between USP and ISP.

    Static Base Register (SB)

    SB is a 16-bit register for SB relative addressing.

    Flag Register (FLG)

    FLG is an 11-bit register indicating the CPU state.

    Carry Flag (C)

    The C flag retains carry, borrow, or shift-out bits that have been generated by the arithmeticand logic unit.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    25/56

    25

    Debug Flag (D)

    The D flag is for debugging only. Set it to 0.

    Zero Flag (Z)

    The Z flag is set to 1 when an arithmetic operation results in 0; otherwise to 0.

    Sign Flag (S)The S flag is set to 1 when an arithmetic operation results in a negative value; otherwise to0.

    Register Bank Select Flag (B)

    Register bank 0 is selected when the B flag is 0. Register bank 1 is selected when this flagis set to 1.

    Overflow Flag (O)

    The O flag is set to 1 when an operation results in an overflow; otherwise to 0.

    Interrupt Enable Flag (I)

    The I flag enables maskable interrupts.Interrupt are disabled when the I flag is set to 0, and are enabled when the I flag is set to 1.The I flag is set to 0 when an interrupt request is acknowledged.

    Stack Pointer Select Flag (U)

    ISP is selected when the U flag is set to 0; USP is selected when the U flag is set to 1.The U flag is set to 0 when a hardware interrupt request is acknowledged or the INTinstruction of software interrupt numbers 0 to 31 is executed.

    Processor Interrupt Priority Level (IPL)

    IPL is 3 bits wide and assigns processor interrupt priority levels from level 0 to level 7.If a requested interrupt has higher priority than IPL, the interrupt is enabled.

    Reserved Bit

    If necessary, set to 0. When read, the content is undefined.

    MEMORY:

    Figure below shows a Memory Map of R8C/26 Group. The R8C/26 group has 1 Mbyte ofaddress space from addresses 00000h to FFFFFh. The internal ROM is allocated loweraddresses, beginning with address 0FFFFh. For example, a 16-Kbyte internal ROM area isallocated addresses 0C000h to 0FFFFh. The fixed interrupt vector table is allocatedaddresses 0FFDCh to 0FFFFh. They store the starting address of each interrupt routine.

    The internal RAM is allocated higher addresses beginning with address 00400h.For example, a 1-Kbyte internal RAM area is allocated addresses 00400h to 007FFh. Theinternal RAM is used not only for storing data but also for calling subroutines and as stackswhen interrupt requests are acknowledged. Special function registers (SFRs) are allocatedaddresses 00000h to 002FFh. The peripheral function control registers are allocated here.All addresses within the SFR, which have nothing allocated are reserved for future use andcannot be accessed by users.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    26/56

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    27/56

    27

    CHAPTER 3

    METHODS AND PROCEDURE

    The following section describes the methodology observed for designing the circuit.

    3.1 DESCRIBING THE ELEMENTAL DESIGN

    This section deals with a basic outline of the circuit to be designed. It goes over theelements required for the circuit and the block or line diagram layout of the circuit.

    It was earlier observed that the output voltage and current from a solar celldecreases with decrease in the intensity of light. Hence to detect the change in lightintensity we can use voltage or current sensors. In the following circuit we have usedvoltage sensors which are interfaced with the microcontroller via its ADC. A current sensorhas also been interfaced for future use and reprogramming.

    Since the model being designed is a miniature version of the actual circuit, we haveused a 20 watt panel instead of a much larger one which is used with a solar pump.

    The switching operation in the circuit can be provided using various methods such as

    using SCRs, Relays, etc. In this model, sugar cube relays have been used for performingswitching. Hence we can draw the line diagram as follows:

    Solar panelVoltage sensorscontrollerRelay 1Pump or battery

    SwitchcontrollerRelay 2 JALVERTER

    3.2 BASIC DESIGN OF THE CIRCUIT:

    The input power to the circuit is provided from the solar panel. This panel alsopowers the Relays for switching and provides the voltage for the microcontroller. Hence, to

    provide a constant voltage for the Relays (14V) and for the microcontroller (5V), we usevoltage regulators, i.e, LM338 and LM 317. To increase the current capacity we use twoLM338 ICs.

    Voltage Regulators (LM338):

    The LM338 series of adjustable 3-terminal positiveVoltage regulators is capable of supplying in excess besides replacing fixed regulators ordiscrete of 5A over a 1.2V to 32V output range. They require only 2 resistors to set theoutput voltage.

    In operation, the LM138 develops a nominal 1.25V reference voltage, VREF, between theoutput and adjustment terminal. The reference voltage is impressed across program resistorR1 and, since the voltage is constant, constant current I1 then flows through the output setresistor R2, giving an output voltage have

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    28/56

    28

    Representation of connection:

    Fig.3.1.Representation of connection of LM338

    An input bypass capacitor is recommended. A 0.1 F disc or 1F solid tantalum on theinput is suitable input bypassing for almost all applications.

    In the circuit designedFor LM 338R1=270 ohmsR2=22k parallel to 3.3kVout=14.60V

    For LM 317R1=270 ohmsR2=22k parallel to 820 ohmsVout=5V

    A 0.1F input bypass capacitor has been provided for input bypassing. Also, a 2200fcapacitor has been provided so as to filter out any ripples from the solar panel.

    In the absence of solar input, the relays and the controller can be powered by the

    battery. To prevent the backflow of current into the solar panel a diode D1 has beenprovided.

    Sensing the input voltage and Current:

    The input voltage from the solar panel is sensed using a voltage sensor that

    consists of a small voltage division circuit. This circuit uses resistors to set 2.4V output fora 22V input. The resistors are depicted as R10=270k and R11=33k.

    This circuit is then interfaced to the microcontroller via its ADC pin P0_7.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    29/56

    29

    The current sensing circuit consists of a .33-ohm resistor, which converts thecurrent into equiavalent voltage (like a current shunt). This voltage is amplified using anop-amp and is interfaced with the microcontroller via ADC pin P0_5.

    Hence using the above circuitry, current and voltage inputs from the solar panelare sensed by the microcontroller.

    The voltage from the Battery terminals is also sensed similar to that of the solarpanel. The two resistors used here are R13=270k and R16=33k to set an output of 1.5V for

    14V DC. This is interfaced to the microcontroller via ADC pin P0_6.

    Relays:

    The circuit developed uses two sugar cube relays RLY1 and RLY2. These are ratedat 12V and 7.5A.

    A sugar cube relay is a basic electromagnetic relay, which is used to switch betweentwo independent functions. In this case, RLY1 switches between pumping and batterycharging. The relay is connected to the output port of the microcontroller P0_2 via amosfet. The Mosfet amplifies the signal from the controller, which turns the relay ON.When Relay 1 is OFF, the battery charging occurs. When Relay 1 is turned on, it switchesto Pumping operation via the JALVERTER.

    Relay 2 is used to divert the power from the Battery to the JALVERTER. This relay isturned ON manually by the user using a switch SW2 and turned OFF using switch SW3.When Relay 2 is switched ON the terminal S1 and S2 are short circuited so that the powerfrom the battery is given to the JALVERTER. This way we can use the battery to supplyhouseholds via the JALVERTER.

    LED Indication:

    L1-Power ONL2- JALVERTER ONL3- Battery ON.L4- Setting mode.

    LCD Display Interfacing:

    Liquid Crystal Display also called, as LCD is very helpful in providing user interface aswell as for debugging purpose. The most common type of LCD controller is HITACHI44780, which provides a simple interface between the controller & an LCD. In this circuit,we have used a 16x2 LCD display (16 characters with 2 lines).

    The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number ondata lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines + 3control lines i.e. total 11 lines are required. And if operated in 4-bit mode then 4 data lines+ 3 control lines i.e. 7 lines are required.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    30/56

    30

    Pin Symbol Function

    1 Vss Ground

    2 Vdd Supply Voltage

    3 Vo Contrast Setting

    4 RS Register Select

    5 R/W Read/Write Select

    6 En Chip Enable Signal

    7-14 DB0-DB7 Data Lines

    15 A/Vee Gnd for the backlight

    16 K Vcc for backlight

    Table 3.2. Pin configuration of LCD

    The above table shows the functions of the various pins in the LCD display. These pins areinterfaced with pins with ports P1 and P3 of the microcontroller. This display is used toshow the Voltage and current from the PV panel and also the battery. It is also used to setthe voltage threshold for the switching operations.

    Switches:

    There are four switches provided in the circuit. These are basic Tact switches thatare interfaced to the pins 1,4,6 and 26 of the controller respectively.

    The various functions of the switches are:SW1-Mode select for selecting Threshold Voltage.

    SW2-Increment threshold/ RLY 2 ONSW3-Decrement threshold/RLY 2 OFFSW4- Enter/LED ON.

    RS232 Interface:

    To transmit information regarding the Panel voltage, current, battery voltage,etc., serially, an RS232 connector has been provided. This is interfaced via the MAX232 ICto match the Voltage levels between TTL and CMOS logics.TxD represents serial transmission from the controller and RxD represents serial receptionby a modem or a PC.

    3.3 CODE FOR THE MICROCONTROLLER:

    The Renesas controller has been programmed using C as a platform and thisRenesas software has been used to convert this C code into hex code and burn it into thecontroller.

    The following is the program burnt into the controller for automated switching,LCD display operation etc.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    31/56

    31

    #include"sfr_r827.h"

    //LCD CONTROL#defineLCD p1#defineRS p3_4

    #defineEN p3_3

    //BUZZER#defineBUZZER p0_0

    //SWITCH#defineMODE p3_5#defineINC p4_7#defineDEC p4_6#defineENTER p0_4

    //RELAY

    #defineRELAY1 p0_2#defineRELAY2 p0_1#defineMOSFET p3_6

    //LED INDICATION#defineBAT_LED p0_3#defineSET_LED p3_1

    //ADC CHANNEL#definePV_CH 0#define BAT_CH 1#define I_CH 2

    //INTER FLASH ADDRESS#define BLOCK_A 0x2400;

    //CURRENT 0.00A-2.00A#define UPPERLIMIT_I 970#define LOWERLIMIT_I 1#define SET_SPAN_I (UPPERLIMIT_I - LOWERLIMIT_I)#define I_OFFSET 1#define I_SIZE 199

    //BATTERY VOLTAGE 00.0V-16.0V#define UPPERLIMIT_BV 694#define LOWERLIMIT_BV 1#define SET_SPAN_BV (UPPERLIMIT_BV - LOWERLIMIT_BV)#define BV_OFFSET 1#define BV_SIZE 159

    //PV VOLTAGE 00.0V-22.0V#define UPPERLIMIT_PV 975

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    32/56

    32

    #define LOWERLIMIT_PV 1#define SET_SPAN_PV (UPPERLIMIT_PV - LOWERLIMIT_PV)#define PV_OFFSET 1#define PV_SIZE 229

    #define RELAY_DELAY 12#define BAT_DELAY 10

    #define SET_BAT_VOLTAGE 120#define RESET_BAT_VOLTAGE 100

    //DELAY 0 - 65535void DELAY(unsigned int NUM1);void DELAY_MSEC(unsigned int NUM2);

    //SELECT 10MHzvoid SET_WORKING_FREQ(void);

    //SET IOvoid SET_IO(void);

    //LCD 2x16void SET_LCD(void);void COM_DATA(unsigned char VALUE,unsigned char ORDER);Void LCD_POS (unsigned char LINE, unsigned char POS);void PRINT(unsigned char I);void CURSOR_OFF(void);void CURSOR_BLINK(void);void CURSOR_STADY(void);

    //SET ADC SETTINGvoid SET_ADC(void);

    //READ ADC CHANNELunsigned int ADC_READ(unsigned char CHANNEL_NO);//CALCULATE CURRENT 000A-200Aunsigned int CURRENT(unsigned int I_DATA);//CALCULATE BATTERY VOLTAGE 00.0V-16.0Vunsigned int BATV(unsigned int V_DATA);//CALCULATE PV VOLTAGE 00.0V-22.0Vunsigned int PVV(unsigned int V_DATA);

    //DISPLAY CURRENT AND VOLTAGEvoid DISPLAY_CURRENT(unsigned char HEX);void DISPLAY_VOLTAGE(unsigned char HEX);

    //SERIAL COMMUNICATIONvoid LOAD_UART1(const unsigned char *PTR);void SEND_UART1(unsigned char VALUE);void SET_UART1(void);

    //BUZZER BEEPvoid BUZZER_BEEP(unsigned char I);

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    33/56

    33

    void SET_PV(void);

    //FLASH READ WRITEvoid READ_FLASH(void);void EraseBlock(void);void WriteBlock(void);

    void SEND_VOLTAGE(unsigned char HEX);void SEND_CURRENT(unsigned char HEX);void CONVERT_HTOS(unsigned int HEX);

    //FLASH ADDRESSunsigned char *flash_addr;

    //16-BIT VALUEunsigned int ADC_COUNT = 0;

    //8-BIT VALUEunsigned char PV_VOLTAGE = 0;

    unsigned char BAT_VOLTAGE = 0;unsigned char PV_CURRENT = 0;unsigned char COUNTER1 = 0;unsigned char COUNTER2 = 0;unsigned char COUNTER3 = 0;unsigned char COUNTER4 = 0;unsigned char COUNTER5 = 0;unsigned char COUNTER6 = 0;unsigned char SET_PV_VOLTAGE = 0;unsigned char RESET_PV_VOLTAGE = 0;unsigned char SETTING_COUNTER = 0;

    //BIT FLAG_Bool RELAY1_FLAG = 0;_Bool BAT_LOW_FLAG = 0;_Bool SETTING_FLAG = 0;_Bool SHOW_SCREEN = 0;_Bool MOSFET_FLAG = 0;

    unsigned char STORE_VALUE[3];

    //LCD DATAconst unsigned char TABLE[12][17] ={

    " ",//0" Kirloskar ",//1" Brothers Ltd ",//2"PV: I: ",//3"BAT: ",//4"Set PV: 00.0V",//5"Use UP/DOWN Key ",//6

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    34/56

    34

    "Factory Restored",//7" Set PV Voltage ",//8" Exit From ",//9" Setting Menu ",//10"BAT: LOW ",//11

    };

    void main(void){

    asm("FCLR I"); //DISABLE GLOBLE INTERRUPTprc0 = 1; //PROTECTION OFF

    SET_WORKING_FREQ();

    SET_IO();

    prc3 = 1;vw0c0 = 1; //Voltage monitor 0 reset enable bit

    vw0c6 = 1; //Voltage monitor 0 circuit mode select bitvca25 = 1; //Voltage detection 0 enable bitprc3 = 0;

    prc0 = 0; //PROTECTION ONasm("FSET I"); //ENABLE INTERRUPTS

    SET_LCD(); //LCD INITIALISE

    SET_ADC(); //ADC INITIALISE

    SET_UART1(); //SET UART1

    READ_FLASH(); //RESTORE

    LCD_POS(1,0);PRINT(1);//" Kirloskar ",//1LCD_POS(2,0);PRINT(2);//" Brothers Ltd ",//2DELAY_MSEC(2000);SHOW_SCREEN = 0;

    while(1){

    if(!SHOW_SCREEN){

    SHOW_SCREEN = 1;LCD_POS(1,0);PRINT(3);//"PV:00.0V I:00.0A",//3LCD_POS(2,0);

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    35/56

    35

    PRINT(4);//"BAT:00.0V ",//4

    SET_PV_VOLTAGE = STORE_VALUE[1];RESET_PV_VOLTAGE = SET_PV_VOLTAGE - 20;

    RELAY1_FLAG = 0;BAT_LOW_FLAG = 0;

    SETTING_FLAG = 0;}

    //450msADC_COUNT = ADC_READ(PV_CH);PV_VOLTAGE = PVV(ADC_COUNT);

    ADC_COUNT = ADC_READ(BAT_CH);BAT_VOLTAGE = BATV(ADC_COUNT);

    ADC_COUNT = ADC_READ(I_CH);

    PV_CURRENT = CURRENT(ADC_COUNT);

    LCD_POS(1,3);DISPLAY_VOLTAGE(PV_VOLTAGE);LCD_POS(1,11);DISPLAY_CURRENT(PV_CURRENT);LCD_POS(2,4);DISPLAY_VOLTAGE(BAT_VOLTAGE);

    //JALWATER ONif(PV_VOLTAGE >= SET_PV_VOLTAGE && !RELAY1_FLAG){

    COUNTER1 = COUNTER1 + 1;}else{

    COUNTER1 = 0;}if(COUNTER1 >= RELAY_DELAY){

    RELAY1 = 1;RELAY1_FLAG = 1;BUZZER_BEEP(2);

    }

    //JALWATER OFFif(PV_VOLTAGE

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    36/56

    36

    }if(COUNTER2 >= RELAY_DELAY){

    RELAY1 = 0;RELAY1_FLAG = 0;BUZZER_BEEP(1);

    }

    //REALY2 ON/OFFif(!INC && BAT_VOLTAGE >= SET_BAT_VOLTAGE &&!BAT_LOW_FLAG)

    {RELAY2 = 1;BUZZER_BEEP(1);DELAY_MSEC(500);

    }else if(!DEC){

    RELAY2 = 0;BUZZER_BEEP(1);

    DELAY_MSEC(500);}

    //MOSFET ON/OFFif(!ENTER && !MOSFET_FLAG){

    MOSFET = 1;MOSFET_FLAG = 1;BUZZER_BEEP(1);DELAY_MSEC(1000);

    }else if(!ENTER && MOSFET_FLAG){

    MOSFET = 0;MOSFET_FLAG = 0;BUZZER_BEEP(1);DELAY_MSEC(1000);

    }

    //BAT LOW ONif(BAT_VOLTAGE < RESET_BAT_VOLTAGE && !BAT_LOW_FLAG){

    COUNTER5 = COUNTER5 + 1;}else{

    COUNTER5 = 0;}if(COUNTER5 >= BAT_DELAY){

    BAT_LED = 0;BAT_LOW_FLAG = 1;LCD_POS(2,0);PRINT(11);//"BAT: LOW ",//11COUNTER5 = 0;

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    37/56

    37

    }

    //BAT LOW OFFif(BAT_VOLTAGE >= SET_BAT_VOLTAGE && BAT_LOW_FLAG){

    COUNTER6 = COUNTER6 + 1;}

    else{COUNTER6 = 0;

    }if(COUNTER6 >= BAT_DELAY){

    BAT_LED = 1;BAT_LOW_FLAG = 0;RELAY2 = 0;LCD_POS(2,0);PRINT(4);//"BAT:00.0V ",//4COUNTER6 = 0;

    }

    //SERIAL DATA SENDLOAD_UART1(" PV:");SEND_VOLTAGE(PV_VOLTAGE);LOAD_UART1(" PV I:");SEND_CURRENT(PV_CURRENT);LOAD_UART1(" BAT:");SEND_VOLTAGE(BAT_VOLTAGE);

    //SETTINGif(!MODE){

    SETTING_COUNTER = SETTING_COUNTER + 1;

    }else{

    SETTING_COUNTER = 0;}if(SETTING_COUNTER >= 5){

    SETTING_COUNTER = 0;SET_LED = 0;LCD_POS(1,0);PRINT(8);//" Set PV Voltage ",//8LCD_POS(2,0);PRINT(6);//"Use UP/DOWN Key ",//6BUZZER_BEEP(1);RELAY1 = 0;RELAY2 = 0;BAT_LED = 1;DELAY_MSEC(1000);SETTING_FLAG = 1;LCD_POS(1,0);PRINT(5);//"Set PV: 00.0V",//5

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    38/56

    38

    }while(SETTING_FLAG){

    SET_PV();}

    }//WHILE-1

    }//MAIN

    //***********************************************************//DELAY (1 - 65535)//***********************************************************void DELAY(unsigned int NUM1){

    while(NUM1--){

    asm("NOP");}

    }

    void DELAY_MSEC(unsigned int NUM2){

    while(NUM2--){

    DELAY(300);}

    }

    //***********************************************************//SET CONTROLLER WORKING FREQUENCY 10MHz//***********************************************************

    void SET_WORKING_FREQ(void){

    fra20 = 0;//HIGH-SPEED DIVIDE BY-2 MODEfra21 = 0;//40MHz/2 = 20MHzfra22 = 0;

    cm13 = 0;cm05 = 1;cm02 = 0;cm14 = 0;ocd0 = 0;ocd1 = 0;

    fra00 = 1;fra01 = 1;

    ocd2 = 1;//SYSTEM CLOCK DIVIDE BY-2cm16 = 1;//20MHz/2 = 10MHzcm17 = 0;cm06 = 0;

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    39/56

    39

    asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");

    asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");

    }

    //***********************************************************//SET IO//***********************************************************void SET_IO(void){//I/P PORT PIN SET - 0

    //O/P PORT PIN SET = 1

    //PV_CH,BAT_CH,I_CH,SW4,SET_LED,RL1,RL2,BUZZERprc2 = 1;pd0 = 0b00001111;

    //LCD OPpd1 = 0b11111111;

    //TxD,MOSFET,SW1,RS,EN,NC,BAT_LED,NCpd3 = 0b11011111;

    //SW2,SW3,RxD,NC,NC,REFF,NC,NCpd4 = 0b00011011;

    pd5_3 = 1;//SCLpd5_4 = 1;//SDA

    RELAY1 = 0;RELAY2 = 0;

    BAT_LED = 1;SET_LED = 1;

    }

    //**********************************************************************//LCD INITIALISE//**********************************************************************void SET_LCD(void){

    COM_DATA(0x38,0);DELAY_MSEC(50);

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    40/56

    40

    COM_DATA(0xC,0);DELAY_MSEC(50);COM_DATA(1,0);DELAY_MSEC(50);COM_DATA(6,0);DELAY_MSEC(50);COM_DATA(0xC,0);

    DELAY_MSEC(50);}

    //**********************************************************************//LCD DATA AND COMMAND//**********************************************************************void COM_DATA(unsigned char VALUE,unsigned char ORDER){

    if(!ORDER){

    asm("NOP");RS = 0;

    }else{

    asm("NOP");RS = 1;

    }

    asm("NOP");LCD = VALUE;asm("NOP");EN = 1;DELAY(100);

    EN = 0;DELAY(100);

    }

    //**********************************************************************//DISPLAY DATA ON LCD//**********************************************************************void PRINT(unsigned char I){

    unsigned char J = 0,DATA = 0;

    for(J = 0; J < 16; J++){

    DATA = TABLE[I][J];COM_DATA(DATA,1);

    }}

    //**********************************************************************//LCD POSITION

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    41/56

    41

    //**********************************************************************void LCD_POS(unsigned char LINE,unsigned char POS){

    if(LINE == 1){

    COM_DATA(128 + POS,0);}

    else{COM_DATA(192 + POS,0);

    }}

    //**********************************************************************//LCD CURSOR BLINK AND STABLE COMMAND//**********************************************************************void CURSOR_BLINK(void){

    COM_DATA(0x0F,0);

    }void CURSOR_STADY(void){

    COM_DATA(0xE,0);}

    //**********************************************************************//LCD CURSOR OFF//**********************************************************************void CURSOR_OFF(void){

    COM_DATA(0xC,0);

    }

    //**********************************************************************//SET ADC SETTING//**********************************************************************void SET_ADC(void){

    cks0_adcon0 = 0;//DIVIDE BY-4cks1_adcon1 = 0;md = 0;

    bits = 1; //10-BIT ADC SELECTvcut = 1; //EXTERNAL REFF SELECT

    smp = 1; //SAMPLE AND HOLD SELECT}

    //**********************************************************************//READ ADC CHANNEL//**********************************************************************

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    42/56

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    43/56

    43

    //**********************************************************************//CALCULATE BATTERY VOLTAGE 00.0V-16.0V//**********************************************************************unsigned int BATV(unsigned int V_DATA){

    unsigned long int I = 0;

    unsigned int DATA = 0;

    DATA = V_DATA;

    if(DATA < LOWERLIMIT_BV){

    DATA = LOWERLIMIT_BV;}else if(DATA > UPPERLIMIT_BV){

    DATA = UPPERLIMIT_BV;}

    DATA = DATA - LOWERLIMIT_BV;I = (unsigned long int)DATA * BV_SIZE;DATA = (I / SET_SPAN_BV) + BV_OFFSET;

    if(DATA == BV_OFFSET){

    DATA = 0;}

    return DATA;}

    //**********************************************************************//CALCULATE PV VOLTAGE 00.0V-22.0V//**********************************************************************unsigned int PVV(unsigned int V_DATA){

    unsigned long int I = 0;unsigned int DATA = 0;

    DATA = V_DATA;

    if(DATA < LOWERLIMIT_PV){

    DATA = LOWERLIMIT_PV;}else if(DATA > UPPERLIMIT_PV){

    DATA = UPPERLIMIT_PV;}

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    44/56

    44

    DATA = DATA - LOWERLIMIT_PV;I = (unsigned long int)DATA * PV_SIZE;DATA = (I / SET_SPAN_PV) + PV_OFFSET;

    if(DATA == PV_OFFSET){

    DATA = 0;

    }

    return DATA;}

    //**************************************************************//DISPLAY VOLTAGE//**************************************************************void DISPLAY_VOLTAGE(unsigned char HEX){

    unsigned char POS = 0,VALUE = 0;

    VALUE = HEX;

    POS = VALUE / 100; //5POS = 0x30 + POS;COM_DATA(POS,1);

    VALUE = VALUE % 100;//55

    POS = VALUE / 10; //5POS = 0x30 + POS;COM_DATA(POS,1);

    COM_DATA('.',1);

    POS = VALUE % 10;//5POS = 0x30 + POS;COM_DATA(POS,1);

    COM_DATA('V',1);}

    //**************************************************************//DISPLAY CURRENT//**************************************************************void DISPLAY_CURRENT(unsigned char HEX){

    unsigned char POS = 0,VALUE = 0;

    VALUE = HEX;

    POS = VALUE / 100; //5POS = 0x30 + POS;

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    45/56

    45

    COM_DATA(POS,1);

    COM_DATA('.',1);

    VALUE = VALUE % 100;//55

    POS = VALUE / 10; //5

    POS = 0x30 + POS;COM_DATA(POS,1);

    POS = VALUE % 10;//5POS = 0x30 + POS;COM_DATA(POS,1);

    COM_DATA('A',1);}

    //***********************************************************

    //UART1 SETTING BAUDE RATE 9600//***********************************************************void SET_UART1(void){

    uart1sel1 = 0; //P4_5(RXD1)uart1sel0 = 1; //P3_7(TXD1)u1pinsel = 1;txd1sel = 1;txd1en = 0;

    //UART mode transfer data 8 bits long selectedsmd0_u1mr = 1;

    smd1_u1mr = 0;smd2_u1mr = 1;

    //Internal clock selectedckdir_u1mr = 0;

    //1 stop bit selectedstps_u1mr = 0;

    //Parity disabledprye_u1mr = 0;

    //BRG count source f8 selectedclk0_u1c0 = 1;clk1_u1c0 = 0;

    //TXD0 pin CMOS outputnch_u1c0 = 0;

    //Transfer LSB first

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    46/56

    46

    uform_u1c0 = 0;

    //Setting UART0 baud rate generator(max 255).//Calculated value is round to the nearest whole number

    u1brg = 15;

    asm("NOP");

    te_u1c1 = 1;asm("NOP");re_u1c1 = 1;

    s1ric = 0x07;}

    void SEND_UART1(unsigned char VALUE){

    asm("NOP");u1tb = VALUE;while(!txept_u1c0);

    DELAY(250);//1-MSEC}

    void LOAD_UART1(const unsigned char *PTR){

    while(*PTR != '\0'){

    asm("NOP");u1tb = *PTR;while(!txept_u1c0);DELAY(300);//1-MSECPTR++;

    }}

    void BUZZER_BEEP(unsigned char I){

    while(I--){

    BUZZER = 1;DELAY_MSEC(150);BUZZER = 0;DELAY_MSEC(100);

    }}

    void SET_PV(void){

    _Bool SCAN = 0;unsigned char ESC_COUNTER = 0;

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    47/56

    47

    SET_PV_VOLTAGE = STORE_VALUE[1];LCD_POS(1,11);DISPLAY_VOLTAGE(SET_PV_VOLTAGE);DELAY_MSEC(1000);BUZZER_BEEP(2);

    while(!SCAN){

    ESC_COUNTER = ESC_COUNTER + 1;SET_LED =! SET_LED;if(!INC){

    SET_PV_VOLTAGE = SET_PV_VOLTAGE + 1;if(SET_PV_VOLTAGE > 200){

    SET_PV_VOLTAGE = 100;}DELAY_MSEC(150);ESC_COUNTER = 0;

    }

    else if(!DEC){

    SET_PV_VOLTAGE = SET_PV_VOLTAGE - 1;if(SET_PV_VOLTAGE < 100){

    SET_PV_VOLTAGE = 200;}DELAY_MSEC(150);ESC_COUNTER = 0;

    }DELAY_MSEC(200);LCD_POS(1,11);

    DISPLAY_VOLTAGE(SET_PV_VOLTAGE);if(!ENTER || ESC_COUNTER >= 75){

    SCAN = 1;SETTING_FLAG = 0;

    STORE_VALUE[1] = SET_PV_VOLTAGE;EraseBlock();WriteBlock();SET_LED = 1;LCD_POS(1,0);PRINT(9);//" Exit From ",//9LCD_POS(2,0);PRINT(10);//" Setting Menu ",//10BUZZER_BEEP(4);DELAY_MSEC(1000);SHOW_SCREEN = 0;

    }}}

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    48/56

    48

    //**********************************************************//CLEAR ALL FLASH RAM//**********************************************************void EraseBlock(void){

    asm("FCLR I"); // Turn off maskable interrupts

    fmr01 = 0;fmr01 = 1; // Set EW0 select bitfmr11 = 0;fmr11 = 1; // Set to EW1 mode

    flash_addr = &(unsigned char)BLOCK_A;

    *flash_addr = 0x50; // Clear status register *flash_addr = 0x20; // Send erase command*flash_addr = 0xD0; // Send erase confirm command

    /* Note: In EW1 Mode, the MCU is suspended until the operation is completed */fmr0 = 0; /* Disable CPU rewriting commands by clearing EW entry bit */

    asm("FSET I"); // Restore I flag to previous setting}

    //**********************************************************//WRITE FLASH RAM//**********************************************************void WriteBlock(void){

    unsigned char I = 0;

    flash_addr = &(unsigned char)BLOCK_A;

    asm("FCLR I"); // Turn off maskable interrupts

    fmr01 = 0;fmr01 = 1; // Set EW0 select bitfmr11 = 0;fmr11 = 1; // Set to EW1 mode

    *flash_addr = 0x50; // Clear status register

    /* Write to the flash sequencer by writing to that area of flash memory */

    for(I = 1; I

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    49/56

    49

    /* Note: In EW1 Mode, the MCU is suspended until the operation completed */

    /* NOTE: The R8C writes to flash a 8 bits at a time where as the M16C

    /* Disable CPU rewriting commands by clearing EW entry bit */

    fmr0 = 0;

    asm("FSET I"); // Restore I flag to previous setting}

    //**********************************************************//READ FLASH//**********************************************************void READ_FLASH(void){

    unsigned char I = 0;

    flash_addr = &(unsigned char)BLOCK_A;

    for(I = 1; I

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    50/56

    50

    VALUE = HEX;

    POS = VALUE / 100; //5POS = 0x30 + POS;SEND_UART1(POS);

    VALUE = VALUE % 100;//55

    POS = VALUE / 10; //5POS = 0x30 + POS;SEND_UART1(POS);

    SEND_UART1('.');

    POS = VALUE % 10;//5POS = 0x30 + POS;SEND_UART1(POS);

    SEND_UART1('V');

    }

    //**************************************************************//DISPLAY CURRENT//**************************************************************void SEND_CURRENT(unsigned char HEX){

    unsigned char POS = 0,VALUE = 0;

    VALUE = HEX;

    POS = VALUE / 100; //5

    POS = 0x30 + POS;SEND_UART1(POS);

    SEND_UART1('.');

    VALUE = VALUE % 100;//55

    POS = VALUE / 10; //5POS = 0x30 + POS;SEND_UART1(POS);

    POS = VALUE % 10;//5POS = 0x30 + POS;SEND_UART1(POS);

    SEND_UART1('A');}

    void CONVERT_HTOS(unsigned int HEX){

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    51/56

    51

    unsigned int VALUE = 0;unsigned char POS = 0;

    VALUE = HEX;

    VALUE = VALUE % 1000;POS = VALUE / 100;

    POS = 0x30 + POS;COM_DATA(POS,1);

    VALUE = VALUE % 100;//35POS = VALUE / 10; //3POS = 0x30 + POS;COM_DATA(POS,1);

    POS = VALUE % 10;//5POS = 0x30 + POS;COM_DATA(POS,1);

    }

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    52/56

    52

    3.4 TESTING THE CIRCUIT:

    The circuit is tested using a Regulated power supply unit (RPSU). The loads areprovided using bulbs and the voltage is varied from the power supply. Switching is testedby reducing the voltage below the threshold levels. When the voltage is below

    threshold(14V default setting) , the bulb connected to the battery terminal lights up. Theoutput voltage and current can be seen on the LCD screen or tested using a multimeter.When the voltage is increased above threshold (16V by default), the bulb

    connected to the inverter terminal lights up. The current and voltage are displayed on theLCD screen.

    3.5 BATTERY SIZING:

    Battery bank capacity - calculating amp hour needs

    Inverter size

    To determine the inverter size we must find the peak load or maximum wattage of the

    home. This is found by adding up the wattage of the appliances and devices that could be

    run at the same time. This includes everything from microwaves and lights to computers

    and clocks. The sum will indicate which inverter size is needed. Appliances take more than

    their rated power at start-up are accounted for. The inverter's surge rating should cover

    these temporary increases.

    Example: A room has two 60-watt light bulbs and a 300-watt desktop computer.

    The inverter size is 60 x 2 + 300 = 420 watts

    Daily energy use

    Next we find the energy the home uses in a day. We Figure out how long each electronic

    device will be run in hours per day and Multiply the wattage of each device by its run-time

    to get the energy in watt-hours per day. Add up all the watt-hour values to get a total for the

    home. This estimate is likely too low as there will be efficiency loses. To get a rough idea

    of the real value with system loses, multiply by 1.5. This will help account for decreasing

    performance when temperature increases.

    Example: Light bulbs run for 5 hours a day. Computer runs for 2 hours a day. 120 x

    5 + 300 x 2 = 1200 watt-hours. 1200 x 1.5 = 1800 watt-hours

    Days of autonomy

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    53/56

    53

    Now decide how many days worth of energy is to be stored in the battery bank. Generally

    this is anywhere from two to five.

    Battery bank capacity

    Finally we can calculate the minimum battery AH capacity. Take the watt-hours per day

    and multiply them by the number you decided upon in step 3. This should represent a 50%depth of discharge on your batteries. Therefore multiply by 2 and convert the kwh result

    into amp hours (AH). Dividing by the battery voltage does this.

    Example: The battery bank has to last three days without recharging and usage 1.8

    kWh per day. As 1.8 x 3 x 2 = 10.8kwh, this is the capacity we need from the batteries.

    Converting this to AH we have to divide by the voltage of your system. This can be 12, 24

    or 48 for commercial application. If we choose to use 48V, the minimum AH capacity is

    then 10 800/48 = 225 AH. Now if you divide by your battery's rating you find the number

    of batteries you must use. Careful, this only applies to certain wiring set-ups.

    Charge controllers

    Charge controller sizing is the next step when sizing the system.

    Overview

    Charge controllers regulate the power coming from the solar panels to the batteries. They

    are a key part of any off-grid system and prevent batteries from over-charging. We will

    discuss two kinds of charge controllers: PWM and MPPT.

    PWM (Pulse-Width Modulation) controllers are cheaper than MPPT but create large power

    loses. Up to 60% of power can be lost. This is because PWM controllers do not optimise

    the voltage going to the batteries. This limitation makes a PWM controller a poor choice for

    a large system. However, in smaller systems their low price makes them a viable option.

    MPPT (Maximum Power Point Tracking) controllers optimise the voltage coming from the

    solar panels so that the maximum amount of energy is transferred to the battery bank. The

    maximum power point, or the optimal conversion voltage, will fluctuate with changes in

    light intensity, temperature and other factors. The digital optimisation process performed by

    the MPPT controller find and adjusts to the maximum power point quickly. Sophisticatedelectronics are needed in MPPT controllers to do this, which explains their high price.

    There is a significant pay-off though: MPPT controllers are 93-97% efficient in converting

    power.

    Calculation

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    54/56

    54

    Once the battery bank has been sized and solar panel array, determining which charge

    controller to use is comparatively straightforward. All we have to do is find the current

    through the controller by using power = voltage x current. Take the power produced by the

    solar panels and divide by the voltage of the batteries. For example:

    Example: A solar array is producing 1 kiwi and charging a battery bank of 24V. The

    controller size is then 1000/24 = 41.67 amps. Introduce a safety factor by multiplying the

    value you have found by 1.25 to account for variable power outputs: 41.67 x 1.25 = 52.09

    amps

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    55/56

    55

    CHAPTER 4

    RESULTS AND SUMMARY

    Hence the circuit for automated switching for battery charging during low light intensityhas been designed according to the above description and tested for successful operation.

    The above circuit can be used for various other switching operations. Forexample: Hence, using the above circuit, the automated switching operations betweenbattery charging and pumping have been implemented. The Battery sizing varies accordingto the households to be powered and can thus be varied according to the necessary outputpower required. The above circuit can also be used for performing other switchingoperations. For eg. If a building is powered using grid supply, a solar panel may be installedon the building to charge a battery. In the absence of the grid supply, the building may bepowered using the solar panels and the batteries.

    LIMITATIONS OF PROJECT:

    1. The above constructed model is a miniature version of the actual circuit to beimplemented so it cannot handle heavy loads(beyond 25V and 7A).

    2. Voltage sensors have been used for switching. Current sensors provide a moredynamic switching range.

    3. Another method can be calculating power using both voltage and current sensors soas to perform switching based on input power rather than input voltage.

    4. Voltage boosters are required for if output voltage has to be high.

    5. If MPPT is done by holding the voltage constant, then this circuit has to be

    connected before the MPPT circuit so as to have varying voltage

    REFERENCES

    [1] Kirloskar solar pump pack guidebook and presentation.

  • 7/28/2019 Implementation of Automated Switching Circuit for Battery

    56/56

    [2] Embedded Lab-An online teaching resource for microcontrollers-www.embeddedlab.com/renesascontrollers/R8cseries/prog

    [3] Interfacing LCDs -http//www.dnatechnology.com/Interfacing-LCD-to-8051.html4.

    [4] Renasas R5F2127 datasheet R8C/26 Hardware manual-renesas technolodies-Rev 2.10-26 September 2008.

    [5] All about solar cells-http// www.tech6.com/all about solar cells.

    [6] LM138/LM338 5-Amp adjustable regulators-Texas Instruments-Revised November2004.

    [7] Effect of light intensity on solar cell efficiency- Leighann Vanncleef and Aaron Baker.

    [8] Solar cell characteristics- www.nrel.gov.in/thinfilm/docs

    [9] Battery and Inverter Sizing-http://www.solartown.com/learning/solar-panels/choosing- and-sizing-batteries-charge-controllers-and-inverters-for-your-off-grid-solar-energy-system/