Text preview for : cpu_charger.pdf part of SHEMI NA KOMPUTARNI ZAXRANVANIYA PSU



Back to : ÑÕÅÌÈ_ÍÀ_ÊÎÌÏÞÒÚÐÍÈ_ÇÀÕÐÀ | Home

AN1015
16HV785: Programmable Lead Acid Battery Charger
Features
· User-configurable battery charger for Lead battery packs · Based on PIC16F785 with integrated shunt regulator · Firmware and support tools for easy design · 10-bit ADC for voltage, current and temperature measurement: - Accurate Voltage Regulation (+/-1%) - Accurate Current Regulation (+/-5%) · Advanced Charge Algorithms: - Chemistry dependent End-of-Charge determination - Charge qualification to detect shorted, damaged or heated cells - Precharge for deeply discharged cells - Configurable overtemperature and overvoltage charge suspension - Charge termination at user-specified minimum current or time-out - Configurable charge status display via two LEDs · Maximum integration for optimal size: - Integrated voltage regulator - Internal 8 MHz clock oscillator - High-Frequency Switch mode charging ­ configurable switching frequency up to 500 kHz

Applications
· · · · · · · · Single-Cell and Multi-Cell Lead Battery Chargers Notebook Computers Personal Data Assistants Cellular Telephones Digital Still Cameras Camcorders Portable Audio Products Bluetooth® Devices

Pin Description
VDD LED2 VIN RESET CTRLOUT CHGOUT LOOPFBK LOOPIN CTRLIN LED1 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 VSS TEMP VOVP SHDN CHGFBK BATID IFBOUT IFBINA IFBINB HVOUT

20-Pin PDIP, SOIC, SSOP

© 2006 Microchip Technology Inc.

16HV785

DS01015A-page 1

AN1015
USING THE 16HV785
Product Overview
The 16HV785 provides an unprecedented level of configurability for charging lead battery packs. Its precise, 10-bit Analog-to-Digital converter and high-frequency Pulse-Width Modulator enable the 16HV785 to provide optimum control of charging algorithms for lead battery chemistries. Special features include an internal voltage regulator and an internal clock oscillator that reduce external component count. The 16HV785 can be configured as either a Switch mode or a linear charger. In Switch mode, it will support either primary or secondary side control. In Linear mode, it can be designed into applications requiring low-power supply noise.

USER CONFIGURABLE PARAMETERS
The 16HV785 supports user-configurable parameters that allow for customizing the charging profile without changing the charger's hardware design. This feature allows for the maximum reuse of hardware, thus reducing time-to-market. These parameters include: · Battery Temperature: - Minimum/maximum temperature for charge initiation - Maximum temperature allowed during charge · Battery Voltage: - Minimum/maximum voltage for charge initiation - Target voltage during Voltage Regulation - Voltage at which the charger will restart charging after completion of a valid charge cycle · Charge Current: - Target current during Current Regulation - Taper current threshold for End-of-Charge during Voltage Regulation - Target current during Precharge · Time: - Precharge time limit - Current Regulation time limit - Voltage Regulation time limit · Status Display: - Duty cycle for the two LEDs denoting charge states can be modified These parameters are configured through the PowerToolTM 200 Development Software for the 16HV785.

MULTI-STEP CHARGING
To insure the proper treatment of lead chemistries during extreme temperature and voltage conditions, multi-step charging is required. The 16HV785 starts the charging cycle upon sensing the presence of a battery pack and a valid charging supply. During charge qualification, the battery's temperature and voltage are measured to determine the appropriate initial state. The initial states include Charge Suspend, Precharge and Current Regulation. Charge Suspend halts charging when the user-defined preset conditions for charging are not met. Precharge allows for the recovery of deeply discharged batteries by applying a low charge (or C) rate. Current Regulation provides constant current, voltage limited charge. Upon reaching the target voltage during Current Regulation, the Voltage Regulation state is entered. Charging continues at a constant voltage until the current decreases to the user-specified minimum current threshold. The user-specified minimum current threshold can be configured for various charging temperatures. At this threshold, charging is terminated and the End-of-Charge state is reached.

SPECIAL FEATURES
The 16HV785 includes a voltage regulator, a voltage reference, an internal clock oscillator and a high-frequency Pulse-Width Modulator. · The internal voltage regulator has a maximum input voltage of 18V and eliminates the need for external references. · The precise, internal 8 MHz clock oscillator eliminates the need for external oscillator circuits. · The high-speed Pulse-Width Modulator is used for power regulation and can support frequencies up to 500 kHz. · In-circuit configurability utilizing on-board EEPROM.

DS01015A-page 2

© 2006 Microchip Technology Inc.

AN1015
TABLE 1:
Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

PINOUT DESCRIPTION
Pin Type Input Type Output Type Supply O I I O O I I I O O I I O I I O I I Supply Power -- Analog ST -- -- Analog Analog Analog -- -- Analog Analog -- Analog Analog -- Analog Analog Power -- CMOS -- -- CMOS CMOS -- -- -- CMOS HVOD -- -- Analog -- -- Analog -- -- -- Supply voltage Status indicator Battery voltage input Reset PWM output for setting current level PWM output to a buck converter for charge control Current feedback loop Current feedback loop input Current level control Status indicator High-voltage, open-drain output pin (optional) Current feedback input pin B used for current scaling Current feedback input pin A used for current scaling Current feedback output Battery ID select Charge control feedback Shutdown signal, active-low Overvoltage protection Battery temperature input Supply ground Description VDD LED2 VIN RESET CTRLOUT CHGOUT

Pin Name

LOOPFBK LOOPIN CTRLIN LED1 HVOUT IFBINB IFBINA IFBOUT BATID CHGFBK SHDN VOVP TEMP VSS

Legend: I = Input, O = Output, ST = Schmitt Trigger Input Buffer, HVOD = High-Voltage Open-Drain

© 2006 Microchip Technology Inc.

DS01015A-page 3

AN1015
16HV785 HARDWARE OVERVIEW
The 16HV785 is a configurable, Switch mode charger which is comprised of a PIC16F microcontroller core and precise analog circuitry. This section explores the hardware features in relation to generic Switch mode charging. The 16HV785 hardware is a PIC16F785 device with an integrated shunt regulator, to allow the device to be powered directly from a battery stack, or from charger voltage. It is available in a 20-pin PDIP, SOIC or SSOP package. See the PIC16F785 data sheet for more hardware description. Hardware features include: · · · · · Oscillator Power-Saving Sleep mode Power-on Reset (POR) Brown-out Reset (BOR) High-Endurance Flash/EEPROM Cell: - 100,000 write Flash endurance - 1,000,000 write EEPROM endurance - Flash/Data EEPROM retention: > 40 years High-Speed Comparator module with: - Two independent analog comparators Operational Amplifier module with two independent op amps Two-Phase Asynchronous Feedback PWM Voltage Regulator 10-bit A/D Converter In-Circuit Serial ProgrammingTM (ICSPTM) via two pins

Hardware Features
The 16HV785 features are well-suited for Switch mode battery charging. The 16HV785 device's block diagram (Figure 1) is to be used in conjunction with the Switch mode charger example (Figure 10, page 9). · Current/Voltage Measurement Block ­ The Current/Voltage Measurement Block consists of a 10-bit Analog-to-Digital converter, operational amplifiers and a comparator. The output of this block is fed into the charge control module. Please refer to Figure 1. The inputs into this block are to be connected as described in Figure 10. The following signals are inputs into this block: LOOPFBK: to comparator LOOPIN: to op amp and ADC CTRLIN: to op amp IFBINB: to op amp IFBINA: to op amp BATID: to ADC TEMP: to ADC CHGFBK: to comparator

· · · · · ·

The following signals are outputs from this block: · - IFBOUT: from op amp Charge Control Module ­ The charge control module generates a Pulse-Width Modulated signal called CHGOUT. Its frequency is configurable and can be set up to 1 MHz. This signal is connected to an external DC/DC buck converter. Voltage Regulator ­ The integrated voltage regulator is designed to work with unregulated DC supplies. The precise internal 8 MHz clock oscillator eliminates the need for external oscillator circuits. In-circuit configurability utilizing 256 bytes of on-board EEPROM. Power on Reset ­ The POR insures the proper start-up of the 16HV785 when voltage is applied to VDD. Brown-out Reset ­ The BOR is activated when the input voltage falls to 2.1V; the 16HV785 is reset.

·

· · ·

·

DS01015A-page 4

© 2006 Microchip Technology Inc.

AN1015
FIGURE 1: 16HV785 BLOCK DIAGRAM
RESET VDD VSS VOVP SHDN

Voltage Regulator

Voltage Reference

-

CTRLIN LOOPIN

+ OA1 -

C1 +

To Charge Control Module Internal Oscillator

Current/Voltage Measurement Block LOOPFBK CHGFBK IFBINB IFBINA IFBOUT VIN BATID TEMP
C2 + + OA2 -

CTRLOUT Charge Control Module CHGOUT LED1 LED2 HVOUT

10-bit ADC

© 2006 Microchip Technology Inc.

DS01015A-page 5

AN1015
REFERENCE SCHEMATIC
Theory of Operation
In this schematic, the 16HV675 is being used to control a step-down buck converter. A buck converter uses a square wave pulse train to turn on and off a switch that provides current into an inductor. The ratio of output voltage to input voltage is the duty cycle of the pulse. Current and voltage feedback are used to control the duty cycle to regulate the output voltage and current. This integral taken over one pulse cycle can be broken down into pulse on and pulse off time. When the pulse is on, VIN = VCHARGE, and when the pulse is low, VIN = 0. Since the current is the same at the beginning of each cycle, the equation becomes:

EQUATION 3:
(VCHARGE ­ VOUT) * TON ­ VOUT * TOFF = 0 or VCHARGE * TON = VOUT * TON + VOUT * TOFF VCHARGE * TON = VOUT * T VOUT = (T/TON) * VCHARGE VOUT = VCHARGE * Duty Cycle When the pulse goes high, the current through the inductor increases as a response. When the pulse goes low, the current decreases. The graph (Figure 3) shows the current through the inductor as a response to the input pulse, and the resulting voltage drop across the inductor. When the current through the inductor is increasing, as a result of the pulse going high, the voltage drop across the inductor is positive (di/dt is positive). This drop is subtracted from the applied charge voltage to produce VOUT. When the current through the inductor is decreasing (di/dt is negative), the voltage drop across the inductor is negative, adding to the zero input voltage to produce VOUT.

Buck Converter
The inductor L1, the capacitor COUT, and diode D1 comprise the buck converter. The MOSFET Q1 is the switch that applies the charger voltage when turned on. It is driven by a pulse train applied by the 16HV675.

FIGURE 2:

BUCK CONVERTER
VCHARGE

Pulse VIN VOUT

FIGURE 3:
In Figure 2, when a constant voltage is applied to VIN, and a pulse train of constant frequency and duty cycle is applied to the age of the MOSFET, the result is a constant voltage at VOUT which is a fraction of VIN equal to the duty cycle of the pulse. The voltage drop across the inductor is:
IL

BUCK CONVERTER WAFEFORMS
VIN

EQUATION 1:
VL = L di dt
VL

With the voltage regulated at VOUT, the drop across the inductor is VIN ­ VOUT, thus the current through the inductor is:

VOUT = VIN ­ VL

EQUATION 2:
i=

Feedback Circuits

(VIN ­ VOUT)dt

The circuit uses feedback for two purposes. One is to provide the ramp waveform that defines the PWM duty cycle. The other is the current sense that is compared to a reference voltage to determine if the current is being regulated at the correct level. This is also fed back into the PWM to modulate the duty cycle.

DS01015A-page 6

© 2006 Microchip Technology Inc.

AN1015
RAMP FEEDBACK
The CHGFBK pin (pin 16) receives the ramp sawtooth waveform that controls the duty cycle of the PWM signal. This sawtooth needs to be generated externally by an RC network connected to the PWM output. The RC network uses the frequency of the PWM to generate the sawtooth waveform. When the PWM is triggered high, the sawtooth starts to ramp up. When the sawtooth reaches a certain point (determined internally by reference voltage and current feedback), the PWM output is sent low, also driving the sawtooth low. The sawtooth starts up again when the internal oscillator sends the PWM high again. The RC circuit can be placed on the output of the PWM signal. A clamping diode can be used to control the total voltage drop.

CURRENT FEEDBACK
The aforementioned reference voltage is determined by current feedback in order to regulate the current. A second PWM, which is under firmware control, is used to create a DC level to which to compare the sensed current. The voltage drop across a current sense resistor is applied to pin 13 (IFBINA) and is internally amplified by an op amp. The output of this op amp is available on pin 14 (IFBOUT). The output on pin 14 is then fed into pin 8 (LOOPIN) which is the input to another op amp. The other input of this op amp is a DC level that is created by the firmware controlled PWM. The firmware controlled PWM is output on pin 5 (CTRLOUT) and fed into an RC circuit whose time constant is high enough to create a rough DC level. This DC level will vary with the duty cycle of the firmware controlled PWM. This DC level is then applied to pin 9 (CTRLIN). This DC level is compared to the current feedback by op amp 1. The output of op amp 1 is fed to the main internal comparator where it is compared to the sawtooth waveform to determine the duty cycle of the main PWM, which regulates current through the buck converter.

FIGURE 4:

SAWTOOTH GENERATOR

pin 6: CHGOUT

pin 16: CHGFBK

FIGURE 6:
Sense Resistor Voltage

FEEDBACK DIAGRAM

Constant Reference Voltage from Firmware Controlled PWM

The voltage at CHGFBK will ramp up when the PWM output at CHGOUT triggers high. When the ramp at CHGFBK exceeds the internal comparator level of reference voltage, the PWM will trigger CHGOUT low. The constant frequency sawtooth will determine the pulse width as a function of internal reference voltage.

PWM Output Sawtooth Feedback Signal

The actual circuit implementation, including op amp feedback RC networks, is shown in Figure 7.

FIGURE 5:

SAWTOOTH AND PWM WAVEFORMS

FIGURE 7:
Firmware Controlled PWM 5

FEEDBACK CIRCUIT

6

PWM Output Sawtooth Feedback Signal

Internal Oscillator Level at which Internal Comparator Switches PWM Low
16 DC Reference Voltage 9 8 13 12

Current Sense 7 14 RIL

RSENSE

Sawtooth Triggered by Oscillator

PWM Triggered by Sawtooth

Amplified Current Feedback

© 2006 Microchip Technology Inc.

DS01015A-page 7

AN1015
Power Supply Shunt Regulator
The 16HV785 has a built-in shunt regulator allowing the device to be powered directly by the charging voltage. The integrated voltage regulator is designed to work with unregulated DC supplies. While there is, theoretically, no limit to the charging voltage, there are guidelines that should be followed. A series limiting resistor (RVDD) should be placed between the unregulated supply and the VDD pin. The value for this series resistor (RVDD) must be between RMIN and RMAX as shown in Equation 4:

FIGURE 8:

OVERVOLTAGE CIRCUIT
Output Voltage of Buck Converter ROVP ROVL

18

EQUATION 4:
RMAX = VS(MIN) ­ 5V) * 1000 1.05 * (16 mA + I(led)) Vs(MAX) ­ 5V) * 1000 .95 * (50 mA)

A/D Inputs
The internal A/D converter is used to measure the charging voltage on pin 3 (VIN), the current on pin 13 (IFBINA) and optionally, the temperature on pin 19 (TEMP) if there is a thermistor present. An external voltage divider is used on pin 3 to measure the charge voltage.

RMIN =

Where: RMAX = maximum value of series resistor (ohms) RMIN = minimum value of series resistor (ohms) Vs(MIN) = minimum value of charger DC supply (VDC) Vs(MAX) = maximum value of charger DC supply (VDC) I(led) = total current drawn by all LEDs when illuminated simultaneously Note: The 1.05 and .95 constants are included to compensate for the tolerance of 5% resistors. The 16 mA constant is the anticipated load presented by the 16HV785, including the loading, due to external components and a 4 mA minimum current for the shunt regulator itself. The 50 mA constant is the maximum acceptable current for the shunt regulator.

FIGURE 9:

A/D INPUTS

Output Voltage of Buck Converter RVH RVL VDD

3 19 Thermistor Connection

Overvoltage Protection
The 16HV786 has a comparator that is gated to the PWM which compares the reference voltage to an external divided voltage applied to pin 18 (VOVP). When the voltage on pin 18 exceeds the reference voltage, the PWM is turned off. The external voltage divider should be chosen such that the preferred overvoltage safety point is used.

DS01015A-page 8

© 2006 Microchip Technology Inc.

FIGURE 10:

REDLED SP+ POWER SUPPLY INPUT SUPPLY MUST BE FUSED OR CURRENT LIMITED 4.7 F OVP DIVIDER VIN DIVIDER SN-

GRNLED

17

18

C18 4.7 F 3 VIN D2: REVERSE CURRENT BLOCKING DIODE TEMP BATID 15 19

1-WIRE COMM. ACCESS SHDN LED1 VOVP 10 2 LED2 VREF

MCLR COMG R4 4 1 MCLR VDD PWM
SHDN

RD
11 4 6 D6 BAT54 2N7002 Q3 MMBT4401 Q4

1 2 3

VDD

1.5K 1
CP2 +

D4 1N4148

5 6 7 8

3

2

LOOPFBK

10.0K 1.00K 14

LOOPIN

IFBOUT

R5/R9/C9 FORM A LOW-PASS FILTER, WITH A TIME CONSTANT OF 4.7 MILLISECONDS. THIS ALLOWS FIRMWARE LOOP UPDATE RATES OF UP TO 50 TIMES A SECOND.

Ccomp1
7

© 2006 Microchip Technology Inc.
RVDD
C23

ROVP
R2 1.5K C3 100 nF R19 10.0K R10 1.5K

ROVL

RVL

RVH

THERMISTOR CONNECTIONS TP TN
BUCK CONVERTER POWER SECTION

D2 CIN

DATA HVOUT CHGOUT

CP1 +

U1 16HV785
RG RT
16 R20 10.0K

Q1 L1 D1 COUT

CHARGER OUTPUT (TO BATTERY) CP+ CN-

C1 100 nF 20 VSS CHGFBK

DISCRETE MOSFET DRIVER: RG/RD VALUES VARY WITH PWM FREQUENCY, SUPPLY VOLTAGE, AND Q1 CHARACTERISTICS. IF SUPPLY VOLTAGE EXCEEDS Q1 V GS RATING, A ZENER CAN BE PLACED IN SERIES WITH THE DRAIN OF Q3, TO LIMIT VGS TO A SAFE LEVEL.

RSENSE

FIRMWARE CURRENT CONTROL OUTPUT: 5 9 CTRLOUT CTRLIN IFBINB RIL 12

R5 10.0K

CT

16HV785 SWITCHING CHARGER SCHEMATIC

CTRLOUT IS COMPARE OUTPUT, WHICH IS A FIRMWARE CONTROLLED PWM THAT SETS CURRENT LEVEL. R5/R9/C9 SCALE AND FILTER THE VOLTAGE FROM CTRLOUT, FOR APPLICATION TO OP1. R9 10.0K R12 8 IFBINA 13 470 nF C9

+ OP1 -

+ OP2 -

RT/CT/D6 CONVERT PWM OUTPUT TO RAMP WAVEFORM, WHICH IS FED BACK TO CP2 AND COMPARED TO ERROR AMP SIGNAL TO DETERMINE PWM DUTY CYCLE.

RIH CIH

R8 10.0K HARDWARE FEEDBACK TO PWM: OP1 IS ERROR AMP. Ccomp1/Ccomp2/Rcomp ARE LOOP COMPENSATION COMPONENTS.

Rcomp

Ccomp2

OP2 IS CURRENT-SENSE AMP. RIH, RIL, RSEN SE DETERMINE CURRENT SIGNAL SCALING. CIH IS USED IN SOME APPLICATIONS TO FILTER NOISE/SPIKES FROM CURRENT SENSE SIGNAL.

COMPONENTS THAT DO NOT HAVE A NUMERICAL VALUE ASSOCIATED WITH THEM ARE DEPENDENT UPON THE VOLTAGE/CURRENT SPECIFICATIONS OF THE PARTICULAR APPLICATION. CONSULT MICROCHIP FOR GUIDANCE IN DEFINING THESE COMPONENT VALUES.

AN1015

DS01015A-page 9

AN1015
FUNCTIONAL DESCRIPTION: LEAD CHEMISTRY
Lead Charging
To ensure the proper treatment of lead chemistries during extreme temperature and voltage conditions, multi-step charging is required. The 16HV785 measures key voltage, temperature and time parameters. It compares them to user-defined voltage, temperature and time limits.

VOLTAGE REGULATION STATE
Voltage Regulation provides charging at a constant voltage while the charge current decreases (or tapers) to the user-specified minimum current threshold (EOCCurrent). There are three possible next states. 1. When the charge current reaches the taper current threshold for End-of-Charge (EOCCurrent), the battery's voltage remains at the regulated voltage value and Float mode is deselected (Mode3<3> = 0), then the battery has reached the Charge Cycle Complete state. When the charge current reaches the taper current threshold for End-of-Charge (EOCCurrent), the battery's voltage remains at the regulated voltage value and Float mode is selected (Mode3<3> = 1), then the battery has reached the Float Charge state. If the time in the Voltage Regulation state exceeds the time limit (TimeoutCVState), then the next state is Charge Suspend.

CHARGE PENDING STATE ­ BEGINNING THE CHARGE CYCLE
The 16HV785 is initially set in the Charge Pending state. In this state, the presence of a battery pack must be sensed in order to begin the charging cycle. The 16HV785 comes up in the Charge Pending state after a Reset, independent of the previous state.

2.

3.

CHARGE QUALIFICATION STATE
During Charge Qualification, the battery's temperature and voltage are measured to determine the next charging state. There are two possible next states. 1. If Mode3<0> is set to `1', then skip to Float Charge state is selected. Charge Qualification will always jump directly to Float Charge state. If Mode3<0> is set to `0', then skip to Float Charge state is deselected. Charge Qualification will always progress to Current Regulation state.

FLOAT CHARGE STATE
In the Float Charge state, a lower charge target voltage is applied. As in Current Regulation state, the target voltage can be a constant or can vary with temperature. When Mode3<1> is set to `0', the charger uses a look-up table of float charge voltages as a function of temperature from the parameters V_FLT_0..9 (voltage) and T_VLUT_0..8 (temperature). When Mode3<1> is set to `1', a constant charge voltage is used from the parameter FloatVolt. The resulting taper current is measured and compared against EOCCurrent. This helps to maintain a full charge. There is only one possible next state and that is Charge Cycle Complete. Charge Cycle Complete is entered when the voltage reaches the float voltage target and the current tapers to less than EOCCurrent, or the float timer, TimeoutFLState, expires.

2.

CURRENT REGULATION STATE
The Current Regulation state is entered from Charge Qualification state. Battery charging is initiated. This state provides constant current, voltage limited charging. The charge current is referred to as ChargeCurr or the regulation current. While the current is applied, the battery's voltage increases until it reaches a voltage limit referred to as the regulation voltage. For lead batteries, this charge voltage can vary with temperature. Colder temperatures can allow the battery to use higher charging voltages. To take advantage of this, Mode3<1> can be set to `0'. This uses a look-up table of charge voltages as a function of temperature from the parameters V_CHG_0..9 (voltage) and T_VLUT_0..8 (temperature). When Mode3<1> is set to `1', a constant charge voltage is used from the parameter ChargeVolt. Charging continues, during which battery voltage and temperature are monitored. There are two possible next states. 1. If the battery's voltage reaches or exceeds the voltage limit, then the next state is Voltage Regulation. If the time in the Current Regulation state exceeds the time limit (TimeoutCCState), then the next state is Charge Suspend.

CHARGE SUSPEND STATE
In the Charge Suspend state, no current is applied to the battery pack. There is only one possible next state. If Mode3<5> is set to `1', then suspend forever is selected. Suspend mode will be active until the battery is removed. If Mode3<5> is set to `0', then Suspend mode will be active until the suspend timer, TimeoutRemSus, expires. Charge Suspend state always progresses to Charge Pending state.

CHARGE CYCLE COMPLETE STATE
When the current is less than the taper current threshold and the voltage is greater than the target voltage, End-of-Charge is triggered. At this threshold, charging is terminated and the End-of-Charge state is reached. If Mode3<4> is set to `1', then refloat is enabled and after the refloat timer, TimeoutRlFloat, expires, Float Charge state will be re-entered.

2.

DS01015A-page 10

© 2006 Microchip Technology Inc.

AN1015
CONFIGURABLE PARAMETERS
The 16HV785 device's configurable parameters allow for flexible changes in designing battery chargers. The parameters are categorized as follows: · · · · Configuration Lead Charging LED Display Configuration Look-up Tables

Lead Charging
The lead parameters govern precharge conditions, current regulation conditions and voltage regulation conditions, as well as when the battery is full and when charging should be suspended.

LED Display Configuration
The 16HV785 supports a 2-LED charging state display. These LEDs can be configured to identify the seven unique charger states

Configuration Parameters
The configuration parameters provide an identity to the battery pack and provide its basic characteristics to the 16HV785.

Look-up Tables
The look-up tables are grids of data that perform thermistor measurement linearization and PWM adjustment based on feedback measurements.

TABLE 2:

16HV785 LEAD CONFIGURATION PARAMETERS
# Bytes Typical Value Units Configuration Parameters Description

Parameter Name

BandgapCF BattIDMax

2 1

248 255

integer

Internal band gap calibration factor.

A/D full BATID input pin value maximum. When using BATID pin battery scale divided detection, voltage on BATID pin must be between BattIDMax and by 255 BattIDMin for battery present. A/D full BATID input pin value minimum. When using BATID pin battery scale divided detection, voltage on BATID pin must be between BattIDMax and by 255 BattIDMin for battery present. mAh integer ASCII AXCII binary Full-charge capacity of the battery pack. For reference only. Current calibration factor. Device name. For reference only. Manufacturer's name. For reference only. Configuration Register: bit 7: Unused bit 6: 1 = Enable GPIO cutoff logic bit 5-3: Unused bit 2: 1 = Battery present on BATID bit 1: 1 = Battery present on voltage sense bit 0: 1 = Battery present always

BattIDMin

1

0

Capacity CurrentCF DevName MfgName Mode

2 2 -- -- 1

2000 2553 16HV785 Microchip 00000001b

© 2006 Microchip Technology Inc.

DS01015A-page 11

AN1015
TABLE 2: 16HV785 LEAD CONFIGURATION PARAMETERS (CONTINUED)
# Bytes Typical Value Units Configuration Parameters (Cont.) Mode2 1 00100000b binary Configuration Register: bit 7: 1 = Disable auto-offset calibration bit 6: 1 = Enable clock output on BATID pin after Reset bit 5: 1 = Use constant temperature from EEPROM bit 4-2: Unused bit 1: 1 = Disable voltage cutoff in regulator bit 0: 1 = Disable PWM auto-shutdown Oscillator trim calibration value. LUT value which determines the PWM frequency. ID for parameter set. Shunt resistor value. Number of series connected cells in the battery pack. Default temperature when using constant temperature in EEPROM (°C * 10 + 200)/4. Temperature calibration value. Recheck timer for End-of-Charge condition. Recheck timer for state change. Voltage calibration value. Minimum voltage to set battery present when using battery voltage as a battery present determination. Charging current during current regulation. Target cell voltage in current regulation. This is set to the fully charged voltage of one cell, typically, as specified by the cell manufacturer. Voltage regulation fully charged current. This is the value of the taper current which will determine that the battery is fully charged. Target cell voltage during Float Charge state. Configuration Register: bit 7-6: Unused bit 5: 1 = Suspend indefinitely ­ until Reset or battery removed bit 4: 1 = Enable refloat ­ entered after Charge Cycle Complete state bit 3: 1 = Enable Float Charge state after Voltage Regulation state bit 2: 1 = Use fixed float voltage (otherwise, use look-up table) bit 1: 1 = Use fixed charge voltage (otherwise, use look-up table) bit 0: Description Parameter Name

OscTrim PWMFreq PatternID SHUNT SeriesCells Tdefault TempCF TimerEOCRecheck TimerStChng VoltageCF BattPresVolt ChargeCurr ChargeVolt

1 1 2 1 1 1 2 1 1 2 2 2 2

0 15 0x102 100 4 112 8192 20 20 5121 500 2000 4200

integer integer integer mOhms integer code integer .25 sec. .25 sec. integer mV mA mV

Lead Charging Parameters

EOCCurrent FloatVolt Mode3

2 2 1

200 2275 00111010b

mA mV binary

1 = Skip to Float Charge state immediately after Charge Qualification state

DS01015A-page 12

© 2006 Microchip Technology Inc.

AN1015
TABLE 2: 16HV785 LEAD CONFIGURATION PARAMETERS (CONTINUED)
# Bytes Typical Value Units Lead Charging Parameters (Cont.) TimeoutCCState TimeoutCVState TimeoutFLState TimeoutRIFloat TimeoutRemSus V_CHG_0 V_CHG_1 V_CHG_2 V_CHG_3 V_CHG_4 V_CHG_5 V_CHG_6 V_CHG_7 V_CHG_8 V_CHG_9 V_FLT_0 V_FLT_1 V_FLT_2 V_FLT_3 V_FLT_4 V_FLT_5 V_FLT_6 V_FLT_7 V_FLT_8 V_FLT_9 PWMAdjust1 PWMAdjust2 PWMAdjust3 PWMAdjust4 VhhVh Vh Vl VllVl Chl T_LUT_N T_LUT_T_0 T_LUT_T_1 T_LUT_T_2 T_LUT_T_3 T_LUT_T_4 T_LUT_T_5 T_LUT_T_6 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 90 0 0 0 2760 2700 2650 2590 2530 2500 2470 2410 2350 2250 2380 2370 2350 2330 2310 2300 2290 2270 2250 2200 12 10 5 1 19 6 6 44 5 8 38 48 61 79 105 183 207 4 min. 4 min. 4 min. 4 min. 4 min. mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV mV integer integer integer integer mV mV mV mV mA integer integer integer integer integer integer integer integer Current regulation time limit. Voltage regulation time limit. Float charge time limit. Re-enter float timer after Charge Cycle Complete state. Time to remain in Suspend mode. Variable charge voltage. Used when TEMP < T_VLUT_0. Variable charge voltage. Used when T_VLUT_0 < TEMP < T_VLUT_1. Variable charge voltage. Used when T_VLUT_1 < TEMP < T_VLUT_2. Variable charge voltage. Used when T_VLUT_2 < TEMP < T_VLUT_3. Variable charge voltage. Used when T_VLUT_3 < TEMP < T_VLUT_4. Variable charge voltage. Used when T_VLUT_4 < TEMP < T_VLUT_5. Variable charge voltage. Used when T_VLUT_5 < TEMP < T_VLUT_6. Variable charge voltage. Used when T_VLUT_6 < TEMP < T_VLUT_7. Variable charge voltage. Used when T_VLUT_7 < TEMP < T_VLUT_8. Variable charge voltage. Used when T_VLUT_8 < TEMP. Variable float voltage. Used when TEMP < T_VLUT_0. Variable float voltage. Used when T_VLUT_0 < TEMP < T_VLUT_1. Variable float voltage. Used when T_VLUT_1 < TEMP < T_VLUT_2. Variable float voltage. Used when T_VLUT_2 < TEMP < T_VLUT_3. Variable float voltage. Used when T_VLUT_3 < TEMP < T_VLUT_4. Variable float voltage. Used when T_VLUT_4 < TEMP < T_VLUT_5. Variable float voltage. Used when T_VLUT_5 < TEMP < T_VLUT_6. Variable float voltage. Used when T_VLUT_6 < TEMP < T_VLUT_7. Variable float voltage. Used when T_VLUT_7 < TEMP < T_VLUT_8. Variable float voltage. Used when T_VLUT_8 < TEMP. Description Parameter Name

LUT Parameters
PWM adjustment for regulation control. PWM adjustment for regulation control. PWM adjustment for regulation control. PWM adjustment for regulation control. Voltage PWM adjustment zone limit. Voltage PWM adjustment zone limit. Voltage PWM adjustment zone limit. Voltage PWM adjustment zone limit. Current PWM adjustment zone limit. Number of temperature linearization LUT entries. Temperature A/D reading axis point. Temperature A/D reading axis point. Temperature A/D reading axis point. Temperature A/D reading axis point. Temperature A/D reading axis point. Temperature A/D reading axis point. Temperature A/D reading axis point.

© 2006 Microchip Technology Inc.

DS01015A-page 13

AN1015
TABLE 2: 16HV785 LEAD CONFIGURATION PARAMETERS (CONTINUED)
# Bytes Typical Value Units LUT Parameters (Cont.) T_LUT_M_0 T_LUT_B_0 T_LUT_M_1 T_LUT_B_1 T_LUT_M_2 T_LUT_B_2 T_LUT_M_3 T_LUT_B_3 T_LUT_M_4 T_LUT_B_4 T_LUT_M_5 T_LUT_B_5 T_LUT_M_6 T_LUT_B_6 T_LUT_M_7 T_LUT_B_7 VLUT_N T_VLUT_0 T_VLUT_1 T_VLUT_2 T_VLUT_3 T_VLUT_4 T_VLUT_5 T_VLUT_6 T_VLUT_7 T_VLUT_8 LED1State1 LED1State2 LED1State3 LED1State4 LED1State5 LED1State6 LED1State7 LED1State8 LED2State1 LED2State2 LED2State3 LED2State4 LED2State5 LED2State6 LED2State7 LED2State8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -23362 1418 -19864 1352 -15709 1255 -12572 1162 -10206 1071 -8631 990 -10154 1127 -12875 1402 10 0 25 50 75 100 112 125 150 175 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b 00000000b integer integer integer integer integer integer integer integer integer integer integer integer integer integer integer integer integer coded coded coded coded coded coded coded coded coded binary binary binary binary binary binary binary binary binary binary binary binary binary binary binary binary Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Temperature linearization slope LUT entry. Temperature linearization Y-intercept LUT entry. Number of entries in V_CHG and V_FLT tables. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Temperature point for V_CHG and V_FLT tables (°C * 10 + 200)/4. Description Parameter Name

LED Parameters
LED1 display during state 1: Charge Pending. LED1 display during state 2: Charge Qualification. LED1 display during state 3: Current Regulation. LED1 display during state 4: Voltage Regulation. LED1 display during state 5: Float Charge. LED1 display during state 6: Charge Cycle Complete. LED1 display during state 7: Charge Suspend. LED1 display during state 8: Unused. LED2 display during state 1: Charge Pending. LED2 display during state 2: Charge Qualification. LED2 display during state 3: Current Regulation. LED2 display during state 4: Voltage Regulation. LED2 display during state 5: Float Charge. LED2 display during state 6: Charge Cycle Complete. LED2 display during state 7: Charge Suspend. LED2 display during state 8: Unused.

DS01015A-page 14

© 2006 Microchip Technology Inc.

AN1015
FIRMWARE SUMMARY
Initialization
During initialization, the firmware will define constants, allocate resources and configure registers. This includes mapping the GPIO, setting up the timers, setting the initial PWM frequency, outputting the optional BATID frequency check signal, configuring the LED pins and configuring the HVOUT pin. Once the resources are configured, RAM is cleared and the main loop is entered. Four of the initialization functions are described below: 1. 2. 3. 4. Programming the initial PWM frequency. Configuring the BATID pin as an analog input and output of the clock frequency. Configuring the LED2 pin as LED or communication. Configuring the HVOUT pin for one of its multiple functions.

TABLE 3:
F: PER <4:0>

PWM FREQUENCY
PWMP<6:5> 8.000 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 8000 4000 2667 2000 1600 1333 1143 1000 889 800 727 667 615 571 533 500 471 444 421 400 381 364 348 333 320 308 296 286 276 267 258 250 1 4000 2000 1333 1000 800 667 571 500 444 400 364 333 308 286 267 250 235 222 211 200 190 182 174 167 160 154 148 143 138 133 129 125 2 2000 1000 667 500 400 333 286 250 222 200 182 167 154 143 133 125 118 111 105 100 95 91 87 83 80 77 74 71 69 67 65 63 3 1000 500 333 250 200 167 143 125 111 100 91 83 77 71 67 63 59 56 53 50 48 45 43 42 40 38 37 36 34 33 32 31

The initial PWM frequency is configured by writing to PWMFreq, where the following table determines the PWM frequency as a function of the bits in the PWMP register.

© 2006 Microchip Technology Inc.

DS01015A-page 15

AN1015
The BATID pin is used to determine if a battery is present by measuring the voltage on the pin and comparing it to the proper EEPROM parameters. Alternatively, after a Reset and during initialization, this pin can be configured by the Mode2 parameter to output a single burst of 256 clocks in order to determine the frequency of the internal oscillator. The LED2 pin is configured as either an LED driver or as the communication pin. See the "Communication" section for more information. The HVOUT pin is a general purpose, open-drain output that can be configured to report if current is flowing by the Mode parameter. Mode<6> = 1: Charge Current Switch Used as an indication of charge current flowing. HVOUT = 1: Charge current flowing HVOUT = 0: No charge current flowing · regulate: Adjust the PWM to regulate current based on charge state and feedback measurements · led_svc: Operate two LEDs to display the charge state · timer_svc: Maintain the firmware timers · ee_write_buf: Background process to write the data block in the RAM buffer into EEPROM · ccmd_svc: React to communication commands · status_build: Build the status byte communication register

Triggers and Charge States
Once data is received from the A/D, it is compared to the parameters using charge state formulas to determine the proper charge states, as explained in the "Functional Description: Lead Chemistry" section.

Regulating the PWM
The PWM duty cycle is adjusted by the firmware in response to the charge state and the feedback measurements. It is increased or decreased to keep the voltage and current as close to the charge requirements as possible without exceeding those requirements. The feedback measurements of voltage and current are compared to the required voltage and current of the particular charge state the device is in. The PWM is either kept the same, increased or decreased a little, or increased or decreased a lot as a function of the difference between the feedback measurements and the requirements. As Table 4 shows, if the voltage feedback is no greater than Vh more than the requirement, and no less than Vl lower than the requirement, the PWM is unchanged. If the feedback voltage exceeds the required voltage by more than Vl, the PWM is decreased by PWMAdjust4, etc. Table 4 shows the PWM adjustment factors as a function of current difference and voltage difference when comparing feedback to requirements:

Main Loop
The main loop cycles through the following functions: · Performs A/D measurements · Checks measurements against triggers and determines the charge state · Adjusts the PWM to regulate current · Operates the LEDs · Maintains the timers · Performs EEPROM reads and writes · Performs communication transactions The actual subroutines are: · adc_svc: Receive the finished A/D conversions, process the data with calibration constants, etc., and store in RAM · adc_start: Start a new set of conversions to be completed for the next cycle · check_triggers: Compare the A/D results with parameters to determine what state the charging should be in · chg_state_svc: Put the charger into the proper state based on A/D results

TABLE 4:

PWM ADJUSTMENT FACTORS
Current Zones < -Cll < -Cl -PWMAdjust1 -PWMAdjust4 0 +PWMAdjust4 +PWMAdjust4 -Chl to +Chl -PWMAdjust1 -PWMAdjust4 0 0 0 > Ch -PWMAdjust1 -PWMAdjust4 -PWMAdjust4 -PWMAdjust4 -PWMAdjust4 > Chh -PWMAdjust1 -PWMAdjust2 -PWMAdjust2 -PWMAdjust2 -PWMAdjust2

Voltage Zones

> Vhh > Vh Vh to -Vl < -Vl < -Vll

-PWMAdjust1 -PWMAdjust4 0 +PWMAdjust4 +PWMAdjust3

DS01015A-page 16

© 2006 Microchip Technology Inc.

AN1015
LED Control
Two LED Configuration registers (one for each LED) determine how the LEDs are displayed when controlling on/off, flashing, flash counts and on/off times.

TABLE 5:
Mode<7,3> 00 01

LED CONFIGURATION REGISTERS
Mode Description OFF Flash N + 1 Times, Pause, Repeat N<6:4> N/A Flash Count = N + 1 F<2:0> N/A On Time = Off Time = F + 1 Pause Time = (F + 1) * 5 Max = 3 N/A Off Time = F + 1

10 11

On Flash Continuously

N/A On Time = N + 1

EEPROM parameters are used to define the settings above for each charge state. The LED1State1-8 and LED2State1-8 parameters are used to program the above configuration parameters based on what state the charger is in.

Since the reference voltage is fixed, this calibration factor is used to compensate for a variance in VDD. It is used to correct any readings that use VDD as a reference.

CURRENT
The current reading is calibrated or translated from the raw A/D measurement (A/DRAW) as follows:

A/D Starting and Processing
The A/D operations consist of starting the A/D readings on up to 5 channels, retrieving the data and calibrating the data. To start the readings, the firmware programs the A/D Control registers (see the "PIC16F785 Data Sheet" (DS41249)) to perform the required measurements. Up to five channels are used for the charger function. They include the following: · · · · · Reference Voltage Current Voltage Temperature BATID

EQUATION 6:
When referenced to VR: Current = A/DRAW * CurrentCF/65536 When referenced to VDD: Current = (A/DRAW * VR/16384) * CurrentCF/65535 The CurrentCF is determined Equation 6 at full scale, for example: by examining

EQUATION 7:
Current(full scale) = VREF/AMPgain/SHUNT = 5000/19.6/0.100 = 2551 mA 2551 = 1023 * CurrentCF CurrentCF = 2.494 Representing the decimal fraction as a ratio using a power of 2:

When conversions are complete, flags are set so the firmware can perform the calibration and processing. For filtering purposes, the average of 16 consecutive readings are used for valid data.

REFERENCE VOLTAGE
The band gap reference voltage (VR) is calibrated or translated from the raw A/D measurement (A/DRAW) as follows:

EQUATION 8:
CurrentCF Base = 1024 CurrentCF = 2553

EQUATION 5:
VR = A/DRAW * 16384/BandgapCF BandgapCF is typically around 248 since: VR/VDD * A/DRAW(FULLSCALE) = 1212/5000 * 1023 = 248

© 2006 Microchip Technology Inc.

DS01015A-page 17

AN1015
VOLTAGE
The voltage reading is calibrated or translated from the raw A/D measurement (A/DRAW) as follows: The temperature response of the thermistor is then subjected to linearization by a look-up table as described in the next section.

EQUATION 9:
When referenced to VR: Voltage = A/DRAW * VoltageCF/1024 When referenced to VDD: Voltage = (A/DRAW * VR/16384) * VoltageCF/1024 Where VoltageCF is determined as follows: Voltage = A/DRAW * VoltageCF' A/DRAW = (Voltage * Cells) * R/VREF * 1023 Where: R = Resistor Divider Ratio VREF = 5000 mV This means: Voltage = VoltageCF' * Voltage * Cells * R/VREF * 1023 or VoltageCF' = VREF/(Cells * R * 1023) and using integer arithmetic: VoltageCF = VoltageCF' * 1024 So that: Voltage = VoltageCF * A/DRAW /1024 Table 6 shows the typical VoltageCF values for the PS2070 evaluation module with a different number of cells and different voltage dividers selected:

Thermistor Linearization
The thermistor reading is subjected to piecewise linear interpolation using a look-up table of line equations. Since the variance of voltage with temperature for the thermistor is not always along the same line (same slope and intercept), multiple line equations must be used for interpolation depending on where the measurement is located. The look-up table was developed by rating raw A/D values; that is why TempCF can typically be set to 1. The look-up table is a series of slopes and y intercepts corresponding to regions of temperature A/D readings. T_LUT_N represents the number of entries in the table, in this case eight entries.

TABLE 7:
A/D Reading
< T_LUT_T_0 < T_LUT_T_1 < T_LUT_T_2 < T_LUT_T_3 < T_LUT_T_4 < T_LUT_T_5 < T_LUT_T_6 > T_LUT_T_6

THERMISTOR LINEARIZATION
Slope
T_LUT_M_0 T_LUT_M_1 T_LUT_M_2 T_LUT_M_3 T_LUT_M_4 T_LUT_M_5 T_LUT_M_6 T_LUT_M_7

Y-intercept
T_LUT_B_0 T_LUT_B_1 T_LUT_B_2 T_LUT_B_3 T_LUT_B_4 T_LUT_B_5 T_LUT_B_6 T_LUT_B_7

TABLE 6:
Cells 1 2 3 4 R# 1 2 3 4

TYPICAL VoltageCF VALUES FOR PS2070
R1 0.232 10.500 20.500 30.900 R2 10.0 10.0 10.0 10.0 R Ratio VoltageCF 0.9773 0.4878 0.3279 0.2445 5121 5130 5088 5117

The typical values are:

TABLE 8:
A/D Reading
< 38 < 48 < 61 < 79 < 105 < 183 < 207 > 207

A/D TEMPERATURE READINGS
Slope
-23362 -19864 -15709 -12572 -10206 -8631 -10154 -12875

Y-intercept
1418 1352 1255 1162 1071 990 1127 1402

BATID
The BATID pin is measured in raw A/D units, scaled to 0 to 255, and compared to EEPROM parameters that are in raw A/D units, scaled to 0 to 255, so no calibration is performed.

TEMPERATURE
The current reading is calibrated or translated from the raw A/D measurement (A/DRAW) as follows:

Communication
Communication for memory reads and writes, typically used for changing parameters, is performed using the LED2 I/O pin (pin 2). Pin 2 is configured during Reset initialization to either be the communication pin, or an LED driver. If pin 2 is driven low during initialization, pin 2 will become the LED driver. If pin 2 is driven high during initialization, communication will be enabled and pin 2 will be the communication pin.

EQUATION 10:
Temperature = A/DRAW * TempCF/8192 Where temperature is in the internal units of: (°C + 20) * 10 TempCF is typically 8192 and is set by comparing a known temperature to the measured temperature.

DS01015A-page 18

© 2006 Microchip Technology Inc.

AN1015
The communication protocol is the Single Pin Serial (SPS) protocol. SPS communication is an asynchronous return-to-one protocol. The signal requires an external pull-up resistor. The timing of the driven low pulses defines the communication. A Break cycle starts a command from the host to the 16HV785. The command is eight bits long. After this, eight data bits are either written to the 16HV785, or read from the 16HV785. A Break cycle is defined by a low period of time equal to or greater than time tb, then returned high for a time greater than or equal to tbr. The data bits consist of three sections each: 1. 2. 3. Start: low for at least time tstr. Data: data high or low valid by time tdsuh/v and held until time tdh/v. Stop: high by time tssuh/v and held until time tcyc. All transactions either read or write an 8-bit register. Each register has a 7-bit address, plus a read/write bit, for a total of 8 bits. Bit 7 is the read/write bit. When bit 7 is `1', the register is written. When bit 7 is `0', the register is read. Of the possible 128 addressable registers, only ten are implemented. A read transaction will receive a single byte of data. A write transaction can write multiple 8-bit data values to a register: READ: BREAK, REG_ADDR, DATA. WRITE: BREAK, REG_ADDR, DATA, DATA, ... DATA

© 2006 Microchip Technology Inc.

DS01015A-page 19

AN1015
FIGURE 11: SINGLE PIN SERIAL TIMING
Break Timing Break bit Break Reset

tB

tBR

Host to 16HV785 Start bit Data bit Stop bit

tstrh tdsu tdh tssu tcych 16HV785 to Host Start bit Data bit Stop bit

tstrb tdsub tdv tssub tcycb

CMD Address Break LSB

CMD and Data Protocol MSB LSB

Data to or from 16HV785

Communication Example CMD Addr = 04 hex Break 0 1 1 0 0 0 0 0 1 0 Data = 25 hex 1 0 0 1 0 0

DS01015A-page 20

© 2006 Microchip Technology Inc.

AN1015
TABLE 9:
Name MEM_ADDR STATUS CONFIG CMND DATA_LO DATA_HI N/A UNLOCK MEM_ACCESS MEM_ACCESS_IA

REGISTER SUMMARY
ADDR 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x0C R/W R/W R R/W R/W R/W R/W n/a W R/W R/W Unlock Key = 0x96 Accesses Memory Indirectly through MEM_ADDR Accesses Memory Indirectly through MEM_ADDR and Post-Increments Memory Address Indirect Memory Address Status Configuration Command Data Data Description

REGISTER DESCRIPTIONS REGISTER 0:
Bit 7:0

MEM_ADDR
Description Indirect memory address used for reading and writing data

Name MEM_ADDR

REGISTER 1:
Bit 7 6 5 4 3 2 1 0 EE_Busy EE_Err Unused

STATUS
Description 1 = EEPROM write is in progress; busy 1 = Error encountered during last EEPROM write 1 = Regulation active 1 = Charge controller active 1 = Data simulation active

Name

REG_ACTIVE CHGCON SIM_ACTIVE Unused Unused

REGISTER 2:
Bit 7:6 5 4 3:2 1 0 Unused SUSPEND

CONFIG
Description

Name

1 = Suspend/skip all processing (used when writing EEPROM) 1 = Suspend charge controller 1 = Indirect memory addressing refers to EEPROM 1 = Indirect memory addressing refers to 2nd bank of RAM

CHGCON_OFF Unused MEMBANK_EE MEMBANK_23

© 2006 Microchip Technology Inc.

DS01015A-page 21

AN1015
REGISTER 3:
Bit 7 6 5 4 3 2 1 0 VERSION PWM_SET REG_ON EE_RQ Unused RESET FORCE_CHGSTATE SIM_RQ 1 = Reset firmware (branch to Reset vector from Idle loop) 1 = Force branch to Charge Controller state 1 = Load simulation data previously written to RAM

CMND
Name Description 1 = Load Data registers (Register 4 and Register 5) with firmware version number 1 = Load control PWM with contents of Data registers 1 = Enable regulation module 1 = Request EEPROM write of data block in RAM

REGISTER 4:
Bit 7:0 DATA_LO

DATA_LO
Name Description Generic data used in memory reads and writes (LSB)

REGISTER 5:
Bit 7:0 DATA_HI

DATA_HI
Name Description Generic data used in memory reads and writes (MSB)

REGISTER 6:
Bit 7:0 Unused

UNUSED
Name Description

REGISTER 7:
Bit 7:0 UNLOCK

UNLOCK
Name Unlock code is written here Description

REGISTER 8:
Bit 7:0

MEM_ACCESS
Name Description Data written to Register 8 is actually sent to the memory address contained in Register 0 and the bank indicated by Register 2 (bits<1:0>)

MEM_ACCESS

REGISTER C:
Bit 7:0

MEM_ACCESS_IA
Description Data written to Register 8 is actually sent to the memory address contained in Register 0 and the bank indicated by Register 2 (bits<1:0>); Register 0 will be post-incremented

Name MEM_ACCESS_IA

DS01015A-page 22

© 2006 Microchip Technology Inc.

AN1015
Host Driven Operations
Host driven operations refer to a host communicating with the 16HV785 in order to read or write memory locations. This is typically done during programming, parameter changing, or troubleshooting. The four basic functions are EEPROM read, EEPROM write, RAM read and RAM write. The host will employ the Single Pin Serial protocol and the registers described in the "Register Descriptions" section to accomplish the functions.

EEPROM WRITE
The EEPROM write follows a more secure protocol in which a "control packet" of data is written to a RAM buffer first. The RAM buffer begins at address 0xA0. A control bit is then set to trigger the writing of the data in the control packet to EEPROM. The control packet takes the following form:

TABLE 10:
Byte 0 1 2 ... N+1 N+2

EEPROM WRITE CONTROL PACKET
Description Starting EEPROM Address to be Written Byte Count (N), Maximum = 29 Data[0] Data[N ­ 1]

RAM READ
There are three steps to the RAM read: 1. Select the bank: Set Communication Register 2 (bit 0 = 0); select bank 0/1 since bank 2/3 is not implemented. Select the address: Set Communication Register 0 to the starting RAM address. Read the data: Read the contents of the Memory Access register (Register 8 or Register C). When using Register C, the address will auto-increment, so step 3 can be repeated to receive more data.

Name ADDR COUNT DATA DATA

2. 3.

CHKSUM Checksum = Sum (byte[0]:byte[N + 1])

The total procedure is a five step process: 1. 2. 3. Suspend normal operation: Set Communication Register 2 = 0x20 (set bit 5 = 1). Check if the EEPROM is busy: Does Communication Register 1 (bit 7 = 1)? If not busy, write the control block data to RAM, beginning at address 0xA0, using RAM write procedure. When all data is written, trigger EEPROM write; set Communication Register 3 (bit 4 = 1). Issue a firmware Reset: Set Communication Register 3 (bit 2 = 1).

RAM WRITE
There are three steps to the RAM write: 1. Select the bank: Set Communication Register 2 (bit 0 = 0); select bank 0/1, since bank 2/3 is not implemented. Select the address: Set Communication Register 0 to the starting RAM address. Write the data: Write the data to the Memory Access register (Register 8 or Register C). When using Register C, the address will autoincrement, so step 3 can be repeated to write more data.

2. 3.

4. 5.

EEPROM READ
There are three steps to the EEPROM read: 1. 2. 3. Select the bank: Set Communication Register 2 (bits<1:0> = 10); select bank = EEPROM. Select the address: Set Communication Register 0 to the starting EEPROM address. Read the data: Read the contents of the Memory Access register (Register 8 or Register C). When using Register C, the address will auto-increment, so step 3 can be repeated to receive more data.

© 2006 Microchip Technology Inc.

DS01015A-page 23

AN1015
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated (the "Company") is intended and supplied to you, the Company's customer, for use solely and exclusively with products manufactured by the Company. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

FIRMWARE SOURCE CODE
Define Constants, Registers and EEPROM Locations
The following section defines variables used by the firmware to control the charging regime. The EEPROM parameters described in the functional description are assigned addresses and variable names. Note that the internal firmware variable names for these parameters may not match the names used in the functional

description above. The names in the functional description match the names in PowerToolTM 200 software. The software and data sheet names have been given names that are more user-friendly. The mode bits are defined which become user-selectable functions and charge features as described in the functional description. Variable names are defined for hardware interface registers like A/D control and data, timers, PWM configuration and GPIO.

;===================================================================== ; ;=====================================================================

;--- defines ;#define CLOCK_4MHZ #define CLOCK_8MHZ ;#define ENABLE_COMM_LOCK ;#define DEBUG_ENABLE_TOGGLE ;--- firmware version #define FW_VERSION_LO #define FW_VERSION_HI #include "p16f785.inc" ;--- configuration __CONFIG _CP_OFF & _CPD_OFF & _BOD_OFF & _BOR_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT ;----------------------------------------------------------;--- registers: special function ;----------------------------------------------------------r_indf equ INDF r_tmr0 equ TMR0 r_pcl equ PCL r_status equ STATUS r_fsr equ FSR r_port_a equ PORTA r_port_b equ PORTB r_port_c equ PORTC r_pclath equ PCLATH r_intcon equ INTCON r_pir1 equ PIR1 r_tmr1l equ TMR1L r_tmr1h equ TMR1H r_t1con equ T1CON r_tmr2 equ TMR2 r_t2con equ T2CON r_ccpr1l equ CCPR1L

0x01 0x03

DS01015A-page 24

© 2006 Microchip Technology Inc.

AN1015
r_ccpr1h r_ccp1con r_wdtcon r_adresh r_adcon0 r_option_reg r_tris_a r_tris_b r_tris_c r_pie1 r_pcon r_osccon r_osctune r_ansel0 r_pr2 r_ansel1 r_wpua r_ioca r_refcon r_vrcon r_eedata r_eeadr r_eedata r_eeadr r_eecon1 r_eecon2 r_adresl r_adcon1 r_pwmcon1 r_pwmcon0 r_pwmclk r_pwmph1 r_pwmph2 r_cm1con0 r_cm2con0 r_cm2con1 r_opa1con r_opa2con equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ CCPR1H CCP1CON WDTCON ADRESH ADCON0 OPTION_REG TRISA TRISB TRISC PIE1 PCON OSCCON OSCTUNE ANSEL0 PR2 ANSEL1 WPUA IOCA REFCON VRCON EEDATA EEADR EEDATA EEADR EECON1 EECON2 ADRESL ADCON1 PWMCON1 PWMCON0 PWMCLK PWMPH1 PWMPH2 CM1CON0 CM2CON0 CM2CON1 OPA1CON OPA2CON

;*** register bank limits #define ram0_start #define ram0_end #define ram0_length #define ram1_start #define ram1_end #define ram1_length

0x20 0x7f ram0_end - ram0_start + 1 0xa0 0xef ram1_end - ram1_start + 1

;----------------------------------------------------------;--- registers: user ;----------------------------------------------------------org 0x20 ; *** bank 0 r_mode res 1 ; operational mode register r_chg_state res 1 ; charge controller "state" r_adc_0 equ $ ; r_adc_0_L res 1 ; adc result - channel 0 r_adc_0_H res 1 ; r_adc_1 equ $ ; r_adc_1_L res 1 ; adc result - channel 1 r_adc_1_H res 1 ; r_adc_2 equ $ ; r_adc_2_L res 1 ; adc result - channel 2 r_adc_2_H res 1 ; r_adc_3 equ $ ; r_adc_3_L res 1 ; adc result - channel 3 r_adc_3_H res 1 ;

© 2006 Microchip Technology Inc.

DS01015A-page 25

AN1015
r_adc_4 r_adc_4_L r_adc_4_H r_pwm_L r_pwm_H r_reg_c r_reg_v r_comm_reg r_comm_reg_0 r_comm_reg_1 r_comm_reg_2 r_comm_reg_3 r_comm_reg_4 r_comm_reg_5 r_comm_reg_6 r_comm_reg_7 r_sim r_chg_timer_a r_chg_timer_b r_chg_timer_c r_chg_timer_d r_temp_1 r_temp_2 r_temp_3 r_temp_4 r_tempi_1 r_timer_a1 r_timer_b r_timer_b1 r_timer_c r_timer_d r_timer_d1 r_led_config_1 r_led_contrl_1 r_led_config_2 r_led_contrl_2 r_adc_control r_adc_raw_L r_adc_raw_H r_count_1 r_accD_L r_accD_H r_accC_L r_accC_H r_accB_L r_accB_H r_accA_L r_accA_H r_comm_count r_comm_data r_comm_flags r_comm_data_cmnd r_mode2 equ res res res res res res equ res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res res $ 1 1 1 1 2 2 $ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; adc result - channel 4 pwm setting pwm setting regulation target: current (mA) regulation target: voltage (mV) comm "registers" indirect address register status config flags command flags data lo data hi

hysteresis timer hysteresis timer hysteresis timer hysteresis timer location sensitive (init ram clear)

temporary reg for isr

adc control

math - accumulator - D math - accumulator - C math - accumulator - B math - accumulator - A

res 1 org res res res res res res 0x60 2 1 2 2 1 1

r_adc_accum r_adc_accum_count r_adc_avg r_adc_avg_shadow r_adc_1_ofs r_tcode ;debug r_not_used

; ; ; ; ; ; ;

res 5

DS01015A-page 26

© 2006 Microchip Technology Inc.

AN1015
r_mode3 res 1 ; r_timer_d2 res 1 ; ;----------------------------------------------------------;--- registers: bank0,1,2,3 (common) ;----------------------------------------------------------org 0x70 ; *** bank 0 (common area) r_shadow_1 res 1 ; r_shadow_2 res 1 ; r_shadow_3 res 1 ; ;r_shadow_4 res 1 ; r_flags_1 res 1 ; assorted bit flags r_flags_2 res 1 ; assorted bit flags r_flags_3 res 1 ; assorted bit flags r_flags_4 res 1 ; assorted bit flags r_flags_5 res 1 ; assorted bit flags r_flags_6 res 1 ; assorted bit flags r_isr_w res 1 ; interrupt context r_isr_status res 1 ; interrupt context r_isr_pclath res 1 ; interrupt context r_isr_fsr res 1 ; interrupt context r_ee_data res 1 ; eeprom data r_ee_addr res 1 ; eeprom address r_tempc_1 res 1 ;

#define #define #define #define #define #define #define #define ;#define #define #define #define #define #define #define #define #define #define

flag0_mode_pchg_always flag0_mode_gpio_cutoff flag0_mode_bpres_battid flag0_mode_bpres_v flag0_mode_bpres_always flag0_mode_cofs_dis flag0_mode_oscout flag0_mode_temp_k flag0_mode_nm flag0_mode_vrchg_dis flag0_mode_vregco_dis flag0_mode_pwmas_dis flag0_mode_suspend_4ever flag0_mode_refloat flag0_mode_postfloat flag0_mode_v_flt_k flag0_mode_v_reg_k flag0_mode_float equ equ equ equ equ equ .7 .6 .5 .4 .3 .2

r_mode, r_mode, r_mode, r_mode, r_mode, r_mode2, r_mode2, r_mode2, r_mode2, r_mode2, r_mode2, r_mode2, r_mode3, r_mode3, r_mode3, r_mode3, r_mode3, r_mode3, ; ; ; ; ; ;

7 6 2 1 0 7 6 5 4 2 1 0 5 4 3 2 1 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

always start with pchg enable gpio cutoff logic use battid for batt present battery present on voltage sense battery present - always current offset - disable enable oscillator out on battid use constant temperature 25degC nickel metal hydride algorithm voltage recharge - disable regulation voltage cutoff - disable pwm auto shutdown - disable suspend forever re-float enable float after CC,CV cycle use constant v float (not vlut) use constant v reg/charge (not vlut) skip to float state immediately

BN_CREG_EE_BUSY BN_CREG_EE_ERR ;BN_CREG_UNLOCKED BN_CREG_REG BN_CREG_CHGCON BN_CREG_SIM #define #define ;#define #define #define #define #define #define #define #define

ee write busy error on last ee write comm unlocked regulation active charge controller enabled simulation active (>=1 channel) BN_CREG_EE_BUSY BN_CREG_EE_ERR BN_CREG_UNLOCKED BN_CREG_REG BN_CREG_CHGCON BN_CREG_SIM 5 4 1 0

flag0_creg_st_ee_busy flag0_creg_st_ee_err flag0_creg_st_unlocked flag0_creg_st_reg flag0_creg_st_chgcon flag0_creg_st_sim flag0_creg_suspend flag0_creg_chgcon_off flag0_creg_membank_ee flag0_creg_membank_23

r_comm_reg_1, r_comm_reg_1, r_comm_reg_1, r_comm_reg_1, r_comm_reg_1, r_comm_reg_1, r_comm_reg_2, r_comm_reg_2, r_comm_reg_2, r_comm_reg_2,

© 2006 Microchip Technology Inc.

DS01015A-page 27

AN1015
#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define flag0_creg_version flag0_creg_pwm_set flag0_creg_reg_on flag0_creg_ee_rq flag0_creg_test flag0_creg_reset flag0_creg_fchgstate flag0_creg_sim_rq flag_ee_busy flag_ee_rq flag_ee_err flag_simdata_ready flag_chg_state_timer flag_math_temp flag_timer_0 flag_led_timer r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_comm_reg_3, r_flags_1, r_flags_1, r_flags_1, r_flags_1, r_flags_1, r_flags_1, r_flags_1, r_flags_1, 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0

;--- trigger flags - lion ;#define flag_v_le_vmin ;#define flag_v_le_vmax ;#define flag_v_le_vreg ;#define flag_v_le_vpchg ;#define flag_t_le_tmin ;#define flag_t_le_tmaxchgi ;#define flag_t_le_tmaxchg ;#define flag_t_le_tpchg ;--- trigger flags - nimh ;#define flag_v_le_vpchg_nm ;#define flag_t_le_tpchg_lo_nm ;#define flag_t_le_tpchg_hi_nm ;#define flag_t_le_tmaxchg_nm ;#define flag_v_le_vmaxchg_nm ;#define flag_v_le_rchg_nm ;#define flag_v_le_dchg_nm ;#define #define #define #define #define #define #define #define flag_unlocked flag_temp_1 flag_temp_2 flag_neg flag_chg_timer flag_adcset_2_rq flag_adcset_1_rq flag_adcset_0_rq

r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_2, r_flags_3, r_flags_3, r_flags_3, r_flags_3, r_flags_3, r_flags_3, r_flags_3, r_flags_3,

7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 7 6 5 4 3 2 1 0

;*** WARNING: DO NOT MOVE: flag_led_2_save ;*** WARNING: DO NOT MOVE: flag_led_1_save ;#define flag_led_2_save r_flags_4, 7 ;#define flag_led_1_save r_flags_4, 6 #define flag_adc_3_sim r_flags_4, 7 #define #define #define #define #define #define #define #define #define #define #define #define #define #define flag_adcset_2_rdy flag_adcset_2_rqq flag_adcset_1_rdy flag_adcset_1_rqq flag_adcset_0_rdy flag_adcset_0_rqq flag_reg_timer flag_battpres1 flag_battpres flag_comm_active flag_reg_on flag_vreg flag_vreg_2 flag_vreg_1 r_flags_4, r_flags_4, r_flags_4, r_flags_4, r_flags_4, r_flags_4, r_flags_5, r_flags_5, r_flags_5, r_flags_5, r_flags_5, r_flags_5, r_flags_5, r_flags_5, 5 4 3 2 1 0 7 6 5 4 3 2 1 0

DS01015A-page 28

© 2006 Microchip Technology Inc.

AN1015
#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define BN_CHGN_TSEL 0 flag_chg_ti1_done r_flags_6, 7 flag_chg_ti2_done r_flags_6, 6 flag_chgn_tsel r_flags_6, BN_CHGN_TSEL MASK_CHGN_TSEL 1<
COMM_UNLOCK_KEY flag_comm_pin flag_comm_timeout flag_comm_cmnd flag_comm_bit flag_comm_H2L flag_comm_xmit

;----------------------------------------------------------;--- registers: bank1 ;----------------------------------------------------------org equ equ res res res res org res 0xa0 $ $ .1 .1 .29 .1 0xb0 .16 ; *** bank 1 ; sim data, ee write buf data ; ; ; ; ; ; overlaps 2nd half of r_buf1 ; scratchpad for LUT

r_buf1 r_ee_buf r_ee_buf_adr r_ee_buf_cnt r_ee_buf_dta r_ee_buf_ptr r_buf2

;----------------------------------------------------------;--- registers: bank2 ;----------------------------------------------------------org 0x110 ; *** bank 2 ;----------------------------------------------------------;--- registers: bank3 ;----------------------------------------------------------org 0x190 ; *** bank 3 ;---------------------------------------------