Specifications

Battery Discharge Test
The objective of this program is to characterize the discharge curves of common household
batteries. It can be used to monitor and log data when a battery is discharged by one of B&K
Precision's 8500 series DC loads.
Instructions
There are two settings that can be modified in the code to cater particular test settings. These
two settings are the interval between each reading, defined as “interval_s” in beginning of the
program, and baudrate, defined as “baudrate” at the end of main(). By default, interval_s = 1
and baudrate = 38400.
To run the command, lets use the example given previously.
python battery.py 5 cc 0.5 0.5 aa_test 78deg F
The above command is in a specific order, which is read as port 5, CC mode, 0.5 A in CC mode,
0.5 V cut off voltage, filename to save data as “aa_test.dat”, and extra strings added at the end of
each record is “78deg F”. Refer to Table 2 below for detailed instructions.
Note: The program will NOT overwrite any existing data files.
Run command Python file
name
Port # Mode: Decimal value
for constant
mode
Cut off voltage Filename of
recorded data
Any string to
attach at end of
each line
python Name of the
python program
COM port #
used to connect
to PC
cc: constant
current
cv: constant
voltage
cp: constant
power
cr: constant
resistance
Any value set
for the
respective
mode. (i.e. 0.5
in cc mode is
0.5 A, 2 in cv
mode is 2 V)
Decimal value
of cut off
voltage to end
program
Files are saved
in same folder
as the python
program file
with .dat
extension
Any strings of
text can be
added for
reference
Table 2. Instructions on Command for Battery Discharge Test Script
battery.py
Data file:
Header info:
# Command line
# Date and time for start of test
Entry info:
time voltage current power
time is in seconds since start of test
Other measurements are in V, A, and W
We talk to a DC load using COM.
'''
import sys, dcload
from win32com.client import Dispatch
from string import join
from time import time, sleep
from msvcrt import kbhit, getch
out = sys.stdout.write
nl = "\n"
interval_s = 1 # Interval between readings
def Usage():
name = sys.argv[0]
msg = '''Usage: %(name)s port mode value cov filename [docstring]
Test a battery with a DC load until the specified cut-off voltage is reached.
Arguments are:
port
COM port that the load is at.
mode
cc for constant current
cv for constant voltage
cp for constant power
cr for constant resistance
value
Decimal value of desired constant mode value.
cov
Cut-off voltage in volts.
filename
Data will be stored in filename.dat.
docstring
Any further text is just logged to the data file.
''' % locals()
print msg
exit(1)
def ProcessCommandLine():
if len(sys.argv) < 6:
13 of 17