You are on page 1of 64

Smart Charger

Project Design Report




Design Team #1
Claudiu Bouruc
Eric Boyer
Mike Petrak
Steven Savage

Dr. Tom T. Hartley

November 23, 2004
Table of Contents

Table of Contents..i
List of Figures..ii
List of Tables..iii
List of Equations.....iv
Table of Listings..v
Abstract1
Introduction..2
Problem Definition: Goals, Objectives, Constraints..2
Design Requirements.....3
Alternative Designs..5
Hardware Ideas..5
System Control and A/D Conversion....5
DC Power Supply Alternatives..9
Software Ideas: User Feedback....11
Accepted Technical Design...14
DC Power Supply...16
Microcontroller Power Supply19
Voltage and Current Sensing......20
System Control: Microcontroller-Based Approach....21
Proportional Integral Control Algorithm.23
Microcontroller Hardware Design Interface...25
External A/D Converter...25
RS-232 Serial Interface...27
Pulse Width Modulation..27
Liquid Crystal Display Interface.28
Precision Temperature Sensing...29
Infrared Remote Input.30
PC Software Application31
Battery Connector...44
Overall Printed Circuit Board Design.44, 55, 56
Final Product Design..45
Parts List.46
Testing Procedures: Validation and Verification...48
Financial Budget50
Team Labor Cost50
Material Cost..50
Team Funding.51
Project Schedule.51
Design Team Information..54
Conclusions and Recommendations..54
References..54
Appendix ...55


i
List of Figures

Figure 1 - Switching-type Power Supply Interfaced with a Microcontroller. 9
Figure 2 - Linear DC Power Supply with Microcontroller Feedback. .10
Figure 3 - Hybrid Switching and Linear Approach. .11
Figure 4 - Entirely Microcontroller-based with Added External Memory. ..13
Figure 5 - Smart Charger Overall Block Diagram. ...15
Figure 6 - Switch-mode DC Power Supply Overview. .16
Figure 7 - Switch-mode DC Power Supply Circuit Schematic. 16
Figure 8 - Smoothed DC voltage from the rectifier...17
Figure 9 - Microcontroller Power Supply Overview.19
Figure 10 - 5V Voltage Regulator.19
Figure 11 - Voltage Sensing Network Schematic. 20
Figure 12 - Microchip MCP 607 Precision Operational Amplifier. .20
Figure 13 - Current Sensing Network Schematic. 21
Figure 14 - High Level Dataflow Diagram. ..22
Figure 15 - Feedback Control Loop. .23
Figure 16 - Main PI Routine. 24
Figure 17 - 40-pin DIL PIC18F452 Package and Schematic25
Figure 18 - AD7705 Interface Schematic. 26
Figure 19 - Maxim RS-232 Serial Interface. 27
Figure 20 - CrystalFontz 40x4 LCD with Backlighting in Operation. .28
Figure 21 - LCD with Hitachi Controller Interface. .28
Figure 22 - LCD Screen During Battery Charging Mode of Operation. ..28
Figure 23 - LM34 Precision Temperature Sensor Package. .29
Figure 24 - Sharp GP1UM28YK Operational Block Diagram. 30
Figure 25 - System Use Case Diagram. 31
Figure 26 - Overall Class Diagram. ..32
Figure 27 - Charging sequence diagram. ..38
Figure 28 - Charging process general state diagram. 39
Figure 29 - Example Battery Holders. ..44
Figure 30 - Finished Product Design. ...45
Figure 31 - Breadboard for Testing During the Design Process49
Figure 32 - Implementation Gantt Chart Timeline View. .53
Figure A1 - Logic Control Board Schematic with Headers to Accessory Devices. .55
Figure A2 - Preliminary System Control PCB Artwork. ..56










ii
List of Tables

Table 1 - Microcontroller-based with Built-in A/D System Comparison5
Table 2 - Microcontroller with External A/D Conversion System Comparison. ...6
Table 3 - Successive Approximation Register Converter Comparison. .7
Table 4 - Dual Slope Converter Comparison. .7
Table 5 - Sigma - Delta Converter Comparison. 8
Table 6 - FPGA-based Controller System Comparison. .8
Table 7 - Entire Hardware Design with Discrete Components. ..8
Table 8 - Switching-type Power Supply Comparison. 9
Table 9 - Linear-type Power Supply Comparison. ...11
Table 10 - Microcontroller with Custom PC Application. ...12
Table 11 - Microcontroller-based with Added External Memory. ...13
Table 12 - PC-Device Communication Packet Protocol. ..34
Table 13 - Device to PC Error codes. ...34
Table 14 - Implementation Parts List.46
Table 15 - Estimated Labor Cost. .50
Table 16 - Estimated Material Cost. .50
Table 17 - Implementation Gantt Chart Tasks and Description. ..52
Table A3 - Communication Protocol. ...57
Table A4 - Device Error Codes. ...58

























iii
List of Equations

Equation 1 DC Voltage...17
Equation 2 Ripple Factor for a Full-Wave Rectifier...17
Equation 3 Smoothing Capacitor Value.....17
Equation 4 Duty Ratio or Duty Cycle.18
Equation 5 Minimum Inductance Value for Switch-Mode Power Supply.18
Equation 6 Parameters to Construct the Inductor...18
Equation 7 Minimum Filtering Capacitor Value19





































iv
Table of Listings

Listing 1 - Pseudo code to Communicate with the External ADC. ..26
Listing 2 - PWM Signal Pseudo code27
Listing 3 - LCD Pseudo code. ...29
Listing 4 - Pseudo code to return Desired Temperature Reading. 29
Listing 5 - Infrared Receiving Routines. ...30
Listing 6 - Example of PSDeviceDriver setVoltage method. ...34
Listing 7 - Building a Sample object from packet data. ...35
Listing 8 - Pseudo code for data analysis voltage calculation. .37
Listing 9 - Pseudo code for data analysis battery temperature first derivative..37
Listing 10 - Lead acid fast charging algorithm. 40
Listing 11 - Nickel Cadmium fast charging algorithm..41
Listing 12 - Nickel metal hydride fast charging algorithm42
Listing 13 - Lithium Ion fast charging algorithm..43





























v
Abstract

With the increase of portable electrical devices, the amount of different types of
batteries a person owns has greatly increased. In addition to different types, the need for
longer battery life has also increased, which led to the need for a universal battery
charger. The purpose of this project is to design and build a true universal battery
charger. This battery charger will charge various battery chemistries, including lead acid,
nickel cadmium, nickel metal hydride, and lithium ion battery types. The charger will
charge a variety of battery sizes with various amp-hour capacities. With a PC, the project
will give the user the control and feedback necessary to completely charge a battery
without damaging it from overcharging. The project will also act as a variable switching
DC power supply using either voltage or current regulation capable of powering a variety
of DC loads.

Features of the Smart Charger:
A universal battery charger that can charge different sizes of batteries
An intelligent and fast battery charging solution for multiple battery chemistries
Report all feedback data of the charging process in an easy to interpret fashion
Easy to use PC software
Variable DC switching power supply
Infrared remote control interface to the variable DC switching power supply

























1
Introduction

Statement of Need The future of many portable electrical devicescellular
telephones, notebook computers, personal digital assistants, and still others to be
developedwill heavily depend upon the use of advanced battery technology. As battery
technology improves, there is a growing need to give the user more control and feedback
during the battery charging process while preventing battery damage due to overcharging.
Current battery chargers offer little to no control over the charging process. Furthermore,
overcharging is a common problem with the simple, inexpensive chargers found in many
consumer electronics products.

Problem Definition

Goals:
This project will address this need by developing an intelligent and fast battery
charging solution for multiple battery chemistries.
This solution will improve the charging efficiency and battery life while
preventing battery damage due to overcharging.
Implement a DC power supply for the battery charging system that will work
independently of a PC.
When interfaced to a PC, a software application will take control of the power
supply to implement an intelligent battery charging solution.
Report all feedback data of the charging process in an easy to interpret fashion
verifiable by a survey of potential battery charging solution users.

Objectives:
Output voltage in the range of 0 20 V with a 20 mV resolution.
Output current in the range of 0 10 A with a 10 mA resolution.
Provide a high level of feedback during the charging process within 20 mV and
10 mA tolerances for error.
Have a liquid crystal display (LCD) to provide user feedback this will allow the
unit to function as a standalone DC power supply when disconnected from a
computer.
Have a user friendly graphical interface compatible with Microsoft Windows to
display the real-time visual feedback.

Constraints:
Charge the following types of modern batteries:
Lithium-Ion (Li-On), Nickel Cadmium (NiCd), Nickel Metal Hydride (NiMH),
and Sealed Lead Acid (SLA).
Support rechargeable batteries in the range of 0 20 V.
Require no modifications to the hardware of existing batteries (i.e. provide a
universal interface).
Must not overcharge any of the four battery types.
Monitor the temperature of the battery and the charging environment.
2
Stay within the current budget of the Electrical and Computer Engineering
Department - $300.

Design Requirements

Output voltage in the range of 0 20 V with a 20 mV resolution.
o After performing research on the commonly used rechargeable Li-On,
NiCd, NiMH, and SLA battery chemistries, it was determined the
0 20 V range would support nearly all rechargeable batteries used to
power domestic and light industrial electronic equipment.
o The 20 mV resolution was selected as a reasonable objective mainly due
to the 10 bit analog-to-digital (A/D) hardware built into commonly
available microcontrollers ( mV
Volts
20
2
20
10
). An accurate and efficient
charging process and high level feedback depend upon the highest
resolution attainable. This resolution must be fine enough to provide
support for charging algorithms that detect subtle voltage changes during
the charging cycle, yet not so fine that the voltage feedback level of
precision becomes irrelevant. In addition, a much higher resolution will
unnecessarily overburden the hardware and software resources required to
implement the design and will introduce much electrical noise into the
system. This will be further explored in the Alternative Design section.
Output current in the range of 0 10 A with a 10 mA resolution.
o Research on commonly used rechargeable batteries reveals the currents
required to fast charge the battery at the 1 C rate
1
lie within this range
(fast charging is a charging rate of greater than 0.5C). Too low of a current
range will not allow fast charging of high capacity batteries, while too
high a current range will introduce unnecessary design complexity that
would not be commensurate with the size and type of batteries intended
for this project.
o The 10 mA resolution was also determined by considering the 10 bit A/D
hardware embedded in commonly available microcontrollers
( mA
Amps
10
2
10
10
). This is a reasonable estimate to produce a high level
feedback of the charging current.
Provide a high level of feedback during the charging process within 20 mV and
10 mA tolerances for error.
o The intelligent charging system will report the real-time feedback of
percentage charge, time to charge, elapsed time while charging, voltage,

1
A charge rate of 1 C means that the battery is charged at the same rate as its nominal capacity. For
example, a 4.2 Ah (amp-hour) battery would require a 4.2 A charging rate for a period of approximately
one hour, with the absolute time dependent on initial state of charge and energy conversion efficiency
during the charging process.
3
current, and power during the charging process
2
. This feedback will be
within the specified resolution for voltage and current.
Have a user friendly graphical interface compatible with Microsoft Windows to
display the real-time visual feedback.
o This custom PC application allows the user to select the desired battery
chemistry and control the charging process. In addition, the user will
receive graphical feedback of the charging process, as mentioned in the
previous objective.
Have a liquid crystal display (LCD) to provide user feedback this will allow the
unit to function as a standalone DC power supply when disconnected from a
computer.
o The LCD will display a text-only user menu selection-type interface.
The user will be allowed to select the constant voltage- or
constant-current mode of operation. The voltage selection must be
within the specified limits of 0-20 V and the current selection
within the specified limits of 0 10 A.
When functioning as a DC power supply, the LCD will display the
constant voltage or constant current value.
This display will also alert the user of any error conditions detected
during the charging process or when functioning solely as a DC
power supply.
Implement an infrared remote control interface to allow user interaction with the
power supply while in stand alone mode.
o An infrared transmitter, combined with the LCD display form a
comprehensive user interface.
o Remote operation allows more freedom in the physical placement of the
power supply.
















2
Not all battery chemistries may support certain feedback information, such as time to charge, without
a priori knowledge of the battery condition, and as such, certain feedback information may not be
supported.
4
Alternative Designs Hardware Ideas

The alternative design analysis below considers system-level and component-level
alternative designs for both the hardware and software parts of the system. The purpose
of this investigation of the advantages and disadvantages of possible alternative designs is
to lead to the accepted technical design which will best meet the stated goals, objectives,
and constraints. Each alternative includes a brief summary, a table comparison of the
advantages and disadvantages, and a functional diagram, where appropriate. One definite
advantage in all alternative designs is the designers familiarity with a particular
hardware component or software tool. On the other hand, a lack of familiarity with a
certain hardware component or software tool leads to an important disadvantage to be
considered. This being said, it is also important not to bias ones decisions on staying
comfortable and limiting ones selection to only what is familiar. The design team
should choose the hardware and software tools that are best suited for the application.

1. System Control and A/D Conversion
To implement a fast-charge algorithm without damaging a battery, the charging
process must be tightly monitored and controlled. The monitoring system is dependent on
accurate feedback of the analog voltage and current signals. In order to process this
analog signal with a digital device, such as a microcontroller or FPGA, an analog-to-
digital converter (ADC) is needed. The amount of resolution is a critical decision to the
success of this system.

1a. Entirely Microcontroller-based with Built-in A/D Conversion.
To control the DC power supply and report feedback to the user via the LCD
display and custom PC application, one possible design uses the built-in analog to digital
resources of the microcontroller. This design lowers overall system cost by reducing the
number of external components. For a scale voltage of 0-20 V, the internal 10-bit
converter will only allow for 20 mV resolution. This is far from ideal when charging
batteries where the end of charge trigger condition may be dependent on small changes in
terminal voltage. To overcome this, the sampling rate could be modified or A/D
conversion for different voltage ranges could be spread over two or more (of the eight
available) analog channels. This design is explored in Table 1.

Table 1. Microcontroller-based with Built-in A/D System Comparison.
Advantages Disadvantages
1. Integrated control and ADC.
2. Minimal assembly required.
3. Only one component to troubleshoot.
4. Built-in 10-bit A/D converter, error
recovery, I/O expansion, and math
support.
5. Student experience with built-in A/D
converter.
6. Software can be implemented in
familiar C programming language.
1. A real-time design may be more
difficult to implement.
2. Much emphasis on software control of
the system.
3. The built-in A/D converter will only
allow for a resolution of about 20 mV;
a much better resolution is needed.
4. Splitting the A/D conversion among
different channels makes
implementation more difficult.
5

1b. Microcontroller with External A/D conversion.
Instead of using the onboard 10-bit ADC with the microcontroller, consider an
external converter that will support a higher resolution. External ADCs are commonly
available in the 12 to 17-bit range of resolutions. This improves the resolution to
approximately 5 mV to .2 mV for the given 0-20 V range. A 16-bit (15-bit + 1 sign bit)
external A/D converter provides approximately a .6 mV resolution, which is sufficient for
this system and much better than the 20 mV resolution. Too high of a resolution, such as
0.2 mV, is unnecessary as the output could easily become indistinguishable from noise.
Since the PWM used to control the MOSFET is set at 10 bits of resolution, this
alternative can take advantage of the coarse built-in ADC with a fast sample frequency as
feedback to control the PWM, while the fine external ADC can be used at a slower
sampling frequency to control the charging algorithm. This alternative is considered in
Table 2.

Table 2. Microcontroller with External A/D Conversion System Comparison.
Advantages Disadvantages
1. Much higher resolution: a 16-bit
external ADC (including a sign bit) will
provide about a .6 mV resolution.
2. The design is more modular this
makes troubleshooting easier.
3. The coarse (10-bit) built-in ADC can
be used for other purposes, such as
feedback to control the PWM at a fast
sampling frequency.
1. More components to implement, test,
and debug.
2. Higher cost.
3. Lack of student experience with
external A/D converters; this may not
be a major issue since the digital signal
will simply be sent to the
microcontroller.

Types of External A/D Converters:

When discussing the alternative of using an external ADC, it is useful to compare
and contrast the various types available, namely: Successive Approximation Register,
Dual Slope, and Sigma-Delta.

1b (i) Successive Approximation Register converters.
Successive approximation register (SAR) converters use a single comparator to
compare the voltage being measured with a reference voltage produced by an internal
digital to analog converter (DAC). The comparison is performed in successive operation
in which a single bit of the representation is resolved during each comparison operation.
A comparison of the SAR converter is shown in Table 3.







6
Table 3. Successive Approximation Register Converter Comparison.
Representative Device: Advantages: Disadvantages:
MicroChip MCP3301
8-pin DIP single
channel
Same type as the 10-bit
ADC built into the
18F452 microcontroller
Up to 100k conversions
per second
High sample frequency
Most common type of
converter

Low(er) resolution;
maximum of 13 bits
May be subject to
excessive error in noisy
environments


1b (ii) Dual Slope converters.
Dual slope converters utilize integration and de-integration components to
determine the output. After a pre-sample initialization, the input is fed to an integrator.
The output of the integrator is a ramp with a slope proportional to the input voltage, and
performed for a fixed period of time. Immediately following the integration period a
precision timer is started and a de-integration is performed using a known internal
voltage reference. The sampled voltage can then be determined with a mathematical
formula based on the reference voltage value and the time required to de-integrate. A
comparison of the Dual Slope converter is shown in Table 4.

Table 4. Dual Slope Converter Comparison.
Representative Device: Advantages: Disadvantages:
Microchip TC500
16 pin DIP package
An inherent benefit is
noise immunity. Input
noise spikes are
integrated (averaged to
zero) during the
integration periods.
Integrating ADCs are
immune to the large
conversion errors that
plague successive
approximation
converters in high noise
environments.
3

High precision; up to 17
bits plus the sign bit.
Front End only,
performs the
integration, de-
integration and
comparison. External
timing of the de-
integration process
determines the
measured voltage.
Requires external,
specialized
polypropylene
capacitors and other
external components
sized to a particular
application.
Low conversion rate
(typically <10
conversions/second).



3
Microchip TC500 datasheet
7
1b (iii) Sigma - Delta converters.
Sigma - Delta converters perform a series of fast, low-resolution samples that are
summed and averaged with a digital filter. A comparison of the Sigma Delta converter
is shown in Table 5.

Table 5. Sigma - Delta Converter Comparison.
Representative Device: Advantages: Disadvantages:
MicroChip TC3400- 16
bit (15 bit and sign bit)
8 pin DIP single channel
High resolution
(effective 15 bit)
microPort 2 wire
serial interface
sample frequency 8
conversions per second

2. Alternatives to the Microcontroller-Based Designs

2a. FPGA-based Controller.
Instead of using a microcontroller to primarily control the system, a Field
Programmable Gate Array (FPGA) is another possible solution. This possibility, which is
explored in courses such as Programmable Logic, is explored in Table 6.

Table 6. FPGA-based Controller System Comparison.
Advantages Disadvantages
1. Low cost.
2. Utilizes knowledge and experience
gained in Switching and Logic and
Programmable Logic courses.


1. Software design and VHDL
implementation require much time and
effort.
2. Debugging with simulation and system
verification may become too difficult
based on the students lack of expertise.
3. External A/D conversion is required.

2b. Entire Hardware Design with Discrete Components.
Instead of using a microcontroller or FPGA, the entire design can be implemented
in hardware with discrete components. In the place of a microcontroller, a control circuit
is used with a LM3524. It contains a voltage reference, oscillator, pulse width modulator,
error amplifier, current sense amplifier, flip-flop, and driving circuitry. It will sense the
output voltage and current levels and control the power transistors. The control circuit
will contain capacitors and resistors to implement a Proportional Integral (PI) control
loop. Some of the advantages and disadvantages of this alternative design are presented
in the Table 7.

Table 7. Entire Hardware Design with Discrete Components.
Advantages Disadvantages
1. Faster response; no A/D conversion or
interface with a computer.
2. Real-time error control with the control
circuit.
3. Inexpensive.
1. Will not meet the design requirements
of a controllable variable output.
2. Lack of data collection capability.
3. Lack of overall control; this hinders the
battery charging process.
8

This design has a quick response and is inexpensive to implement. However,
since the main objective is to charge batteries, this design is not practical. When charging
batteries, the process is slow and the fast response of the LM3524 may be unnecessary.

3. DC Power Supply Alternatives

3a. Switching-type Power Supply.
There is a number of switching power supply designs including boost, buck, and
phase-controlled types, among others. Our design focuses primarily on the direct connect
buck type switching converter. This type of DC power supply rectifies and filters the
incoming AC voltage to produce a high-voltage DC signal. It uses a power MOSFET or
bipolar transistor connected in series with an inductor. The MOSFET acts as an on-off
switch and cycles at a set frequency, typically in the range of 30-150 kHz. While the
MOSFET is conducting, the magnetic field in the inductor increases. When the
MOSFET is switched off, the built up magnetic field collapses causing current to
continue to flow to the load. The average DC voltage supplied to the load is dependent
upon the duty cycle, or the on-vs.-off time of the switching element. This timing is
typically controlled by a pulse width modulator (PWM). By sampling output parameters,
such as V
out
and I
load
,

the PWM period can be varied dynamically to produce a desired
output. A block diagram of a switching power supply is shown in Figure 1.


Figure 1. Switching-type Power Supply Interfaced with a Microcontroller.

A switching-type supply comparison appears in Table 8.

Table 8. Switching-type Power Supply Comparison.
Advantages Disadvantages*
1. High efficiency: 80 90 %.
2. High reliability.
3. Light and small.
1. More complicated to design than linear-
type.
2. Radiated EMI and electrical noise may
become a problem due to the wide
frequency range of harmonics
generated at high switching
frequencies.
Unregulated DC
power supply
Output
Sampling
Circuit
Error
Amplifier
Voltage
Reference
PWM OSC
Switching
Element
Energy
Storage
(Inductor)
9
*Note: Early switching-type power supplies included the disadvantages of reduced
reliability and radiated electromagnetic interference (EMI) due to the discrete
components used to control the pulse width and the transistors used as switch
components. Modern advances in PWM circuits and the use of MOSFETs have
significantly decreased these disadvantages.

3b. Linear-type Power Supply.
A linear-type DC power supply takes the incoming AC voltage and steps it down to a
lower AC voltage. This voltage is then rectified through a full-wave bridge rectifier and
filtered. The output is then passed to the load via a power transistor that is used to control
the output to the load. This transistor is controlled by a circuit that senses the output and
modifies the transistor bias voltage in order to maintain the desired output. The common
7805 integrated circuit is a three terminal device with terminals for input, ground, and
output that effectively combines a power transistor and feedback sensing loop into a
single device.
A linear power supply can be interfaced with a microcontroller by coupling the
microcontroller to a power bipolar transistor or power FET (field effect transistor) that
acts as the linear regulating device. The bipolar device is current controlled, and the field
effect device is voltage controlled. Some specialty microcontrollers have built in DACs,
but this is more common with PSoc (Programmable system on chip) mixed signal array
devices. External DA converters are commonly available that interface to a
microcontroller via a synchronous serial port (I2C, SPI, Dallas one wire, etc) or parallel
port. A high-level diagram of this interface is shown in Figure 2.

Linear
Control
Element
Unregulated DC
power supply
Figure 2. Linear DC Power Supply with Microcontroller Feedback.

The linear supply system comparison is shown in Table 9.







Output
Sampling
Circuit
Error
Voltage
Amplifier
Reference
10
Table 9. Linear-type Power Supply Comparison.
Advantages Disadvantages
1. Easy to design.
2. Inexpensive.
3. Relatively free of noise and EMI.
4. Superior regulation performance with
minimal ripple.

1. Low efficiency: typically 50% or less.
The power loss is mostly in the form of
heat dissipated by the power transistor.
This heat must be dissipated by some
means, and may necessitate the use of
heat sinks, fans, or some other cooling
method.
2. Typically heavy and bulky due to the
large transformers and other power
components needed compared to a
similar switching supply of the same
output power.

3c. Hybrid Switching and Linear Approach.
The final design could incorporate both the switching and linear-type power
supplies. The switching power supply can be used to supply a coarsely regulated input to
a final linear stage. This design attempts to leverage the advantages and minimize the
disadvantages of each type of regulation scheme by a combination of both. The
switching supply provides high efficiency and an output that minimizes the voltage drop
across the linear section, which minimizes the continuous power dissipation of the linear
section. This hybrid approach is illustrated in Figure 3.

Linear
Control
Element
Figure 3. Hybrid Switching and Linear Approach.

Alternative Designs Software Ideas

1. User Feedback.

1a. Microcontroller with Custom PC application.
In order to provide high quality feedback of the charging process, one solution is to
display critical information on an LCD and display the graphical and numerical data on a
custom PC application. The LCD would serve as a simple alphanumeric user menu-type
interface and display the constant supply voltage and current in the appropriate modes.
The PC application will display real-time parameters of the charging process such as
percentage charge, time to charge, elapsed time while charging, voltage, current, and
Unregulated DC
power supply
Sampling
Circuit
Error
Amplifier
Voltage
Reference
PWM OSC
Switching
Element
Energy
Storage
(Inductor)
Sampling
Circuit
Error
Output Voltage
Amplifier
Reference
11
power during the charging process. The big advantage of using a PC application is the
enormous amount of processing power and hard drive space provided on modern PCs
this can be used to display rich graphical data plots and even log the charging process for
further engineering study. The PC is also capable of processing high precision floating
point numbers that are generally beyond the capabilities of a microcontroller and can
only be implemented in slow software algorithms (i.e. the microcontroller has no
hardware floating point unit). For example, some complex charging algorithms require
first and second derivative voltage computations. Percent charge information may
require a numeric integration computation. The complex instruction set microprocessor
in modern PCs, combined with the extensive mathematic libraries accessible by high
level languages forms a highly capable platform to implement even the most complex
algorithms. The PC is the tool to implement Smart in the Smart Charger design. This
solution is considered in Table 10.

Table 10. Microcontroller with Custom PC Application.
Advantages Disadvantages
1. Can display numerical data and rich
graphical data plots of the charging
process.
2. Much processing power for
computationally intensive algorithms.
3. Plotting and storage capability for data
logging.
4. Gives the average user and the
experienced engineer a robust tool for
monitoring and analyzing purposes.
This allows the product to be used in an
industrial setting as well.
1. Requires a computer and an appropriate
software and interface.

1b. Entirely Microcontroller-based with Added External Memory.
This alternative was based on todays need for portability. For that reason, a
microcontroller with added external memory could be used to store all the software
needed for charging batteries and displaying pertinent data. The microcontroller should
be smart enough to know what software to load from the memory depending on the type
of battery needed to be charged, or depending on the input of the user. The capability of
hooking this assembly to a computer is still present for various purposes like
reprogramming the microcontroller, or adding new software to the external memory.
Given the fact that the unit can be built professionally in a very small size, this could be a
very compact independent battery charger, or a variable power supply, as needed. A
diagram of the unit is presented in Figure 4 below:


12

Figure 4. Entirely Microcontroller-based with Added External Memory.

PIC
Microcontroller
External Memory
Unregulated
DC power
supply
Switching
Element
PWM
LC Filter
Network

EMI Filter
LCD Display
Current Sensing
Temperature probes
Temperature Sensing
Voltage Sensing
DC output
Infrared Remote
PC Workstation

Some of the advantages and disadvantages of this alternative design are presented in the
Table 11:

Table 11. Microcontroller-based with Added External Memory.
Advantages Disadvantages
1. Very compact unit that could be easily
carried anywhere.
2. Same battery charging capabilities as
the unit connected to a computer
3. Focuses the design on the
microcontroller.
4. No need to develop a custom PC
application.
1. An alphanumeric LCD could not
display graphical data plots of the
charging process.
2. A more robust display would be much
more difficult to program and debug.
3. Limited processing power (compared to
a PC) for numerical data manipulation
and severely limited storage capability
and data logging.
4. Overall programming and debugging
effort would become quite complex.

The fact that graphs cannot be displayed with a portable charger would be a very big
disadvantage. During the charging process it would be very beneficial to be able to see
the graphs of the voltage and current. The graphs give a lot of information about the
charging process to a knowledgeable person.


13
Accepted Technical Design: High-Level

After performing a detailed alternative design analysis, the Smart Charger group has
decided to design the battery charging system using a microcontroller, an external
analog-to-digital converter, a switch-mode power supply, and an LCD and custom PC
application for high-level user feedback. In the process, the group extracted a clearer
understanding of the problem definition and how to meet this definition in an actual
technical design. As the core of the Smart Charger design, this section will discuss all
hardware and software components of the accepted technical design and is a major step
towards successfully implementing the design in the spring semester.
A good initial understanding of the design can be obtained by carefully examining
the overall high-level block diagram shown in Figure 5 on the following page. In order to
prevent the propagation of electrical noise from the switch-mode power supply to the
integrated logic control components, the system is divided into two boards: a power
electronics board and a system control board. As the core source of power to the battery,
the design will begin with the switch-mode power supply, proceed to the logic control
circuitry, and finally progress to the custom PC application design. The resulting detailed
hardware design will combine the system components into a full schematic illustrating
the interfaces between the components
14
120V AC
DC output
Figure 5. Smart Charger Overall Block Diagram.
Control Board

PC Workstation
PIC Microcontroller

Step-down
transformer
Switching
Element
LCD Display
IR Detector
+5V GND
Temperature probes
(ambient, battery)
External A/D
SPI PWM
A/D
IR Remote
Power Board 5 Volt
Regulator

Rectifier,
Filter
Inductor

Catch
Diode


Filter
Current
Sense
Voltage and Current
Sense, Scaling
Load
Step-down
transformer,
Rectifier,
Filter
RS 232 Level Converter
15
DC Power Supply
The core of the Smart Charger design is the DC power supply. This power supply
must operate in a constant voltage or constant current mode. With these two modes, the
power supply can recharge most common types of batteries using the correct algorithms.
From the knowledge gained through the Alternative Design Analysis process, the power
supply will be a switching type. A switching power supply will allow for high efficiency,
about 80 90 %, and high reliability. A switching power supply will also be smaller and
lighter than a linear type. The switching power supply will have two converters: an
uncontrolled full-wave bridge rectifier to obtain an unregulated DC voltage that will be
fed into a buck converter to get the desired output. With the two converters, a range of 0
to 20V could be obtained at the output, which should be enough to charge most batteries.
An overview of this supply is shown in Figure 6.

Figure 6. Switch-mode DC Power Supply Overview.

A detailed view of the power supply is shown in Figure 7. The unregulated DC comes
from a full wave bridge converter. The switching element is a power MOSFET and the
energy storage element is an inductor. All these parts are explained below.


Figure 7. Switch-mode DC Power Supply Circuit Schematic
Unregulated DC
power supply
Load:
battery
Sampling
Circuit:
Vdiff, Idrain PWM
Switching
OSC
Element
Energy Storage
(Inductor)
to microcontroller
16
The AC line voltage signal will be stepped down to 24VAC (rms value) with the aid of a
transformer. The AC transformer output voltage will go through a full-wave
uncontrollable bridge rectifier. The AC input voltage is applied to the diagonally opposite
ends of the bridge and the DC voltage is available on the other side. The bridge rectifier
is a circuit which converts an AC voltage to a DC voltage using both half cycles of the
AC input voltage.
The value of the DC voltage obtained out of the bridge can be determined by Equation 1,
where V
m
is the peak AC voltage:

m m
m DC
V
t
V
tdt V V
2
cos sin
1
] [
0
0
= = =

Equation 1
For our power supply, V
m
is 24* 2 = 34V, thus yielding a V
DC
or an average voltage
equal to 22V. The ripple factor for a full-wave rectifier is given by Equation 2, which
yields a 0.5V ripple at the bridge output.
1
) (
2
=
DC
rms
V
V
Equation 2
Since there is no average current through a capacitor, the smoothing capacitor will have
no DC current going through it, thus all the DC current will go into the MOSFET, while
the AC components will be filtered out. Also, the capacitor will smooth out the
unregulated voltage coming from the full bridge rectifier. Figure 8 shows the rectified
varying DC (dotted line) and the smoothed DC (solid line). The capacitor charges quickly
near the peak of the varying DC, and then discharges as it supplies current to the output.
The smoothing capacitor value can be computed with Equation 3.

fRC
V
V V
m
m dc
4
= Equation 3


Figure 8. Smoothed DC voltage from the rectifier.
For an AC frequency of 60 Hz, an input peak voltage of 34V, a 22V DC voltage and a 2
maximum output resistance, the capacitor value required is 5.9mF. The larger the
17
capacitor, the better, since an increased level of smoothing of the input voltage will result
in a nearly constant DC input voltage.
The buck converter will decrease the input voltage to the desired value by turning a
switch on and off. In order to control the supply, the microcontroller will dynamically
send a PWM signal to the gate of an n-channel power MOSFET. When the MOSFET is
turned on the diode will not work since it is reversed bias, and the inductor will begin to
store energy. When the transistor switches off, the diode becomes conductive, and the
inductor releases energy to the load, and then the cycle repeats. The purpose of this diode
is to direct current flow in the circuit and to ensure that there is always a path for the
current to flow into the inductor. The Schottky diode was chosen because of the very fast
switching times that the diode is capable of, and also the low forward-voltage drop given
by its construction (a metal-semiconductor barrier, rather than a semiconductor-
semiconductor barrier found in most of the other diodes). To determine the voltage, the
PWM will have a duty ratio or duty cycle given by Equation 4.

D
V
V
IN
O
= Equation 4


The duty cycle D will change depending on the desired output voltage V
0
.
An inductor is also used in the buck converter to store energy when the switch is
on and to supply energy when the switch is turned off. Equation 5 was used to determine
the required minimum inductance value:

TR
D
L
crit
*
2
1
= Equation 5

In this equation D is the duty cycle, T is the period and R is the maximum resistance. For
a PWM switching at a frequency of 32 kHz, the period T is 31.25s and the maximum
resistance R is 2. For the minimum duty cycle, the largest critical inductor value is
calculated to be 31.25H. Since the value of the needed inductor is known, the following
formula can be used to determine how to properly build it:

l
A N
L

2
= Equation 6

Here, N is the number of turns, is the permeability of the core material, A is the area of
the coil, and l is the average length of the coil. Given a regular size core with an area of
around 2 square inches, a permeability of around 25
0
for a high flux core, and an
average length of the coil of 10 inches, the desired number of turns would be around 5
turns.
A capacitor is used at the output as a filter to reduce ripple in the voltage. Since
switched power regulators are commonly used with high current, high-performance
power supplies, the capacitor should be chosen for minimum loss. Equation 7 will
determine the capacitor value.
18
I Lf
D
C

=
) 8 (
1
2
Equation 7
L is the inductance and is the frequency at which the PWM operates. Given the
desired ripple
f
I as 0.1, the minimum filtering capacitor value is 40.96 . F

Microcontroller Power Supply

The microcontroller is the brain of the design. It requires a constant 5V input that has
to be as clean as possible, meaning that it is desired to have as small ripple voltage as
possible. Since the current requirements are rather small (less than 1A), it was proposed
that a commercial transformer will be used to power up the microcontroller. This will
ensure the proper voltage will be supplied at all times, making the overall project more
reliable. Figure 9 shows a general schematic of the power supplies:


Figure 9. Microcontroller Power Supply Overview
The schematic in Figure 10 shows the basic construction of the 5V supply. It is based on
the inexpensive 7805 voltage regulator.











Figure 10. 5V Voltage Regulator
19
Voltage and Current Sensing
In order to accurately and efficiently charge a battery and deliver feedback to the
user, voltage and current sensing networks must be built into the switch-mode power
supply circuitry. To monitor the voltage across the battery, the 0-20 V output will be
scaled using two precision resistors. The voltage output will be sent to Channel 0 on the
internal PIC ADC to control the PWM for the battery charging algorithm and the
standalone power supply modes of operation. This signal will also be sent to Channel 1
on the external ADC. This signal will be for the high-precision feedback to the
microcontroller and PC for user feedback purposes. The voltage sensing network in the
context of the power supply circuitry is shown in Figure 11. As can be seen from this
schematic, a simple voltage-divider branch will scale the outputs to achieve compatibility
with the PIC ADC and external ADC input voltage requirements.


Figure 11. Voltage Sensing Network Schematic.

These signals will be isolated from the power supply circuitry using a voltage follower
operational amplifier stage. The purpose of this is to prevent an over voltage condition on
the ADC pins and to isolate the ADC input impedance requirements from the rest of the
circuit. For this application, the Microchip MCP 607 op-amps were chosen because of
their precision low power operation and rail-to-rail output swing capability. These
devices, which are shown in Figure 12, are available in dual packages, which will reserve
an additional op-amps for the current sensing network.

Figure 12. Microchip MCP 607 Precision Operational Amplifier.

20
In order to sense the current flowing through the battery, a low-side current sensing
network will be used. Low-side current monitoring consists of measuring the voltage
across a small current sense resistor connected in series with the ground path and dividing
by the known value of the sense resistor. This technique is illustrated in Figure 13. Since
the voltage measured across this 0.01 resistor is small, it is amplified before being sent
to the two A/D converters.


Figure 13. Current Sensing Network Schematic.

System Control: Microcontroller-Based Approach
After evaluating the options for system control, the embedded microcontroller-based
approach was determined to be the most suitable alternative for this smart design. As
the core controller, the integrated microcontroller will serve many purposes:
implementing the proportional integral (PI) control loop to change the voltage or current
output, processing the serial digital voltage and current sensing signals from the external
ADC, processing the temperature sensor feedback signals, transmitting these sensing
signals to the PC application via the RS-232 serial interface, processing the infrared-
remote input, and driving the LCD for user feedback. This overview is illustrated in the
high-level block diagram of Figure 14.








21













































Initialize System
Init PIC, ADC, LCD and PWM=0
Start
Wait for Command
From the computer or IR (polling)

Command
Received
No
Yes
Parse Command

Source

IR remote
Output Defaults
Parse command
1. Mode
2. Set point
PI
Set the PWM
User feedback
Computer
Figure 14. High Level Dataflow Diagram.
22
Proportional Integral Control Algorithm
A very important part of this design is developing a control algorithm that will
accurately modify the output voltage or current in response to an input voltage or current
setpoint. Most algorithms for charging batteries require different charging stages that
output a certain amount of current depending on the stage in the charging process.
Control is also vital to the DC power supply mode of operation, for if a user decides to
change the voltage from 5 to 10 V, or the current from 2 to 3 A, for example, the system
must respond to perform this change.
To accomplish this control, the design will use a simplified form of the well-known
Proportional, Integral and Derivative (PID) technique that is used to control many
continuous processes in a feedback system. This control algorithm consists of a simple
proportional gain (K
P
) that is multiplied by the present error, an integral term that looks at
the sum of past errors and has an integral gain (K
I
), and a derivative term that works on
the present and past error to forecast a future response of the system. The derivative term
is useful in situations where the time response to reach the setpoint is required to be
small. Since this application does not require fast changes in the system output, the
group was advised that Proportional, Integral, or PI, control would be sufficient.
A basic feedback control loop for this system is shown in Figure 15. In this figure,

Figure 15. Feedback Control Loop.

the userthe computer charging algorithm or DC power supply usersignals a desired
current or voltage setpoint. This is the value that the system will drive towards. The
difference in the desired setpoint and current system output is calculated and is called the
error. The PI Controller will take this error and attempt to correct it by modifying the
duty ration of the PWM signal to the power electronics board. The plant, or physical
circuitry, will output the modified current or voltage. The plant output will be measured
with the voltage and current sensing methods discussed above and sent back to be
compared with the desired setpoint.
The most significant aspect of the control system is the block labeled PI
Controller. This component is responsible for measuring the output of the plants
voltage and current sensors, process these signals, derive an error based on the signal and
the setpoint, and determine the PI values that have to be sent to the plant for correction.
setpoint + error
(t)
(PWM
duty ratio)
system
output
PI
Controller
Plant
Feedback
-
23
The proportional term is the proportional gain multiplied by the error. The amount of
correction necessary is directly proportional to this error, hence the term proportional.
Proportional control alone will drive the error to a small value, leaving a steady-state
error. The integral control is used to determine the sum of all past errors at fixed time
intervals. The actual constants themselves must be tuned along with the plants
implementation, and this will be done in the spring semester. For now, the main PI
control routine will be implemented based on the design shown in the flowchart in Figure
16.

error
error = 0?
YES
PI action not
n required, retur
NO
Calculate
al term Proportion
K
P
* error
Calculate
m
K
I
* Proportional
Integral ter Term
Proportional +
Integral

Figure 16. Main PI Routine.

To perform the system control functions mentioned above, the Microchip
p
In
.
PI Output: sent
to plant

PIC18F452 was chosen because of its rich feature set, familiarity to the design grou
(based on the Microprocessor Interfacing course and laboratory experience), and
accompanying Microchip MPLAB IDE tool suite and In-Circuit Debugger (ICD).
addition, since the PWM frequency is directly related to the microcontrollers clock
oscillator frequency, a suitable microcontroller had to support a high clock frequency
The microcontroller software will be coded in the C language using the robust CCS
compiler. The microcontroller design will begin with the hardware design interface
24
including all connected design accessoriesand proceed to the detailed software desig
Given that the microcontroller design is primarily implemented in software, the software
design portion will include the function, input/output description, data flow charts, and
pseudo code procedural definitions of each of the stated control functions.

n.
icrocontroller Hardware Design Interface
The 40-pin Dual In Line PIC18F452 and 8 MHz clock oscillator that will be used as
M


input to pins 13 and 14 is shown in Figure 17. The microcontroller will actually operate
at 32 MHz by setting a 4x phase lock loop multiplier.


Figure 17. 40-pin DIL PIC18F452 Package and
S
Pin 17 will be used as output for the PWM signal (through a logic board to power supply
xternal Analog-to-Digital Converter
learly revealed that the high-quality feedback
C was high-resolution;
the sampling frequency need not be very fast for data acquisition of battery systems. As a
chematic (including the 8 MHz clock oscillator).

board header), input / output (I/O) pins 18, 23, and 24 for the SPI communication to the
external ADC, I/O pins 25 and 26 for the Maxim RS-232 interface, and output pins 19-21
and 27-30 of PORTD for the liquid crystal display controller command and data bus. The
final design will also include an LED for testing and verification purposes (although not
shown to the user). Each of these subcomponents will be considered separately.

E
The Alternative Design Analysis c
required to control the battery charging algorithm is a vital part of this design. As a result,
a high-resolution external A/D converter (ADC) was selected over the built-in converter.
The function of this device is to convert the differential analog voltage and current
sensing signals into digital signals to be processed by the microcontroller. The
microcontroller will report these digital signals to the computer application that will
display the signals and adjust the charging algorithm if required.
The driving criteria behind selecting a suitable external AD
25
result, the Analog Devices AD7705 16-bit Sigma-Delta ADC was chosen. This device
yields a resolution of 20V/2
16
= 0.305 mV over a 0-20 V design constraint. The AD7705
features no missing codes, two fully-differential analog input channels, a differential
reference input, 4.75 V to 5.25 V operation, a three-wire Serial Peripheral Interface (SPI),
and many more features. Particularly attractive is the high degree of compatibility with
the microcontroller: the flexible serial interface and SPI protocols are fully compatible
with the PIC18F452 and the supply voltage range allows for the microcontroller and
ADC to be powered on the same system logic board
For this battery monitoring application, one input channel will be used to
differentially measure the voltage across the battery. The other input channel will be used
m to onitor the current to the battery. The AD7705 device and input / output schematic is
shown in Figure 18. The external ADC will be placed on the system logic board which is
powered by the 5 V supply (VDD). This particular device requires a 2.4576 MHz
oscillator as clock for MCLK, and communication is done on the (active low) data ready
or DRDY signal. There will be a logic header attaching the ADC to the other integrated
board components.


Figure 18. AD7705 Interface Schematic.

To communicate troller, the pseudo
code driver shown in Listing 1 will be imple ented. The embedded C pseudo code
display
) ; / / I ni t i al i zat i on r out i ne: conf i gur es cl ock, chi p
/ / sel ect , r eset pi ns, del ay; cal l s

/ / St ar t A/ D conve
( r equi r ed_t i me_ s synchr onous r eadi ng
_ c_
the External ADC.
with the external ADC from the microcon
m
ed for all listings uses the actual functions and variables provided in the CCS C
compiler.

adc_i ni t (
/ / set up_adc_devi ce( ) t o set up t he
/ / devi ce par amet er s
r si on
el apsed) / / Endl es i f
i f ( ADC_DRDY) {
gl obal Vol t age = r ead_adc_val ue( ch 1) ;
= r ead ad val ue( ch 2) ; gl obal Cur r ent
}
Listing 1. Pseudo code to Communicate with


26
RS-232 Serial Interface
The bi-directional feedback between the microcontroller and PC application will be
axim RS-232 serial interface. This device performs a level made possible via the M
conversion from the TTL level signals of the microcontroller to the RS-232 levels of the
computer. This hardware interface is shown in Figure 19.


Figure 19. Maxim RS-232 Serial Interface.

The communicatio iscussed in Tables A3
the Appendix.

The Pulse Width Modulation (PWM) signal will be generated by the microcontroller
rent output of the DC power supply. A change in pulse width
in
set up capt ur e compar e modul e f or PWM;
f r equency;
I
_i ni t ( ) ; / / I ni t i al i ze PWM t o zer o wi dt h
ack on bot h channel s
l e



n protocol and impromptu error codes are d
and A4 in

Pulse Width Modulation

to adjust the voltage or cur
is itiated by either a change in the desired voltage or current from the infrared remote or
from the PC charging application. This signal will be sent to the base of the power
MOSFET in order to perform this function. In order to isolate the system control board
from the power electronics board, the signal will be passed through an isolation buffer
(TC1141N). The PWM signal will be sent on pin CCP1 (pin 17) and generated with the
pseudo code shown in Listing 2:

voi d pwm_i ni t ( ) {

conf i gur e PWM
}

n t he endl ess l oop, use: / /
wm p
val ue = r ead_adc( ) ; / / Feedb
S set _pwm1_dut y( val ue) ; / / et s pul se hi gh t i me f or each cyc
Listing 2. PWM Signal Pseudo code


27
L

(L
iquid Crystal Display Interface
A central component to the user feedback of this system is the liquid crystal display
CD). The LCD will be used to display the load voltage, load current, and battery
mperature (ambient, etc.) to the user during both the battery charging and the
ply modes of operation. For this design, the 40x4
te
standalone programmable power sup
(40 columns x 4 rows) CrystalFontz alphanumeric LCD with the built-in Hitachi 44780
controller and LED backlighting will be implemented for this important purpose. The
manufacturers sample picture of this LCD is shown in Figure 20 below.


Figure 20. CrystalFontz 40x4 LCD with Backlighting in Operation.

The LCD display and controller hardware interface is shown in Figure 21. The
microcontroller will communicate with the LCD using a four-bit bus consisting of D00-
D03a n wn in the
gure are used for command / data, enable, and read / write signals, respectively.

ibble mode operation. In addition, the RS, E, and R/W lines sho
fi

Figure 21. LCD with Hitachi Controller Interface.

A sample screen during operation of the Smart Charger system is illustrated in Figure 22.



M o d e : P C T e m p .


V o l t a g e : 1 0 . 0 0 0 V B a t t e r y : 8 0 . 3 F


C u r r e n t : 1 . 5 2 0 A A m b i e n t : 7 0 . 5 F



Figure 22. L D Screen During Battery Charging Mode of Operation. C



28
The pseud

l cd_i ni t ( ) ; / / t he di spl ay.
cd_got oxy( l ef t - most col umn, t op r ow) ; / / posi t i on ( 1, 1)
D.
ct er on di spl ay
D Pseudo code.
Precisi
The LM des a
voltage output in linear propo ut of the device is 10mv per
degree Fahrenheit, referenced from 0 degrees Fahrenheit. The device has a guaranteed
ample, 0F outputs 0mV, 70 F outputs 700mV. The
device
o code to communicate with the LCD is included in Listing 3 below.
I ni t i al i ze
l
/ / Def aul t scr een speci f y desi r ed put c f unct i on
r i nt f ( l cd_put c, Mode: V Temp. , t emp) ; p
i f ( di spl ay t o be updat ed) {
l cd_got oxy( x l oc. , y l oc. ) ; / / Go t o l ocat i on on LC
pr i nt f ( l cd_put c, Message t o Di spl ay, t emp) ;
/ / Cal l s l cd_put c( ) t o pl ace each char a
}
Listing 3. LC

on Temperature Sensing
34 precision temperature sensor is a 3 terminal device that provi
rtion to temperature. The outp
accuracy of 1 F at 70 F . For ex
can be powered from a 5-30 volt source. The device comes in multiple packages,
including a TO-92 plastic package that will be used in this design. The LM34 package is
shown in Figure 23. The function to read the temperature is displayed in Listing 4 below.





Figure 23. LM
oubl e get Temper at ur e( i nt adcVal ue) {
/ / 10 bi t adc, max adc i nput at 5000mV
r et ur n adcV at i on
}
esired Temperature Reading.

34 Precision Temperature Sensor Package.

d

al ue/ ( ( 2^10) - 1) *( 5/ 10) ; / / Temper at ur e cal cul
D Listing 4. Pseudo code to return



29
Infrared Rem
The Infrared detection is implemente with the Sharp GP1UM28YK infrared
etecting unit. This unit combines a number of signal processing functions in a compact
terminal device. The operational block diagram of the device can be seen in Figure 24.
ote Input
d
d
3


Figure 24. Sharp GP1UM28YK Operational Block Diagram.

The device discriminates between a plethora of extraneous infrared noise sources
and locks in on the modulated 38 kHz source produced by an infrared remote control.
The device im ring inactive
eriods, and 0 volts when in the presence of the 38 kHz source. The device is connected
to the
/ / Don t pr ocess anot her command unt i l
/ / l ast command i s r ead
ast Ti me;
t o_
r ecei veBi t 0
&& I RFr ameVal i d)
E; }
Listing 5. Infrared Receiving Routines.
plements negative logic, and outputs approximately 5 volts du
p
microcontroller via an external interrupt pin that is configured to interrupt on
falling edge signals. The microcontroller interprets the command from the infrared
remote control by timing the interrupts, or falling edges of the signal, in the interrupt
service routine. The C code to implement this function is show in Listing 5.

I ni t i al i zat i on;
voi d I R_i sr ( ) {
i sr _i ni t i al i zat i on;
i f ( I Rhi t )
r et ur n;
del t aTi me = t i mer ( ) l
l ast Ti me = t i mer ( ) ;
i f ( del t aTi me_ o smal l | | del t aTi me_t oo_l ar ge) {
= ;
r et ur n;
}
set _dat abi t _based_on_del t aTi me;
shi f t _l ef t ( I RFr ameAddr ess, shi f t _amount , dat abi t ) ;
i f ( ent i r eFr ameRecei ved
I Rhi t = TRU

i nt I Rhi t ( ) { r et ur n I Rh; }

i nt get I RCommand( ) {
I Rh = FALSE;
Ret ur n I RFr ame. command;
}
30
PC Software Application
ge, such as Visual Basic
his is an object orien ft Windows developers.
The application will be enginee ing the notion of
class modules and objects. These class modules implement data encapsulation by
providing a public interface while hiding the internal data and implementation.
Because the application is object oriented, it makes sense to model much of the
application using UML (unified modeling language). This is an open standard modeling
language managed by the Object Management Group (OMG), and used extensively in
industry. One benefit of using a graphical modeling language is that the computing
system can be understood by the computer programmer as well as client users of that
software. The use of UML in documenting Object Oriented (OO) software design has
become the de-facto standard, and in fact the UMLs importance comes from its wide
use and standardization within the OO development community. The UML has become
not only the dominant graphical notation within the OO world but also a popular
technique in non-OO circles.
4
This document will primarily utilize UML diagrams to provide a general, overall
software system description with supplemental descriptions for those not familiar with
UML syntax. The use of pseudo code will also be utilized to provide more focus on the
underlying details.
Figure 25 represents the general system use case with respect to the user. The
user may interact with the Power supply hardware directly to power a general DC load.
The user may also interact with a personal computer (PC) that will extend the
functionality of the power supply to act as a battery charger, which connects to a battery.
This section primarily describes the PC interface with the user and the implementation of
the charger.

















Figure 25. System Use Case Diagram.


The PC application will be written in a high-level langua
6. T ted language very popular with Microso
red using an object oriented style by us

4
UML Distilled, Martin Fowler, Adison-Wesley publishing 2004
Battery
User
PC
Charger
Power Supply
Smart Charger
DC Load
<<extends>>
31
The operation of object oriented programs is determined by the class objects used to
reate the application and the interaction of these class objects. Figure 26 shows the
overall

Figure 26. Overall Class Diagram.
ain Form
The main form implements the main user interface when the application starts. This
rm provides all the control and feedback necessary to operate the power supply
anually. This form interacts with the Powe anual operation of
e power supply. The main form is t in opening other application forms
ia a menu bar control or command button. From the main form configuration data that
stored in the Windows registry can be edited.

c
class diagram of the application. Each class object is further described in the
discussion.

M

fo
m r Supply class to allow m
he starting point th
v
is

Main
Form
Power
Supply
PS Device
Driver
MS Comm
Control
Charger Charging
Form
Timer
Sample Data Graph
Data
Analyzer
Configuration
Device
Timer
*
Association multiplicities are 1
unles
Lead Acid NiCad Li Ion NiMh
Create
s specified otherwise
Store Sample
*
Primary Attributes
ComSettings:String
PSSettings
ChargerSettings


Primary Methods
Load()
Save()
getComSettings()
getPSSettings()
getChargerSettings()

Primary Responsibilities
Loads configuration data
from registry
Dispatch settings via
blic inte
Save edits to registry
Configuration Class Summary
rface pu
32

The configuration class contains initialization information used by various
component classes of the application. This includes communication port and baud rate
setting, update rates, and sampling frequency settings. The Configuration class stores the
configuration data in the operating system registry.



The PowerSupply class is a high level representation of the power supply. Public
methods of this class include those that a power supply user would typically invoke,
includ ltage and setCurrent. These parameters are stored as data members of the
class. The PowerSupply class sends messages to PSDeviceDriver, which is a class in the
chain that implements communication between the PowerSupply class and the physical
hardware. PowerSupply periodically queries the hardware as a response to an event
trigger (typically once a second) from mer object. The device then sends a status
message indicating t age, d Temp . This in on is stor
in instance of a Sample object, with the time appended to the data, and then stored in the
Data container class.



er re essages from PowerSupp
packet that the hardware wi iceDriver also re
d es these PowerSupply
protocol for all messages to given in Table 12. Error codes sent
from the device to the PC a These table
Appendix as Tables A3 and A4.

Primary Attributes
Mode:MODETYPE
VoltSet:double
CurrentSet:double

Primary Methods
setVoltage(double)
rrent(double)
mple():Sam
Event()
ing setVo
the Ti
Current, an he Volt eratures formati ed as
The PSDeviceDriv ceives m ly and creates a message
ll interpret. PSDev
by
ceives messages from the
. The communications evice and translat messages for use
and from the device is
shown in Table 13. re s are also given in the
Primary Attributes

Primary Methods
setVoltage(double)
setCurrent(double)
getSample():Sample
recEvent():Event
Primary Responsibilities
Data conversion between
higher level PowerSupply
class and device
Package monitored
parameters (voltage,
current, temperature,
time) into Sample object
PSDeviceDriver Class Summary
setCu
getSa
timer
ple
Primary Responsibilities
Direct power supply
hardware in response to
us s


PowerSupply Class Summary
er interaction
33
Table 12. mmunication Packet Protocol.

sumed

Table 13. Device to PC Error codes.

The main function of h level commands (like set
th 3 v streams (0x56, 0x1D, 0x71) sent via RS-
232 serial communications ation is a co
PowerSupply represents voltages and currents in floating point
utilizes unsigned 16-bit inte um supply t. With
a maximum output voltage bit integer 0xF
represents 10 volts, and 0x0000 represents 0V. This type of conversion is represented in
Listing 6 pseudo code.

unct i on set Vol t age( doubl e ar g)
i n
by
tData
ambient temperature, and battery temperature in one
acket. In the PC this data is converted to a Sample class type, and ultimately stored in
PC-Device Co
Error Codes
Code Description Notes
0 Power on reset Normal message during a power up
1 Watchdog reset Watchdog timer timed out
2 reserved
3 reserved
4 ADC consistency check failed AD7075 and internal AD differ too much
5 PWM at maximum PWM is at maximum and the supply cannot achieve the set point
6 PWM at minimum PWM is a minimum and the supply cannot achieve the set point
7 Over Voltage fault Voltage exceeds max output for the desired current set point
8 Over Current fault Current exceeds max output for the desired voltage set point
9 reserved
10 communications timeout During PC control, device must receive a message every 10 seconds or a loss of communication is as
11 UART frame error
12 UART error
13 SPI error
14 communication failure to AD7075
15 reserved
16 reserved
17 reserved
18 reserved
19 reserved
20 reserved
PSDeviceDriver is to convert hig
e output voltage to 2. olts) into byte array
. The main interpret nversion in data types. The
numbers, while the device
voltage, or curren gers scaled to the maxim
of 20 volts, the 16 FFF represents 20V, 0x7FFF
f
t v= ar g / 20 * ( 2^16- 1)
t e[ ] message = V & hi Byt e( v) & l owByt e( v) \ \ set Vol t age Packet
send( message)
end f unct i on
Listing 6. Example of PSDeviceDriver setVoltage method.

PSDeviceDriver also performs the conversion from data sent to the PC. The ge
acket returns voltage, current, p
P
34
the Data container class. Listing 7 shows the pseudo code function for building a Sample
object from a communications packet received from the device.

f unct i on get Sampl e( byt e[ ] m) as Sampl e
S=new Sampl e
/ / i nt make16( byt e Hi Byt e, byt e LoByt e)
/ / r et var = f r act i on of max x f ul l scal e val ue
doubl e V = make16( message[ 1] , message[ 2] ) / ( 2^16- 1) *20
doubl e I = make16( message[ 3] , message[ 4] ) / ( 2^16- 1) *10
doubl e TA = make16( message[ 5] , message[ 6] ) / ( 2^10- 1) *500
doubl e TB = make16( message[ 7] , message[ 8] ) / ( 2^10- 1) *500
doubl e t i me = Syst emTi mer ( )

r et ur n Sampl
end f unct i on
Listing 7. Building a Sample object from packet data.

MS Comm Control
This is a control built into Visual Basic. The control has an input() method that
returns a byte array of buffered data received on a serial port. The control also has an
output() method that transmits data in a byte array to a device on the serial port. The
control is set up from configuration data, such as port number and baud rate, from the
Configuration class.


e( V, I , TA, TB, t i me)

The Sample class is a container class for monitored voltage, current, temperature,
and time. A sample represents a snapshot of these monitored parameters at a particular
instant of time.
Primary Attributes
Voltage:double
Current:double
AmbientTemp:double
BatteryTemp:double
Time
Primary Methods
getVoltage():double
getCurrent():double
ge
getBTemp():double
Primary Responsibilities
Container class for
monitored parameters

Sample Class Summary
tATemp():double
getTime():double
Sample(V,C,AT,BT,TS):Sam
ple
Stamp:double

35

c
Graph class to di also used by the
which processes queries from the Charger class during charging


r clas y the Charger class to query the
Data class. Recall that th ection of Sample objects, and
these Sample objects represent a data set of voltage, current, temperature and time. The
used by the DataAnalyzer class. The
ta collection. The default value is the sampling rate per minute, so if
mples are obtained every second, getVoltage() returns the average voltage over the last
minute. This averaging is advantageous because the charging process is slow and the
averaging will minimize the effect of an inconsistent sample. Other methods in this class
are only slightly more complicated. Listing 8 is an example pseudo code implementation
for voltage and Listing 9 implements the first derivative of temperature with respect to
time.

The data lass is a storage class that holds an array of samples. It is used by the
splay data and trends over time. The Data class is
DataAnalyzer class
operations.

The DataAnalyze s is a utility class that is used b
e Data class is an ordered coll
Data class provides the raw history data
DataAnalyzer exposes a number of public methods that is necessary information to
implement a charging algorithm. Some of the more direct methods, such as
getVoltage(s) are quite simple. It simply returns the average of the latest n voltage
amples in the da s
sa
Data Members
Data DataSet (byRef)
Methods
getVoltage(int n=60)
getCurrent(int n=60)
getTe

mp(int n=60)
getDVdt(int n=60)
getD2Vdt2(int n=60)
getDTdt(int n=60)
getDeltaT(int n=60)

Responsibilities
Data Analysis
DataAnalyzer Class Summary
Primary Attributes
DataSet:Sample[]
Primary Methods
getSample(int index)
addSample()
Primary Responsibilities
Provides History of
charging process
es raw data to
alyzer class
Data Class Summary
Container class for
Sample data
id Prov
DataAn

36
f unct i on get Vol t age( n) as do
/ / DS i s a r ef er ence t o t he
ys FI FO t ype


v=v+DC[ 0] . get Vol t ag
next i
r et ur n v/ n
end f unct i on
Listing 8. Pseudo code for data analysis voltag

f unct i on get DTdt ( n) as doubl e
/ / r et ur ns t he f i r st der i vat i ve of bat t er y t emper at ur e wi t h
ct t o t i me of n sampl es
t o n- 1
T1=T1+DC[ i ] . get BTemp( )
next i
T1=T1/ n / / aver age t emp


BTe
next j
T2=T2/ n / / aver age t emper at ur e of pr evi ous n sampl es

r et ur n ( T1- T2) / ( ( DC[ 0] . get Ti me( ) - DC[ 2*n- 1] . get Ti me( ) ) / 2)
end f unct i on
Listing 9. Pseudo code for temperature first derivative

Charging Form
The charging form is called by the main form when the user selects charging from
ubl e
Dat a col l ect i on
/ / i ndex 0 i s al wa t he l at est dat a ( dat a st r uct ur e)
v=0
f or i =0 t o n- 1
e( )
e calculation.
/ / r espe
/ / DS i s a r ef er ence t o t he Dat a col l ect i on
/ / i ndex 0 i s al ways t he l at est dat a ( FI FO t ype dat a st r uct ur e)
T1=T2=0

f or i =0
er at ur e of n sampl es
f or j =n t o 2*n- 1
T2=T2+DC[ i ] . get mp( )
data analysis battery

the tools menu. This form accepts user input regarding a particular battery a user wishes
to charge. This information is passed to the Charger class. The primary information
necessary to implement a charging algorithm include battery chemistry, Amp Hour
capacity of the battery, and number of cells. A sequence diagram for a typical charging
scenario can be seen as Figure 27.


37
38


Figure 27. Charging sequence diagram.


Main Form
Settings
Form
Charger
Form
<<create>>
begin charging
User updates
settings
close form
<<create>> Charger
Class
User enters battery
parameters
charging
complete
close form
Data Members
Chemistry:BATTYPE
AhCapacity
NumberOfCells:Int
TerminalVoltage

Methods
timer()

Responsibilities
Process data from charger
form
Determine appropriate
charging algorithm based
on user feedback
Dispatch charging
algorithm via periodic
Timer event
Charger Class Summary
ger class implements the functionality of a battery charger by directing
PowerSupply to apply voltage or current to the battery as directed by a charging
algorithm. The Charger class receives information about the battery to charge from the
Charging Form. From this information a battery chemistry class (Lead Acid, NiCad,
NiMh, L hich implements the charging algorithm for the particular
battery chem h rger class enables a Timer object that acts as a free running
periodic event trigger. The Timer object calls a public method of Charger that dispatches
the associated chemistry class.
The following battery che sses implement the charging algorithm for that
particular chemistry. The battery charging process is modeled as a state machine, where
the entire ch may contain many states.
As a minimum, at least two charging algorithms will be implemented for each
chemistry class. As a g neral rule, a fast charging algorithm require ore stringent,
more compl than a slow charg thm. For ex the charging
process is not terminated when a battery is fu rged, excess energy can cause gas to
be produced in the cell, as well as heat. At slow charge rates the gas can be safely
vented and the heat can safely be dissipated. During a fast charge, the cell may not be
capable of dissipating the e gy, and a cell could rupture. For the user with
enough information about a particular battery, the fast charge algorithm will be an option.
If the user does not know much about the battery ( mp hour capacity) a
slow charge algorithm will be available to charge the battery. Figure 28 represents the
state diagram for the charging process in a general sense.


Figure 28. Charging process general state diagram.
The Char
i-Ion) is refe
istry. T
renced, w
e Cha
mistry cla
arging process
e
ex algorithm
s a m
ample, if ing algori
lly cha
xcessive ener
particularly the A
Perio
Event
dic
absolute
conditions
Trig
condition
achieved
ger
charging
phase 1
H
charging
phase 2
t
ch
rickle
arge
Trigger
condition
achieved
condition
failed
conditions
OK
History state
memorizes the internal
state between calls
Trigger
condition not
achieved
Trigger
condition not
achieved
Trigger
condition not
achieved
Conditions include
voltage, current,
temperature and time
39

har ge( )
i f DA. get Del t aTemp( ) > 10F cal l t er mi nat eChar ge( )
i f DA. get Del t aTi me( ) > 60 cal l t er mi nat eChar ge( )

sel ect case ( st at e)
case ( 0)
PS. set Vol t age( Cel l s * 2. 45 vol t s)
st at e=1
cas
i f DA. get Cur r ent ( ) < . 2 * C_r at e
e( Cel l s ol t s
st at e=2
end i f
case ( 2)
/ / t r i ckl e char ge unt i l t i me expi r es
end sel ect
end f unct i on
Listing 10. Lead acid algorithm.


The lead acid battery is charged using voltage regulation with current triggers.
Listing 10 is an example of a fast charge algorithm for lead acid batteries.

f unct i on char ge( )
st at i c st at e=0 / / st or e st at e i nf or mat i on bet ween cal l s
/ / DA i s t he dat a anal ysi s obj ect
/ / PS i s t he Power Suppl y obj ect

/ / pr ocess gener al condi t i ons t hat ar e st at e i ndependent
i f DA. get Temper at ur e( ) < 0F cal l t er mi nat eChar ge( )
i f DA. get Temper at ur e( ) > 113F cal l t er mi nat eC
Data Members
C_rate:Double
Cells:Int
TerminalVoltage

Methods
fastCharge()
slowCharge()
Responsibilities
Implement charging
algorithm for lead acid
battery types

Lead Acid Class Summary
e ( 1)
PS. set Vol t ag * 2. 25 v )
fast charging
40


NiCad batteries are charged at a constant current. Many end of charge
rmination conditions exist based upon voltage and temperature. Inflection point
etecti
ing process.
for NiCad cells is endothermic, and the battery temperature can
ly charged level,
and battery temperatures rise. Other voltage
gers can be used as a backup to the primary
tteries.
l s
di t i ons t hat ar e st at e i ndependent
mper at ur e( ) < 41F cal l t er mi nat eChar ge( )
mi nat eChar ge( )
har ge( )
l t aTi me( ) > 90 mi nut es cal l t er mi nat eChar ge( )
cal l t er mi nat eChar ge( )
ent ( C_r at e amps)
DVdt ( ) <=- 20 mv/ mi n eoc=t r ue / / - dv/ dt ( backup) or
i f DA. get DTdt kup) t hen end
i f eoc / / f ast
PS. set Cur r ent ( C_r at e*. 025) / / set up t r i ckl e char ge
st at e=2
end i f
case ( 2)
/ / t r i ckl e char ge unt i l t i me expi r es
end sel ect
end f unct i on
Listing 11. Nickel Cadmium fast charging algorithm

te
d on calculation of the second derivative of voltage is an advanced method of charge
termination that has superior performance over other termination methods.
Temperature sensing also produces valuable indications of the charg
The charging process
actually drop below ambient temperature until the battery reaches a ful
when the process quickly turns exothermic
termination triggers, and temperature trig
trigger. Listing 11 is an example of a fast charge algorithm for NiCad ba

f unct i on f ast Char ge( )
al st at i c st at e=0 / / st or e st at e i nf or mat i on bet ween c
/ / DA i s t he dat a anal ysi s obj ect
PS i s t he Power Suppl y obj ect / /
/ / pr ocess gener al con
i f DA. get Te
i f DA. get Temper at ur e( ) > 104F cal l t er
t aT( ) >15F cal l t er mi nat eC i f DA. get Del
i f DA. get De
i f DA. get Vol t age( ) >= ( 1. 5V * Cel l s)
sel ect case ( st at e)
case ( 0)
r r PS. set Cu
st at e=1
case ( 1)
D2Vdt 2( ) =0 eoc=t r ue / / i nf l ect i on poi nt or i f DA. get
i f DA. get
( ) >=1. 8F/ mi n eoc=t r ue / / dT/ dt ( bac
char ge
Data Members
oltage
Met
()

C_rate:Double
Cells:Int
TerminalV

hods
fastCharge
slowCharge()
Responsibilities
ging
ry
NiCad Class Summary
Implement char
algorithm for Nickel
Cadmium (NiCad) batte
types

41


Data Members
C_rate:Double
Cells:Int
TerminalVoltage
Methods
fastCharge()
slowCharge()
Responsibilities
Implement charging
algorithm for Nickel
Metal Hydride (NiMh)
battery types
NiMh Class Summary
Nickel Metal Hydride batteries are charged at a constant current in a similar
fashion as the Nickel Cadmium battery. The voltage termination characteristics are
typically not as pronounced as the NiCad battery. Temperature indicators for the NiMh
battery are also more difficult to determine because the charging reaction is exothermic
throughout the charging cycle, although heat is more rapidly generated when the cell is
being overcharged. As with the NiCad cell, a comprehensive charge termination strategy
includes multiple trigger conditions, or backup conditions, and many of these conditions
are identical to those used with NiCad batteries. Listing 12 is an example of a fast charge
algorithm for NiMh batteries.

f unct i on f ast Char ge( )
st at i c st at e=0 / / st or e st at e i nf or mat i on bet ween cal l s
/ / DA i s t he dat a anal ysi s obj ect
/ / PS i s t he Power Suppl y obj ect
/ / pr ocess gener al condi t i ons t hat ar e st at e i ndependent
i f DA. get Temper at ur e( ) < 41F cal l t er mi nat eChar ge( )
i f DA. get Temper at ur e( ) > 104F cal l t er mi nat eChar ge( )
i f DA. get Del t aT( ) >15F cal l t er mi nat eChar ge( )
i f DA. get Del t aTi me( ) > 90 mi nut es cal l t er mi nat eChar ge( )
i f DA. get Vol t age( ) >= ( 1. 5V * Cel l s) cal l t er mi nat eChar ge( )
sel ect case ( st at e)
case ( 0)
PS. set Cur r ent ( C_r at e amps)
st at e=1
case ( 1)
i f DA. get DVdt ( ) <= - 10 mv/ mi n eoc=t r ue / / - dv/ dt or
i f DA. get DTdt ( ) >= . 9F/ mi n eoc=t r ue / / dT/ dt ( backup) t hen end
e char ge unt i l t i me expi r es
Listing 12. Nickel metal hydride fast charging algorithm
i f eoc / / f ast char ge
ckl e char ge PS. set Cur r ent ( C_r at e*. 025) / / set up t r i
st at e=2
end i f
case ( 2)
/ / t r i ckl
end sel ect
end f unct i on

42


Lithium Ion (Li Ion) batteries are the most advanced types in this group. These
batteries are charged at a constant current at a particular cell terminal voltage. This
voltage level varies among manufacturers, typically 4.1 or 4.2 volts/cell. A unique aspect
to proper charging of Li Ion batteries is monitoring battery terminal voltage, and not
charging voltage, while charging in current regulation mode. To perform this
measurement, the supply must be effectively turned off during the measurement.
Some manufacturers do not recommend a float or trickle charge after charging.
If trickle charging is desired, it should be done in a similar manner to the fast charge, but
t a greatly reduced rate or .0
Data Members
C_rate:Double
Cells:Int
TerminalVoltage
CellVoltage
Methods
fastCharge()
slowCharge()
Responsibilities
Implement charging
algorithm for Lithium
(LiIon) battery types
Ion
LiIon Class Summary
a 25C or lower, and terminated after a fixed time period.
a fast charge algorithm for Li Ion batteries.
or mat i on bet ween cal l s
t
= ( Cel l Vol t age * Cel l s) cal l t er mi nat eChar ge( )
r ent ( C_r at e amps)
l l V
t age( Cel l Vol t age*Cel l s)

Cur r ent ( ) <( 50ma*Cel l s)
end i f
end sel ect
end f unct i on
Listing 13. Lithium Ion fast charging algorithm
Listing 13 is an example of

f unct i on f ast Char ge( )
st at i c st at e=0 / / st or e st at e i nf
/ / DA i s t he dat a anal ysi s obj ect
/ / PS i s t he Power Suppl y obj ect
/ / pr ocess gener al condi t i ons t hat ar e st at e i ndependen
r ge( ) i f DA. get Temper at ur e( ) < 41F cal l t er mi nat eCha
i f DA. get Temper at ur e( ) > 104F cal l t er mi nat eChar ge( )
i f DA. get Del t aT( ) >15F cal l t er mi nat eChar ge( )
> 90 mi nut es cal l t er mi nat eChar ge( ) i f DA. get Del t aTi me( )
l t age( ) > i f DA. get Vo
sel ect case ( st at e)
case ( 0)
PS. set Cur
st at e=1
case ( 1)
PS. set Cur r ent ( 0) / / t ur n of f suppl y
PS. get Sampl e( ) / / get a sampl e wi t h suppl y of f
l t age( 1) =Cel l s*( Ce ol t age- 50mv) i f DA. get Vo
ol PS. set V
st at e=2
end i f
case ( 2)
i f DA. get
t er mi nat eChar ge( )


43
Battery connector
Perhaps the simplest part of the projec
G iety of b ay, it is difficult to ha nector that
w ttery to th me of the most com
AA type and D type, have standard battery holders types that can be used to charge a
n tteries simultaneously as seen in Figure two
prongs sticking out, or even flat metal contacts as it is often seen in cellular telephone
batteries. For those reasons, the team decided to fit the charging system with the most
common types of connectors. Thus, some standard AAA, AA, C and D type connectors
along with some alligator clips for the prongs, and a clamp system for the metal contacts,
will be provided with the charger. This should accommodate most types of batteries.

t may prove to be the hardest to achieve.
iven the wide var atteries tod ve a universal con
ill attach the ba e charger. So mon types of batteries, like
29. Others may have umber of these ba


Figure 29. Example Battery Holders.

ign: Overall Printed Circuit Board (PCB) Des
The design is based on a two-board design. The control board contains the
ents such as the
gital signals (5 volts
ircuit voltages) are
atic for this
e
n in Figure A2.
uits that implement the main switching power
ply, along with the voltage and current sense
circuits have been shown in Figures 7, 9, 10, 11, and 13. The boards will
the control board and
the boards.

microcontroller, accessories, and various headers to peripheral compon
LCD display and IR remote detector. Only low power analog and di
el shift c or less, with the exception of low power RS-232 lev
transmitted and received on this board. The comprehensive circuit schem
board is shown in the Appendix as Figure A1. The preliminary PCB artwork for th
system control board is show
The power board contains the circ
rocontroller linear sup supply and mic
circuits. These
be connected by an interconnecting cable that supplies power to
een transmits PWM signals and voltage/current sense signals betw








44
Final Product Design
After integrating all of the components described above, the finished design product
is envisioned to appear as shown in Figure 30.











Mode : PC Temp.
Voltage : 10.000 V Battery: 80.3 F
Current : 1.520 A Ambient: 70.0 F
Battery | Com Temp. Sensors
Mode : PC Temp.
Voltage : 10.000 V Battery: 80.3 F
Current : 1.520 A Ambient: 70.0 F

Figure 30. Finished Product Design.













45
Parts List

The finalized parts list shown in Table 14 includes all parts necessary to implement the
echnical Design discussed above.
Qty.
T

Table 14. Implementation Parts List.
Refdes Part Num. Description
1 IC1 PIC18F452-I/P PIC ntroller Microco
1 IC2 MAX el converter 232 S 232 lev R
1 IC3 AD7705BN Analog to digital converter 16 pin dip
1 IC4 M rochip precision rail-to-rail op amp 8pin dip CP607-I/P Mic
1 IC5 TC1411NCPA Microchip power mosfet driver 8pin dip
1 Q1 ECS-80-20-4 CRYSTAL 8.00MHZ 20PF HC-49/US
1 Q2 MP024S CRYSTAL 2.4576MHZ HC-49, 32PF
2 R1 3296Y-1-103 Bourns 3296Y 10K pot .5W top adjust 3/8" SQ CERM SL MT
1 R2 3296Y-1-200
Bourns 3296Y 20 ohm pot .5W top adjust 3/8" SQ CERM SL
MT
1 R3 ERD-S2TJ 222V 2.2K 1/4W 5%
1 R4 ERO-S2PHF4703 470K 1/4 W 1% metal film
2 R5,R7 3296Y-1-203 Bourns 3296Y 20K pot .5W top adjust
1 R6 MFR-25FBF-10K0 10K 1/4W 1%
2 R8 CFR-25J B-1K0 1K 1/4W 5%
1 ERD-S2TJ 470V 47ohm 1/4W 5%
1 Z1 LM4040AIZ-2.5 LM4040AIZ-2.5 precision 2.5V reference TO92 package
1 2-640379-4 S DIP 15AU CONN IC SOCKET 40PO
2 2-640358-4 OS DIP 15AU CONN IC SOCKET 16P
2 2-640463-4 CO N IC SOCKET 8POS DIP 15AU N
2 C1,C2 1206CG200J 9B200 20pf disk cap
1 C3 ECA-1EM100 10uF Electrolytic 25VDC
5 C4,C5,C6,C7,C8 ECA-1HM010 1uf c Electrolyti
2 C9,C10 GRM0335C1E300J D01D 30pf disk cap
1 EEU-FC1E470 47uF
1 D1 1N4148 1N4148
3 LM34DZ-ND IC SENSOR TEMP PREC FAHR TO-92
1 CFAH4004A-YYB-J P CrystalFontz 40x4 LCD
1 GP1UM27XK Sharp GP1UM28XK IR remote control receiver
1 351-43-0201 molex RC car battery connector plug
2 357-28-0201 molex RC car battery connector socket pin
4 rs232,temp,pb 22-23-2091 molex 9 pin .100 pin header
4 22-01-3097 molex 9 pin .100 connector
3 ICSP,LCD1 22-23-2061 molex 6 pin .100 pin header
2 22-01-3067 molex 6 pin .100 pin connector
2 LCD2 22-23-2041 molex 4 pin .100 pin header
2 22-01-3047 molex 4 pin .100 connector
2 IR 22-23-2031 molex 3 pin .100 pin header
2 22-01-3037 molex 3 pin .100 pin connector
100 08-50-0114 molex Crimp terminals for .100 housings
2 747905-2 9 pin D-sub Female
46
1 747904-2 9 pin D-sub Male
1 03-09-2022 molex .093 2 cir Plug 12A
5 03-09-1022 molex .093 2 cir Receptacle 12A
1 molex .093 male terminals 14-20 crimp 02-09-2103
1 02-09-1104 molex .093 female terminals 14-20 crimp
1 02-09-211 18-22 crimp 8 molex .093 male terminals
1 BH48A AA 8 cell battery holder AL
1 BH26CW C 6 cell battery holder
1 BH24DL D 4 cell battery holder
1 364-1042-ND Power Line EMI Filter, 10A
1 12FR010 RES CURRENT SENSE .010 OHM 2W
1 IRFP244 HEX/MOS N-CH 250V 15A TO-247AC
3 10CTQ150-1-ND DIODE SCHOTTKY 150V 10A TO-262
2 LM7805CT-ND Voltage Regulator, 5V,1A
4 493-1079-ND CAP 0.33uF, 35V Elec Radial
3 P11214-ND CAP 27UF 25V ELECT FC RADIAL
1 688CKS035M 6800uF 35V Elect Radial CAP
2 P11855-ND CAP 2700UF 200V ELECT TS-UQ
1 182S12 Power Toroid Transformer 225W 24V@9.38A




























47
Testing Proced fication and V ures: Veri alidation

A vital part to a successful implemen er design is the
ability to test individual components and i the
alternative desig echnical desig hases.
Beginning with on and detaile as agreed
to modularize th d test each com er it has been verified
that each component functions alone, the erfaced with local
subsystem components and eventually em of the entire design.
The entire desig that the liste
section will discuss the testing procedures the more
formal testing p ll be used been
prototyped.

Hardware Testin
tation of the entire Smart Charg
nterfaces between components during
n analysis, t n, and especially the implementation p
the concepti d definition of this design, the team h
e design an ponent separately. Aft
component will be int
erge as a functioning part
d requirements specificati n must verify ons are met. This
that have already been performed and
rocedures that wi when the hardware and software has
g:

Power Supply: Since the switch-mode p sign, the
gine built a prototype ith
these supplies, to determine the voltage and current outputs under varying parameters and
WM signals, and determine what is necessary to proceed with the power supply design.
his prototype was first tested with digital multimeters and an oscilloscope. The pulse
idth modulation signal was driven by a pulse generator and varied with respect to
equency and duty ratio.
The final power supply design will be tested to verify that can output a voltage in the
nge of 0-20 V and a current in the range of 0-10 A. The PWM signal will be adjusted to
etermine the voltage and current resolutions of 20 mV and 10 mA, respectively.
icrocontroller and Accessories: The microcontroller and control board accessories
ecessary for high-level feedback have been tested during the actual design phase to
ecide what can be feasibly implemented given the time, budget, and experience
onstraints. In addition, the group individually tested these logic components in a
readboard circuit to compare the compatibility of interconnected devices and decide
hich devices should be purchased for the actual implementation. The breadboard
rototype is shown in Figure 31.
ower supply is the core of this de
electrical en ers have power supply in order to gain experience w
P
T
w
fr

ra
d

M
n
d
c
b
w
p

48

Figure 31. Breadboard for Testing During the Design Process.

Software Testing:
Microcontroller software: The microcontroller software will be tested with the
Microchip MPLAB IDE and In-Circuit Debugger-2 (ICD-2). The microcontroller and
various parts of the logic system can be easily tested with a development board, such as
the LAB-X1 board, before it is implemented in the actual design. The software routines
e
r-
ers of the public to rate the ease of use of this
application.

System Testing:
will be individually tested with test scripts with varying input parameters to determine if
they return accurate results. In addition, the scripts will test the communication protocols
between the logic system interfaces.
The final logic board design will also be tested with the ICD-2 module to make sure
that the voltage and current feedback signals are accurate to within 20 mV and
10 mA tolerances for error.
Visual Basic Custom PC application: The PC application will be tested and
debugged with the Microsoft Visual Basic.NET environment. It will be tested on th
common Microsoft Windows XP and Windows 2000 operating systems to ensure
compatibility with Microsoft Windows users. In order to test the requirement for a use
friendly interface, the design group will create a survey allowing their engineering
olleagues, professors, and memb c

As each component passes the preliminary testing procedures, it will then be
interfaced with the rest of the system on its board (power board and control / logic
board). The hardware will be tested and troubleshot by hand with digital multimeters and
an oscilloscope. This step is to ensure that good soldering methods were used and that the
system is relatively free of excessive amounts of electrical noise.
After following the testing procedures discussed and validating that the system meets
the LCD and infrared remote requirements, the entire design will meet the stated design
requirements specifications.

49
Financial Budget
The teams labor budget has been set by the Electrical and Computer Engineering
Department at $10.00 per hour for each student. This is shown in Table 15. The estimated
material cost is shown in Table 16.

Table 15. Estimated Labor Cost.
Design Team
Member
Cost per Hour Hours Per
Week
Number of
Weeks
Estimated Cost
Claudiu Bouruc $10.00 10 15 $1,500.00
Eric Boyer $10.00 10 15 $1,500.00
Mike Petrak $10.00 10 15 $1,500.00
Steven Savage $10.00 10 15 $1,500.00
Total Cost $6,000.00

Unit Total
Table 16. Estimated Material Cost.

Qty. Description Cost Cost Part Num.
1 PIC18 8 $9.38 F I/P PIC Microcontroller $9.3 452-
1 MAX 232 $3.31 RS 232 level converter $3.31
1 AD770 $9.70 5BN Analog to digital converter 16 pin dip $9.70
1 MCP6 $1.33 07-I/P Microchip precision rail-to-rail op amp 8pin dip $1.33
1 TC141 $0.95 1NCPA Microchip power mosfet driver 8pin dip $0.95
1 ECS-8 $0.58 0-20-4 CRYSTAL 8.00MHZ 20PF HC-49/US $0.58
1 MP024 $2.08 S CRYSTAL 2.4576MHZ HC-49, 32PF $2.08
2 3296Y ot .5W top adjust 3/8" SQ CERM SL MT $2.50 $5.00 -1-103 Bourns 3296Y 10K p
1 3296Y 2.50 $2.50 -1-200
Bourns 3296Y 20 ohm pot .5W top adjust 3/8" SQ CERM SL
MT $
1 ERD-S $0.07 2TJ 222V 2.2K 1/4W 5% $0.07
1 ERO-S PH $0.17 $0.17 2 F4703 470K 1/4 W 1% metal film
2 3296Y $5.00 -1-203 Bourns 3296Y 20K pot .5W top adjust $2.50
1 MFR-2 1 $0.11 5FBF-10K0 10K 1/4W 1% $0.1
2 CFR-2 $0.13 5J B-1K0 1K 1/4W 5% $0.07
1 ERD-S $0.07 2TJ 470V 47ohm 1/4W 5% $0.07
1 LM404 .39 $2.39 0AIZ-2.5 LM4040AIZ-2.5 precision 2.5V reference TO92 package $2
1 2-6403 $1.80 $1.80 79-4 CONN IC SOCKET 40POS DIP 15AU
2 2-6403 CONN IC SOCKET 16POS DIP 15AU $0.87 $1.74 58-4
2 2-6404 ONN IC SOCKET 8POS DIP 15AU $0.57 $1.14 63-4 C
2 1206C $0.19 G200J 9B200 20pf disk cap $0.10
1 ECA-1EM1 .21 $0.21 00 10uF Electrolytic 25VDC $0
5 ECA-1 $1.05 HM010 1uf Electrolytic $0.21
2 GRM0 $0.11 335C1E300J D01D 30pf disk cap $0.05
1 EEU-F $0.28 C1E470 47uF $0.28
1 1N414 $0.07 $0.07 8 1N4148
3 LM34D -ND $6.99 Z IC SENSOR TEMP PREC FAHR TO-92 $2.33
1 CFAH4 $48.70 004A-YYB-J P CrystalFontz 40x4 LCD $48.70
1 GP1UM UM28XK IR remote control receiver $1.33 $1.33 27XK Sharp GP1
1 351-43 201 molex RC car battery connector plug $0.44 $0.44 -0
50
2 357-28 molex RC car battery connector socket pin $0.10 $0.20 -0201
4 22-23-2091 molex 9 pin .100 pin header $0.87 $3.48
4 22-01-3097 $2.68 molex 9 pin .100 connector $0.67
3 22-23- $1.80 2061 molex 6 pin .100 pin header $0.60
2 22-01- in connector $0.48 $0.96 3067 molex 6 pin .100 p
2 22-23-2041 molex 4 pin .100 pin header $0.47 $0.94
2 22-01-3047 molex 4 pi $0.35 $0.70 n .100 connector
2 22-23-203 molex 3 pin .100 pin h $0.78 1 eader $0.39
2 22-01-3037 molex 3 pin .100 pin con $0.58 nector $0.29
100 08-50- molex Crimp terminals for . gs $5.34 0114 100 housin $0.05
2 747905 9 pin D-sub $4.94 -2 Female $2.47
1 747904 9 pin D-sub $1.82 -2 Male $1.82
1 03-09- molex .093 2 cir Plug 12A $0.33 2022 $0.33
5 03-09- molex .093 2 cir Receptacle 12A $1.80 1022 $0.36
1 02-09- molex .093 male terminals 14-20 crimp $0.79 2103 $0.79
1 02-09-1104 molex .093 female terminals 14-20 crimp $0.78 $0.78
1 02-09-2118 molex .093 $0.81 $0.81 male terminals 18-22 crimp
1 H48AAL A 8 cell battery holder B A $1.46 $1.46
1 BH26C C 6 cell battery holder W $1.60 $1.60
1 BH24DL D 4 cell battery holder $1.71 $1.71
1 364-1042-ND 0A $ $ Power Line EMI Filter, 1 18.53 18.53
1 12FR010 RES CURRENT SENSE .010 OHM 2W $1.56 $1.56
1 IRFP244 HEX/MOS N-CH 250V 15A TO-247AC $3.16 $3.16
3 10CTQ150-1-ND DIODE SCHOTTKY 150V 10A TO-262 $0.88 $2.64
2 LM7805CT-ND Voltage Regulator, 5V,1A $0.53 $1.06
4 493-1079-ND CAP 0.33uF, 35V Elec Radial $0.23 $0.92
3 P11214-ND CAP 27UF 25V ELECT FC RADIAL $0.28 $0.84
1 688CKS035M $10.00 $10.00 CAP 6800uF 35V Elect Radial
2 P11855-ND CAP 2700UF 200V ELECT TS-UQ $ $8.12 16.24
1 182S12 Power Toroid Transformer 225W 24V@9.38A $ $ 54.66 54.66
To $2 tal 49.92

Team Funding
e teams member.
gn team m or this de
ct.

dule

Th material funding has been set at $75 per design team
embers, this yields a total material funding of $300 f
With
four desi sign
proje
Project Sche

The Smart Ch d a strategy for completing a successful design
2005 semester. This strategy is shown in the fo an
ntation Ga art: Table 17 shows the detailed tasks and description a
gure 32 shows th entation schedule in a timeline format.
arger team has
g
develope
implementation during the Sprin rm of
Impleme ntt Ch nd
Fi e implem
51
Table 17. Implementation Gantt Chart Tasks and Description.
52


Figure 32. Implementation Gantt Chart Timeline View.
53
54
Design Team Information
Steven Savage
Computer Engineer
Team Leader, PC Software Design

Claudiu Bouruc
Electrical Engineer, Hardware Design

Eric Boyer
Electrical Engineer, Hardware Design

Mike Petrak
Computer Engineer, Microcontroller Hardware and Software, Interfacing

Conclusions and Recommendations
The design presented above was inspired by todays need of a universal battery
charger. The Smart Charger is intended to provide charging for the most common type of
rechargeable batteries. It is designed to be a very powerful tool for the knowledgeable
engineer or technician.
The ability of the charger to output real time graphs with the current and voltage
levels during battery charging makes it a very useful tool for engineers. Depending on the
chemistry of the battery that is being charged, some parameters are closely monitored,
thus giving the user an insight of the charging process.
Since the heart of the Smart Charger system is a switching power supply with
variable output, the system can easily convert from a battery charger to just a plain power
supply. This versatility would be appealing in the industry.
One of the constraints that our team was confronted with was to come up with an
elegant solution for a connector that would hook up to any battery topology. As trivial as
this may sound, this is a very complicated issue due to the fact that batteries com
countless shapes and forms. So far the team decided to have multiple connectors that
would fit the most common types of batteries, but this is an area where there is room for
improvement. This is just one example of many where the project could be developed
further. Overall, our system is a pioneer in the hybrid world of battery chargers and
power supplies, and could provide a solid base for future teams to build upon.

References
e in
1. Microchip MCP 607 Precision Operational Amplifier Data Sheet.
2. Microchip PIC18F452 Data Sheet.
3. Analog Devices AD7705 External Analog-to-Digital Converter Data Sheet.
4. Maxim RS-232 Interface Data Sheet.
5. CrystalFontz 40x4 Liquid Crystal Display Data Sheet.
6. LM34 Precision Temperature Sensor Package Data Sheet.
7. Sharp GP1UM28YK Infrared Detecting Unit Data Sheet.

Figure A S c de ssory Devices. rs to Acce with Hea
55
chemati 1. Logic Control Board
Appendix


56
Figure A2. Preliminary System Control PCB Artwork.







Table A3. Communication Protocol.
PC sends Device Replies
Packet Type Byte 0 1 2 Byte 0 1 2 3 4 5 6 7 8 notes
set Voltage 'V' hb lb 'v' hb lb Vmax=0xFFFF, 0V=0x0000
set Current 'I' hb lb 'i' hb lb Imax=0xFFFF, 0A=0x0000
set Control 'C' 0,1 'c' 0,1 0=local control, 1=pc control
set OutputOnOff 'O' 0,1 'o' 0,1 0=output off, 1=output on
get Data 'R' 'r' Vhb Vlb Ihb Ilb T0hb T0lb T1hb T1lb device to send actual voltage, current, temperatures (V,I 16bit, T 10 bit)
get PWM 'P' 'p' hb lb device replies with current 10 bit PWM value
get Status 'S' 's' Mode Control errorCode get mode, control, last error status
impromptu error 'e' errorCode device detects error or warning condition and transmits error code without promping
General Notes:
multi byte data types expressed in big endian form
Votage and Current input/output are 16 bit values
10 bit values (such as temperature and pwm status) are right justified in 16 bit field
























57
Table A4. Device Error Codes.
Error Codes
Code Description Notes
0 Power on reset Normal message during a power up
1 Watchdog reset Watchdog timer timed out
2 reserved
3 reserved
4 ADC consistency check failed AD7075 and internal AD differ too much
5 PWM at maximum PWM is at maximum and the supply cannot achieve the set point
6 PWM at minimum PWM is a minimum and the supply cannot achieve the set point
7 Over Voltage fault Voltage exceeds max output for the desired current set point
8 Over Current fault Current exceeds max output for the desired voltage set point
9 reserved
10 communications timeout
During PC control, device must receive a message every 10 seconds
or a loss of communication is assumed
11 UART frame error
12 UART error
13 SPI error
14 communication failure to AD7075
15 reserved
16 reserved
17 reserved
18 reserved
19 reserved
20 reserved


58