You are on page 1of 54

DC-AC/DC Power Inverter

Team Not Platypus


Matthew Brown
Henry Godman
John Martinez
Dylan Paiton
Matthew Paiz
May 12, 2010
Abstract
An intelligent DC-DC/AC converter system was designed and implemented in the Spring of 2010
for New Mexico Techs Junior Design Class. The intelligent converter draws power from two
energy harvesters; a 400W-12V Sunforce Wind Generator and a 60W-12V Sunforce Solar PV kit.
The power is stored in an Optima 12V sealed lead acid battery. The inverter is comprised of ve
major subsystems: smart battery charger, inverter, measurement system, data logger and internet
interface. Components were selected through decision matrices and purchased online or procured
through the Electrical Engineering department at NMT. Circuits were designed in Protel 99SE and
created from etching and milling processes. Data was sent via HTTP to the EE server on the NMT
campus and displayed real-time information on a web page. Operation of each subsystem was
demonstrated independently and in whole.
1
Acknowledgements
We would like to take a moment to thank the following people for all of their help on this project.
Dr. Erives gave us constant guidance, constructive critique and useful advice throughout the
semester. Dr. Jorgenson was kind enough to let us gure out how to use his milling machine with
no prior experience. Dr. Wedeward and Dr. Rison both helped us with their expertise when we
ran into walls. Norton was a great resource this semester. He let us use materials from his shop
and found exactly what we needed more than a few times. David Park helped with the initial
setup of the milling machine. Andy Tubesing and Chris Pauli were always available to help us get
all the miscellaneous parts that made our project a success.
Dr. Erives
Dr. Jorgensen
Dr. Wedeward
Dr. Rison
Norton Euart
David Park
Andy Tubesing
Chris Pauli
2
Contents
1 Introduction 8
2 Background 9
3 Design and Implementation 11
3.1 Overall Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Field Components and Field Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.1 Wind Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2 Wind Generator Regulation Data . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.3 Solar Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.4 Solar Panel Regulation Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.5 Battery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 DC to DC/AC Power Inverter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3.3 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4 Smart Battery Charger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3
3.4.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4.2 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.5 Data Logger Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.5.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.5.3 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.5.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.6 Measurement Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.6.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.6.3 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.6.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7 Internet Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.2 Problem Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7.3 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.1 Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Bibliography 35
4
A Code For Data Logger 38
B Code For Internet Interface 48
5
List of Tables
2.1 Intelligent Power Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1 Decision Matrix for Data Logger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Decision Matrix for Internet Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6
List of Figures
3.1 Level One Schematic of Intelligent Converter . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Example of Various Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 A Diagram of The SG3524 IC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4 Driver Schematic for Inverter Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 Power Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6 Filter Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.7 Driver Stage Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.8 Finished Inverter Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.9 Three Stage Charge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.10 Battery Trickle Charger Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.11 Protel PCB Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.12 Real Time Voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.13 Client Mode Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.14 Example of Various Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.15 Protel Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.16 Measurement Circuit Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.17 Progress Comparison For Each Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . 34
7
Chapter 1
Introduction
Today we are seeing a fast growing availability of renewable energy harvesters. While the energy
conversion process of these devices produces little to no pollution, the power that is generated is
often intermittent and unreliable. This is best exemplied by the wind generator and photovoltaic
(PV) solar cells; both work well while the wind is blowing and the sun is shining, but fail to pro-
duce when they are not. The purpose of this project is to try to take those two sources and make a
power system that can provide, at least somewhat, a more stable source of energy. To accomplish
this, our team has designed a system where the energy produced from both of these sources is
stored into a sealed lead acid battery. An inverter is connected in series with this battery, produc-
ing 120VAC at 60Hz to emulate wall power. Power and signal characteristics will be measured,
logged, and displayed in real time on the Electrical Engineering server at New Mexico Tech. The
project design was implemented according the specications for the spring 2010 EE382 guidelines
[1].
The following paper outlines the system we developed. First we describe the background of
intelligent chargers, and then we discuss each individual subsystem in detail. For symmetry,
we included individual conclusions for each subsystem, stating its current progress. There is an
overall conclusion at the end of the paper as well, which gives a broader overview of the status of
the project. The scope of this project was to develop a working prototype for the inverter circuit.
It was suggested about three fourths of the way into the project that we develop an enclosure for
the system as well, but a working prototype with proper output was the primary concern.
8
Chapter 2
Background
Intelligent Inverters are currently available on the market. Microchip Technologies provides a
detailed list for the functions of an intelligent inverter (below).
Digital On/Off control for low standby power
Power supply sequencing and hot-swap control
Programmable soft-start prole
Power supply history logging and fault management
Output voltage margining
Current fold back control
Load sharing and balancing
Regulation reference adjustment
Compensation network control and adjustment
Full digital control of power control loop
Communications for status monitoring and control
AC RMS voltage measurement
Power factor correction
Table 2.1: Intelligent Power Functions
They are designed for both grid-tie and off the grid applications. They operate much like uninter-
ruptable power supplies (UPS). The main goal is be able to supply power to a load directly from
a main power source, be it a generator or a wall outlet while available and continue to provide
constant power when that main source of power goes ofine.
A range of technologies is implemented to meet the functions listed above. Computers, microcon-
trollers and FPGAs are all currently used to manage these sorts of systems. Square wave, modied
sine wave and pure sine wave inverters are all implemented as well, depending on the load re-
9
quirements. Analog circuitry exploiting timers and op-amps are used to measure voltages and
currents on these systems. ICs are also becoming more and more popular as devices are more
available for high power applications. The same is true for battery charging circuitry. While the
technology exists to easily display data about the system online, it is not employed often.
Meeting all of the functions above is beyond the scope of this project. For this design, our team
will provide a proof of concept for an intelligent inverter system that can log data online in real
time. The budget for the project was $400. Because of this limited budget, cost was a major factor
when selecting components.
10
Chapter 3
Design and Implementation
3.1 Overall Design
Our intelligent converter will contain ve major subsystems.(Figure 3.1) Each subsystem is de-
signed to accomplish a unique goal. Each subsystem will be described in detail in the following
sections. The rst subsystem to be outlined is the smart battery charger. This system uses a three
stage charging scheme to safely charge the battery from the photovoltaic panels. The second sys-
tem is the data logger subsystem, which receives inputs from other systems and interprets them
for the internet interface. The third subsystem in our overview is the measurement subsystem.
This is used to record the output power characteristics to the load. The fourth subsystem is the
internet interface, which displays the measured power characteristics to the end user. The fth
and nal subsystem is the power inverter, which performs the actual inversion from the input
renewable power sources to the output wall power.
3.2 Field Components and Field Testing
3.2.1 Wind Generator
The Air-X by Southwest Windpower Inc. was provided to test our implemented designs. It is
rated for 12V operation with a boosting function that allows for power output at low RPM us-
ing a brushless permanent magnet alternator. It incorporates two main protection systems. The
rst is over-speed protection that dramatically reduces RPMs at around wind speeds of 35 mph
and the second is hysteresis, which dramatically reduces RPMs when the battery voltage matches
the regulated set point of 14.1V. When the voltage sensed in the generators internal meter mea-
11
Figure 3.1: Level One Schematic of Intelligent Converter
sures 12.75V it will come out of regulation and begin another charge cycle. Peak power output is
maintained through its microprocessor by altering the loading of the alternator [8].
3.2.2 Wind Generator Regulation Data
Minor testing was conducted on the wind generators performance characteristics. We placed
the generator outside on a breezy day and applied different valued resistors ranging from 10k-10
Ohms. Whenever these loads were applied the generator stopped abruptly. We found that if there
is to high of a resistance, the generator will stop supplying current to keep from forcing current to
its lead terminals that could induce an Electro-static discharge(ESD). An ESD will usually damage
circuitry and render our intelligent convert useless. The battery was tested to have a low internal
resistance (less than one Ohm). As such, placing the sealed lead acid as the load to the generator
allowed it to reach high RPMs. A voltmeter was placed across the battery terminals and an am-
meter was placed between the positive terminal of the generator and battery. This conguration
kept the generator from stalling and gave a reading of 12.24V-12.89V depending on wind speed.
The current ranged from 1.5A- 3.2A with a spike in current no more than 4.5A from gusts.
3.2.3 Solar Array
The solar panel array provided is rated at 60 Watts, 12V. The array is made by SunForce and uses
four 15 Watt amorphous solar panels. The array is rated at supplying 5 Amps maximum. Solar
panels on their own are not regulated energy harvesters and therefore need regulation circuitry
that can also maintain maximum power output. Additionally, the regulation circuitry needs to
12
protect the array from current owing back into itself, which can cause damage to the crystalline
silicone structure that converts photons into electrons [9].
3.2.4 Solar Panel Regulation Data
During the research portion of the project we recorded measurements of the solar panels voltage
and current output with the solar panels loaded with different resistances. These measurements
provided data to graph the panels power curve showing that the panels output a relatively linear
current drop from 4.25-3.25A from 1-16V voltage range, then the current drops from 3.25-0.5A
from 16-23V. This gave us a power curve relationship that was graphed to show where the knee
point that can determine the maximum power we can harvest from the solar panel array.
3.2.5 Battery
Lead acid batteries were developed by a French physician Gaston Plante in 1859 and are the oldest
and most widely used electrical storage unit [7]. They can take a fare amount of abuse, high dis-
charge rates and fast charging, but need to be maintained at full charge when not used to ensure
that degeneration of the plates integrity and depth of discharge is not compromised. For long term
storage lead acid has the most favorable characteristics, losing 40% of its charge over one year as
compared to 6 months with NiMH [8]. State of charge can be determined from the terminal volt-
age, though care should be taken since a cold battery has higher than expected value while a hot
one has lower than expected voltage which can prevent a charge cycle from terminating causing
over-saturation and potentially damaging itself and nearby equipment [10]. Allowing 4-8 hours
of rest from charging will provide an accurate measurement of terminal voltage to determine state
of charge.
3.3 DC to DC/AC Power Inverter
3.3.1 Introduction
A DC-AC/DC power inverter is a circuit which modies an input varying or non-varying direct
current (DC) to an alternating current (AC) of a specied voltage and frequency, and a regulated
DC voltage. In the case of this project, the input DC voltage source will be a battery, which is being
supplied by photovoltaic (PV) panels and a wind turbine. As such, the DC voltage will likely be
inconsistent, and considerations will need to be made in order to produce the desired output. This
desired AC output is a 120Vrms, 60Hz pure sine wave, or what would be seen out of a standard
13
US wall socket. The desired DC output is a 12V regulated. This will allow the system to output
power which is usable by any load.
3.3.2 Background
Power inverters available on the market today vary greatly in efciency and output type. Gen-
erally, of higher end inverters, the output waveforms seen are either pure sine or modied sine.
Another characteristic which determines the quality and price of an inverter is the power output
in Watts.[22] There are many inverters which vary in their strengths/weaknesses regarding the
points mentioned. In addition, many circuitry examples are available for those who wish to con-
struct their own inverter.[23][24] In our case, we decided to model our circuit after that found in
[23]. We used an integrated circuit (IC) in to produce a waveform of our desired frequency, and
then used a transformer to amplify the voltage to specication.
3.3.3 Design
The only input to the inverter subsystem is from the battery. As described previously, the battery
is being charged from the PV panels through the charging subsystem and from the wind turbine
through its integrated system. Our key concerns regarding the power inverter system were as
follows:
1. Safety - because we are dealing with high currents, many safety concerns needed to be ac-
counted for
2. Output Waveform - pure vs. modied sine wave vs. square wave
3. Power Output needs to handle at least 500W
4. Efciency generally there are a lot of losses associated with converting power
The inverter will receive DC power from the battery, and convert it to usable DC and AC outputs.
All other subsystems receive information from the output of the power inverter. As such, the
inverter is critical to the integrity of the entire system. Safety concerns must be at the forefront
of the circuit design. These concerns stem to the safety of the users, as well as the circuitry itself.
We recognized this issue, and accounted for it with properly placed kill-switches and fuses/circuit
breakers. The circuit was designed so that if a power spike occurred, or something malfunctioned,
the key components of the system would be saved, and the system would be shutdown.
Our next major concern was the output waveform. The three major waveform options were a
square wave, modied sine wave, and pure sine wave. The difculty of the system increases
14
greatly with each waveform option, respectively. Figure 3.2 shows the three different waveforms
on a single graph.[25] Apure sine wave is required to run any type of load, but most loads can run
on a modied sine wave. The primary side effect to a modied sine wave is a decrease in efciency
and an increase in noise in the system. Fewer (but still a signicant amount of) loads can run on a
square waveform. Because of the immense difculty associated with designing a pure sine wave
inverter, and the limited amount of loads which can run off of a square wave inverter, our team
decided to go with a modied sine wave output. This can be obtained by producing a square
wave from the output, and ltering it to resemble a sine wave. The desired result would look like
an average of the three waveforms presented in Figure 3.2.
Figure 3.2: The vertical axis is Voltage, while the horizontal is Time. As can be seen, the red
waveform is a pure sine wave, blue is a modied sine wave, and green is a square wave. The
specied period (20ms) would vary based on desired frequency.
We used a SG3524 IC to generate the PWM signal, off of which we would create the square wave
output. A general overview of the internal circuitry of this IC can be observed in Figure 3.3.[26]
The IC was the heart of our inverter circuit, and was heavily protected by fuses. The circuitry
which utilized the SG3524 to create an output signal can be seen in Figure 3.4. Following the
circuitry surrounding the SG3524 was the power amplication circuit.
The frequency-regulated output of the SG3524 was then sent to a power amplifying circuit, which
created the desired output. To account for the output power required, we decided to mill the entire
inverter circuit onto copper plating, so as to increase the allowed current ow. We also set up a
parallel transistor conguration before the power was amplied. In order to dissipate the power
delivered to the transformer. This can be seen in the power stage of the circuit, in Figure 3.5. The
circuits displayed in gures ?? and 3.4 were connected via pads J3, J4, J8, and J9. Combined, these
circuits represent the power inverter.
To accommodate for efciency and power output concerns, we designed the entire circuit with
bipolar junction transistors (BJTs). BJTs can typically handle much higher currents than the alter-
native options, MOSFETs.[27] We also placed four BJTs in parallel in the power stage of the circuit
15
Figure 3.3: Relevant pins: Pins 1 and 2 are used for reference pins, to verify that the output is as
desired (using a feedback system described later). Pin 6 is used to determine the desired output
frequency. Pins 7 and 9 are also reference pins. Pin 10 is a shutdown pin, which is used to stop the
output. Pins 11 through 14 produce the square wave output. Pin 15 receives 8v DC power from a
regulator.
to dissipate more power, observable in Figure 3.5.
The output of this circuit as shown is not as expected. It currently outputs a square wave, which
works with any resistive load. The next stage in design would be to convert this into a modied
sine wave, via a lter circuit. Although a prototype is built and tested, the actual circuit was not
integrated. The band-pass lter circuit can be seen in Figure 3.6.
3.3.4 Implementation
The power inverter design chosen will output a standard modied sine wave at 120Vrms and
60Hz. We initially constructed the circuit on a proto-board and were able to achieve the output
we expected from the driver stage. Figure 3.7 shows the output of the driver stage.
We were unable to test the power circuit on a proto-board, so instead we milled the circuit. The
milling process was quite extensive. With the help of David Park, we set up an industrial circuit
mill to build our circuit. We then soldered all of the components on, and tested the circuit with a
test load of a 75 Watt bulb. A picture of the nished circuit can be seen in Figure 3.8.
Our inverter was able to output a maximum 43Vrms at 60Hz. This was tested using a voltmeter.
The primary reason that the circuit did not achieve a 120Vrms output is that the power transformer
16
Figure 3.4: A detailed description of the main component of the circuit, the SG3524, can be seen
above. The red boxed region is the input of the feedback system, which receives the AC signal
generated by the power stage (Figure 3.4), recties it to a DC signal, and steps the voltage down
to within the SG3524s specications. The green region is the input from the battery, which goes
through a kill switch and a power regulator to step the voltage to 8v DC. The blue region is de-
signed to adjust the frequency of the pulse width output. The black box outlines the output of
the driver stage, which will split the waveforms between the positive and negative portions of the
square wave.
Figure 3.5: This circuit receives a square wave from the driver stage of the circuit. It distributes
the power across the BJTs, and sends it to transformers via J10, J11, and J12. The output of the
transformer is then fed to the load, and also back to the J1 and J2 of the driver circuit, for reference.
17
Figure 3.6: This circuit is a standard band-pass lter, to smooth the edges of the square wave.
The theoretical output of the circuit is expected to resemble a sine wave. Actual testing wasnt
completed.
Figure 3.7: This output shows the desired square wave generated between pads J3 and J4 of the
driver circuit. The output is 10Vp-p at 60Hz, which is as expected.
not work like we expected it to. The secondary side of the transformer (the side with the center
tap) we ordered only allows 3A of current to pass through it, which severely limited the power
output. The part was mislabeled as a step up transformer, when in reality it is just a step down
18
Figure 3.8: We used a circuit miller to outline the traces seen between components. The right side
is the power stage, and the left side is the driver stage. The left transformer is used to step the AC
power from the output for a feedback.
wired backwards. We strongly believe that replacing the transformer with a proper one would
allow enough current to ow to step up the voltage to the full 120Vrms.
In spite of the input not being exactly to specication, we were able to record a power reading
through the measurement subsystem from the output of the inverter. Power was received from
the battery, and outputted to a 75W bulb. The power output was successfully measured and
displayed on the internet interface.
The inverter subsystem for the power converter circuit was very close to being a nished prod-
uct. We milled the driver and power stages, and powered a resistive load. Future work would
include constructing the lter circuit design which is mentioned above, and replacing the step-
up transformer with one more suited for our purposes. Beyond that the circuit should work as
expected.
3.4 Smart Battery Charger
The intelligent power converter requires a consistent DCvoltage to be supplied. As such, a battery
coupled with a smart charging subsystem is needed to buffer the unpredictable characteristics of
19
the power sources. The energy stored needs to be maintainable over long periods and have a
large charge capacity. Sealed lead-acid batteries are suited for this task and are reasonably priced
compared to NiMH and Li-ion of similar charge capacity.
Smart charging is used in medical equipment, laptops, mobile phones, and cameras that allow
optimized charging of what are usually expensive batteries that provide long discharge periods
[3]. Using smart charging, the device running on the battery can be alerted to the battery being at
the end its discharge point. Once alerted, the device can either power down without losing data
or provide an opportunity for the user to switch power sources to avoid discontinuous operation
of equipment. Smart charging and monitored charging schemes are being applied to many energy
storage devices, resulting in little human intervention in the charging process.
3.4.1 Background
Typically, smart battery charging incorporates a battery packaged with integrated circuitry that
contains algorithms specic to the batterys chemistry and charge cycle. The amount of voltage
and current supplied by the charger is controlled by the battery which modies its internal resis-
tance to constrict current ow. The circuitry uses voltage, temperature, and duration of charging
to determine the batterys state of charge (SoC) and state of health (SoH), which can be used to
optimize charging and help increase a batteries life expectancy [3].
Life expectancy is decreased by reducing the amount of overcharging and discharging too deep.
Over charging causes grid corrosion on the positive plates and gassing that exhausts the elec-
trolyte, while discharging to deep causes the negative plate to formsulfate. In addition to decreas-
ing the batterys life, these adverse actions can reduce the amount of Amp-hours it can deliver.
There is still much debate as to the denition and classication of intelligent charging systems
by battery manufactures and organizations dedicated to the topic [4]. The term smart/intelligent
charging is used loosely in consumer electronics marketing that generally describes a charging
system that does not require human attention. Many low end electronics and automotive charg-
ers employ multi-stage charging that supply constant current up to 70-80% of the usable charge
range and then supply a constant peak voltage to provide a topping off charge without over-
charging, thus keeping the battery at optimum performance [5]. When the current supplied has
decreased to a substantial value, indicating over-saturation is eminent, a lower oat voltage is
supplied to counter internal discharge. These low end systems are designed for specic battery
types (i.e. SLA, NiMH, Li-ion) which are, in general, lacking charging algorithms which are based
on manufacturing processes or nothing at all.
Some batterys integrated circuitry communicate their desired voltage and current to the charger
by means of the SMBus. The SMBus is based on the I2C bus which uses a data line and a synchro-
nization/clock line for transmitting data [6]. With this conguration the batterys supervisory
circuitry is the master and the charger circuit is the slave. This system requires a much more
20
complex battery setup than was available to us, and as such we will not be using it.
3.4.2 Design
Because the wind generator has the capability of charging batteries on its own, it can be treated
as an independent part of the smart battery charging subsystem. Therefore, the main focus is to
regulate the solar panels to ensure maximumpower output to the batteries and inverter subsystem
without interfering with the wind generators internal regulation. We found that there are three
prominent approaches to intelligently charging a battery.
Fast charging is typically used for smaller rechargeable batteries (i.e. AA, golf carts, and auto-
motive batteries). The side effect of this method is an increase in temperature during charging.
This, in turn, increases gassing and can mislead measurements of terminal voltage, causing over-
charging and reducing the lifespan. An automotive lead-acid can be fully charged from a deep
discharge in roughly six to eight hours using this method.
Trickle charging is a scheme which allows more accurate measurement of terminal voltage en-
abling a full charge to be attainable without risk of over-charging or over-heating. The drawback
to this method is that it can take up to sixteen hours to fully charge a battery [5].
The third approach is three-stage charging. First a constant current is supplied until 70-80% of the
total charge is reached, which takes roughly ve hours. A constant peak voltage is then supplied
to nish charging the battery, which also takes about ve hours. The nal stage uses a oat voltage
that is lower than the peak voltage to prevent corrosion from forming on the positive plate. This
oat voltage will maintain the batterys shelf life and counter its natural internal discharge [5].
This three-stage charging technique takes advantage of the speed of a fast charge, but only when
within safe charge levels. Once the battery is beyond the margin of error created by fast charging,
the trickle charge takes over. This was the scheme we chose for our system. Figure 3.9 gives the
charging characteristics.
Options for the monitored charging scheme vary from simple transistor circuits to complex Op-
Amp, transistor and IC regulators attempting to employ intelligent charging [14]. Attempts at
designing the PV charger from scratch proved to be a very daunting task since our circuit engi-
neering skills beyond simple Op-Amps is novice at best. In addition, trying to understand and
employ the amateur designs found online ended up being a waste of time. A lot of time was
invested reading datasheets from the Linear Technologies and Analog Devices web sites to nd
a solution. Linear Technologies became our vendor of choice because of their extensive online
videos, help documentation, and supplementary applications with parts lists and diagrams which
proved to be very insightful for developing designs.
For the PV charger design we settled on using the LT3652 monolithic step down battery charger
that provides constant-current/constant-voltage charge characteristics, with a maximum charge
21
Figure 3.9: Three Stage Charge
current externally programmable up to 2A [11]. Float voltage and charge duration are also ex-
ternally programmable allowing for design exibility. A 1MHz switching regulator regulates the
maximum programmed average current by taking voltage measurements about an external cur-
rent sensing resistor that is compared to internal voltage references. These are then integrated to
produce an error current ITH that is proportional the average inductor current. This IC will allow
implementing our desired multi-stage charging scheme in addition to the option of designing a
trickle charge feature that can be used to initially charge up a battery from a deep discharge, in-
creasing battery life. When the battery is fully charged, power from the solar cells is directed to
the inverter subsystem. A continuous portion of the PV power is diverted to the battery when
needed. Along with the LT3652, the LT4151 high side current and voltage monitor with I2C inter-
face allows our data logger subsystem to record the batteries state of charge for the user. Minimal
external components are required to operate this IC: a current sense resistor, and a pull up resistor
for the I2C. The IC also has an additional voltage measurement pin that is less accurate then its
primary and could be used to assist the data logger by monitoring the solar panels output voltage.
The battery would be set up as the central hub to the wind generator, PV charger and the inverter
subsystem. This conguration can be modeled as a parallel network where wind, PV and battery
can be assumed as current sources for easy of analysis.
A 1A maximum was desired for the constant-current/constant-voltage charge characteristic up
to 14.4V, where the current supplied drops, over time, to a tenth of the design maximum (0.1A).
22
The battery will then be oated at 13.5V, if the battery drops below 13.2V the 14.4V charge cycle
is initiated, if the battery is below 10V it will be supplied a trickle charge of 0.15A until it reaches
13.2V, were the normal charging cycle takes over [11]. The external components of the LT3652
were built on a proto board to test the operation of the IC in trickle mode since the low current
should not damage the proto board.
In order to properly test the circuit designs, break-out boards were etched for the two ICs. The
LT3652 and LT4151 use the MSOP12 and MSOP10 footprints for printed circuit board (PCB) place-
ment [11][12]. This allows us to test our designs with reasonable exibility, for if we built a PCB
with the components and IC installed, only to nd that there was a wiring problem would have
set us behind an IC that is non recoverable once installed. Also, the same chip could be used in the
nal design reducing cost and labor to getting/using a new/spear IC. Both are little more than
a tenth of an inch long, their input/output pins are roughly 0.035 by 0.0197 of an inch, making
fabrication of the test circuits challenging.
3.4.3 Implementation
Circuit Etching
Using a guide created by our lab manager, Andy Tubesing, we etched our own PCB to house the
ICs for testing their operation [13]. To design the circuit layout and paths we used Protel 99 SE.
Once designed we could print the circuit on blue etching paper that will be used to etch the circuit
image into copper plated circuit board material. The copper was rst cleaned free of oxide, dirt
and oil using steel wool and then washed using gel soap and dried. The blue circuit transcribing
paper was printed onto the circuit board using heat from a clothes iron. The copper plate was
placed in diluted ferric acid and agitated until all of the excess copper was dissolved. The pin
holes were drilled and then the ICs and header pins were soldered to the PCB.
1st Phase of Testing Lab Test
The power generator was set to 17Vbecause of an advisement fromthe LT3562 data sheets to have
a minimum 2V over head from the peak battery voltage. A current of 1.4-2.8mA was observed in
addition to a voltmeter output of 12.21V. When the battery was not connected it maintained a
potential of 12.19V. Next, the power supply voltage was increased to just shy of maximum output,
where the ammeter measurements increased as well, though randomly uctuated. The highest
current value was 10.4mA using the lab power supplies.
Panel Test
23
Figure 3.10: Battery Trickle Charger Re-
sults
The solar panels (all four) were taken outside and
aligned to receive near normal incident sunlight. The
panels were connected to the charging circuit, and the
charging circuit was wired to the battery. We initiated
a trickle charge and observed that the battery was be-
ing supplied with a constant 0.12A throughout testing.
The battery read 12.19Vbefore connection, and then read
12.39V once a connection was made. It then increased
in potential for the next 14 minutes until the voltage
stopped at 12.60V. The charging curve can be observed
in Figure 3.10. Investigating into the battery we found
that some of the other design teams that had used it con-
nected it straight to the power supply to charge it up
quickly, and some had put low ohm resistances across
it to discharge the battery quickly for their testing purposes. Both methods are damaging to the
batteries integrity and reliability. This abuse causes a reduction in charge capacity which explains
our lower maximum potential. Before additional testing could be conducted on another battery,
the negative terminal to the battery came disconnected and fell onto a 0.1 Ohm current sense
resistor. The resistor exploded, and brought our charger circuit testing to a prompt end.
3.4.4 Conclusion
Figure 3.11: Protel PCB Schematic
Our tests showed that the solar panels were much more
stable in voltage and current outputs than the wind tur-
bines.
While waiting for a new current sense resistor to arrive,
our team designed the now tested charging circuit in
Protel. The end goal of this design was to mill the cir-
cuit using a professional circuit mill. Figure 3.11 shows
the PCB schematic designed. We were sure to make the
traces wide as possible for the high current paths since
increasing the cross sectional area will decrease resis-
tance and power loss. This circuit will be used to test the
multi-stage charging functionality. It will also be used
to determine the peak charging voltage, the oat volt-
age, the trip voltage (which starts another charge cycle),
and the maximum average inductor current. The data
acquired will be used to assist in testing integration with the other subsystems. Fixing the bugs
associated with integrating the subsystems will bring the project to completion. Once the lab test-
ing with the fully integrated project is complete the only thing left to do is eld test the Intelligent
24
DC-DC/AC Convert to determine any more errors in the project.
3.5 Data Logger Subsystem
3.5.1 Introduction
Data Loggers are any piece of digital and/or analog hardware systems that keep a log of informa-
tion about a given system. In our case, we are logging real-time voltage and current information
of different parts of our system. We are logging information about voltage and current character-
istics being delivered to our load, voltage and current characteristics of the battery and voltage
characteristics of our energy harvesters. This information is not stored on the system, but rather
piped via Ethernet to the EE server at the school. The information is then displayed and stored on
the server side of our system.
3.5.2 Background
Current technology for data loggers for intelligent inverter subsystems has not advanced much in
recent years. This is because technology has long since met the requirements for such a system.
The real considerations for data loggers come down to the type of hardware that one wishes to
use. For these systems, there is a balance of computing power to energy used that needs to be
considered. For our case we do not need to crunch that much data and also energy is not abundant
or reliable, so we are mainly looking at nding a very low power system that can start and stop
operation automatically. Again, these technologies are available. We broke down the hardware
options into four categories:
1. Computer with a CPU
2. Microcomputer with a CPU
3. Microcontroller
4. FPGA or CPLD
We found examples of several of these in the industry. Green Champ Co., Ltd produces an intelli-
gent grid-tie inverter that uses a CPU to control the operation of the inverter and display charac-
teristics of its operation[15]. Also, we found an IEEE paper explaining how a microcontroller can
be adapted for power systems [16].
25
3.5.3 Design
Our selection process for the data logger started by analyzing how much data were going to need
to handle. We realized that we would be taking inputs from up to four sources simultaneously:
The measurement system, the battery bank, the wind generator and the solar panels. This infor-
mation would then have to send all of this data, as it was collected, over the internet. Assuming a
couple inputs from both the battery and the measurement system, we gured that we would need
anywhere up to eight simultaneous inputs and one continuous output. We would also would
have to utilize several data busses including SPI and IIC and possibly several ADCs to receive
and send data from the logger. We would need to display the data in real-time on the internet, so
we will need to sample the data on the millisecond scale and output at a somewhat slower rate.
The second requirement we analyzed was the ability for system to be able to start and stop auto-
matically from power down/up. Because the implementation of the project would be such that
the power supplied would be intermittent, we needed a system that would be able to restart op-
eration after a loss of power without any assistance from a human operator.
The third requirement was cost. We are working with a very limited budget of $400 so we needed
nd something that would not use a lot of our budget.
The last requirement was power consumption of the data logger. Again, the purpose of the entire
systemis to supply consistent power to a load for as long as possible so we want a data logger that
consumes as little power as possible. We weighted all of these requirements into decision matrix
(Table 3.1).
Computer Microcomputer Microcontroller FPGA/CLPD
Criteria Weight Score Weighted Score Weighted Score Weighted Score Weighted
Cost 4 1 4 2 8 5 20 4 16
Stability 3 2 6 2 6 5 15 5 15
Power 2 1 2 2 4 3 6 4 8
Processing 2 1 2 2 4 3 6 4 8
Total 9 17 10 22 16 44 16 42
Table 3.1: Decision Matrix for Data Logger
From this matrix we immediately saw that the computer and microcomputer we not suitable for
this project. They were too expensive and consumed too much power. Also, it would be more
difcult to have these systems operate independently after a power down. Our choices then were
narrowed down to either the Microcontroller or the FPGA/CPLD. They both offered about the
same functionality and both consume little amounts of power. However, we did not have an
FPGA available that we could easily interface with such as on an evaluation board. We did have
an HCS12 available to us on and evaluation board, the Dragon12 board. This board also has ADCs
on board as well as modules to handle communication over both the SPI and IIC buses that we
26
Figure 3.12: Real Time Voltage Figure 3.13: Client Mode Operation
were planning on using. Furthermore, all of the team members had used this before and were
very to somewhat capable with it. This made the HCS12 the clear winner for our project.
Internet Connection
To implement the data logger, this rst thing we needed to do was establish internet connectivity.
Because the microcontroller had no way to do this by itself, we needed to purchase an Ethernet
module. We considered several, including the SPINET using the ENC28J60 Ethernet controller
[17] and the ENC28J60 Ethernet to SPI Header Board [18]. Without much information to decide
the functionality of these devices, we went with one of the cheaper models that the team members
agreed upon. This was the Wiznet WIZ811MJ [19]. Once the part arrived and we connected it
to the microcontroller, we started writing the driver for it. The driver was written in C (see the
supplementary material for the code). We began by testing the ability to read and write to the
setup registers on the device. Once this was completed we connected the device to a router and
tried to establish a connection to a simple server written in Java. After a successful connection
we then worked on sending packets of data. This took some time as the Wiznet module had
many peculiarities about it. Once we were able to send the sort of data that we wanted, we then
established a connection to the EE server and sent sample data to a real-time display on a webpage
(Figure 3.12).
At this point, we were able to execute the full client mode operation of the Wiznet 5100 (Figure
3.13). This part of the implementation took some time to make successful as well. We were able
to successfully send packets of information at about 100ms intervals without losing any packets.
We successfully increased the size of each packet to about 1kb. This was much more than enough
to send data collected from each subsystem simultaneously at 1ms intervals and display selected
data in real-time. This surpassed all requirements for a live link described in the outline of the
project.
27
Incoming Data
The next stage of testing this subsystem was to generate varying A/D signals on the Dragon12
board, have the HCS12 read that data at intervals of 1ms and see if we could pipe that data as we
got it to the server. We were successful in doing so and proved the full functionality of the data
logger subsystem.
Powering the System
Once we were able to verify a full-path functionality for the data logger, we then tested the sub-
systemfrompower fromthe battery. I rst measured the output of the AC-DCconverter the board
came with to transform wall power to DC. I measured an output of 11.42V. We were unsure as to
how we were going to generate this DC power needed by the Dragon12 Board. We then realized
that at the input of the power plug, the board had a simple 5V linear regulator, so any DC source
above roughly 8V should work. We connected another Dragon board directly to the battery and
veried that this was the case. We then connected our board directly to the battery and again
veried the operation of the board (Figure 3.14). The Wiznet was mounted on the Dragon12s
breadboard and powered from the 5V bus on the board. This subsystem was now fully functional
and could be powered out in the eld.
Figure 3.14: Example of Various Waveforms
28
Automation
The last step of making sure that this system could begin operation automatically upon startup
was fairly simple. Previously we had been storing all of the code into the HCS12s RAM. Once
all completed, we placed the code into EEPROM (non-volatile memory) and switch the Dragon12
Board to Load from EEPROM on startup. We then powered down the system, powered it back up
and veried that it continued operation as it should.
3.5.4 Summary
To summarize this system, we were able to establish full connectivity to the EE server, send 1kb
packets of data at 100ms intervals, simulate real time data by interrupt driven A/D readings,
power the system off of the battery bank and have it be able to continue operation after a power
loss. If we were to attempt this again, we would not use the Wiznet 5100. Its interface was very
unordinary and hard to use. We would denitely use the Dragon12 Board again as it was very
easy to use and satised all of our requirements.
3.6 Measurement Subsystem
3.6.1 Introduction
The Measurement system could be any hardware that gathers measurements from any particular
output. As for our project, this is a subsystem of the intelligent DC-DC/AC converter which mon-
itors and collects measurements from the Inverter. The outputs that are needed to be measured
are the frequency, voltage, current, and power factor. Those measurements need to be outputted
to a data logger which will then be put out to the internet.
3.6.2 Background
Today many tools are made to measure voltage, current, frequency, and power from systems.
These include ICs, circuit components, and voltmeters. A four quadrant multiplier allows us to
multiply an analog signal and output a signal to tell us what direction it is going. That is to tell us
whether or not the signal is leading or lagging. This was our reasoning for using a four quadrant
multiplier in our system. This led us in a curtain direction in our decision for a design.
29
Figure 3.15: Protel Schematic Figure 3.16: Measurement Circuit Prototype
3.6.3 Design
There are many design examples for the measurement of the values that are needed in a sys-
tem such as the one we have to create. The system selections started by knowing what kind
of measurements were being outputted. An estimated voltage of 120 and current of 4A were
outputted from the inverter. Two main ways to going about creating the measurement system
is to create it with an IC that has a four quadrant multiplier and building the circuit with im-
plementing the multiplier. Cost was not a big issue for either design since we had a budget of
400andtheestimatedcostforeitherdesignwas30. After discussion we decided to go with the IC de-
sign. The LT2940 is an IC with the four quadrant multiplier with outputted voltage and current
proportional to power and current. The LT2940 was donated for our junior design project.
3.6.4 Implementation
The implementation of the design started with the LT2940 IC and creating a Fully Isolated Power
and Current Monitor (Figure 3.6.4). It started by getting the chip from Linear Technology and
surface mounting that on a board for testing. Circuit etching was the process in which we went
about doing that task. Next all the components had to be gathered and implemented into the
circuit for testing (Figure 3.6.4). After much trial and error we got an output that was proportional
to voltage on a breadboard stimulus.
3.7 Internet Interface
3.7.1 Background
The Internet is becoming more vital to our society everyday. It allows billions of people to share
huge amounts of information with relative ease. The Internet also allows users to communicate
in real-time from the farthest corners of the globe. The widespread adoption of this service makes
30
it a prime candidate for a way of publicizing information. The Internet is not just limited to news
articles, social networking, and blogs. It can be used to publish status information about a device.
3.7.2 Problem Description
The specications for this subsystem require that information be uploaded to the electrical engi-
neering web server (geek.nmt.edu) in real-time. The specications also require that the informa-
tion is accessible from a publicly available web page. In addition, we have added a few more
features that we believed would benet the end user. These are:
Highly Graphical User Interface
Support for Information Archiving
Email / Text Messaging Alerts
These additional features were selected to provide the end user with more tools for data analysis.
3.7.3 Design
The major design restriction that we encountered was the limited access to the electrical engineer-
ing server. Too better explain this issue, we must rst discuss some background information. The
Internet is a complex network of computers that communicate with each other. The computers
can be broken up into two different categories: clients and servers. Servers on the Internet are
responsible for providing information to the clients. For example, Google.com is the address of a
server that provides information to a persons computer, the client. Typically this information is
in the form of a web page but it can also include other types of information like email. Clients
and servers communicate using a predened language called a protocol. Depending on what
type of service is needed (web page, email, chat, etc.) determines the appropriate protocol to use.
To connect to the electrical engineering server, we needed to know what services were available,
and then select the appropriate protocol. After talking to Chris Pauli (network administrator for
geek.nmt.edu), we found that the following services were available.
HTTP (Hypertext Transfer Protocol) is the most commonly used protocol on the Internet. It allows
clients to request web pages and submit form data to a remote server. It has a simple syntax that
would make it easy to implement on a device like a microcontroller. [20]
SSH (Secure SHell) is used to allow clients to remotely login to a remote server using a terminal.
It allows users to both send and receive information in a very secure manner. SSH is a complex
protocol due to its encryption and authentication mechanisms. [21]
31
Both methods were based on the assumption that the smart inverter would act as a client. A
third option was considered that would have our device behave as a server. This would require a
special hardware module that had a fully functional web server on board. To view the real-time
properties of the device, the end user would be required to go to the address of the board in a web
browser, instead of geek.nmt.edu. All three options were compared using a weight matrix (Table
3.2).
Criteria Weights HTTP SSH HTTP Server
Security 0.21 0.32 0.36 0.32
Reliability 0.23 0.36 0.27 0.36
Cost 0.23 0.33 0.33 0.33
Performance 0.15 0.45 0.25 0.30
Accessibility 0.18 0.43 0.13 0.43
Score 0.37 0.27 0.35
Table 3.2: Decision Matrix for Internet Interface
The rst option we ruled out was making the device the web server. This would only allow the
end user to access the device information in the same local area network, defeating the original
purpose of the Internet Interface. In addition, the specications clearly state that information
was to be uploaded to geek.nmt.edu. After comparing the two remaining options, we decided to
use the HTTP protocol. The deciding factor was simplicity. It would have been very difcult to
implement a SSH client on a microcontroller.
Our design was focused at making our microcontroller behave like a web browser. To allow us
to send information to the server, we programmed our device to mimic the act of submitting a
form on the web. In the event that information was ready to send, the following HTTP command
would be transmitted to geek.nmt.edu using TCP/IP.
GET /matthew.paiz/jd/update.php?voltage=120&current=1
&pf=0&frequency=60
This command would send information about voltage, current, power factor, and frequency to
a program stored on the server called update.php. The program update.php was programmed
using the PHP (PHP hypertext processor) programming language. It would receive information
from our device and store it on the server as an archive. The server also contained a separate
web page responsible for displaying real-time data. This web page also contained links to the
archived information. The archive was organized by date and hour, and would only show the
average for every minute of the hour to conserve space. In addition, update.php was responsible
for determining if user dened thresholds were surpassed. These thresholds could be dened in
a separate web page. In the event that the threshold was surpassed, the update.php script would
32
email or text the end user with a notication describing the event. This was done using the send
mail program on the geek.nmt.edu server.
The biggest emphasis in this subsystem was ease of use. To make data analysis more convenient,
the data was presented in a graphical manner (Figure 3.12). To prevent frequent page reloads,
we used an embedded Java program called an applet in the web page. Java applets allow us to
update a web page graphically without reloading the page. It made it possible for us to display a
real time wave form of the data.
Overall we were able to complete every one of our goals for this subsystem. It was successfully
tested using data from the data logger. The Email and Texting Notications were also successfully
tested, yielding the following message:
Smart Inverter Voltage Limit Exceeded
Voltage: 203 Volts
3.8 Conclusions
3.8.1 Progress
The objective of the circuit was to invert power from renewable energy sources into usable power
for any load. We were able to partially meet this objective. Our power output is usable for any
resistive load, and most other loads which are not sensitive to having sinusoidal inputs. We were
also able to output power characteristics to the user and charge a battery from the renewable
sources. Each subsystem was completed enough to give some form of desirable output, establish-
ing that it is in line with completion. Figure 3.17 shows the estimated percent completion for each
subsystem.
One note to be made is that although the gure shows the project as being only 70% done, the
three most difcult subsystems are either completed or very close to completion. The fact that we
were able to integrate the whole system and achieve a desired output of both the power and the
internet interface shows that we have much more than 70% of the project completed.
3.8.2 Future Work
Our progress showed a proof of concept, and that creating a practical intelligent power converter
is denitely an obtainable goal. In its current state, the converter demonstrates functionality for
33
Figure 3.17: Progress Comparison For Each Subsystem
each subsystem. We were under our required budget, and we project that any purchases which
need to be made to complete the subsystems will not push the project over budget.
There are a few changes that we recommend for future work, however. The Wiznet Ethernet
module was very nicky, and not practical for our application. We would denitely recommend
looking into alternative modules for the nal design. As mentioned earlier, the transformers used
in the power inverter were not suitable for the amount of power required. Proper transformers
are recommended, such as a current sense transformer. The measurement subsystem required a
very unique transformer which was not readily available to us, or easy to locate. As such, we
would recommend modifying the measurement circuit to require a more basic transformer for
future work. The charger circuit only had two of the three charging modes completed, so the third
needed to be worked out still. In addition, we would recommend housing even the prototype
boards in enclosures to avoid unwanted contact with the high power sources. We were set back
signicantly when part of our charger circuit blew because of a stray wire from the battery.
3.8.3 Conclusion
The converter performed as we expected, and our level of completion was in accordance with the
amount of time given. We successfully proved the feasibility of the circuit, and demonstrated an
example output of a functioning prototype.
34
Bibliography
[1] An Intelligent DC-DC/AC Converter. [Online].
http://www.ee.nmt.edu/erives/382 10/Intelligent%20Converter.pdf [Accesed: Feb 10,
2010].
[2] Intelligent Power Conversion Functions and Benets. [Online].
http://www.microchip.com/stellent/idcplg?IdcService=SS GET PAGE&nodeId=2524&param=en539230
[3] What is a Smart Battery Charger. [Online].
http://www.wisegeek.com/what-is-a-smart-battery-charger.htm [Accesed: Apr 11, 2010].
[4] What is a Smart Battery. [Online].
http://www.wisegeek.com/what-is-a-smart-battery.htm [Accesed: Apr 11, 2010].
[5] Charging the Lead Acid Battery. [Online].
http://www.batteryuniversity.com/partone-13.htm [Accesed: Apr 11, 2010].
[6] Smart Battery Charger Specication. [Online].
http://sbs-forum.org/specs/sbc110.pdf [Accesed: Apr 11, 2010].
[7] Smart Battery Charger Specication. [Online].
http://en.wikipedia.org/wiki/Gaston Plant%C3%A9 [Accesed: Apr 12, 2010].
[8] The New 400 watt turbine! [Online].
http://www.sunforceproducts.com/prodinfo/manuals/44444AirXManual.pdf
[9] 60 WATT SOLAR 12 VOLT POWER GENERATOR KIT. [Online].
http://www.sunforceproducts.com/prodinfo/manuals/50044 60WSolarKitManual.pdf
[10] Can the lead-acid battery compete in modern times? [online].
http://www.batteryuniversity.com/partone-6.htm [accesed: apr 30, 2010].
35
[11] LT3652 Data Sheet [Online].
http://cds.linear.com/docs/Datasheet/3652fb.pdf [Accesed: Apr 30, 2010].
[12] LTC4151 Data Sheet [Online].
http://cds.linear.com/docs/Datasheet/4151fb.pdf [Accesed: Apr 30, 2010].
[13] A. Tubesing, Printed Circuit Board Construction. [Online].
http://www.ee.nmt.edu/ tubesing/ee101/labs.html [Accessed: May 2, 2010].
[14] Charge Monitor for 12V Rechargeable Lead-acid Battery. [Online].
http://www.electronicsforu.com/efylinux/circuit/feb2003/sept99 chargemonitor.pdf [Ac-
cesed: Apr 29, 2010].
[15] Solar Intelligent Inverter [Online].
http://www.alibaba.com/product-free/103269681/solar intelligent inverter 300W 30KW .html
[Accesed: Apr 30, 2010].
[16] An Intelligent Power Supply Conditioning System [Online].
http://ieeexplore.ieee.org/Xplore/defdeny.jsp?url=http%3A%2F%2Fieeexplore.ieee.org%2Fstamp%2Fstamp.jsp
[17] Ethernet to SPI Interface Module [Online].
http://microcontrollershop.com/product info.php?cPath=98 322&products id=1971&osCsid=f265efb0a9cdd369fd12835bfd3caa37
[Accesed: Apr 30, 2010].
[18] ENC28J60 Ethernet to SPI Header Board. [Online].
http://microcontrollershop.com/product info.php?cPath=98 322&products id=1390 [Ac-
cesed: Apr 30, 2010].
[19] ENC28J60 Ethernet to SPI Header Board. [Online].
http://microcontrollershop.com/product info.php?cPath=98 322&products id=1390 [Ac-
cesed: Apr 30, 2010].
[20] WIZnet W5100 Network Module with Mag Jack - WIZ811MJ. [Online].
http://www.sparkfun.com/commerce/product info.php?products id=9473 [Accesed: May
1, 2010].
[21] The Secure Shell (SSH) Authentication Protocol. [Online].
http://tools.ietf.org/html/rfc4252 [Accesed: May 2, 2010].
[22] Home Page: TheInterterStore.com [Online].
http://www.theinverterstore.com/ [Accesed: May 1, 2010].
[23] DC-AC 12V -110V/220V 500W or More Inverter. [Online].
http://www.instructables.com/id/DC-AC-12V-110V220V-500W-or-more-inverter/ [Ac-
cesed: Feb 1, 2010].
36
[24] Electrical Inverter [Online].
http://en.wikipedia.org/wiki/Inverter (electrical) [Accesed: Feb 10, 2010].
[25] REGULATING PULSEWIDTH MODULATOR.S [Online].
http://focus.ti.com/lit/ds/symlink/sg3524.pdf [Accesed: Mar 27, 2010].
[26] Introduction to MOSFETS [Online].
http://www.aoc.nrao.edu/ pharden/hobby/ ClassDEF1.pdf [Accesed: May 7, 2010].
37
Appendix A
Code For Data Logger
1 #include hcs12 . h
2 #include DBug12 . h
3 #include vect or s12 . h
4 #include <s t r i ng . h>
5
6 /
7 Copyr i ght Not Pl at ypus I n d u s t r i e s
8 F i l e Cr e a t e d By Matt Brown
9
10 d a t a l o g . c
11 Send Data From ATD t o t he WizNET and o ve r t he
12 i n t e r n e t
13
14 /
15
16 / / DEFINITIONS
17 #define TRUE 1
18 #define FALSE 0
19 #define enabl e ( ) asm( c l i )
20 #define di s abl e ( ) asm( s e i )
21 #define S0 TX MASK 0x07FF
22 #define S0 TX BASE 0x4000
23 #define RESET WIZNET PORTA = 0x00 ; delayby1ms ( 1 ) ; PORTA = 0xFF
24
25 / / FUNCTIONS
26 void s pi s et up ( void ) ;
27 void wi znet set up ( void ) ;
28 void spi send byt e ( unsigned char byt e ) ;
29 unsigned char s pi r e c byt e ( void ) ;
30 void send wi znet dat a ( unsigned char upper , unsigned char lower , unsigned char data ) ;
31 unsigned char r ec wi znet dat a ( unsigned char upper , unsigned char lower ) ;
32 void send wi znet packet ( char message ) ;
33 void wi znet t es t i ng ( void ) ;
34 void delayby1ms ( i nt k) ;
38
35
36 / / GLOBAL VARIABLES
37 unsigned i nt RR TX POINTER, WR TX POINTER;
38
39 void INTERRUPT r t i i s r ( void ) ;
40
41 char gmessage = GET / matthew. pai z/j d/update . php? data=
;
42
43
44
45 /
46 MAIN
47 /
48 / / 1) r e c i e v e s da t a vi a i n t e r r u p t s and p l a c e s i nt o a b u f f e r
49 / / 2) when b u f f e r i s f u l l , s e nds da t a t o EE s e r v e r
50 / / 3) r e p e a t
51 main ( ) {
52
53 ATD0CTL2 = BIT7 ; / / Enabl e ATD0
54 ATD0CTL3 = 0x00 ; / / Ei ght c o nv e r s i o ns
55 ATD0CTL4 = 0x85 ; / / 8b i t mode
56 ATD0CTL5 = 0xA6 ; / / Sampl e Ch7 onl y , Ri ght J u s t i f i e d
57 / / Unsi gned , Cont i nuous Se que nce
58 / Se t up f o r RTI /
59 RTICTL = 0x47 ; / / Pr e s c a l e s OSClock t o 8ms
60 CRGINT = 0x80 ; / / Enabl e s RTI I nt e r r up t ( e ve r y 8ms )
61 CRGFLG = 0x80 ; / / Cl e a r s RTI I nt e r r up t Fl ag
62 UserRTI = ( unsigned short ) &r t i i s r ; / / Se t s I nt e r r up t Ve c t or
63
64 / / HTTP HEADER
65 / / gmessage [ 38] = 1 ;
66 gmessage [ 38] = 2 ;
67 gmessage [ 39] = 0 ;
68 gmessage [ 40] = 10; / / LF
69 gmessage [ 41] = 0; / / NULL
70
71 / / SETUP
72 di s abl e ( ) ; / / Di s a b l e I nt e r r up t s
73 TSCR1 = TSCR1 & BIT7 ; / / Di s a b l e Ti mer
74
75 s pi s et up ( ) ; / / Se t s up pa r a me t e r s f o r SPI 0 on HCS12
76 DDRA = 0xFF ; / / PORTA s e t t o ouput
77
78 RESET WIZNET;
79
80 TSCR1 = BIT7 ; / / Enabl e Ti mer
81 enabl e ( ) ; / / Enabl e I nt e r r up t s
82
83
84 DB12FNP>pr i nt f ( end of setup\n\r ) ;
39
85
86 wi znet set up ( ) ; / / s e t IP i n f o and e s t a b l i s h c o nne c t i o n t o
s e r v e r
87
88 DB12FNP>pr i nt f ( end of wiznet setup \n\r ) ;
89
90 / / SEND TEST MESSAGE
91 / / s e nd wi z ne t p a c k e t ( gmessage ) ;
92
93 DB12FNP>pr i nt f ( end of send wiznet packet \n\r ) ;
94
95
96 char d = 1 ;
97 for ( d = 1 ; d <= 9 ; d++) {
98 i f ( d == 8 )
99 d = 0 ;
100 delayby1ms ( 100) ;
101 send wi znet packet ( gmessage ) ;
102 }
103
104
105 asm( swi ) ;
106 }
107
108 /
109 END OF MAIN
110 /
111
112
113
114
115
116
117
118
119 void s pi s et up ( void ) {
120
121 MODRR | = 0x10 ; / / Re r out e SPI0 t o PORTM
122
123 DDRM = 0x38 ; / / Co nf i gur e SPI pi ns as out put / i nput a p p r o p r i a t e l y
124 / / 0x38 / / 0 0 1 1 | 1 0 0 0
125 / / | | | | | | | \ PM0 RXB ( don t c a r e )
126 / / | | | | | | \ PM1 TXB ( don t c a r e )
127 / / | | | | | \ PM2 MISO 0 ( i nput )
128 / / | | | | \ PM3 / SS 0 ( out put )
129 / / | | | \ PM4 MOSI 0 ( out put )
130 / / | | \ PM5 SCK 0 ( out put )
131 / / | \ PM6 RXCAN4 ( don t c a r e )
132 / / \ PM7 TXCAN4 ( don t c a r e )
133
134 SPI0BR = 0x41 ; / Se t f r e q ue nc y t o 4MHz/ ( 4+1) 2 ( 1+1) = 25MHz/ 20 = 1. 25MHz /
135 / / BaudRat e Di vi s or = ( SPPR+1) 2 ( SPR+1)
40
136 / / BaudRat e Di vi s or = ( 5 ) 2 ( 2 )
137 / / = 54 = 20
138 / / BaudRate = BusCl ock / BaudRat e Di vi s or = 25MHz/ 20 = 1. 25MHz
139 / / NOTE Max SPI r a t e i s 14. 28MHz f o r t he wi zne t w5100
140
141 SPI0CR1 = 0x52 ; / / 0 1 0 1 | 0 0 1 0
142 / / | | | | | | | \ LSB F i r s t Enabl e ( Di s abl e d , s o MSB i s f i r s t )
143 / / | | | | | | \ Sl a ve S e l e c t Output Enabl e
144 / / | | | | | \ Cl oc k Phase
145 / / | | | | \ Cl oc k Po l a r i t y
146 / / | | | \ Mast er Mode
147 / / | | \ SPI Transmi t I nt e r r up t Enabl e
148 / / | \ SPI System Enabl e
149 / / \ SPI I nt e r r up t Enabl e
150
151 }
152
153 void wi znet set up ( void ) {
154 unsigned char upper , lower ;
155 unsigned i nt i , connected , poi nt er ;
156 unsigned i nt dummy;
157
158 / / Gateway
159 send wi znet dat a ( 0 x00 , 0x01 , 0x0A) ; / / 10
160 send wi znet dat a ( 0 x00 , 0x02 , 0x00 ) ; / / 0
161 send wi znet dat a ( 0 x00 , 0x03 , 0x00 ) ; / / 0
162 send wi znet dat a ( 0 x00 , 0x04 , 0xFE) ; / / 254
163
164 / / Gateway
165 / / s e nd wi z ne t d a t a ( 0 x00 , 0x01 , 192) ; / / 1 9 2
166 / / s e nd wi z ne t d a t a ( 0 x00 , 0x02 , 168) ; / / 1 6 8
167 / / s e nd wi z ne t d a t a ( 0 x00 , 0x03 , 0) ; / / 0
168 / / s e nd wi z ne t d a t a ( 0 x00 , 0x04 , 1) ; / / 1
169
170 / / Subnet Mask
171 send wi znet dat a ( 0 x00 , 0x05 , 0xFF ) ; / / 255
172 send wi znet dat a ( 0 x00 , 0x06 , 0xFF ) ; / / 255
173 send wi znet dat a ( 0 x00 , 0x07 , 0xFF ) ; / / 255
174 send wi znet dat a ( 0 x00 , 0x08 , 0x0 ) ; / / 0
175
176 / / Mac Address
177 send wi znet dat a ( 0 x00 , 0x09 , 0x00 ) ; / / 00
178 send wi znet dat a ( 0 x00 , 0x0A, 0x08 ) ; / / 08
179 send wi znet dat a ( 0 x00 , 0x0B , 0xDC) ; / / DC
180 send wi znet dat a ( 0 x00 , 0x0C, 0x01 ) ; / / 01
181 send wi znet dat a ( 0 x00 , 0x0D, 0x02 ) ; / / 02
182 send wi znet dat a ( 0 x00 , 0x0E , 0x03 ) ; / / 03
183
184 / / Sour c e IPAddress
185 send wi znet dat a ( 0 x00 , 0x0F , 0x0A) ; / / 10
186 send wi znet dat a ( 0 x00 , 0x10 , 0x00 ) ; / / 0
187 send wi znet dat a ( 0 x00 , 0x11 , 0x00 ) ; / / 0
41
188 send wi znet dat a ( 0 x00 , 0x12 , 0x4B) ; / / 75
189
190 / / s e nd wi z ne t d a t a ( 0 x00 , 0x0F , 192) ; / / 1 0
191 / / s e nd wi z ne t d a t a ( 0 x00 , 0x10 , 168) ; / / 0
192 / / s e nd wi z ne t d a t a ( 0 x00 , 0x11 , 0) ; / / 0
193 / / s e nd wi z ne t d a t a ( 0 x00 , 0x12 , 75) ; / / 7 5
194
195 / / So c k e t 0 De s t i na t i o n IPAddress
196 / / s e nd wi z ne t d a t a ( 0 x04 , 0x0C , 10) ;
197 / / s e nd wi z ne t d a t a ( 0 x04 , 0x0D, 0) ;
198 / / s e nd wi z ne t d a t a ( 0 x04 , 0x0E , 0) ;
199 / / s e nd wi z ne t d a t a ( 0 x04 , 0x0F , 40) ;
200
201 / / 129. 138. 40. 11 GEEK
202 send wi znet dat a ( 0 x04 , 0x0C, 204) ;
203 send wi znet dat a ( 0 x04 , 0x0D, 236) ;
204 send wi znet dat a ( 0 x04 , 0x0E , 233) ;
205 send wi znet dat a ( 0 x04 , 0x0F , 39) ;
206
207 / / So c k e t 0 Lo c a l Por t
208 send wi znet dat a ( 0 x04 , 0x04 , 0x04 ) ;
209 send wi znet dat a ( 0 x04 , 0x05 , 0x22 ) ; / / 1058
210
211 / / So c k e t 0 De s t i na t i o n Por t
212 send wi znet dat a ( 0 x04 , 0x10 , 0) ;
213 send wi znet dat a ( 0 x04 , 0x11 , 88) ;
214
215 / / So c k e t 0 Mode Re g i s t e r
216 send wi znet dat a ( 0 x04 , 0x00 , 0x01 ) ; / / Se t t o TCP Mode
217
218
219 / / F i l l a l l b u f f e r s p a c e wi t h wh i t e s p a c e
220 poi nt er = 0x4000 ;
221 f or ( i = 0; i <0x2000 ; i ++) {
222 send wi znet dat a ( ( poi nt er & 0xFF00 ) >> 8 , ( poi nt er & 0x00FF ) , 0 x00 ) ;
223 poi nt er ++;
224 }
225
226 / / Se t t he WR TX POINTER
227 WR TX POINTER = 0x0001 ;
228 send wi znet dat a ( 0 x04 , 0x24 , ( WR TX POINTER & 0xFF00 ) >> 8) ;
229 send wi znet dat a ( 0 x04 , 0x25 , ( WR TX POINTER & 0x00FF ) ) ;
230
231 / / So c k e t 0 Open
232 send wi znet dat a ( 0 x04 , 0x01 , 0x01 ) ; / / OPEN Command
233
234 / / So c k e t 0 Connect
235 send wi znet dat a ( 0 x04 , 0x01 , 0x04 ) ; / / CONNECT Command
236 while ( ! ( r ec wi znet dat a ( 0 x04 , 0x02 ) && 0x01 ) ) ; / / Wait un t i l Conne c t i on
Es t a b l i s h e d
237
238 send wi znet dat a ( 0 x04 , 0x01 , 0x20 ) ; / / SEND Command
42
239 while ( ! ( r ec wi znet dat a ( 0 x04 , 0x02 ) && 0x10 ) ) ; / / Wait un t i l SEND s u c c e s s f u l
240
241 / / Get t he RR TX POINTER
242 upper = r ec wi znet dat a ( 0 x04 , 0x22 ) ;
243 lower = r ec wi znet dat a ( 0 x04 , 0x23 ) ;
244 RR TX POINTER = ( upper << 8) + lower ;
245
246 / / Get t he WR TX POINTER
247 upper = r ec wi znet dat a ( 0 x04 , 0x24 ) ;
248 lower = r ec wi znet dat a ( 0 x04 , 0x25 ) ;
249 WR TX POINTER = ( upper << 8) + lower ;
250
251 / / F i l l b u f f e r s p a c e wi t h whi t e s p a c e
252 / / t r y t o ge t RR TX POINTER t o 0x0000 ;
253 dummy = 0x0000 RR TX POINTER;
254 poi nt er = 0x4000 ;
255 f or ( i = 0; i <dummy; i ++) {
256 send wi znet dat a ( ( poi nt er & 0xFF00 ) >> 8 , ( poi nt er & 0x00FF ) , 0 x00 ) ;
257 poi nt er ++;
258 i f ( poi nt er > 0x6000 )
259 poi nt er = 0x4000 ;
260 }
261
262 send wi znet dat a ( 0 x04 , 0x01 , 0x20 ) ; / / SEND Command
263 while ( ! ( r ec wi znet dat a ( 0 x04 , 0x02 ) && 0x10 ) ) ; / / Wait un t i l SEND s u c c e s s f u l
264
265 / / Get t he RR TX POINTER
266 upper = r ec wi znet dat a ( 0 x04 , 0x22 ) ;
267 lower = r ec wi znet dat a ( 0 x04 , 0x23 ) ;
268 RR TX POINTER = ( upper << 8) + lower ;
269
270 / / Get t he WR TX POINTER
271 upper = r ec wi znet dat a ( 0 x04 , 0x24 ) ;
272 lower = r ec wi znet dat a ( 0 x04 , 0x25 ) ;
273 WR TX POINTER = ( upper << 8) + lower ;
274
275 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x10 ) ; / / CLOSE Command
276 / / whi l e ( ! ( r e c wi z ne t d a t a ( 0 x04 , 0x02 ) && 0x02 ) ) ; / / Wait un t i l CLOSE s u c c e s s f u l
277
278 }
279
280
281
282
283
284 void spi send byt e ( unsigned char byt e ) {
285 unsigned char dummy;
286 PTM &= BIT3 ; / / send SPI0SS l ow
287 / Make s ur e t r a ns mi t da t a r e g i s t e r empty /
288 while ( ! ( SPI0SR & SPTEF) ) ;
289 / Send da t a /
290 SPI0DR = byte ;
43
291 / Wait f o r b yt e t o be s h i f t e d out /
292 while ( ! ( SPI0SR & SPIF ) ) ;
293 dummy = SPI0DR ;
294 PTM | = BIT3 ; / / send SPI0SS hi gh
295 }
296
297
298
299
300
301 unsigned char s pi r e c byt e ( void ) {
302 unsigned char dummy;
303 PTM &= BIT3 ; / / send SPI0SS l ow
304 / Make s ur e t r a ns mi t da t a r e g i s t e r empty /
305 while ( ! ( SPI0SR & SPTEF) ) ;
306 / Send dummy da t a t o r e c e i v e some /
307 SPI0DR = 0x00 ;
308 / Wait f o r b yt e t o be s h i f t e d i n /
309 while ( ! ( SPI0SR & SPIF ) ) ;
310 dummy = SPI0DR ;
311 PTM | = BIT3 ; / / send SPI0SS hi gh
312 ret urn dummy;
313 }
314
315
316
317
318
319 void send wi znet dat a ( unsigned char upper , unsigned char lower , unsigned char data ) {
320 spi send byt e ( 0 xF0 ) ; / / wr i t e opc ode
321 spi send byt e ( upper ) ; / / upper b yt e o f a d d r e s s
322 spi send byt e ( lower ) ; / / l owe r b yt e o f a d d r e s s
323 spi send byt e ( data ) ; / / da t a
324 }
325
326
327
328
329
330 unsigned char r ec wi znet dat a ( unsigned char upper , unsigned char lower ) {
331 unsigned char dummy;
332 spi send byt e ( 0 x0F ) ; / / r e a d opc ode
333 spi send byt e ( upper ) ; / / upper b yt e o f a d d r e s s
334 spi send byt e ( lower ) ; / / l owe r b yt e o f a d d r e s s
335 dummy = s pi r e c byt e ( ) ; / / da t a
336 ret urn dummy;
337 }
338
339
340
341
342
44
343 i nt l en ( char message ) {
344 i nt count = 0;
345 while ( message[++count ] ! = 0) ;
346 ret urn count ;
347 }
348
349
350
351
352
353 void delayby1ms ( i nt k)
354 {
355 i nt i x ;
356 TSCR1 = 0x90 ; / e na b l e TCNT and f a s t t i me r f l a g c l e a r /
357 TSCR2 = 0x06 ; / d i s a b l e t i me r i nt e r r up t , s e t p r e s c a l e r t o 64 /
358 TIOS | = BIT0 ; / e na b l e OC0 /
359 TC0 = TCNT + 375;
360 f or ( i x = 0; i x < k ; i x ++) {
361 while ( ! ( TFLG1 & BIT0 ) ) ;
362 TC0 += 375;
363 }
364 TIOS &= ( BIT0 ) ; / d i s a b l e OC0 /
365 }
366
367
368
369
370
371 void send wi znet packet ( char message ) {
372 unsigned char upper , lower ;
373 i nt i , j , connected , poi nt er ;
374 unsigned i nt physi cal r r addr , physi cal wr addr ;
375 unsigned i nt send si ze = l en ( message ) ;
376
377 / / So c k e t 0 Open
378 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x01 ) ; / / OPEN Command
379
380 / / So c k e t 0 Connect
381 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x04 ) ; / / CONNECT Command
382 / / whi l e ( ! ( r e c wi z ne t d a t a ( 0 x04 , 0x02 ) && 0x01 ) ) ; / / Wait un t i l Conne c t i on
Es t a b l i s h e d
383
384 / / So c k e t 0 Send
385 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x20 ) ; / / SEND Command
386 / / whi l e ( ! ( r e c wi z ne t d a t a ( 0 x04 , 0x02 ) && 0x10 ) ) ; / / Wait un t i l SEND s u c c e s s f u l
387
388 / / Get t he RR TX POINTER
389 upper = r ec wi znet dat a ( 0 x04 , 0x22 ) ;
390 lower = r ec wi znet dat a ( 0 x04 , 0x23 ) ;
391 RR TX POINTER = ( upper << 8) + lower ;
392
393 / / Get t he WR TX POINTER
45
394 upper = r ec wi znet dat a ( 0 x04 , 0x24 ) ;
395 lower = r ec wi znet dat a ( 0 x04 , 0x25 ) ;
396 WR TX POINTER = ( upper << 8) + lower ;
397
398 f or ( j =0; j <1; j ++) {
399 / / Convert t he RR TX POINTER t o i t s r e a l p h y s i c a l a d d r e s s
400
401 phys i c al r r addr = ( RR TX POINTER & S0 TX MASK) + S0 TX BASE ;
402 physi cal wr addr = phys i c al r r addr ;
403 / / Wri t e t o So c k e t 0 b uf f e r , s t a r t i n g a t t he r e a d p o i nt e r
404 for ( i =0; i <send si ze ; i ++) {
405 i f ( physi cal wr addr > 0x4800 )
406 physi cal wr addr = 0x4000 ;
407 send wi znet dat a ( ( physi cal wr addr & 0xFF00 ) >> 8 , ( physi cal wr addr & 0
x00FF ) , message [ i ] ) ;
408 physi cal wr addr ++;
409 }
410
411
412 send wi znet dat a ( ( physi cal wr addr & 0xFF00 ) >> 8 , ( physi cal wr addr & 0x00FF
) , 3) ; / / End Of Text
413 physi cal wr addr ++;
414 send wi znet dat a ( ( physi cal wr addr & 0xFF00 ) >> 8 , ( physi cal wr addr & 0x00FF
) , 4) ; / / End o f Tr ans mi s i on
415
416 / / Update WR TX POINTER
417 WR TX POINTER = RR TX POINTER + send si ze + 2 ;
418 send wi znet dat a ( 0 x04 , 0x24 , ( WR TX POINTER & 0xFF00 ) >> 8) ;
419 send wi znet dat a ( 0 x04 , 0x25 , ( WR TX POINTER & 0x00FF ) ) ;
420
421 / / So c k e t 0 Open
422 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x01 ) ; / / OPEN Command
423
424 / / So c k e t 0 Connect
425 / / s e nd wi z ne t d a t a ( 0 x04 , 0x01 , 0x04 ) ; / / CONNECT Command
426 / / whi l e ( ! ( r e c wi z ne t d a t a ( 0 x04 , 0x02 ) && 0x01 ) ) ; / / Wait un t i l Conne c t i on
Es t a b l i s h e d
427
428 send wi znet dat a ( 0 x04 , 0x01 , 0x20 ) ; / / SEND Command
429 while ( ! ( r ec wi znet dat a ( 0 x04 , 0x02 ) && 0x10 ) ) ; / / Wait un t i l SEND s u c c e s s f u l
430
431 / / Get t he RR TX POINTER
432 upper = r ec wi znet dat a ( 0 x04 , 0x22 ) ;
433 lower = r ec wi znet dat a ( 0 x04 , 0x23 ) ;
434 RR TX POINTER = ( upper << 8) + lower ;
435
436 / / Get t he WR TX POINTER
437 upper = r ec wi znet dat a ( 0 x04 , 0x24 ) ;
438 lower = r ec wi znet dat a ( 0 x04 , 0x25 ) ;
439 WR TX POINTER = ( upper << 8) + lower ;
440 }
441 / / whi l e ( ! ( r e c wi z ne t d a t a ( 0 x04 , 0x02 ) && 0x02 ) ) ; / / Wait un t i l CLOSE s u c c e s s f u l
46
442 }
443
444 void INTERRUPT r t i i s r ( void )
445 {
446 i nt a , b , c ;
447 i nt val ue ;
448
449 val ue = ATD0DR0;
450
451 / / va l ue = va l ue 196/ 100;
452
453 a = val ue /100;
454 b = ( valuea 100) /10;
455 c = ( valuea100 b10) ;
456
457 gmessage [ 38] = a + 0x30 ;
458 gmessage [ 39] = b + 0x30 ;
459 gmessage [ 40] = c + 0x30 ;
460 gmessage [ 41] = 10;
461 gmessage [ 42] = 0;
462 / / s t a t i c f l o a t DC, k = . 0000025 , Sd ;
463
464 / / a ve r a ge = (ATD0DR0 + ATD0DR1 + / / a v e r a g e s a l l t he va l ue s f rom PAD7
465 / / ATD0DR2 + ATD0DR3 +
466 / / ATD0DR4 + ATD0DR5 +
467 / / ATD0DR6 + ATD0DR7) >> 3 ;
468
469 / / Sd = ( 0 . 2 5 + 0. 75 a ve r a ge / 255) 3050;
470 / / DC = DC + k ( Sd RPM) ;
471 / / i f (DC > 1 . 0 ) DC = 1 . 0 ;
472 / / i f (DC < 0 . 2 ) DC = 0 . 2 ;
473 / / PWMDTY4 = (DC255) ;
474 / / p r i n t v o l t s = 1;
475 CRGFLG = BIT7 ;
476 }
477
478 void wi znet t es t i ng ( void ) {
479
480 }
47
Appendix B
Code For Internet Interface
Graph.java
1 import j ava . appl et . ;
2 import j ava . awt . ;
3 import j ava . i o . ;
4 import j ava . net . ;
5 import j ava . ut i l . ;
6
7 /
8 Copyr i ght Not Pl at ypus I n d u s t r i e s
9 F i l e Cr e a t e d By Matt Pai z
10
11 Graph . j a va
12 Di s pl a ys r e a l t i me g r a p h i c s about t he i ncomi ng da t a .
13
14 /
15
16 public c l as s Graph ext ends Applet implements Runnable {
17
18 pr i vat e boolean er r or = f al s e ;
19 pr i vat e St r i ng message ;
20
21 pr i vat e f i na l i nt MAX Y = 250; / / Maximu Y Val ue
22 pr i vat e f i na l i nt MAX X = 100; / / Maximum X Val ue
23
24 pr i vat e f i na l i nt GRID Y = 5; / / Number Of S p l i t s I n t he Y Axi s
25
26 pr i vat e f i na l i nt AXIS Y = 20; / / Maximum YAxi s Re s o l ut i o n
27 pr i vat e f i na l i nt AXIS X = 50; / / Maximum XAxi s Re s o l ut i o n
28
29 pr i vat e f l oat x i nc ;
30 pr i vat e f l oat y i nc ;
48
31
32 / / To Opt i mi ze Pe r f or manc e The Program Was Broken Up I nt o Two Thr e ads
33
34 pr i vat e Thread drawi ng thread ;
35 pr i vat e Thread net worki ng t hread ;
36
37 pr i vat e i nt poi nt s [ ] ;
38
39 i nt l a s t va l ue ;
40
41 / / I n i t i a l i z e J a va Appl e t
42 / / Cr e a t e Buf f e r s t o St o r e Data
43
44 public void i n i t ( ) {
45
46 poi nt s = new i nt [MAX X] ;
47
48 f or ( i nt x = 0; x < poi nt s . l engt h ; x++)
49 poi nt s [ x ] = 0;
50
51 x i nc = ( ( f l oat ) getWidth ( ) AXIS X) / ( ( f l oat ) MAX X) ;
52 y i nc = ( ( f l oat ) get Hei ght ( ) AXIS Y) / ( ( f l oat ) MAX Y) ;
53
54 }
55
56 / / Push New I nf o r ma t i o n I nt o Buf f e r
57 / / Push Old I nf o r ma t i o n Out o f Buf f e r
58 / / Ba s i c a l l y J us t I mpl e me nt i ng a St a c k
59
60 pr i vat e void add t hen s hi f t ( i nt y) {
61
62 i nt previ ous = y ;
63 i nt tmp;
64
65 f or ( i nt x = 0; x < poi nt s . l engt h ; x++) {
66 tmp = poi nt s [ x ] ;
67 poi nt s [ x ] = previ ous ;
68 previ ous = tmp;
69 }
70
71 }
72
73 / / Re que s t s Updated I nf o r ma t i o n From The Se r ve r
74
75 public i nt getVal ue ( ) throws Except i on {
76
77 HttpURLConnection connect i on = ( HttpURLConnection ) new URL( ht t p : //geek . nmt . edu/
matthew. pai z/j d/l og . t x t ) . openConnection ( ) ;
78 connect i on . setUseCaches ( f al s e ) ;
79
80 Scanner scanner = new Scanner ( connect i on . get Input St ream ( ) ) ;
81
49
82 i nt x = scanner . next I nt ( ) ;
83
84 scanner . c l os e ( ) ;
85
86 ret urn x ;
87 }
88
89 / / Re s p o ns i b l e For Running Bot h Thr e ads
90 / / One Thread Handl es Gr aphi c s
91 / / One Thread Handl es Net worki ng
92
93 public void run ( ) {
94
95 i f ( Thread . current Thread ( ) . getName ( ) . equal s ( Draw ) ) {
96 t r y {
97
98 l a s t va l ue = 0;
99
100 for ( ; ; ) {
101 add t hen s hi f t ( l a s t va l ue ) ;
102 r epai nt ( ) ;
103 t r y {
104 Thread . sl eep ( 100) ;
105 } cat ch ( I nt errupt edExcept i on ec ) {
106 }
107 }
108 } cat ch ( Except i on ec ) {
109 er r or = t rue ;
110 message = ec . getMessage ( ) ;
111 r epai nt ( ) ;
112 }
113 } el se {
114 for ( ; ; ) {
115 t r y {
116 l a s t va l ue = getVal ue ( ) ;
117 Thread . sl eep ( 100) ;
118 } cat ch ( Except i on ec ) {
119 }
120 }
121
122 }
123
124
125 }
126
127 public void s t a r t ( ) {
128 drawi ng thread = new Thread ( t hi s , Draw ) ;
129 net worki ng t hread = new Thread ( t hi s , Reload ) ;
130 drawi ng thread . s t a r t ( ) ;
131 net worki ng t hread . s t a r t ( ) ;
132 }
133
50
134 / / Pai nt Gr aphi c s
135
136 public void pai nt ( Graphi cs g) {
137
138 g . set Col or ( Color . BLACK) ;
139
140 f l oat gr i d i nc = ( get Hei ght ( ) AXIS Y) / GRID Y;
141
142 f or ( i nt y = 0; y < GRID Y + 1; y++) {
143 i f ( y ! = GRID Y)
144 g . drawStri ng ( ( ( GRID Y y) MAX Y / GRID Y) + , AXIS X 30 , ( i nt ) ( y
gr i d i nc ) + 10) ;
145 g . drawLine ( AXIS X , ( i nt ) ( y gr i d i nc ) , getWidth ( ) , ( i nt ) ( y gr i d i nc ) ) ;
146 }
147
148 g . drawLine ( AXIS X , 0 , AXIS X , get Hei ght ( ) AXIS Y) ;
149
150 g . set Col or ( Color . BLUE) ;
151
152 f or ( i nt x = 0; x < poi nt s . l engt h 1 ; x++)
153 g . drawLine ( ( i nt ) ( AXIS X + x x i nc ) , ( i nt ) ( get Hei ght ( ) AXIS Y poi nt s [ x ]
y i nc ) , ( i nt ) ( AXIS X + ( x + 1) x i nc ) , ( i nt ) ( get Hei ght ( ) AXIS Y
poi nt s [ x + 1] y i nc ) ) ;
154
155 g . set Col or ( Color . BLACK) ;
156 g . drawLine ( AXIS X , get Hei ght ( ) AXIS Y , getWidth ( ) , getHei ght ( ) AXIS Y) ;
157
158 i f ( er r or ) {
159
160 g . set Col or ( Color . RED) ;
161 g . drawStri ng ( Error : + message , AXIS X + 100 , getWidth ( ) / 2) ;
162
163 }
164
165 }
166 }
51
update.php
1 <HTML>
2 <BODY>
3 <?php
4
5 / / Copyr i ght Not Pl at ypus I n d u s t r i e s
6 / / Cr e a t e d By Matthew Pai z
7 / /
8 / / updat e . php
9 / / Handl es I nf o r ma t i o n Ar c hi vi ng and Emai l / Text No t i f i c a t i o n s
10
11 / / Open Log F i l e s For Output
12 $myFile = l og . t x t ;
13 $fh = fopen ( $myFile , w ) or di e ( can t open f i l e ) ;
14 $st r i ngDat a = $ GET[ data ] ;
15 f wr i t e ( $fh , $st r i ngDat a ) ;
16 f f l us h ( $fh ) ;
17 f c l os e ( $fh ) ;
18
19 / / Cr e a t e Ar c hi ve Fo l d e r s
20
21 $ f i l e = date ( H ) ;
22 $f ol der = date ( m. d. y ) ;
23 $minute = date ( s ) ;
24
25 $timestamp = date ( H: i ) ;
26
27
28 exec ( mkdir archi ve/$f ol der ) ; / / Cr e a t e Di r e c t o r y
29 exec ( chmod 777 archi ve/$f ol der ) ; / / Se t Pe r mi s s i o ns For Di r e c t o r y
30
31 $cont ent s = f i l e g e t c o nt e nt s ( archi ve/$f ol der /$ f i l e ) ;
32
33 i f ( st r pos ( $cont ent s , $timestamp ) == FALSE) {
34 exec ( echo \( $timestamp \) Vol tage : $st r i ngDat a Vol t s >> archi ve/$f ol der /$ f i l e ) ;
35 exec ( chmod 777 archi ve/$f ol der /$ f i l e ) ;
36 }
37
38 $bl ocked = f i l e g e t c o nt e nt s ( bl ock . t x t ) ;
39 $enabl ed = f i l e g e t c o nt e nt s ( enabl ed . t x t ) ;
40 $l i mi t = f i l e g e t c o nt e nt s ( l i mi t . t x t ) ;
41 $emai l = f i l e g e t c o nt e nt s ( emai l . t x t ) ;
42
43 / / Handl e Emai l I f Lock i s Not Enabl e d
44
45 i f ( s t r s t r ( $blocked , no ) ) {
46 i f ( $enabl ed == yes ) {
47
48 $a = ( i nt ) $st r i ngDat a ;
49 $b = ( i nt ) $l i mi t ;
50
52
51 echo $a > $b\n ;
52
53 i f ( $a > $b ) {
54 exec ( . / t e xt $emai l $st r i ngDat a ) ;
55 }
56 }
57 }
58
59 echo $minute ;
60
61 ?>
62 </BODY>
63 </HTML>
53

You might also like