Docstoc

Modular_ Scalable Solar Power System

Document Sample
Modular_ Scalable Solar Power System Powered By Docstoc
					Modular Solar Power System




      Sally Simmons

      Jeff Spanogle

     Matthew Johnson

     Joshua Peterson




       May 2, 2003

        ELEE 452

    Grove City College
                                   Table of Contents



Abstract                                                       5

Introduction                                                   5

Charge Controller                                              10

Battery Data Gathering/Analysis                                17

Battery Monitor                                                28

Solar Panel/Battery/Inverter Interaction                       52

Cost and Parts List                                            55

Users Manual                                                   57

ABET Objectives                                                58

Individual Contributions                                       72

Conclusion                                                     77

References                                                     78

Appendix A: Project Code                                       78



                                     List of Figures

Figure 1: Overall System Block Diagram                         7

Figure 2: Overall Circuit Diagram for Final System Prototype   9

Figure 3: Charge Controller Block Diagram                      10

Figure 4: Charge Controller Schematic                          11

Figure 5: Orcad Generated Schematic                            12

Figure 6: Orcad Charge Controller Layout                       15




                                            2
Figure 7: LM555 Output During Charging Cycle                              16

Figure 8: Inverter IC Output During Charge Circuit                        17

Figure 9: The Battery Logging Circuit                                     19

Figure 10: Battery Draining Characteristic Curve 1                        20

Figure 11: Battery Draining Characteristic Curve 2                        22

Figure 12: Loaded Voltage Dropping Characteristics 1                      23

Figure 13: Loaded Voltage Dropping Characteristics 2                      24

Figure 14: Draining of Destroyed Battery                                  25

Figure 15: Heated, Cooled and Normal Temperature Battery Draining         26

Figure 16: Open-Circuit Voltage Recovery for Heated, Cooled and Normal    27

Figure 17: Partial Loading Effects on Loaded Voltage                      28

Figure 18: Plot of Data Points from Table 2                               32

Figure 19: Signal Conditioning Circuits for A/D Measurements              35

Figure 20: A General Difference Amplifier Circuit                         37

Figure 21: Characteristic Curve for OCV Signal Conditioning Circuit       39

Figure 22: Characteristic Curve for Current Signal Conditioning Circuit   41

Figure 23: Possible Plot of OCV vs. Time (on a Logarithmic Scale)         43

Figure 24: OCV Recovery Curve Plotted on Semilog Scale                    44

Figure 25: Plot of Discharge Current vs. Maximum Time of Use              47

Figure 26: Tripp Lite PV500                                               50

Figure 27. Output waveform of PV500 inverter                              54



                                     List of Tables




                                              3
Table 1: Quantitative Specifications                             10

Table 2: Open Circuit Voltage vs. State of Charge Relationship   30

Table 3: Lookup Table Based on SOC vs. OCV Relationship          33

Table 4: Actual Implementation of Lookup Table                   34

Table 5: LCD Output Display                                      49

Table 6: Parts list/Cost of Project Components                   55




                                           4
Abstract

       The need for a simple, portable power system in remote areas of the world is real.

This document defines this need and sets out a plan to implement a solution to meet that

need. The modular solar power system consists of a solar cell array, a charge controller,

a battery, a battery monitor, and an inverter. Each of these components is discussed

individually below. The introduction lays out the problem statement and the project

objectives. The next four sections outline the charge controller, battery data gathering

and analysis, battery monitor, and battery/inverter interaction. The project is still in its

development stage. A finished, working prototype has been constructed. Each of these

three sections lays out the progress completed thus far.

Introduction

       Throughout the world, situations arise in which conventional access to the power

grid is not available. These situations could include recreational activities such as

camping and RV trips or more everyday life situations such as remote home locations in

areas without power transmission systems common in Africa and areas of South

America. The absence of connection to electric power prevents these people from using

everyday appliances as well as vital medical machines and everything in between. In this

design project, the team planned to develop a scalable, modular solar power system that

is easy to use and portable. Products that meet some of these needs currently exist on the




                                               5
market. For instance, ICP Technologies markets solar panels which contain an integrated

charge controller. However, the battery, battery monitor, and inverter are not included in

this system. In general, companies do not currently provide integrated systems

encompassing the solar cell, charge controller, battery, battery monitor, and inverter.

Thus consumers with little or no technical knowledge face a real challenge in solving this

problem. The project will provide a portable power system to those with the

aforementioned needs without this difficulty of setup and integration in current systems

while supplying reliable battery monitoring capabilities.

       This problem is important from a practical standpoint because access to electricity

is almost a necessity today. The design and construction of this small scale power system

has served as an excellent educational tool. The project also includes work on an

embedded microprocessor, discrete circuitry, as well as data gathering and analysis.

These areas are all significant aspects of electrical engineering.

       The project has required the team members to read and understand published

journal articles, specifically those focusing on battery monitoring techniques. The battery

monitoring technique selected had to be adapted for the project, and some simple

mathematical analysis was required.

       Included below is an overall system block diagram of the project.




                                              6
                        Figure 1: Overall System Block Diagram

Note that the overall system has three major divisions, the battery/charge controller

interaction, the inverter, and the microprocessor. The primary and secondary battery,

both charged by the solar panel via the charge controller, alternately provide power to the

inverter, which converts the DC voltage from the battery into AC voltage suitable for

powering standard appliances. Initially in the design phase, the team had hoped to make

this system scalable. This goal was to be realized by allowing the user to easily connect

more batteries and/or solar panels thus increasing power storage and output. However,

this project objective was not met.

       This project involves a number of technical challenges. Initially, a simple charge

controller circuit was analyzed, extended, and then implemented as a printed circuit

board. Also the battery monitoring algorithm presented in Aylor et al. must be verified

through experimental testing. Finally, microprocessor implementation of the battery




                                             7
monitoring algorithm serves as a technical hurdle. So this project involves circuit

analysis and design, data gathering and analysis, and embedded system programming.

All three of these tasks relate to areas of electrical engineering studied in the curriculum.

       This report consists of sections outlining the major portions of the project. First

the charge controller is discussed, then the battery data gathering and analysis, the battery

monitoring system, and finally the solar panel/battery/inverter interaction. The report

concludes with a discussion of the individual contributions of each group member.

       The following figure is an overall circuit diagram of the final prototype.




                                              8
9
                              Figure 2: Overall Circuit Diagram

       The following table outlines a few quantitative specifications for the project.

                              Table 1: Quantitative Specifications

              Specification                  Value                   Tolerance
         Power output                       Maximum 500W                          25W
         Battery SOC accuracy                         N/A            Within 15 minutes
         A/D input readings                        11-13V                       0.08 V



Charge Controller

       The charge controller is located between the solar panels and the lead-acid battery

controlling the amount of current being fed to the battery. Continual full charging of an

already full battery will cause damage to the battery resulting in a degradation of

performance or even total failure. Thus, the charge controller is a necessary piece of the

project design.

       As shown in Figure 3, there are two main components to the charge controller. A

basic on-off charge controller found in a hobbyist magazine will be responsible for the

high amperage charging of the battery [1].




                       Figure 3: Charge Controller Block Diagram


                                              10
Using the circuit shown in Figure 4, taken from [1], the circuit will charge the battery

until it nears capacity.




                           Figure 4: Charge Controller Schematic

The circuit will realize the battery is nearing capacity when the battery terminal voltage

rises above a calculated point set by the potentiometers, R2 and R3. This set point is

14.40 volts, based on the specification provided by the battery manufacturer. It will then

remain off until the terminal voltage falls below another point, again set by the

potentiometers, at which point the controller will again allow the high current to reach the

battery. This set point is 10.5 volts, again specified by the manufacturer. The on/off

switching of this circuit has been demonstrated in lab. The circuit successfully supplies

current when needed and disconnects the source (solar cell) from the battery at near full

charge. An analysis of the switching function of the charge controller is included in the

lab report written for ELEE 451 found on the project webpage. The International

Rectifier P-Channel FET 048 is used for its exceptionally low internal resistance when in


                                             11
an on state. This greatly reduces the power loss through it in an energy transfer

applications where such losses significantly reduce the effectiveness of the controller.

       The original design for the charge control comes in the trickle charge block of the

controller. Once a battery is charged to its capacity, it is beneficial to continue to allow a

small “trickle” or “maintenance” charge to continue to run to the battery. Our trickle

charge design will supply no more than 100mA. This maintenance charge keeps the

battery completely “topped off”. Some articles and advertisements also claim that the

trickle charge prolongs battery life by “preventing deep discharge cycles that occur in

dormant batteries” [2]. Commercial charge controllers can be purchased which are

capable of charging a battery with full current to capacity and then running the

maintenance charge. However, the cost of these smarter devices is nearly triple the cost

of the basic on-off controller. While contemplating simply purchasing one of these smart

chargers, the group realized a possible method for improving the basic controller.




                           Figure 5: Orcad Generated Schematic



                                              12
       The trickle charge portion of the charge controller designed by the group is shown

boxed above in Figure 5. The output of the LM555 will run through an inverter and the

output of the inverter will control a transistor which will allow or stop current to the

trickle charge circuit. The trickle charge circuit will only run when the battery is near full

and the other charge circuit is off. The 2N3906 in this part of the circuit requires a 0.7

Volt turn-on voltage. This is supplied by the inverter IC as it is powered by the battery

voltage which should always be above 10 Volts. The trickle charge circuit will contain a

current limiting resistor of 30 Ohms which will allow a small amount of current to flow

to the battery at all times with no power loss in the system during the full charge cycle.

This will limit the charging current to about 100 mA as suggested by the battery

manufacturer to avoid damage due to chemical reactions occurring in batteries left to sit

for extended periods of time. The power sunk in the resistor is of no concern as it would

have been lost anyway if no trickle charge circuit was present.

       The choice of the basic, “canned” circuit shown in Figure 3 was made for

precisely that reason. It was the simplest version of the product available. It consists of

basic parts that can be reasonably easily assembled and analyzed. This allows the

opportunity to easily make the improvement described above without complex analysis

of the original full charger. With this design choice, exactly how the circuit is

functioning can be determined allowing a constructive debate on the feasibility of

building a charge controller in-house when the final product is ready for manufacture.

       After the design and analysis of the charge controller was done during the last

semester, questions of reliability were raised. The possibilities of failure of a circuit held

on a breadboard are much higher than those of a printed circuit board. Thus, one of the




                                              13
goals of this semester has been to have the charge controller mounted on a circuit board.

This is accomplished through the use of the Orcad Capture and Layout Suite. This

product allows the drawing of schematics and facilitates their transfer to printed traces

and drilled connections. Circuit components not included in the basic libraries packaged

with the product can be downloaded from manufacturers’ websites. It is to their

advantage to have parts available as designers are more likely to use their products if they

can be easily incorporated into circuit board design software. The schematic shown

above in Figure 4 was created using the Capture utility. The design is then compiled into

a netlist which is exported into the Layout utility. Footprints corresponding to the size

and pin locations for a part are chosen from the included libraries and attached to each

part found in the netlist. The traces are routed by the connections also detailed in the

netlist. The utility can then automatically arrange the components on the board to

minimize parasitics. A design rule check should then be done before finalizing the board

layout. The board layout for the charge controller is shown below in Figure 6.




                                             14
                        Figure 6: Orcad Charge Controller Layout

The appropriate files can be generated from this layout and submitted for actual

production. The elongation in the middle allows for mounting holes to be drilled in the

spaces above and below the row of resistors without fear of cracking the board near any

mounted parts.

       The printed circuit board arrived and parts were mounted. A charging simulation

was then done to verify the switching action of the circuit board. Figure 7 illustrates the

main charge controller portion of the circuit functioning by taking measurements of the

output of the LM555 IC and the battery voltage as the voltage rises above and falls below

the turn on and turn off voltages. The 555 output is not steady as one might think a TTL

output should be as it is powered by the battery voltage which is not at a constant voltage

during its charging and discharging. Figure 8 then shows the output of the inverter IC.




                                             15
This is on when the main controller is off and vice versa, and it is not constant for the

same reason as the 555 output.

                                                               LM555 Output vs. Battery Voltage

           18



           16



           14



           12



           10
 Voltage




                                                                                                                                               Battery Voltage
                                                                                                                                               LM555 Output
            8



            6



            4



            2



            0
                1   29 57 85 113 141 169 197 225 253 281 309 337 365 393 421 449 477 505 533 561 589 617 645 673 701 729 757 785 813 841 869
                                                                       Sample Number




                                           Figure 7: LM555 Output During Charging Cycle




                                                                                   16
                                                                 Inverter IC Output

            18


            16


            14


            12


            10
  Voltage




                                                                                                                         Battery Voltage
                                                                                                                         Inverter IC Output
            8


            6


            4


            2


            0
                 1   36 71 106 141 176 211 246 281 316 351 386 421 456 491 526 561 596 631 666 701 736 771 806 841 876
                                                            Sample Number


                                     Figure 8: Inverter IC Output During Charge Circuit


                     The properly configured charge controllers were then mounted to the final system

built by the group.

Battery Data Gathering/Analysis

                              The premise behind our entire system is an idea from the paper “A Battery

State-Of-Charge Indicator for Electric Wheelchairs” by James H. Aylor which states the

open-circuit voltage across the battery drops linearly with the capacity. Thus by

measuring the open-circuit voltage or Voc we will know how much capacity remains in

the battery. To this end, battery logging was done to prove a relationship between

capacity and Voc. Also data would be used to show support for the capacity prediction

theory described in the paper along with other ideas given for battery prediction. Finally,

data logging would be used to predict various characteristics of the battery’s behavior




                                                                         17
under various conditions. By using the Keithley 3108 for monitoring the battery,

accurate data was obtained with precise timing. Alongside the Keithley 3108, an Excel

plug-in called Excelinx was used to capture data and store it in the Excel spreadsheet

format. Using Excel graphing features, the data could be easily graphed or exported to

other programs for further analysis or processing. A series of experiments was set up for

initial testing of the Excelinx features and for some indication that there is a linear

relationship between capacity and Voc. The following circuit diagram shows initial

layout of the battery monitoring. The two resistors of 1MOhm create a voltage divider

without allowing much current to pass through and affect the draining of the battery. The

reason for the voltage division is in the Keithley where a maximum range of -10Volts to

10Volts prohibits a direct connection between the battery terminals and the Keithley

inputs.




                                              18
                          Figure 9: The Battery Logging Circuit



       Using known resistances, the batteries were drained in various ways. One of the

first data logging sequences was simply the draining of a 1.2 Amp-Hour capacity Power

Sonic model PS-1212 battery down to exhaustion. This was the first meaningful data

taken with Excelinx demonstrating not only that it worked but that there is indeed a linear

relationship between capacity and terminal voltage. The following figure shows the

graphed results. This figure was created by importing the data into Matlab from Excel.

Using this technique, more options and control is given to how the data is graphed.




                                            19
                    Figure 10: Battery Draining Characteristic Curve 1



       This graph shows that there is a linear region of operation for the loaded terminal

voltage shortly after the battery is loaded until the battery nears the end of its capacity.

The batteries capacity is diminished at the bending of the curve at a time of nine hours.

The bend in the curve is called the ‘knee’ and is referred to by James Aylor in the paper.

It says that at this point – the’knee’ – the battery capacity is depleted. The battery

terminal voltage level at which this point occurs is called the ‘knee voltage’ and

according to the paper is variable depending on the size of the load. The load for this

particular data set was 146 Ohms and the data sampling rate was one second. The data

sampling rate was kept at a consistent one second throughout all data logging sequences.




                                              20
The next graph shows the same battery with a different load draining to depletion. The

‘knee’ in this graph is further ahead in time than the previous graph. Here again, the

graph has a linear region for the loaded battery terminal voltage until the knee occurs at

which point the voltage behavior becomes irregular. The load for this particular set of

data was 170 Ohms. There is also a difference in the initial voltages of the two graphs.

The first graph has a greater initial voltage drop than this graph. This is due to the larger

load across the terminals in the first data set than the load across the terminals in this next

graph. This supports the idea found in the paper that the loaded voltage is proportional to

both the load and the capacity – the higher the load the lower the voltage drops. The

capacity cannot be directly determined in this way without knowing the load value

because of the variance in loaded voltage among different loads. If the knee voltage is

known, then the time remaining can be estimated by taking the slope of the line over time

and finding the point at which it intercepts the knee voltage.




                                              21
                   Figure 11: Battery Draining Characteristic Curve 2



Using V=IR to find the current passing through the load, we take an average voltage

measurement from part of the graph before the knee. The function in Excel gave 5.97

average volts which is half what the battery is supplying due to the voltage divider;

dividing the voltage by the load gives a current of 70.2 mA. To approximate the time

that the battery will sustain the load, we divide the capacity – 1.2 Amp-Hr – by the

amperage of the load and get 17 hours. This is a good approximation considering that the

knee in the graph occurs at about eighteen hours.

       The following graph shows an enormously long delay in settling time for the

loaded voltage. This data set was taken with a load of 146 Ohms on a 33 Amp-Hr

capacity Power Sonic model PS-12330 battery. Notice that the voltage takes over an


                                            22
hour to reach a stable loaded terminal voltage. If the remaining time was calculated

during this first hour it would certainly give a much lower time than is actually the case

due to the steeply sloped line at the start.




                   Figure 12: Loaded Voltage Dropping Characteristics 1



The next graph shows the loaded voltage dropping for the 1.2 Amp-Hr. battery with the

same load across it as the 33 Amp-Hr battery. Compare times of the loaded voltage

dropping between Figure 12 and Figure 13. The time for the drop in Figure 13 is in

several seconds compared to over an hour as shown in Figure 12.




                                               23
                    Figure 13: Loaded Voltage Dropping Characteristics 2



          The next graph shows what happens to a battery after its useful life has expired.

The voltage is not maintained above eleven volts for longer than a few minutes. In this

case, the battery is no longer of any value because it cannot retain any useful amount of

energy.




                                               24
                        Figure 14: Draining of Destroyed Battery



       A last set of experiments were performed with variations in the ambient

temperature for the battery. First a heated environment was done using a plastic tub with

insulation and a heating blanket to keep the battery in a temperature of about 114º F.

This temperature was measured with a small glass thermometer. Secondly, a cooled

environment was achieved using a small refrigerator. Inside the refrigerator the

temperature remained around 26º F. Finally, the battery was drained at room temperature

or about 70º F. For these experiments, the 33 Amp-Hr battery was used with the inverter.

Through the inverter, we plugged in a light and an overhead projector which used 65

Watts and 360 Watts respectively for a total of about 425 Watts. By using the inverter,

we came across another problem due to circuitry built into the inverter for battery


                                            25
protection. The inverter has an alarm built-in to let the user know when the battery is

down to about 10.7 volts. If the inverter reaches a voltage level across its terminals of 9.8

then it automatically shuts off to preserve the battery. For us the alarms simply kept us

from draining the battery to capacity depletion. The following graph shows the results

for all three sets on one graph. The red line is for the warm environment, the light-blue

line is for the cooled environment and the green line represents the room temperature set.


                                             Heated versus Cooled versus Normal Temperature Battery

                                    16

                                    14
   Loaded Battery Voltage (Volts)




                                    12

                                    10

                                    8

                                    6

                                    4
                                                                                          Heated (114 *F)
                                    2
                                                                                          Cooled (26 *F)
                                                                                          Room Temperature (70 *F)
                                    0
                                         1           601         1201           1801         2401           3001
                                                                        Time (seconds)



                                         Figure 15: Heated, Cooled and Normal Temperature Battery Draining



                                     Although these results do not prove anything, they do show support for the idea

that as the temperature decreases, the overall capacity decreases. This is not conclusive

due to the fact that we did not drain the batteries to depletion. The next graph shows the

Voc recovery curves for all three environments. One thing to note is that if the battery


                                                                           26
capacity shrinks as the temperature drops then Aylor’s theory does not hold for changes

in temperature because according to the Voc recovery, the cold battery still has the most

capacity of them all.


                                                Heated versus Cooled versus Normal Temperature Open
                                                           Circuit Voltage Recovery Curves

                                   12.2
 Open Circuit Voltage Across Battery




                                       12

                                   11.8
          Terminals (Volts)




                                   11.6

                                   11.4

                                   11.2

                                       11                                            Heated (114 *F)
                                                                                     Cooled (26 *F)
                                   10.8
                                                                                     Room Temperature (70 *F)
                                   10.6
                                            1                  601                  1201                  1801
                                                                       Time (seconds)



 Figure 16: Open-Circuit Voltage Recovery for Heated, Cooled and Normal Conditions



                                       One last graph to show how the loaded voltage is affected by load is shown in

figure 17. Here the battery is loaded by two separate loads through the use of the

inverter. One is a simple 65 Watt light while the other is the overhead projector at 360

Watts. The oscillations in the loaded voltage could not be explained at this time. This

does show support for the idea that the loaded voltage shows just how much time remains

using the battery with whatever load is present.




                                                                           27
                                                                   Effects of Partial Load

                                      12.6

                                      12.4
   Terminal Battery Voltage (Volts)




                                      12.2

                                       12


                                      11.8

                                      11.6


                                      11.4

                                      11.2
                                             1   64    127 190 253 316 379 442 505 568 631 694 757 820 883 946
                                                                             Time (seconds)



                                                      Figure 17: Partial Loading Effects on Loaded Voltage



                                       A final conclusion for the data logging is that we did not prove Aylor’s theory of

open-circuit voltage but did give support for a linear region with the loaded voltage. The

ideal graph would have been something showing the open-circuit voltage alongside the

battery capacity, but measuring battery capacity was not readily available to us. Further

testing on our system as a whole could be done to see how close our battery monitoring

techniques resemble the actual battery capacity.



Battery Monitor

                                       The main function of the battery monitor will involve the tracking and reporting

of the battery state of charge (SOC). The technique the team will implement is based on



                                                                               28
the techniques developed by Aylor et al. [3]. The techniques laid out in this article

involve two measurements of the electrical condition of the battery. They are the open-

circuit (or unloaded) voltage (OCV) across the battery terminals and a coulometric

measurement which tracks the current discharged from the battery.

       The monitoring methodology works as follows. Each battery has a predetermined

total capacity. The coulometric measurement allows a user to determine how much of

that capacity has been used, and therefore how much remains. However, that usable

capacity is not constant over the life of that battery. Also, we have not verified that the

charge controller circuit used will always provide a total charge to the battery. Battery

capacity tends to vary with age, use, and temperature. For short periods of time, the

coulometric measurement is rather accurate. In order to deal with the degradation of the

accuracy of that measurement, the open-circuit voltage will be measured. This

measurement may give an accurate account of the total remaining capacity available.

The OCV measurement does have a few drawbacks. First, it can take between one half-

hour to many hours for the OCV to stabilize. Also, by its very definition, the open-circuit

voltage measurement requires that the load be disconnected from the battery.

       Other means of measuring the battery state of charge include a direct specific

gravity measurement and a loaded voltage measurement. Specific gravity has the most

direct relationship to total capacity, but it can be measured only by physically removing

the cover of the battery. This is simply impractical, since requiring consumers to remove

the battery cover often could expose them to harmful chemicals. The team has been

unable to find a sensor that can be permanently inserted in to the battery to measure

specific gravity. The loaded voltage can be attractive because like OCV it has a linear




                                             29
relationship with total capacity, but doesn’t require the load to be disconnected from the

battery. However, that relationship is linear only under constant current conditions. The

solar power system is intended to be used with a variety of appliances, included those

involving non-constant loads (and therefore drawing non-constant currents), like motors.

       Thus the coulometric measurement and the OCV measurement remain options,

although neither alone will be sufficient. They can be combined. Under normal

operating conditions, the coulometric measurement will be used to update remaining

battery capacity every ten seconds. To ensure that the error does not build up in the

coulometric measurement, the OCV voltage measurement will be performed once per

hour to update total remaining capacity. By using a logarithmic time scale, it becomes

possible to predict the OCV with no more than 4.7% error [3]. This result from Aylor’s

paper was taken on faith, and the team did not attempt to independently verify it. Such

verification would have been useful and would have lent more credibility to the project.

In many cases the error is much less. This prediction does still require 6.5 minutes of

unloaded battery operation, but it certainly is an improvement over the much longer time

normally necessary.

       One glaring problem remains in this plan. Despite the prediction algorithm, the

OCV still requires over six minutes of unloaded “rest” time. In some circumstances, such

as those involving medical equipment, this period is unacceptable. As shown in Figure 1,

the system block diagram, the team will implement a technique using two batteries. A

larger primary battery will supply power most of the time. During the short period when

the OCV must be measured for the primary battery, a smaller secondary battery will

power the load.




                                            30
        Also, one major goal of the battery monitor is to display output not only in terms

of percent of battery capacity remaining, but more usefully as time of use under current

load remaining. This will require the microprocessor to track and store discharge rate

over a period of time, then calculate the remaining time of use. Total energy

consumption will also be measured. The user will access this information via an LCD

display.

        It has been shown that the open circuit voltage (OCV) measured across the battery

terminals varies linearly with the state of charge (SOC) measured as percent of total

capacity [3]. This relationship has been quantified [5]. Table 2 shows this relationship.

              Table 2: Open Circuit Voltage vs. State of Charge Relationship

                          Open Circuit Voltage [V]   State of Charge
                                             12.66            100%
                                             12.45             75%
                                             12.24             50%
                                             12.06             25%
                                             11.89              0%



Figure 11 is a plot of this relationship.




                                              31
                        Figure 18: Plot of Data Points from Table 2

This is yet another case where the team accepted this important data on the assumption

that is correct, without attempted to verify it. In hindsight, verification of data this

important should have been the part of the initial project stages. Based on this plot and

the five data points from Table 2, a relationship between OCV and SOC can be

developed. Take two points from Table 2, say (12.66, 100) and (12.06, 25). The slope of

the line representing this relation is given by

                                          SOC1  SOC 2
                                     m
                                          OCV1  OCV 2

                                         100  25
                                  m                  125 .
                                       12.66  12.06

Using the point-slope form of the equation of a line, with SOC represented as the

dependent variable and OCV as the independent variable,


                                              32
                              SOC  SOC1  m(OCV  OCV1 )

                              SOC  100  125(OCV  12.66)

                          SOC  125  OCV  (125)(12.66)  100

                                SOC  125  OCV  1482.5 .

The solid line in Figure 11 is a plot of this relationship. After viewing the results, it was

decided that this relationship is sufficient, and more rigorous data interpolation algorithm,

like a least squares fit, were not necessary. The project could have benefited from the

more rigorous discussion, as it could give a provable measure of error. Nonetheless, this

relation is used to derive the lookup table implemented in the microprocessor to compare

measured OCV to SOC. The lookup table is generated by solving the relation for OCV

as follows

                                           SOC  1482.5
                                   OCV                 .
                                              125

The lookup table is shown as Table 3.

               Table 3: Lookup Table Based on SOC vs. OCV Relationship

                                     SOC [%]        OCV [V]
                                           100        12.66
                                            95        12.62
                                            90        12.58
                                            85        12.54
                                            80        12.50
                                            75        12.46
                                            70        12.42
                                            65        12.38
                                            60        12.34
                                            55        12.30
                                            50        12.26
                                            45        12.22
                                            40        12.18
                                            35        12.14
                                            30        12.10
                                            25        12.06



                                               33
                                                  20    12.02
                                                  15    11.98
                                                  10    11.94
                                                   5    11.90
                                                   0    11.86



Note that the relationship is not completely linear, as the OCV at SOC of 0% is 11.86V in

Table 3 and 11.89V in Table 2. However, this linear assumption is will not adversely

affect the performance of the battery monitor. The error between the linear assumption

and the actual data is at its greatest

                                 11.89  11.86
                                                100  0.25% .
                                     11.89

        At this point, note that the charge controller and microprocessor are both active

circuits, and thus require power from the battery to operate. So draining the battery

capacity to zero would be detrimental to the system operation. Thus Table 3 must be

adjusted to account for this possibility. Based on a procedure similar to that discussed

above, Table 4 was generated by setting its lower limit at 11.94 V, or 10 % SOC on an

absolute scale.

                      Table 4: Actual Implementation of Lookup Table

                         SOC
                          [%]            OCV [V]         Hex sent to LCD
                         100              12.66                 2A
                          95              12.63                 B9
                          90              12.59                 39
                          85              12.55                 B8
                          80              12.52                 38
                          75              12.48                 B7
                          70              12.45                 37
                          65              12.41                 B6
                          60              12.37                 36
                          55              12.34                 B5
                          50              12.30                 35
                          45              12.27                 B4
                          40              12.23                 34



                                                   34
                       35           12.19                   B3
                       30           12.16                   33
                       25           12.12                   B2
                       20           12.09                   32
                       15           12.05                   B1
                       10           12.01                   31
                        5           11.98                   B0
                        0           11.94                   30



       Table 4 also includes the hexadecimal value which is sent to the LCD output

routine for a given SOC. The table works as follows. The A/D converter measures

voltages in the range of 0V to 5V. The range needed to measure the battery condition of

11V to 13V will be mapped using an operational amplifier circuit to a range of 0V to

2.5V. Figure 19 shows these signal conditioning circuits.




             Figure 19: Signal Conditioning Circuits for A/D Measurements



                                            35
Note the two main circuits in dashed boxes. The upper circuit conditions the open-circuit

terminal voltage as described above. The lower circuit conditions the voltage across the

shunt resistor, used to measure the current drawn from the battery. This portion of the

circuit will be discussed later in the report.

        The A/D converter on the Motorola 68HC11 can measure voltages between 0 and

5V. However, this range is not fixed, and in fact can be influenced by changing the input

to either the VRH or the VRL pins. The actual range of measurement is defined by VRH on

the high end and VRL on the low end. The operational amplifiers used are the LM324

models. These op amps have a single-sided power supply, 0V and 5V. These op amps

were chosen in favor of other types (such as the LM741) which require double-sided

power supplies since a single-sided power supply is readily available from the

microprocessor. Attempts to create a double-sided power supply were unsuccessful.

        Yet this decision has consequences. The LM324 op amps do not perform well at

output voltages near 0V and 5V. Specifically, performance at 5V is very poor, as the op

amps reach saturation usually around 3.7V. Performance near 0V is much better,

although still not ideal, with saturation usually occurring near 0.5V. So since the chosen

op amps cannot output up to 5V, the VRH pin was set at 2.5V. Thus the full eight bits

used by the A/D converter measure only 0V to 2.5V. VRH is held at 2.5V using an

LM336Z2.5 2.5V precision voltage reference and a simple voltage follower circuit. The

1 k resistor and 1 F capacitor were included at the suggestion of the 68HC11

programmer’s reference manual.

        The signal conditioning circuit for the open-circuit voltage maps voltages in the

range of 11V to 13V from the battery terminals to 0V to 2.5V for measurement by the




                                                 36
A/D converter. This range of 11V to 13V was assumed based data reported from outside

sources. In hindsight, the team should have performed more testing to verify that this

range is suitable for our specific battery.

        The signal conditioning circuit consists of a voltage divider, used to

approximately divide the voltage by four, followed by a voltage follower op amp, and

then a difference amplifier. A general difference amplifier circuit, taken from a linear

circuits textbook, is shown in Figure 20.




                    Figure 20: A General Difference Amplifier Circuit

The output of this circuit vo is given by the equation

                                          1  R1 
                                  R           R2 
                                                     v   R 2 v .
                             vo   2
                                  R    
                                         R                1
                                                          R 
                                                    
                                                       2
                                   1    1  3          1
                                                R4 

For the OCV signal conditioning circuit, the following resistor values have been used:

                                           R1 = 199

                                          R2 = 1104

                                           R3 = 304

                                          R4= 988.



                                               37
Note also that in this case, the input v1 is held at 2.5V. So based on these resistor values,

the output vo of this circuit is


          vo  
                          
                1104  1 
                             199          
                                  1104 v   1104 2.5V   1.243v  13.87 .
                       
                           
                199  1  304
                                   988
                                          
                                         in 
                                             199 
                                                                    in




Note that vin in this equation is the open-circuit voltage across the battery terminals (i.e.

before the voltage divider). In order to verify this conclusion, the circuit was tested over

a large range of input values. These data values were then used in a least squares fit

algorithm, implemented in Matlab, to find the actual equation of the characteristic curve

for this circuit. This equation was found to be

                                   vo  1.243 vin  13 .874 .

Figure 21 shows a plot of the measured data.




                                               38
              Figure 21: Characteristic Curve for OCV Signal Conditioning Circuit

So the OCV signal conditioning op amp circuit behaves as expected. Note that the op

amp hits output saturation on the low end when the input voltage is between 11.68V and

11.78V. If the OCV vs. SOC data from outside sources is correct, then this should not be

a problem, as any input voltage that needs to be measured is in the linear region.

However, the team should have taken data for our battery to verify that is circuit is

sufficient.

        The second electrical characteristic that must be measured is the current drawn

from the battery. This is accomplished by using a small shunt resistor, with a precise

value of 1m. Since the current drawn from the battery is limited by fuses to a



                                              39
maximum of 50A, the voltage across this shunt resistor varies from 0 to 50 mV. That

second signal conditioning circuit is also a difference amp, but this one acts like a straight

gain, multiplying the input voltage by a factor of 50. Specifically the resistor values for

the circuit are

                                      R1 = 200.67 k

                                       R2 = 9.99 M

                                      R3 = 200.17 k

                                       R4 = 9.96M.

Thus the actual equation relating vin to v0 is given by

                                       v 0  49 .78 * vin .

Figure 22 shows the data gathered to test the operation of this op amp circuit.




                                               40
          gure 22: Characteristic Curve for Current Signal Conditioning Circuit

Based on a least squares fit of data taken across the input on the op amp, the equation is

                                   v0  49 .9vin  0.027 .

These two equations are almost identical, so we can verify that this op amp signal

conditioning circuit does indeed work correctly.

The A/D converter will read a two digit hexadecimal value between $00 and $FF based

on the measured voltage. This value will be used as the lower byte of the address in the

lookup table. The upper byte will be fixed. For example, if the A/D converter measures

2.5V, it will return a value of $FF. Assuming the upper byte of the address where the

lookup table is located is $01, the address $01FF will contain the value $2A, which



                                             41
corresponds to 100% capacity in Table 4. The code used to implement this algorithm is

included in Appendix A.

       The encoding scheme used for the hexadecimal value sent to the LCD is as

follows. The OCV measurement will always generate a SOC value multiple of 5%.

Thus the ones digit which needs to be displayed on the LCD is either a zero or a five.

The tens digit can be 0 through 9, with a value of 100% capacity presenting a special

case. The value sent to the LCD consists of the ASCII value for the tens digit, with one

small modification. The bit just to the right of the highest order bit in the byte is set to 1

if the ones digit should be a five and 0 if the ones digit should be a zero. The decoding of

this scheme is also part of the code in Appendix A.

       Aylor et al. note that although this relationship between OCV and SOC is useful,

in many cases the time required for the OCV between the terminals of a battery to

stabilize is on the order of hours, and becomes prohibitive for using this measurement.

However, Aylor et al. have developed a method to accurately predict the OCV. If time is

plotted as the independent variable on a logarithmic scale such that

                                           t  10 X ,

where t is measured in minutes, then

                                         X  log 10 t .

A possible plot of OCV vs. X is shown in Figure 12. Note that this plot is not based on

actual data, but rather is a theoretical representation of what Aylor et al. claim the OCV

recovery curve will look like.




                                              42
           Figure 23: Possible Plot of OCV vs. Time (on a Logarithmic Scale)

Note the intersection of the dashed asymptotes. The value of X at this point will be

designated Xp. If the slope of the rising asymptote is denoted m, and V0 denotes the OCV

at X = 0 (t = 100 = 1 minute) then the OCV at Xp is given by

                                    VOC  m  X p  V0

Aylor et al. determined experimentally the value of Xp is not consistent for all lead acid

batteries. However its value varies only slightly. In fact, Aylor et al. obtained an

experimental average for Xp,

                                         X p  1.64 .

Thus the open circuit voltage across the battery terminals is given by

                                    VOC  1.64  m  V0 .




                                             43
       However, the relationship between open circuit voltage and X is not actually

linear. Note that as X varies from 0.1 to 0.2, the voltage rises about one-tenth of a volt.

Yet when X varies from 0.3 to 0.4, the voltage rises only about one-twentieth of a volt.

This discrepancy was not discovered until late in our project, and as such, the team

decided that to make the assumption that a linear relationship does exist. This decision

was made to simplify the project, and certainly calls into question the accuracy of the

information reported to the user. In hindsight, the team should have adopted a different

approach.

       Figure 24 is a plot of an actual OCV recovery curve taken by the team. The time

scale is the same as that in the theoretical plot above.




                                              44
                Figure 24: OCV Recovery Curve Plotted on Semilog Scale

This curve is similar to the one Aylor et al. claimed would occur. The curve looks

relatively linear (not withstanding the discussion about linearity above), although the

“slope” of the curve is not constant. Also, it doesn’t exhibit the bend toward a constant

final value that Aylor et al. claim will occur. However this single plot is not conclusive

in any way. More experimentation and data would be necessary to speak with confidence

about the validity of the predictions of Aylor et al.

       Aylor et al. found the average error between the actual OCV measured after

allowing time for stabilization and this predicted OCV to be 1.6%. At its greatest, the

error was found to be 4.7%, and at it’s least, 0.6%. The average error is well within the ±

4% range specified for the A/D voltage measurement in the team’s SEED lab proposal,

and is therefore acceptable. The error of 4.7% is certainly troubling, but Aylor et al.

found that the next highest error was only 2.4 %, so the one instance of 4.7% error seems

to be an anomaly, and can be disregarded.

       Since the load must be disconnected from the battery to measure VOC, the OCV

cannot be practically measured often. Between OCV voltage measurements, a

coulometric measurement, which is also discussed in [3], will be used. Given that the

average current drawn from the battery over some sampling period Ts is Iav, the capacity

of the battery charge used, Cremoved, measured in Amp-hours is

                                                  Ts [ s ]  I av [ A]
                                    C removed                         .
                                                   3600 [ s / H ]

Since the battery being used in this case has a total maximum capacity of 100 AH, the

total capacity remaining, Cremaining, is given by

                                C remaining  100 AH  C removed .


                                                  45
However, this discussion of coulometric measurement assumes a constant load current.

As the load current increases, the battery capacity decreases more rapidly. Thus the OCV

measurement will be used once per hour to more accurately set the total remaining

capacity, leaving the final coulometric measurement equation to be

                                C remaining  C OCV  C removed .

When the SOC, as given by the OCV measurement discussed above, is 100%, then COCV

= 100AH. This coulometric measurement is practically implemented by measuring the

current once every ten seconds. Each value of current is added to a running sum, which

has a limit of 1 AH. When the sum reaches 1 AH, the percent capacity displayed to the

user is decremented by 1% and the sum of currents over that period is divided by the

number of ten second intervals in that period, thus providing an average current draw

over that period.

       Based on this average current, the program, then calculates the time of use

remaining. Data provided by the battery manufacturer correlates rates of discharge

current to maximum possible time of use. Figure 25 is a plot of that relationship.




                                               46
             Figure 25: Plot of Discharge Current vs. Maximum Time of Use

This curve is implemented in the code as a lookup table. The lookup table correlated

discharge rate to maximum time. That maximum time is then multiplied by the current

percent capacity, giving a remaining time of use to the user.

       The implementation of the battery monitoring technique and mathematical

analysis outlined above will be accomplished using assembly language for the 68HC11

microprocessor. The program consists of a main program loop which handles the OCV

and current measurements and updates the LCD display.

       The initialization section configures the microprocessor to use each of the

necessary peripheral devices. The techniques used to employ the 68HC11 A/D converter




                                            47
were drawn from [4]. Configuration of the A/D converter is accomplished by setting the

correct bits in the designated A/D control registers. To turn on the A/D charge pump, the

ADPU bit in the OPTION register must be set. The voltage that the A/D charge pump

produces is used to run the group of capacitors that are utilized in the A/D converter

system. This initialization is seen below.



START            ldaa     OPTION
                 oraa     #$80
                 staa     OPTION
                 jsr      DELAY

After the charge pump is activated, the program must wait until the pump and comparator

circuit is stable.

        Next, the A/D control/status register ADCTL will have the MULT bit set and the

SCAN, CD, CC, CB, and CA bits will be set to zero. The MULT bit set to 1 will cause

the A/D converter to sample all four channels at once. The code which sets the ADCTL

register is seen below.

                 ldaa     #$10
                 staa     ADCTL


        The initialization will produce a result on pin PE1 (ADR2) for the OCV and PE2

(ADR3) for the current measurement.

        The CCF bit in the ADCTL register is a read-only status bit. When the A/D

converter is finished, the CCF bit goes to 1. The code polls the bit and when the bit goes

high, valid results can be read from the PE1 and PE2 pins. This is seen in the code below.

                 clrb
POLLAD           ldaa     ADCTL
                 incb



                                             48
               anda #$80
               cmpa #$80
               bne  POLLAD

       The OCV will be measured by the A/D converter once per hour. This is

accomplished by first measuring the voltage V0 one minute after the battery is open

circuited, and then waiting for 5.5 minutes, and then measuring the voltage VS. The result

will be approximately given by

                            VOC  2  (VS  V0 )  V0  2VS  V0 .

       The last part of the battery monitor program is taking the data gathered inside and

displaying it to the LCD display for the user. This is done by a series of LCD subroutines

that can be called throughout the program to update the display. The LCD also needed to

display the data in a user friendly manner. The display was set up to look like the

following table:

                                Table 5: LCD Output Display

         C    a    p    a   c     i   t    y             #   #   #   %
         T    i    m    e         L   e    f         t       H   H   H   :   M M


The # symbols indicate where the value of the total percentage remaining is to be

displayed, from 0% to 100%. The H and M symbols indicate where the hours and

minutes will be displayed for the amount of time left under the current load. Using this

display, we will not be switching back and forth between various screens. These values

are deemed to be the most vital for the user.

       Figure 13 below is a flowchart for the overall battery monitoring program.




                                                49
                 Figure 13: Flow Chart for the Battery Monitor Program



       Aylor et al. outlined a method useful for predicting the OCV in only a few

minutes. Aylor et al. go further to discuss simplifying the final equation so that it can be

efficiently implemented in a microprocessor. Note again that this mathematical analysis

is only approximate, as a true linear relationship does not exist. This equation is repeated

below for convenience

                                    VOC  1.64  m  V0 .




                                             50
Recall that V0 was defined to be the OCV at X = 0 (t = 1 minute). Now define XS as X

such that 0 < XS < 1 (1 < tS < 10 minutes) and VS as the OCV at X = XS (t = tS). Then the

slope is given by

                                        V S  V0 V S  V0
                                   m                    .
                                        XS 0       XS

Since XP = 1.64

                                   V S  V0                       1.64
                        m XP               1.64  (VS  V0 )       .
                                      XS                           XS

The subtraction (VS – V0) is a relatively efficient arithmetic operation in the

microprocessor. However, both the division and multiplication required to evaluate

1.64/XS and multiply it by the earlier difference are extremely resource intensive and

overly complex. The 68HC11 can perform division, but a simpler approach is more

appealing. Ideally, the factor 1.64/XS would be equal to a power of two, say 2N for some

N, since multiplication by powers of two is equivalent to binary left shifting. Letting

                                          1.64
                                                2N
                                           XS

implies the following possible values for XS

                             n  0  X S  1.64 (t S  43 .7 min)

                              n  1  X S  0.82 (t S  6.6 min)

                             n  2  X S  0.41(t S  2.57 min) .

Of these choices, tS = 6.6 minutes is the most reasonable since the time period is not too

long, but it is long enough to ensure that the slope of the linear portion of the OCV curve

is measured accurately. Thus the battery monitor will sample the OCV at X = 0 (t = 1

minute) and XS  0.82 (tS  6.5 minutes). So with N = 1 and


                                               51
                                  m  X P  2  (VS  V0 )

the equation used to compute VOC becomes

                           VOC  2  (VS  V0 )  V0  2VS  V0 .

       The program which runs the battery monitoring system must be stored in some

non-volatile form on the microprocessor. The 68HC11 used includes on chip EEPROM.

The development board also has the Buffalo monitor program in ROM. When the HC11

is reset, Buffalo checks the voltage level on pin PE0. If PE0 is low, Buffalo executes

normally. If PE0 is high, Buffalo begins execution at the first location of EEPROM

memory, in this case $B600. The code in Appendix A includes a small portion which

dumps all of the memory from EEPROM, where the program will be stored, into RAM,

and begins executing at the beginning of the program.

       Note that in Figure 1, the control unit contains two solid state relays. These relays

are used to connect or disconnect either the primary or the secondary battery. Both relays

are single pole single throw relays manufactured by Crydom. These were the only relays

the team could locate. Also included in the full code in Appendix A are portions use to

switch the relays on and off, and therefore switch between batteries.

Solar Panel/Battery/Inverter Interaction

       The inverter block is the Tripp Lite PowerVerter Ultra-Compact Inverter PV500

which is capable of supplying 500 watts of continuous power and will enable a surge of

power up to 800 watts (Figure 26).




                                            52
                               Figure 26: Tripp Lite PV500



This inverter will convert the 12 volt dc input from the battery into the 120 volt AC 60Hz

output that will run the appliances. The PV500 is a compact inverter which weighs

2.50lbs. This feature was significant in selecting the inverter. Since one of the design

goals is to make the device portable, a contribution of 2.50lbs. to the complete system is

within reason. The inverter includes three outlets that each supply 120 volts AC at 60 Hz.

The user can utilize all of the three outlets. However, the combined load to the inverter

can not exceed 500 watts. The inverter also includes a low battery alarm. This alarm

sounds when the battery’s voltage drops to 10.4 volts. When the battery’s voltage is 9.7

volts the inverter will completely turn off, thereby protecting the battery from a deep-

cycle discharge which is harmful and limits the battery’s life span.

The inverter’s output wave form, as seen below in figure 9, is a periodic stair step

waveform. The output did not seem to act adversely with the devices that, in testing, were

powered by the inverter. Some of the devices that were included in the test are a function

generator, overhead projector, and sun lamps. However, if the user of the system finds

that this waveform is not sufficient, another inverter can replace it by simply removing

the PV500 and connecting a better suited inverter in its place. This shows one aspect of

the systems modularity.




                                             53
                      Figure 27. Output waveform of PV500 inverter



       As described above, the battery monitor will utilize a LCD display. The unit,

which is powered by 9 volts dc, will draw power from the 12 volt dc battery. The voltage

regulator that will be used in the design is from National Semiconductor.

       The battery that the team currently plans to use as the primary power storage

source is a deep-cycle lead acid battery, rated for a capacity of 100 Amp-hours. A deep-

cycle battery is able to supply a continuous flow of current for a long period, but it is also

capable of supplying short surges of power. The battery also allows the user to deeply

discharge it, up to 80% of its capacity, hundreds of times without being ruined. The

battery supplies 12 volts, and is manufactured by Power Sonic as model PS-121000 NB.

This battery should provide enough total capacity. However, it does present some

problems. It weighs approximately 65 lbs. One of the objectives outlined above focuses

on the size of the overall system. To compensate for this weight, the power unit, as

described in Figure 1, will be mounted on wheels to allow for easy transportation.




                                              54
       A secondary battery will also be used. This battery also supplies 12 volts, and is

rated to a capacity of 33 Amp-hours. It is manufactured by Power Sonic as model PS-

12330. This battery is much smaller in size, weighing only 35 lbs.

       The solar cell array block will be composed of one SM110-12 photovoltaic solar

module from Shell Solar. The 110 watt solar panel will be used to collect energy from the

sun and supply 12 volts to the two lead acid batteries. Solar power was chosen for the

design for many reasons. One reason is that the power source being developed will be

marketed to consumers outside the power grid that do not have easy access to electricity.

Solar power will enable these consumers to collect enough energy to power electrical

appliances that do not exceed 500 watts. The solar panel that we purchased is also

modular. If the user decides that more energy is required, additional solar panels can be

connected in parallel to the initial system to accommodate the user’s needs (via more

power units from Figure 1). The SM100-12 solar panel is 25.4 lbs., 4.3 feet long, 2.2 feet

wide, and 1.6 inches thick (excluding the junction boxes). The module has a rated power

output of 110 watts, a peak power voltage of 17.5 volts, and a peak current output of 6.3

amps. At this current output the panel can completely charge the 100 Amp-hour battery

in approximately 16 hours. This is an advantage since the user can run appliances longer

with less hours of sunlight. The design will utilize one panel and it will be mounted on

the exterior of the frame that houses the battery, inverter, and battery monitor.



Cost

                      Table 6: Parts list/Cost of Project Components

 Budgeted Components
                               Unit Price
 Quantity                      ($)          Description                                  Total Price ($)



                                             55
                       3         4.34    IRFP048 N Channel HEXFET                            13.02
                                         Miscellaneous Charge Controller
                       1            25   Components                                              25
                       5           0.9   LM340T-15 15V Regulator                                4.5
                       1            99   HC11 Development System                                 99
                       2         16.5    LCD                                                     33
                       1          200    100 AH Battery                                        200
                       1            30   Discrete Circuit Components                             30
                       1          119    PV500 DC/AC Inverter                                  119
                       1            25   Miscellaneous Battery Monitor Components                25
                       2           8.5   LM35 Temperature Sensor                                 17
                       1          535    Solar Panel                                           535
                       3            50   Solid State Relay                                     150
                       3            33   Printed Circuit Board                                   99
                       1          100    40 AH Battery                                         100
                       1          150    Commercial Battery Monitor                            150


                                         Budget Total:                                    1599.52
Purchased Components
                           Unit Price
Quantity                   ($)           Description                                Total Price ($)
                       3          4.34   IRFP048 N Channel HEXFET                            13.02
                                         Miscellaneous Charge Controller
                       1            25   Components                                              25
                       5           0.9   LM340T-15 15V Regulator                                4.5
                       1            99   HC11 Development System                                 99
                       2         16.5    LCD                                                     33
                       1          200    100 AH Battery                                        200
                       1            30   Discrete Circuit Components                             30
                       1          119    PV500 DC/AC Inverter                                  119
                       1            25   Miscellaneous Battery Monitor Components                25
                       2           8.5   LM35 Temperature Sensor                                 17
                       1          535    Solar Panel                                           535
                       3            50   Solid State Relay                                     150
                       3            33   Printed Circuit Board                                   99
                       1          100    40 AH Battery                                         100
                       2            43   Shunt Resistor                                          86
                       3            70   DC Output Relay                                       210


                                         Purchased Total                                  1745.52



Used Components
                           Unit Price
Quantity                   ($)           Description                                Total Price ($)
                       2          4.34   IRFP048 N Channel HEXFET                             8.68
                                         Miscellaneous Charge Controller
                       1           25    Components                                             25


                                         56
                            0           0.9   LM340T-15 15V Regulator                               0
                            0            99   HC11 Development System                               0
                            1         16.5    LCD                                                16.5
                            1          200    100 AH Battery                                      200
                            1            30   Discrete Circuit Components                          30
                            1          119    PV500 DC/AC Inverter                                119
                            1            25   Miscellaneous Battery Monitor Components             25
                            0           8.5   LM35 Temperature Sensor                               0
                            1          535    Solar Panel                                         535
                            0            50   Solid State Relay                                     0
                            2            33   Printed Circuit Board                                66
                            1          100    40 AH Battery                                       100
                            1            43   Shunt Resistor                                       43
                            2            70   DC Output Relay                                     140


                                              Purchased Total                                 1308.18

 Efficiency: (Used /
 Purchased)                                                                                   74.95%



Users Manual

        This device is not a toy and has the capability of supplying harmful amounts of

electricity if used improperly. The system should not be turned upside down or leaned

too far in one direction due to the batteries not being held down by anything but gravity.

        This system was designed to charge the battery under bright sunlight days and

capable of discharging up to 500 Watts of power to the user. To use the system for

discharging simply turn on the switch on the inverter located on the side of the box. If

the inverter is on, a slight whirring noise should be heard from the inverter’s fan as well

as a small light above the switch should turn on. After turning on the inverter, simply

plug anything into the inverter outlet plugs to power.

        The inverter will give a low battery alarm with an audible screeching noise at

which point the inverter should be turned off and the batteries recharged. If the inverter




                                              57
is not turned off, it will eventually turn itself off so there is no need for the user to worry

about draining the battery too far.

        The system will charge the batteries automatically if the sunlight is strong enough

to give the power. To use the battery monitoring system, simply plug in a device and

wait for the LCD screen to update. With the current settings in the program, the LCD

display will not show the true time remaining till a full amp-hour has been used. The

capacity will be correct but the time remaining takes a little more time to adjust itself.



ABET Objectives

(a) an ability to apply knowledge of mathematics, science, and engineering (supports

program objective 1)



The battery monitoring algorithm involves mathematical analysis techniques.



(b) an ability to design and conduct experiments, as well as to analyze and interpret

data (supports program objective 1)



This objective was met with the data acquisition through the Keithley for relevant

information concerning the battery characteristics and behaviors under various

conditions. The analysis of such data was done in the section Data Gathering / Analysis.




                                               58
(c) an ability to design a system, component, or process to meet desired needs

(supports program objectives 1 and 3)



The charge controller maintenance circuit involved original design to meet the need of

preventing battery damage from long term stagnation.



(d) an ability to function on multi-disciplinary teams (supports program objective

2)



This project involved work with mechanical engineers in the building of the frame of our

solar energy system. This required making drawings and communicating needs to those

helping.




(e) an ability to identify, formulate, and solve engineering problems (supports

program objective 1)



Project required defining objectives and then breaking down the problems into

manageable sub-problems such as the charge controller and battery monitor. These were

then treated as individual design problems which were then solved to meet the required

criteria.




                                           59
(f) an understanding of professional and ethical responsibility (supports program

objective 2)



Each member of the team was given responsibilities which they were expected to

complete. Each group member successfully completed their work fulfilling their

obligations to the other group members. Proper requisitions for parts were made and

discussion as to the needs for the parts were made to avoid unnecessary purchases.

(g) an ability to communicate effectively (supports program objective 2)



Central to the project is the final presentation, certainly an excellent opportunity to learn

and display formal communication skills. More important than that, the team found that

the lab walk through procedures were very informative. Intense, one-on-one

communication with faculty members provided a chance for the students to groom their

speaking skills in the way those skills will most often be employed in the future.



(h) the broad education necessary to understand the impact of engineering solutions

in a global and societal context (supports program objective 2)



Our project initially set out to target third-world markets. Although it is not nearly

reliable enough at this stage to constitute usage in remote environments, the program and

experience of faculty members provided the students to learn how engineering can

positively affect the world at large.




                                              60
(i) a recognition of the need for, and an ability to engage in life-long learning

(supports program objective 3)



Certainly the most important lessons learned throughout this project had very little to do

with circuit or solar cells or batteries. This project taught us how to approach large

endeavors, and specifically how to (and how not to) break them down into smaller

chunks. The team was been repeatedly reminded that thinking one knows something and

actually understanding it are two very different things.



(j) a knowledge of contemporary issues (supports program objectives 1 and 2)



       For the design, knowledge of current battery monitoring techniques was reviewed

and studied to provide insight into the theories for our project. Also knowledge of such

things as how batteries behave is relevant to making the project meet criteria.



(k) an ability to use the techniques, skills, and modern engineering tools necessary

for engineering practice (supports program objective 1)



       Throughout the project, skills involved in circuit analysis were used to construct

various components such as the battery charging system and the op-amp circuitry

involved in the A/D conversion into the HC11. Also, modern engineering tools were

used such as Matlab to process and analyze information.




                                             61
(l) an understanding of the character qualities needed to conduct oneself honorably

and with distinction in a professional career (supports program objectives 2 and 3)



       For this report, the objective was not specifically met in any way except in the

way group members supported each other throughout the year by meeting together to

discuss our current project status, help each other by giving suggestions or time, and

maintaining a professional appearance in what we write in the lab reports.



Individual Contributions

Sally A. Simmons

The Modular, Scalable Solar Power System has been a challenging project. The

complexity of this project has required the search for information and design aspects to

be assigned to different team members. The following are my contributions to the team.

       Since I was the only non-computer electrical engineer on our team, I took it upon

my self to learn about the power aspects of the project. The search began at the end of

junior year. During the summer I searched for information on DC/AC inverter methods

and became knowledgeable of solar power and civilian solar advancements. In the fall,

one team member and I discussed the possibility of building our own inverter. We

combined the knowledge we had gathered and arrived at one method that seemed to

produce what was required for the design. However, I pointed out to him and my other

team members many safety and efficiency issues that I had noticed in my search. Our

lack of experience and knowledge in power could not only prove dangerous but the

design could be too inefficient for our requirements. Through these major disadvantages




                                            62
and time restrictions, the team decided to buy an inverter and I was in charge of

purchasing the unit.

       The issue of how to power the LCD display was another matter I had to resolve.

The LCD display uses 5 volts however, the battery supplies 12 volts. After some

searching and conversations with a professor, I concluded that the problem could easily

be solved by using a voltage regulator. However, I still had to decide if I should use the

voltage regulator on the HC11 or the LM78M05CT voltage regulator. To make this

decision, I took a current measurement from the battery, read the data sheets for the

voltage regulator on the HC11 and the LM78M05CT, and I talked to a professor to verify

my decision. I finally decided to use the LM78M05CT. My next task was to implement

the LM78M05CT into the project by powering the LCD display. In the final design, a 9

volt regulator was used but it functioned and was connected in a similar manner.

       Another issue I had to resolve was what solar panels to select for the project. As a

part of my selection process, I spoke on several occasions to a technical representative

from Shell Solar. He was very helpful in the selection process. Since all of my knowledge

of solar power was theoretical, he was able to provide me with plenty of practical

expertise. I combined all the information I had gathered and choose the panel that best

coincided with our initial design goals. Once purchased and delivered, I implemented the

solar panel into the final design by connecting them to the charge controllers, batteries,

and necessary fuses. I also did testing on the solar panel, charge controller, and battery

interaction.




                                             63
       I was also given the task to create software to measure the battery’s open-circuit

voltage. This task required that I reacquaint myself with the A/D converter on the HC11.

I also had to create efficient code since our memory is limited.

Furthermore, while implementing and designing the final packaging for the complete

system, I worked closely with the mechanical engineers. I also did much wiring of the

final system.

Matthew Johnson

       This semester’s work begins with a focus on the production of a circuit-board

version of the charge controller portion of overall design. This involves learning the

Orcad Capture and Layout Suite of software which has mostly been accomplished by this

point in the semester. Schematics have been created and netlists generated. The netlists

have also been exported to the Layout portion of the program. Footprints were matched

to each circuit element found in the design ensuring the correct spacing and drilling

during board construction. The components have been arranged in an optimal format

using Layout’s automatic arrangement procedures minimizing possible parasitic

capacitances, resistances, etc., optimizing board space usage, and ensuring feasible trace

manufacturing as well as allowing room for drill holes to be made in the board.

       The breadboard and printed circuit board versions of the charge controller have

been completed and tested for functionality. Data was taken verifying the switching

function of the design. The following weeks work consisted of a connection of all major

portions of the design to ensure successful charging and discharging of the battery as well

as identifying any potential trouble spots. Additionally, further analysis was done on the




                                             64
charge controller circuit as discussed in this paper. I helped to build the prototype used in

our project presentation involving extensive hours in the week preceding the presentation.

       Other miscellaneous work completed includes several original design ideas for the

battery monitor programming. These include the idea of improved methods of scaling

voltage measurements for D/A conversion and the use of a variable to represent the

overall state of the battery and subtracting from this value an amount proportional to the

current measurement taken at the last sample time. This method has been adopted for

estimating the state of the battery between open circuit voltage measurements.

Joshua Peterson

       This semester I have contributed to a variety of aspects of the project. I wrote the

abstract and introduction for this report, and also compiled the some of the written

portions submitted by each group member for his or her individual technical

responsibilities. I also updated various figures and tables to reflect current progress.

From a technical perspective, I have communicated to the group as a whole the technique

we will implement to perform the battery monitoring. I devised a scheme to store the

OCV and current discharge rate lookup tables in memory, and derived those tables

mathematically from available data [5]. I also performed and Internet search to discover

a technique for beginning program execution in EEPROM. I then implemented code to

move the program from EEPROM into RAM, and begin execution. This is the start-up

procedure that is used in the final project. I have spent time this semester learning how to

use the solid state relays and working on developing code to switch between the primary

and secondary battery. Also, I designed and constructed operational amplifier circuits to




                                             65
condition the OCV and current from the battery so they can be easily measured by the

A/D converter.

Jeff Spanogle

       In the initial lab ideas for the semester, I thought of the idea to log the battery

under various conditions and loads to determine if temperature was a factor and as well to

calibrate our lookup table. These lab experiments were put under my supervision along

with devising a means to collect data and ensure the results were accurate and realistic to

our application. After attempting to program in Visual Basic, I found and installed a new

tool for the Keithley called Excelinx. Some time was spent in learning to use this tool

efficiently and debugging some initial problems in using it. I have taken data of various

battery characteristics and done analysis to see what could be used to help us in our

project. I took responsibility to see that the LCD subroutines were not only written but

would work with the rest of the program, correlating between Sally and Josh on what

they were doing with their respective subroutines. Also, I did some debugging of the

final code and much debugging of the testing on the charge controller with solar panel

attached. I also put together the final pieces of the final technical paper and did the

proofreading on it. I wrote the sections for Battery Data Gathering/Analysis, the Users

Manual and a small portion of the Battery Monitoring sections. I also worked with Sally

on the Solar Panel – getting it to charge the battery.

Conclusion

       The charge controller, while a necessary component of the final product, could

have been designed and built using a different angle. Having a microprocessor onboard

the overall system, the charge controller and maintenance charge circuit could have easily




                                              66
been integrated into the battery monitor circuit. The battery monitor only takes current

measurements every 10 seconds. Measurements of the connected solar panel-battery

voltage could be taken in between these. Another relay could be used turning on either

full charge or a resistor limited current depending on the voltage measured. This would

greatly simplify the system improving reliability and performance.

       Since the microprocessor approach was not realized in the time allowed, the

charge controller circuits were adequate for full charging the battery. Longer periods of

times, weeks or months, would be needed to fully judge the effectiveness of the trickle

charge circuit in preventing battery damage. However, some successful design went into

the circuit making it a worthwhile exercise in the project.

       After reviewing the work done by the team this semester, especially with respect

to the battery monitor, some progress was made. The signal conditioning circuits and the

HC11 code work as expected. The team certainly has achieved a working

implementation. However, the accuracy of that implementation is very much in doubt.

The team did not spend enough resources to ensure that the data reported to the use is

actually correct. In this application, that is of the utmost importance, and represents a

glaring mistake. The mathematical support for the OCV prediction scheme presented by

Aylor et al. is shaky at best. Even if the linear assumption is a good enough

approximation to what Aylor et al. claim will happen, the team did not verify those

claims to be true. So the battery monitor works, but doesn’t work well. And for all

practical purposes, that is equivalent to not working at all.

       The project has however, served as a tremendous learning experience. One of the

most important parts of this experience has been compiling this final report. The team




                                              67
has been able to look at the big picture, whereas during the semester we often got caught

up in details. After reviewing the project from a higher level, the team sees that it

certainly could have made some better decisions which would have lent much more

credibility to the project.

References

[1] T. Kirkgaard, “Low Cost PV Regulator” in Home Power, 1999, 70: p.40-42

[2] http://www.global-merchants.com/home/hppanel.htm

[3] J.H. Aylor, A. Thieme, and B. W Johnson, “A Battery State-of-Charge Indicator for

        Electric Wheelchairs,” in IEEE Transactions on Industrial Electronics, 1992,

        39(5): p. 298-409.

[4] HC11 M68HC11 Reference Manual. Motorola Inc., 1991.

[5] http://www.interstatebatteries.com/www_2001/content/faqs/tech_talk/

        maintenance/ocv_chart.htm

Appendix A

*----------------------------------------*
*----------------------------------------*
*
* Constant Declaration Section
*
*----------------------------------------*
*----------------------------------------*
PORTA                      EQU $1000
PORTB                      EQU $1004
PORTD                      EQU $1008
DDRD              EQU $1009
PACTL                      EQU $1026
SCCR2                      EQU $102D
ADCTL                      EQU $1030
ADR2              EQU $1032
ADR3              EQU $1033
ADR4              EQU $1034
OPTION                     EQU $1039



                                             68
EOT               EQU $04
*----------------------------------------*
*----------------------------------------*
*
* Variable Declaration Section
*
*----------------------------------------*
*----------------------------------------*
CARRY                      EQU $2000
TEMPD                      EQU $2002
TEMPX                      EQU $2004
VOC               EQU $2006
VO                EQU $2007
AMP               EQU $2008
CAP1              EQU $200A
CAP0              EQU $200B
HR1               EQU $200C
HR2               EQU $200D
MIN1              EQU $200E
MIN2              EQU $200F
CCOUNT                     EQU $2010
CAPACITY EQU $2012
TA2H              EQU $2014
HOURS                      EQU $2016
MINUTES                    EQU $2018
FLAG              EQU $201A
TEMPA                      EQU $201B
*----------------------------------------*
*----------------------------------------*
*
* Main Program Body
*
*----------------------------------------*
*----------------------------------------*
*
* The program transfers two bytes at a time,
* using register X to count the number of words
* transfered.
*
         ORG $E000
*
* Initialization Section
*
START             CLRB
*
* Disable the SCI



                                           69
*
       LDAA SCCR2
       ANDA #$F3
       STAA SCCR2
*
* Here we initialiaze all of the variables to zero.
*
         CLRA
         CLRB
         LDX #$2000
ILOOP STD 0,X
         INX
         INX
         CPX #$201A
         BHS CTRL
         BRA ILOOP
*
* Initialize the time and capacity to be ASCII zero
*
CTRL LDAA #$30
         STAA CAP0
         STAA CAP1
         STAA HR1
         STAA HR2
         STAA MIN1
         STAA MIN2
*
* Program Control Section
*
         JSR LCD_INIT
*
* These next two commands switch to the secondary battery
*
MEASURE LDAA #$08
         STAA PORTA
         JSR VOLT
         JSR TABLE
         JSR LCD_DATA
*
* These next two commands switch to the primary battery
*
         LDAA #$00
         STAA PORTA
*
* The B register will be used as a counter in VOLT, so clear it
*



                                            70
       CLRB
*
* This loop measures the current, waits 10 seconds, then measures
* the current again. After 53.5 minutes, it jumps back to MEASURE
* where the program measures the OCV again.
*
CLOOP             JSR CURRENT
         JSR LCD_DATA
         JSR WAIT
         INCB
         CMPB #321
         BNE CLOOP
         LDAA SCCR2
         ORAA #$0C
         STAA SCCR2
         BRA MEASURE
*----------------------------------------*
*----------------------------------------*
* Subroutine VOLT:
*
* This subroutine measures the OCV across
* the battery terminals, waits 6.5 minutes
* and measures the OCV again, then does
* the calculation:
*
* VOC=2*V(6.5minutes)-V(0 minutes)
*
* to get an estimate of the real OCV.
* This value is in register B when the
* subroutine returns.
*----------------------------------------*
*----------------------------------------*
*
* Set ADPU to turn on A/D charge pump.
* Use the E clock for timing.
*
VOLT LDAA OPTION
         ORAA #$80
         STAA OPTION
         JSR LCD_DELAY
*
* Start the A/D conversion by writing to the ADCTL register
* The conversion is set up to sample all four channels once
* meaning that
*        SCAN = 0
*        MULT = 1



                                         71
*        CD=CC=CB=CA=0
* Results will be in ADR2
*
         LDAA #$11
         STAA ADCTL
*
* Now poll the CCF flag in ADCTL. When this flag
* goes high, the conversion results are available.
*
POLLAD            LDAA ADCTL
         ANDA #$80
         CMPA #$80
         BNE POLLAD
*
* Once the code drops out of that loop, the results of the
* open circuit voltage (OCV) measurement should be available in
* ADR2, while the results of the measurement of voltage across
* a known resistance will be available in ADR3. Read those results.
*
* VO is measured.
*
         LDAA ADR2
         CMPB #$0
         BEQ FIRST
         BRA NOW
FIRST STAA VO
JUMP JSR WAIT
         INCB
         CMPB #30
         BNE JUMP
         BRA VOLT
*
* The code is delayed for 6.5 minutes then VS is measured. The process is
* repeated the next hour.
* VOC = 2VS - VO
*
NOW LSLA
         SUBA VO
         TAB
         STAB VOC
         RTS
*----------------------------------------*
*----------------------------------------*
* Subroutine CURRENT:
*
* This subroutine measures the current



                                           72
* drawn from the battery. The current is
* measured every 10 seconds.
*----------------------------------------*
*----------------------------------------*
*
* After the VOC is determined, the code will measure the current every 10 seconds
* for the rest of the hour.
*
CURRENT LDAA #$11
         STAA ADCTL
*
* Now poll the CCF flag in ADCTL. When this flag
* goes high, the conversion results are available.
*
POLLC             LDAA ADCTL
         ANDA #$80
         CMPA #$80
         BNE POLLC
         LDAB ADR3
         CLRA
         LDY CCOUNT
         INY
         STY CCOUNT
*
* Sum the currents per 10 seconds until
* we find enough current has been drawn off
* to be 1 AH. When that occurs, we update
* the overall capacity. For example, say we're
* drawing 10 amps from the battery, then the op amp
* circuit will output 0.5 volts, and the ADR3 register
* will have 256/2.5*0.5 = 51.2 in it. For 1 AH, we should
* be able to average 10 amps 36 times, so 36*51 = 1836 = $72C
*
         ADDD AMP
         CPD #$72C
         BHS UPDATEC
*
* If we haven't hit 1 AH, store the accumulated current
* and exit the routine.
*
         STD AMP
         JMP EXITCUR
*
* CCOUNT is the number of current readings
* taken since the last update. Use this to get
* an average current draw over the period:



                                          73
*
*        AMP/CCOUNT
*
UPDATEC LDX CCOUNT
         IDIV
         XGDX
*
* Now the average A/D reading is in Reg B. To convert
* this to a current reading, do
*
*        2.5/256*AVG*1000/50 = 50*AVG/256
*
         LDAA #50
         MUL
         LDX #256
         IDIV
         XGDX
*
*
* If we have to update the capacity and time,
* zero the AMP and CCOUNT variables.
*
         LDY #AMP
         CLR AMP
         CLR 1,Y
         LDY #CCOUNT
         CLR 0,Y
         CLR 1,Y
*
* Data from the battery manufacturer tells the total
* time the battery can operate at a given level of
* current draw. Categorize the average current into
* one of these levels and get the corresponding overall
* time.
*
         CPD #50
         BLS LOOKUP
         LDD #50
LOOKUP           LDAA #$2
         MUL
         SUBB #$2
         LDAA #$E5
         XGDX
         LDD 0,X
         STD CAPACITY
*



                                          74
DIGITS           LDAA CAP0
        CMPA #$30
        BEQ ROLL
        DEC CAP0
        BRA TIME
ROLL DEC CAP1
        LDAA #$39
        STAA CAP0
*
* Now using the data from the average current
* and the total capacity at the current level,
* the program computes the time remaining
* to use the battery. This is computed by
* treated the percent capacity remaining as a fraction
* and multiplying that fraction by total possible
* capacity. For example, if the average current
* discharge is 10 Amps, then the maximum time of
* use is 420 minutes. If the battery is at 74%
* capacity, we do
*
*       420*(74/100)
*
TIME CLR FLAG
*
* Get the current capacity from memory
* and translate it from ASCII to hexadecimal
* representation.
*
        CLRA
        LDAB CAP0
        ANDB #$0F
        STD TA2H
        LDAA CAP1
        ANDA #$0F
        LDAB #$A
        MUL
        ADDD TA2H
        XGDX
*
* Check to see if the capacity is 1200 minutes.
* in this case, multiplying 1200 by capacities
* greater than 54% will cause an overflow in ACCD.
* If that is the case we can account for the problem
* by adding a known offset at the end. So we check for
* that possibility here and set the FLAG variable if it is
* the case.



                                             75
*
       LDD CAPACITY
       CPD #1200
       BNE MATH
       CPX #54
       BLS MATH
       LDAA #$FF
       STAA FLAG
*
* Here we "multiply" the maximum capacity
* by the numerator of the percentage fraction.
* This is accomplihed by adding that maximum capacity
* to itself the numerator number of times.
*
MATH CLRA
         CLRB
ADD CPX #$0
         BEQ DIVIDE
         DEX
         ADDD CAPACITY
         BRA ADD
*
* Now we divide the results by 100 to give us
* the remaining time in minutes.
*
DIVIDE           LDX #100
         IDIV
*
* If we had an overflow case, we need to
* add this offset for correct the result.
*
         LDAA FLAG
         CMPA #$FF
         XGDX
         BNE CONV
         ADDD #656
*
* Now convert the minutes to hours and minutes
* for display to the user.
*
CONV LDX #60
         IDIV
         STD MINUTES
         XGDX
         STD HOURS




                                         76
*
* Finally we call HEX2ASC to convert the hex hours
* and minutes to their corresponding ASCII representation.
* We do the hours first.
*
        CLRA
        CLRB
        STD CARRY
        LDY #CARRY                     * reg Y will be used to access the lower byte of
CARRY
        LDD HOURS
*
* Prepare the highest 4 bits of the LSB of D to be transferred to reg X
*
        LSRD
        LSRD
        LSRD
        LSRD
        XGDX                   * move them to reg X
        STX TEMPX                      * save X
        LDD HOURS                      * reload D with the length of time in hex
        ANDA #$00              * these two commands mask out all but the
        ANDB #$0F              * lowest nibble of HEXCOUNT
        JSR HEX2ASC                    * the low byte of HEXCOUNT can now be
converted
        ADDB #$30
        STAB HR2               * store the 1's digit of the decimal ASCII representation
*
* Now we have to add the amount in CARRY, generated in the HEXTOASC routine
* to what was originally in reg X, but we do that in reg D
*
        LDD TEMPX
        ADDD CARRY
        STD TEMPD
        LDD #$0000                     * reset CARRY to 0
        STD CARRY
*
* Here we run through the same process as above, shift reg D, transfer those four bits to
* reg X, then reload reg D, and mask out all but the least signifigant nibble, call
* HEXTOASC, and store this reults as the 10's digit
*
        LDD TEMPD
        LSRD
        LSRD
        LSRD
        LSRD



                                            77
       XGDX
       STX TEMPX
       ldd  TEMPD
       ANDA #$00
       ANDB #$0F
       JSR HEX2ASC
       ADDB #$30
       STAB HR1
       LDD TEMPX
       ADDD CARRY
       STD TEMPD
       LDD #$0000
       STD CARRY
*
* Now convert the minutes.
*
       CLRA
       CLRB
       STD CARRY
       LDY #CARRY                      * reg Y will be used to access the lower byte of
CARRY
       LDD MINUTES
*
* Prepare the highest 4 bits of the LSB of D to be transferred to reg X
*
       LSRD
       LSRD
       LSRD
       LSRD
       XGDX                    * move them to reg X
       STX TEMPX                       * save X
       LDD MINUTES                     * reload D with the length of time in hex
       ANDA #$00               * these two commands mask out all but the
       ANDB #$0F               * lowest nibble of HEXCOUNT
       JSR HEX2ASC             * the low byte of HEXCOUNT can now be converted
       ADDB #$30
       STAB MIN2               * store the 1's digit of the decimal ASCII representation
*
* Now we have to add the amount in CARRY, generated in the HEXTOASC routine
* to what was originally in reg X, but we do that in reg D
*
       LDD TEMPX
       ADDD CARRY
       STD TEMPD
       LDD #$0000                      * reset CARRY to 0
       STD CARRY



                                             78
*
* Here we run through the same process as above, shift reg D, transfer those four bits to
* reg X, then reload reg D, and mask out all but the least signifigant nibble, call
* HEXTOASC, and store this reults as the 10's digit
*
         LDD TEMPD
         LSRD
         LSRD
         LSRD
         LSRD
         XGDX
         STX TEMPX
         ldd      TEMPD
         ANDA #$00
         ANDB #$0F
         JSR HEX2ASC
         ADDB #$30
         STAB MIN1
         LDD TEMPX
         ADDD CARRY
         STD TEMPD
         LDD #$0000
         STD CARRY
EXITCUR           RTS
*----------------------------------------*
*----------------------------------------*
* Subroutine: HEX2ASC
*
* This routine converts an 8 bit hex number into it's decimal
* equivalent. The code can then add $30 to it later to put it
* in it's ASCII representation. The routine expects the least
* significant nibble in register D and the most significant
* nibble in register X. The results is in register D on exit,
* with the amount of the higher decimal place value carry in
* the CARRY memory location.
*
*----------------------------------------*
*----------------------------------------*
HEX2ASC           CPD #$9
         BHI OVER9
CHECKX            CPX #$0
         BEQ STRIP
         ADDD #$6
         DEX
         BRA CHECKX
OVER9             SUBD #$A



                                            79
         INC 1,Y
         BRA CHECKX
STRIP CPD #$9
         BLS DONE
         SUBD #$A
         INC 1,Y
         BRA STRIP
DONE RTS
*----------------------------------------*
*----------------------------------------*
* Subroutine WAIT:
*
* This subroutine will delay exactly 10
* seconds before returning to the caller.
* This delay is calculated from the time the
* JSR or BSR command ends. It assumes the HC11
* E clock is running at 2 MHz. The contents
* of register A, B, X, and Y are pushed onto
* the stack before they are modified, and popped
* off of the stack before the subroutine returns.
* Thus their values are not modified.
*----------------------------------------*
*----------------------------------------*
*
* The next four instructions push the values in registers
* A, B, X, and Y onto the stack. They will be popped off
* later before returning to the caller.
*
WAIT PSHA
         PSHB
         PSHX
         PSHY
*
* The WAIT subroutine makes heavy use of the IDIV instruction.
* IDIV is called eight times, using 164 microseconds. The next
* three instructions manage the loop counter, and add 6 microseconds
* to the loop, for a total of 170 micro seconds. The loop executes
* $E5C7 or 58823 times.
*
         LDY #$E5C7
WLOOP             IDIV
         IDIV
         IDIV
         IDIV
         IDIV
         IDIV



                                          80
        IDIV
        IDIV
*
* If the loop counter isn't zero, repeat the loop, otherwise
* drop below to exit the subroutine eventually.
*
         DEY
         CPY #$0
         BNE WLOOP
*
* The following IDIV, MUL, NOP, and LDX instructions are simply
* filler to account for the fact that the 170 microseconds waited
* in the loop is not evenly divisible into 10 seconds.
* These instructions simply waste more time.
*
         IDIV
         IDIV
         MUL
         MUL
         MUL
         MUL
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         LDX #$FFFF
*
* The main part of the subroutine has accounted for most of the 10
* second delay, but now restore the A, B, X, and Y registers from
* the stack before returning to the caller.
*
         PULY
         PULX
         PULB
         PULA
         RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine TABLE
*
* This routine converts the
* data byte from the A/D converter
* into an ASCII SOC percentage.



                                             81
* It assumes the data comes into
* register B.
*----------------------------------------*
*----------------------------------------*
*
* Set the upper byte of the address in the lookup table.
* The lower byte is in register B already.
*

TABLE          LDAA #$E4

*
* Move the address from register D into register X
* for the reference to the lookup table.
*
         XGDX
         LDAA 0,X
*
* Move a copy to register B.
*
         TAB
*
* In register A we want the ASCII representation of
* the 10s digit of the SOC, so zero the highest order
* bit.
*
         ANDA #$7F
*
* In register B we want either an ASCII "0" or a "5".
* If the highest order bit is a 1, then we want ASCII "5"
* otherwise, we want ASCII "0". This is tested using
* %1000 0000, or $80 as the cut off. Any values greater than
* or equal to $80 have a "5" as the ones digit. Values less
* than $80 have a "0" as the ones digit.
*
         CMPB #$80
         BHS GREATER
         LDAB #$30
         BRA DISPLAY
GREATER LDAB #$35
DISPLAY           STAB CAP0
         STAA CAP1
         RTS
*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_INIT:



                                             82
*
* This subroutine will initialize the LCD
* and get it ready to send data. This
* subroutine will be called at the
* beginning of the program.
*----------------------------------------*
*----------------------------------------*
LCD_INIT
         LDAB PACTL                        *This will set DDRA7 to be one causing
         ORAB #$88                  *PA7 to be an output.
         ANDB #$BB
         STAB PACTL
         BSR LCD_DELAY                     *This subroutine delays for about 5ms
         LDAB #$3F                  *This loads the correct values to set the
         STAB DDRD                  *Port D pins as input or output
         CLRA
         STAA PORTD                        *The initial value of 0 is stored in PortD
         LDAB #4                    *Here we need to loop for 4 times with the
LCD_LOOP1
         LDAA #$38                  *same command being sent to the LCD
         JSR LCD_SEND *This subroutine actualy sends the command
         DECB                       *Decrements B to get only four commands
         BNE LCD_LOOP1                     *This jumps back if B is not zero

        LDAA #$08    *These are the next four commands
        JSR LCD_SEND *needed to initialize the LCD
        LDAA #$01
        JSR LCD_SEND
        LDAA #$06
        JSR LCD_SEND
        LDAA #$0E
        JSR LCD_SEND
        RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_SEND:
*
* This routine sends commands to the LCD
* that are passed to it via register A.
*----------------------------------------*
*----------------------------------------*
LCD_SEND
         STAA PORTD                 *STORES DB4-DB0 INTO PD4-PD0
         ANDA #$C8 *PREPARES DATA FOR PORTA
         STAA PORTA                 *STORES THE DATA INTO PORTD



                                               83
     ORAA #$10 *CHANGES PIN PA4 HIGH FOR A STRB EFFECT
     STAA PORTA       *STROBES THE E PIN ON THE LCD
     ANDA #$08 * Preserve PA3 which controls the relays
     STAA PORTA       *RESETS THE STROBE PIN FOR DATA TO BE READ
ON LCD
     JSR LCD_DELAY
     RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_DELAY:
*
* This waits for a minimum of about 5
* milliseconds.
*----------------------------------------*
*----------------------------------------*
LCD_DELAY
         PSHA
         PSHB
         PSHX
         CLRA                       *Clears REG. A to be safe
         CLRB                       *Clears Register B for incrementing
LCD_DELAY2
         IDIV                       *spends the most cycles of any instruction
         INCB                       *Increments the B register
         CMPB #$0
         BNE LCD_DELAY2                    *checks for overflow flag
         PULX
         PULB
         PULA
         RTS                        *returns when B overflows (256 loops)
*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_DISP:
*
* This displays the message 'Capacity'
* and 'Time Left' preparing the screen to
* show the data in a user friendly
* fashion.
*----------------------------------------*
*----------------------------------------*

LCD_DISP
     LDX #MSG     *loads the address of the 1st line
     LDAA #$80    *loads A with 1st position on LCD display
     JSR SEND_MSG *jumps to subroutine to send message



                                               84
        LDX #MSG2           *loads the address of the 2nd line
        LDAA #$C0    *loads A with address to 2nd line of LCD
        JSR SEND_MSG *sends entire message string to LCD
        RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine SEND_MSG:
*
* This will send out a string pointed to
* by the LDX register.
*----------------------------------------*
*----------------------------------------*

SEND_MSG
     JSR LCD_SEND *sends initial positioning command
SEND_MSG_LOOP
     LDAA 0,X      *load the 1st character into Reg. A
     CMPA #EOT     *checks for END-OF-STRING character
     BEQ SEND_MSG_END *if END-OF-STRING, end subroutine
     JSR LCD_WRITE        *sends character out to LCD display
     INX           *increment the pointer to the next character
     BRA SEND_MSG_LOOP *repeat loop till END-OF-STRING
SEND_MSG_END
     RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_WRITE:
*
* This subroutine will send a character
* out to the LCD display through register
* A.
*----------------------------------------*
*----------------------------------------*

LCD_WRITE
     STAA PORTD       *This loads DB4-DB0 into PD4-PD0
     ANDA #$C8 *This prepares the data for store in portA
     ORAA #$20 *This makes the RS signal high
     STAA PORTA       *Stores the data into PD=A
     ORAA #$10 *The STRB effect to signify data is to be read
     STAA PORTA       *Stores the signal to portA
     ANDA #$08 * Preserve PA3 which controls the relays
     STAA PORTA
     JSR LCD_DELAY           *delays for the LCD display



                                             85
       RTS

*----------------------------------------*
*----------------------------------------*
* Subroutine LCD_DATA:
*
* This subroutine will send data to the
* LCD display such as the percentage of
* power remaining and the amount of time
* remaining Data is passed via register A
* and register B which contain the ASCII
* characters of the capacity percentage.
*----------------------------------------*
*----------------------------------------*

LCD_DATA
     LDAA CAP1
     LDAB CAP0
     CMPA #$2A               *checks for the case of 100%
     BEQ LCD_100             *branches for the 100% exception
     CMPA #$30               *checks for an initial zero case
     BEQ LCDD0               *branches for initial zero case
     PSHB                    *pushes B onto stack temporarily
     PSHA                    *pushes A onto stack temporarily
     LDAA #$8A               *specifies the position on the LCD display
     JSR LCD_SEND            *sends the command to the LCD
     PULA                    *pulls the original character off the stack
     JSR LCD_WRITE                   *sends the character out to the LCD
     PULB                    *pulls the 2nd character off the stack
     TBA                     *switches REG A and REG B
     JSR LCD_WRITE                   *sends 2nd character of % to LCD display
     JMP LCDPRCNT
LCD_100
     LDAA #$89               *specifies the position on the LCD display
     JSR LCD_SEND            *sends the position command to the LCD
     LDAA #$31               *loads the number 1 and sends it to LCD
     JSR LCD_WRITE
     LDAA #$30               *loads two zeros and sends them to LCD
     JSR LCD_WRITE
     JSR LCD_WRITE
     JMP LCDPRCNT
LCDD0
     PSHB                    *pushes REG B onto stack to save it
     LDAA #$8B               *specifies position on LCD display
     JSR LCD_SEND            *sends the command
     PULB                    *pulls REG B off the stack



                                             86
         TBA                        *sends REG B to REG A
         JSR LCD_WRITE                     *writes character in B to display
         JMP LCDPRCNT
LCDPRCNT
         LDAA #$25
         JSR LCD_WRITE
         LDAA #$CA                  *This sends the cursor to 2nd line at correct place
         JSR LCD_SEND
         LDAA HR1                   *The tens digit of total hours
         JSR LCD_WRITE
         LDAA HR2                   *The ones digit of total hours
         JSR LCD_WRITE
         LDAA #$3A                  *This is ASCII for the ":"
         JSR LCD_WRITE
         LDAA MIN1                  *This is the tens digit of total minutes
         JSR LCD_WRITE
         LDAA MIN2                  *This is the ones digit of total minutes
         JSR LCD_WRITE
         JSR LCD_DISP
         RTS
*----------------------------------------*
*----------------------------------------*
*
* LCD Data Declaration Section
*
*----------------------------------------*
*----------------------------------------*
MSG FCC 'Capacity '                 *the 1st message
         FCB #EOT
MSG2 FCC 'Time Left ' *the 2nd message
         FCB #EOT
*----------------------------------------*
*----------------------------------------*
*
* OCV Lookup Table
*
*----------------------------------------*
*----------------------------------------*
         ORG $E46C
         FCB $30
         FCB $30
         FCB $30
         FCB $B0
         FCB $B0
         FCB $B0
         FCB $B0



                                                87
FCB   $B0
FCB   $31
FCB   $31
FCB   $31
FCB   $31
FCB   $B1
FCB   $B1
FCB   $B1
FCB   $B1
FCB   $B1
FCB   $32
FCB   $32
FCB   $32
FCB   $32
FCB   $32
FCB   $B2
FCB   $B2
FCB   $B2
FCB   $B2
FCB   $33
FCB   $33
FCB   $33
FCB   $33
FCB   $B3
FCB   $B3
FCB   $B3
FCB   $B3
FCB   $B3
FCB   $34
FCB   $34
FCB   $34
FCB   $34
FCB   $34
FCB   $B4
FCB   $B4
FCB   $B4
FCB   $B4
FCB   $35
FCB   $35
FCB   $35
FCB   $35
FCB   $35
FCB   $B5
FCB   $B5
FCB   $B5
FCB   $B5



            88
         FCB $36
         FCB $36
         FCB $36
         FCB $36
         FCB $B6
         FCB $B6
         FCB $B6
         FCB $B6
         FCB $B6
         FCB $B6
         FCB $37
         FCB $37
         FCB $37
         FCB $37
         FCB $B7
         FCB $B7
         FCB $B7
         FCB $B7
         FCB $38
         FCB $38
         FCB $38
         FCB $38
         FCB $38
         FCB $B8
         FCB $B8
         FCB $B8
         FCB $B8
         FCB $39
         FCB $39
         FCB $39
         FCB $39
         FCB $39
         FCB $B9
         FCB $B9
         FCB $B9
         FCB $B9
         FCB $B9
         FCB $2A
         FCB $2A
*----------------------------------------*
*----------------------------------------*
*
* Total Capacity Lookup Table
*
*----------------------------------------*
*----------------------------------------*



                                             89
ORG   $E500
FDB   #1824
FDB   #1668
FDB   #1512
FDB   #1356
FDB   #1200
FDB   #1044
FDB   #888
FDB   #732
FDB   #576
FDB   #420
FDB   #406
FDB   #392
FDB   #378
FDB   #364
FDB   #350
FDB   #336
FDB   #322
FDB   #308
FDB   #294
FDB   #180
FDB   #177
FDB   #174
FDB   #171
FDB   #168
FDB   #165
FDB   #162
FDB   #159
FDB   #156
FDB   #153
FDB   #150
FDB   #147
FDB   #144
FDB   #141
FDB   #138
FDB   #135
FDB   #132
FDB   #129
FDB   #126
FDB   #123
FDB   #120
FDB   #117
FDB   #114
FDB   #111
FDB   #108
FDB   #105



              90
FDB   #102
FDB   #99
FDB   #96
FDB   #93
FDB   #90




             91

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:10
posted:2/13/2012
language:
pages:91