Professional Documents
Culture Documents
March 2007
Developments in Battery Stack Voltage Measurement
A Simple Solution to a Not So Simple Problem
Jim Williams and Mark Thoren
Automobiles, aircraft, marine vehicles, uninterruptible
power supplies and telecom hardware represent areas
utilizing series connected battery stacks. These stacks
of individual cells may contain many units, reaching potentials of hundreds of volts. In such systems it is often
desirable to accurately determine each individual cells
voltage. Obtaining this information in the presence of the
high common mode voltage generated by the battery
stack is more difcult than might be supposed.
, LT, LTC and LTM are registered trademarks of Linear Technology Corporation.
All other trademarks are the property of their respective owners.
1See Appendix A, A Lot of Cut Off Ears and No Van Goghs for detail
and
N CELLS
+
VOLTMETER
+
+
BATTERY
STACK
GND
+
SWITCH
CONTROL
GND
+
+
+
SINGLE CELL
BATTERY
GND
AN112 F02
AN112 F01
AN112-1
T1s primary (Trace B) responds by rising to a value representing the sum of VDIODE + VBATTERY along with a small
xed error contributed by the transformer. T1s primary
clamps at this value. After a time (Trace C) dictated by
the delayed pulse generator a pulse (Trace D) closes S1,
allowing C1 to charge towards T1s clamped value. After a
number of pulses C1 assumes a DC level identical to T1s
primary clamp voltage. A1 buffers this potential and feeds
differential amplier A2. A2, operating at a gain near unity,
subtracts the diode and transformer error terms, resulting
in a direct reading VBATTERY output.
Accuracy is critically dependent on transformer clamping
delity over temperature and clamp voltage range. The
carefully designed transformer specied yields Figure 6s
waveforms. Primary (Trace A) and secondary (Trace B)
clamping detail appear at highly expanded vertical scale.
Clamping atness is within millivolts; trace center aberrations derive from S1 gate feedthrough. Tight transformer
clamp coupling promotes good performance. Circuit accuracy at 25C is 0.05% over a 0V to 2V battery range with
120ppm/C drift, degrading to 0.25% at VBATTERY = 3V.
2Battery stack voltage monitor development is aided by the oating,
variable potential battery simulator described in Appendix B.
PULSE
GENERATOR
DELAYED PULSE
GENERATOR
T1
DIODE
+
+
PULSE
GENERATOR
N CELLS
T1
PRIMARY
VBATTERY
DELAYED
PULSE
VBATTERY + DIODE
AND T1 ERROR
N CELLS
DC POTENTIAL =
T1S CLAMP VALUE
ANALOG INPUT
SAMPLING
VOLTMETER
SAMPLE COMMAND
DIODE TRANSFORMER
ERROR TERMS
SUBTRACTION
OUTPUT = VBATTERY
AN112 F03
Figure 3. Transformer-Based Sampling Voltmeter Operates Independently of High Common Mode Voltages. Pulse
Generator Periodically Activates T1. Delayed Pulse Triggers Sampling Voltmeter, Capturing T1s Clamped Value.
Residual Error Terms are Corrected in Following Stage
an112f
AN112-2
OUT
IN
LT1761-5
GND
12VIN
= 1/6 74HC04
PULSE GENERATOR
DIODE
10k*
SAMPLING VOLTMETER
(SAMPLE-HOLD)
Q1
T1
VBATTERY
12V
10F
S1
1/4 CD4016
6.34M*
A1
LTC1050
10k
+
A2
LT1789
C1
0.001F
4.7k
Q2
12V
OUTPUT =
VBATTERY
A = 1.03
22k
5V
5V
DELAYED
PULSE
7.5k*
ERROR SUBTRACTION
Q3
100pF
511*
5V
AN112 F04
A2
DELAYED
PULSE
GENERATOR
74HC123
A1 B1 CL1
5V
C2 RC2 G
270pF
DELAY TIME
14.7k*
5V
Figure 4. Transformer Fed Sampling Voltmeter Schematic Closely Follows Figure 3s Concept. Error Subtraction Terms
Include Q3 Compensating Q1 and Resistor/Gain Corrections for Errors in T1s Clamping Action. Q1-Q3 Transistors
Replace Diodes for More Consistent Matching. Q2 Prevents T1s Negative Recovery Excursion from Inuencing S1
A = 5V/DIV
B = 2V/DIV
A = 2mV/DIV
ON 2.2V STEP
C = 5V/DIV
D = 5V/DIV
B = 2mV/DIV
ON 2.2V STEP
2s/DIV
AN112 F05
2s/DIV
AN112 F06
AN112-3
TO
SAMPLE-HOLD
BATTERY
STACK
ENABLE
LINES
AN112 F07
N SECTIONS
AN112-4
OFFSET
10k
2N3904
T1
74HC14
ADC_CH7
EN0
4.7k
VN2222
RB0/EXCITATION
ENABLE
LINES
74HC574
DB0
DB1
DB2
PROCESSOR DB3
DATA BUS DB4
DB5
DB6
DB7
RB1/LATCH
1D
2D
3D
4D
5D
6D
7D
8D
CLK
1Q
2Q
3Q
4Q
5Q
6Q
7Q
8Q
74HC00
EN0
EN1
10k
GAIN
10k
EN2
EN3
EN4
EN5
EN6
EN7
2N3904
T2
74HC14
ADC_CH6
TO OTHER
CHANNELS
EN1
VREF
10F
4.7k
VN2222
RB0/EXCITATION
74HC00
5V
IN
OUT
LT1790-1.25
OC
5V
0.1F
2.2F
ADC_CH0
ADC_CH1
ADC_CH2
ADC_CH3
ADC_CH4
ADC_CH5
ADC_CH6
ADC_CH7
10F
1F
VCC
LTC1867
VREF
CH0
CH1
CH2
CH3
CH4
CH5
CH6
CH7
REFCOMP
GND
RB5/CS
RC3/SCK
RC5/MOSI
RC4/MISO
T3
74HC14
2N3904
ADC_CHX
PROCESSOR
SPI BUS
10F
4.7k
ENX
RB0/EXCITATION
VN2222
CHX+
INPUT
CHX
74HC00
AN112 F08a
an112f
AN112-5
PIC16LF877A-I/PT
0.1F
0.1F
VDD
5V
LTC1799CS5
V+
0.1F
5k
OUT
GND
OSCIN
22.1
SET DIV
20MHz
SUPERVISOR
5V
0.1F
14k
102k
0.1F
2200pF
10k
10k
100pF
22.1
RST
MMBT3904
LTC1726EMS8-2.5
WT
GND
PGD/RB7
PGC/RB6
RB5
RB4
RB3
OSCOUT RB2
RB1
INT/RB0
RX/RC7
TX/RC6
MOSI/RC5
MISO/RC4
SCK/RC3
RC2
RC1
MCLR
RC0
WDI
WT
RE2
RE1
RE0
EN
5V
DIS
OPT
VDD
2N7002
PRE
Q
PRE
Q
VCC
D
CLR
RD7
RD6
RD5
RD4
RD3
RD2
RD1
RD0
VDD
RA5
RA4/ISO PWR SHDN
USB TXE#
USB WR CLK
USB RXF#
USB RD CLK#
1.5k
CLK
GND
CLR
VCC
RESET VIA USB
5V
RC7/RX
RC6/TX
RC5/MOSI
RC4/RISO
RC3/SCK
RC2
RC1
RC0
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
USB
COMMAND
49.9k
IN-CIRCUIT
PROGRAMMING
PORT
475
USB RXF#
RB7
RB6
RB5/CS
RB4
RB3
RB2
RB1/LATCH
RB0/EXCITATION
SPI BUS
INDICATORS
5V
5V
+
475
PROCESSOR
DATA BUS
5V
RC2
+
475
RC1
475
RC0
USB RD
CLK#
74HC74PW
74HC74PW
Q
VCC
VDD
RA5
RA4
RA3
RA2
RA1
RA0
AN112 F08b
CLK
GND
5V
0.1F
SYS
22.1 10MHz
10M
NC7SP17P5X
an112f
AN112-6
475
0.1F
5V
USB5V
0.1F
10F
6.3V
0.1F
USB5V
0.1F
PROCESSOR
DATA BUS
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
USB_RD_CLK#
USB_WR_CLK
USB_TXE#
USB_RXF#
RD#
WR
TXE#
RXF#
10k
22.1
XTIN
SW/WU
TEST
PWREN#
RST#
AGND GND GND
USB5V
LTC6905CS5-96
V+
47pF
USB-B
CONNECTOR
0.1F USB5V
3V3VOUT
XTOUT
0.1F
47pF
1.5k
10k
EEDATA
USB5V
10k
22.1k
EESK
48MHz
10k
1
2
3
4
22.1k
47pF
10k
VCC
DO
CS
VSS
CLK
2.21k
DI
93LC46BT-1/OT
EE
EN
DIS
AN112F08c
OUT
GND
SET
DIV
Firmware Description
The complete rmware code listing is in Appendix C. The
code for this circuit is designed to be a good starting point
for an actual product. Data is displayed to a PC via an
FTDI FT242B USB interface IC. The PC has FTDIs Virtual
Com Port drivers installed, allowing control through any
terminal program. Data for all channels is continuously
displayed to the terminal, and simple text commands
control program operation.
A timer interrupt is called 1000 times per second. It controls the pulse generators and ADC, and stores the ADC
readings to an array that can be read at any time. Thus if
the main program is reading the buffer, the most out-ofdate any reading will be is 1ms.
Automatic calibration routines are also included. Two
functions store a zero reading and a full-scale reading for
AN112-7
output_high (CS);
output_low (EXCITATION);
delay_us (delay);
output_high (EXCITATION);
output_high (LATCH);
output_low (LATCH);
output_low (CS);
AN112 F09
i = 7;
i = 6;
i = 5;
i = 4;
i = 3;
i = 2;
i = 1;
i = 0;
AN112 F10
digital designer would never dream of trading a good logic analyzer for
a mixed-signal oscilloscope to test signal integrity across a complicated
backplane. And its 100MHz analog channels pale in comparison to a good
four channel, half-gig scope. But for testing a circuit with a microcontroller
and data converters up to a few megasamples per second, a good mixed
signal oscilloscope is the master of the trade.
an112f
AN112-8
A
B
C
INH
X0
X1
X2
X3
X4
X5
X6
X7
10k
10k
74HC138
A
B
C
LTC1867_CH7
LTC1867
INPUTS
EXCITATION
G1
G2A
G2B
74HC14
2N3904
4.7k
10F
VN2222
Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7
10k
10k
74HC14
CH63
6 ADDITIONAL
CIRCUITS PER
BANK
2N3904
4.7k
LTC1867_CH0
CHANNEL
SELECTION
WITHIN BANK
74HC138N
BANK SELECTION
(FOLLOWS SELECTED
LTC1867 INPUT)
EXCITATION
A
B
C
G1
G2A
G2B
Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7
74HC4051
X
A
B
C
INH
10k
10k
A
B
C
EXCITATION
G1
G2A
G2B
CH56
60 ADDITIONAL CIRCUITS
X0
X1
X2
X3
X4
X5
X6
X7
74HC138
CH56+
10F
VN2222
6 ADDITIONAL
BANKS
CH63+
74HC14
2N3904
4.7k
10F
VN2222
Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7
10k
10k
74HC14
4.7k
VN2222
CH7+
CH7
6 ADDITIONAL
CIRCUITS PER
BANK
2N3904
CH0+1
10F
CH01
AN112 F11
an112f
AN112-9
an112f
AN112-10
N AMPLIFIERS
MULTIPLEXER
A/D
DECODE
DATA
OUTPUT
N CELLS,
GND REFERRED
AN112 FA01
N AMPLIFIERS
Figure A1. Unworkable Scheme Suppresses High Common Voltages by Converting Cell Potentials
to Current. Circuit Decodes Amplier Outputs to Derive Individual Cell Voltages. Required
Resistor Precision and Values are Unrealistic. Resistors Draw Current from Cells
an112f
AN112-11
N CELLS
ISOLATION
AMPLIFIER
ISOLATION BARRIER
POWER IN
FLOATING
POWER
SUPPLY
POWER COMMON
AMP
POWER DRIVER
FLOATING INPUT
BATTERY
STACK
OUTPUT
DEMODULATOR
FLOATING COMMON
MODULATOR
AN112 FA02
OUTPUT COMMON
ISOLATION AMPLIFIER
(DETAIL)
ISOLATION
AMPLIFIER
N CELLS
N ISOLATION
AMPLIFIERS
Figure A2. Isolation Ampliers Galvanically Floating Input Eliminates Common Mode Voltage Effects.
Approach Works, but is Complex and Expensive Requiring Isolation Amplier per Cell
an112f
AN112-12
N SWITCH-CAP
SECTIONS
N CELLS
OUT
OUTPUT
COMMON
BATTERY
STACK
OUT
SWITCH
DRIVE
LEVEL
SHIFT
OUTPUT
COMMON
OUT
AN112 FA03
OUTPUT
COMMON
N CELLS
N SWITCH-CAP
SECTIONS
ISOLATED
SUPPLY DRIVE
ISOLATION
BARRIER
N CELLS
N A/D SECTIONS
ISOLATED
SUPPLY
POWER
SUPPLY
TO OUTPUT
COMMON
REFERRED LOADS
DATA
ISOLATOR
A/D
DATA OUT
OUT COMMON
ISOLATED
SUPPLY
BATTERY
STACK
DATA
ISOLATOR
A/D
DATA OUT
OUT COMMON
ISOLATED
SUPPLY
A/D
DATA
ISOLATOR
DATA OUT
OUT COMMON
AN112 FA04
N CELLS
N A/D SECTIONS
ISOLATION
BARRIER
Figure A4. A/D per Cell Requires Isolated Supplies and Data Isolators. Multiplexed Input A/Ds
can Minimize A/D Usage. Isolated Supply Population is Reducible, but Cannot be Eliminated
an112f
AN112-13
2 9V
1 9V
+
+
18V
+
9V
75k*
50k
18V
IN
TRIM
LT1021 OUT
GND
10.000V
BAT85
18V
100k**
1k
A1 LT1012
OUTPUT
A2 LT1010
1F
150k
9V
1N4001
+
680F
AN112 FB01
Figure B1. Battery Simulator Has Floating Output Settable Within 1mV.
A1 Unloads Kelvin-Varley Divider; A2 Buffers Capacitive Load
an112f
AN112-14
A = 5V/DIV
0.5V/DIV
B = 50V/DIV
NOISE AVERAGED
20ms/DIV
AN112 FB02
2s/DIV
AN112 FB03
APPENDIX C
Microcontroller Code Listing
The microcontroller code consists of three les:
Battery_monitor.c contains the main program loop, including calibration and temperature correction, and support
functions.
an112f
AN112-15
// Initialize hardware
// Wait until any character is received
// display calibration constants before starting.
while(1)
{
if(usb_hit()) parse(); // get keyboard command if necessary
for(i=0; i<=7; ++i)
// Read raw data first
{
readflag[i] = 1;
// Tell interrupt that were reading!!
an112f
AN112-16
AN112-17
by 10
case v: delay -= 10; break;
//
by 10
case n: calculate = 1; break; // Calculate voltages
case m: calculate = 0; break; // Display raw values
case t:
// Echoes text to terminal so you can insert comments into
{
// data that is being captured. Terminate with !
busbusy = 1;
printf(tx_usb, enter comment\r\n);
while((ch=rx_usb())!=!) tx_usb(ch);
tx_usb(\r);
tx_usb(\n);
busbusy = 0;
} break;
case k: filter = 0; break;
// Disable filter
case l: filter = 1; break;
// Enable Filter
case o: write_offset_cal(); break;
// Store offset to nonvolatile mem.
case p: write_fs_cal(); break;
// Store FS to nonvolatile mem.
}
setup_timer_2(T2_DIV_BY_16,period,8);
// Update period if necessary
}
/*******************************************************************************
write offset and full-scale calibration constants to non-volatile memory
arguments: none
returns: void
*******************************************************************************/
void write_offset_cal(void)
{
int i;
unsigned int16 intvoltage;
for(i=0; i<=7; ++i)
{
intvoltage = (unsigned int16) voltage[i];
// Cast as unsigned int16
write_eeprom (init_offset_base+(2*i), intvoltage >> 8); // Write high byte
delay_ms(20);
write_eeprom (init_offset_base+(2*i)+1, intvoltage); // Write low byte
delay_ms(20);
}
}
void write_fs_cal(void)
{
int i;
unsigned int16 intvoltage;
for(i=0; i<=7; ++i)
{
an112f
AN112-18
AN112-19
an112f
AN112-20
/*******************************************************************************
Timer 2 Interrupt
This interrupt service routine does all of the work of controlling transformer
excitation and controlling the LTC1867.
*******************************************************************************/
#int_TIMER2
// Tell compiler that this is the Timer 2 ISR
TIMER2_isr()
{
static int8 ledstatus;
int8 j, highbyte, lowbyte;
if(++ledstatus == 0x80) output_low(LED);
// Blink light every 256 calls
if(ledstatus == 0x00) output_high(LED);
an112f
AN112-21
an112f
AN112-22
PIN_B0
PIN_B1
PIN_C1
#define
#define
#define
#define
#define
#define
#define
PIN_A0
PIN_A1
PIN_A2
PIN_A3
PIN_A4
PIN_A5
PIN_B5
RD_
RXF_
WR
TXE_
ISO_PWR_SD_
LCD_EN
CS
#define AUX_MAIN_
#define I2C_SPI_
#byte SSPCON
#byte SSPSTAT
#bit CKP
#bit CKE
PIN_E1
PIN_E2
= 0x14
= 0x94
= SSPCON.4
= SSPSTAT.6
// Function Prototypes
void parse(void);
void write_offset_cal(void);
void write_fs_cal(void);
unsigned int16 read_offset_cal(int channel);
unsigned int16 read_fs_cal(int channel);
void print_cal_constants(void);
char usb_hit(void);
void initialize(void);
void tx_usb(int8 value);
char rx_usb(void);
an112f
AN112-23
an112f
AN112-24
www.linear.com