Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

DC Electronic Load

Application Note
DC Electronic Load Applications and Examples
Application Note

V 3032009

22820 Savi Ranch Parkway Yorba Linda CA, 92887-4610 www.bkprecision.com


Table of Contents

INTRODUCTION.........................................................................................................................3
Overview of software examples........................................................................................................3
POWER SUPPLY TESTING.......................................................................................................4
Load Transient Response................................................................................................................. 4
Load Regulation................................................................................................................................ 5
Current Limiting................................................................................................................................ 6
BATTERY TESTING...................................................................................................................7
Battery Discharge Curves................................................................................................................. 7
Battery Internal Resistances............................................................................................................. 8
PERFORMANCE TESTING OF DC LOADS...........................................................................10
Slew Rate....................................................................................................................................... 10
OTHER DC LOAD APPLICATIONS.........................................................................................11
Voltmeter........................................................................................................................................ 12
Fuse............................................................................................................................................... 12
SOFTWARE EXAMPLES.........................................................................................................12
Battery Discharge Test.................................................................................................................... 13
Voltmeter Reading.......................................................................................................................... 15
Fuse Application............................................................................................................................. 15
Reference.................................................................................................................................16
later sections utilize B&K
INTRODUCTION Precision's DC load model
Unfortunately, the software
8500 as part of the different
files are supported only for
setups and test configurations.
Windows platforms. However,
Most applications can be
due to the excellent cross-
simulated in the same fashion
platform capabilities of
As technology is constantly with other brands of DC loads,
python, some users may be
advancing, demands for with the exception of all the
able to get the library (which
quality test instruments software examples. They are
does not have to be utilized
increase due to the need for written specifically for full
via COM) working on other
making better and accurate compatibility with B&K
platforms. Please see the
measurements to Precision's 8500 series DC
library's documentation for
accommodate newer loads and are not intended to
more details.
technologies. For most support other brands of DC
electronic applications today, loads. In general, any
using energy efficient and measurements made with B&K
Although the software and
reliable power sources is Precision's equipments are
examples are written in
critical. For this reason, it is typical, but not guaranteed.
python, users who have other
important to have a test particular preferences in terms
instrument that can accurately Overview of software of the programming language
portray results that define the to use can easily use the COM
examples
performance of the power library provided in the
sources used to provide software package to write
electricity for devices such as Throughout some of the similar examples in the
electrical vehicles, computer sections in this application language of their choice.
power supplies, 3G cellular note, software examples are Some languages that have
phones, and even consumer provided to enhance and been found to work well with
standard household batteries. simplify test methods as well the COM library are Visual
Programmable DC Electronic as to bolster features of B&K Basic and Visual C#. Other
loads are one such instrument Precision's 8500 series DC languages are also expected
that will aid in testing various loads that can be controlled to work with the library, given
settings, configurations, remotely with a PC computer the correct declarations and
schemes, and methodologies. via RS-232 interface. Unless modifications within the
The intention of this otherwise noted, all examples program.
application note is to provide a are written in python
general scope of a DC load's programming language. They
usage. Some standard also require two python
performance tests for testing libraries and the 8500 DC load
power supplies will be COM library installed on the PC
described in details. used for communication in
Furthermore, several methods order to operate correctly. To
for testing the DC load itself obtain all these as well as
will be included in the later instructional documentation
sections. Additional details on for installation and setup,
practical DC load applications please visit one of our DC load
and setup information are product pages at:
provided as a source to assist http://www.bkprecision.com/p
in performing various test roducts/dc-electronic-
setups and measuring data. loads/8500-300-w-
As a note, all software programmable-dc-electronic-
examples contained in the load.html.

3 of 16
POWER SUPPLY
TESTING

For design testing and


verification, the need for
regulated power supplies are
increasing with ongoing
advancement in technology.
More so, it has become a
necessity in newer electronic
devices to be tested with
precise and sophisticated
power supplies. There are
some specifications that
determine some underlying
performance factors in typical
power supplies. Particularly, Figure 2. Transient Response for B&K Precision 9130
the load transient response,
load regulation, and current
limit. In the following results may vary and may not the load current. In order to
sections, each of these factors reflect exactly what is shown verify the response,
are addressed as an example in the following sections. measurements of the rise and
to describe and demonstrate fall times upon a step change
the setup, configuration, and in the load is necessary.
Load Transient Generally, this type of test
equipment required for testing
and verification. Each
Response requires a load that is able to
example will utilize a DC load produce a rise and fall time
as part of the setup. An important element to approximately five times
power supply testing is a faster than the power supply.
Disclaimer: The following measurable unit of load The following application
sections include general transient response, which demonstrates an effective
setups with some settings characterizes the capability of approach to testing the load
specified for the test the power supply to stabilize transient response of a power
environment. Some details itself upon a step change in supply.
are ignored, and therefore

Power Supply DC Load


Mode: Transient
Settings: 5 V
Trigger: Pulse 0.1 A to 3.0 A Digital Oscilloscope
Limit: 3.1 A Trigger: negative slope
+ - + -

Figure 1. Load Transient Response Test Setup

4 of 16
Objective with a step change from 1.5 A Approach
to 3 A. The output voltage
Characterize the time it takes dropped by approximately 1.6 Use a DC voltmeter to
for a power supply to stabilize mV. measure the voltage change
its output voltage after a step when the DC load is used to
change in the load. step the power supply from 0
current to rated current.
Approach Load Regulation
Setup
Connect a DC load to a power
supply. Use the DC load's Load regulation is another The measurement is
transient mode to apply a step important element when conceptually simple, but it is
change in load to the power testing a power supply. It is a critical that the voltmeter
supply. performance measurement used to measure the voltage
that requires setting the power change is connected to the
supply to its rated voltage. To output terminals of the power
Setup be specific, the test for supply independently of the
measuring this element is leads used to connect to the
A power supply was set to 5 V
based on measuring the DC load. Failure to do this will
output with the current limit
output voltage levels of the measure the contact
set to 3 A. A digital
supply when a load connected resistance of the power leads,
oscilloscope was used to view
to it changes from zero overestimating the load
the power supply's output
current to rated current, which regulation and output
voltage. The scope was AC
differs depending on the resistance of the power
coupled and set to trigger on a
model used under testing. supply. Connect the voltmeter
negative slope.
The purpose for this test is to and DC load in parallel to the
ensure the accuracy and power supply's terminals (See
DC Load Setup capability for a power supply Figure 3 for setup diagram).
to maintain its voltage output
The DC load was set to level under rated load current
transient mode from 1.5 A to changes. Before testing, DC Load Setup
3 A. Pulse triggering mode verify that the load used for
was selected for the DC load, Press the I-set button (for B&K
the test supports the
which means a trigger signal Precision DC loads) to change
maximum rated current and
causes the load to go from 1.5 the DC load to constant
voltage of the power supply.
A to 3 A, then back to 1.5 A. current mode (you may have
to press the button twice).
Objective Set the current to the rated
Results current of the power supply.
Measure the change in output
Looking at Figure 2, the load voltage from no current load
transient response is observed to the rated current load of
during the rise time in the load the power supply.

DC Load Power Supply


Mode: CC mode
Settings: Rated output V Voltmeter
Current: Rated current of
power supply Current: Max. limit

+ - + - + -

Figure 3. Load Regulation Test Setup

5 of 16
Procedure measuring 30 V with 100 μV characteristics look like Figure
resolution is required to have 4, with small or very minimal
1. Turn on the power supply two significant figures in the bending near the crossover
and set it to its rated load regulation number. This point. It is good practice to
output voltage. Ensure measurement would require a test the current limits of a
that the current adjust 6 digit voltmeter. power supply because it will
knob, if present, is set to aid in protecting the
its maximum value. equipment for its application.
2. Write down the measured
Current Limiting Without a certain degree of
voltage of the power current regulation, the supply
supply. Call this value V0. Power supplies in constant may even over power or
voltage mode generally have a damage certain devices. The
3. Press I-set on the DC load preset limit to the maximum following describes a test
to set to power supply's current output. Current limit setup for testing current limit
rated value. Turn on the testing consists of of a power supply.
input of the load by measurements that define the
pressing On/Off. behavior of a power supply
and its current regulation. Objective
4. Write down the measured
voltage of the power These measurements can be Determine the current limit of
supply. Call this value V. characterized by a voltage vs. a power supply under test.
current curve, which portrays
5. Turn off the DC load's input how and when the power
by pressing the On-Off supply enters from CV to CC Approach
button. mode. Ideally, precise current Use a power supply, DC load,
6. Turn off the power supply. regulation reflects a voltage and a computer to analyze
vs. current curve similar to voltage versus current
Calculate the load regulation Figure 4.
(in percent) of the power characteristics.
supply by
For CV/CC mode power Setup
supplies, typical current limit
V0 −V Connect the power supply in
100 (1)
V0

You can also calculate the


output resistance of the power
V 0 −V 
supply as where i
i
is the current drawn in this
test.

High quality power supplies


have low output resistances in
the order of 1 mΩ or less.
This means measuring V0 and
V with enough digits is
necessary to avoid loss of
significance in the subtraction.
As an example, for a 30 V
supply rated at 3 A with an Figure 4. Voltage vs. Current Curve
output resistance of 1 mΩ,

6 of 16
parallel to the DC load. Set these sources, it is useful to
the power supply to its rated have a programmable test
It follows that the
voltage and set a preset value instrument that can verify
measurements demonstrate a
for current. The DC load precise details of the sources'
voltage vs. current curve
should display the rated behavior. This is often where
similar to Figure 4. Drawing
voltage if power supply's a DC load comes in handy
from the data, the voltage
output is on. Incrementally because of its programmable
drops immediately upon
increase the current drawn flexibility as well as its
reaching the crossover point,
from the load and observe the capability to run discharge
which is at 2.99467 A in this
behavior of the voltage in the tests on power sources like
case. The power supply
power supply. When the changes to CC mode after this
batteries. This section will
current on the load gets close provide a basic overview that
point, and voltage remains at
to the power supply preset demonstrates an efficient way
0.1569 V, with current limited
current limit, observe before, to perform battery discharge
to 2.99999 A. This behavior is
during, and after the crossover and internal resistance testing.
normal and expected for a
point, where the power supply CV/CC power supply. There
switches from CV to CC mode. are other types of power Battery Discharge
supplies with different current Curves
DC Load Setup limit designs such as foldback
current and CV power supplies
Set the DC load to CC mode (without CC mode). The When designing and testing a
by pressing I-set (for B&K voltage versus current curve battery for powering a device,
Precision DC loads). You may will greatly differ from that of a great deal of attention
have to press twice. Turn on CV/CC power supplies, so it is reflects on energy efficiency
DC load's input. advised to test their current and lifetime. For this reason,
limit characteristics before a standard performance test
utilizing them in devices or consists of analyzing discharge
Results curves that characterize the
applications.
A DC power supply rated at 32 behavior of the battery. By
V and 3 A was tested with a observing these curves, the
DC load. The voltage from BATTERY TESTING battery life can be measured,
before to after the current and its efficiency can be
crossover point was observed. computed. Some DC loads
Table 1 shows the data of provide this feature to allow
some measurements to battery discharge
demonstrate the power supply measurement, in which the
behavior before and after the The forms and standards for total charge is provided in Ah
crossover point. storing, renewing, and using (ampere*hour) to a specified
energy are evolving. New voltage. B&K Precision's 8500
methods for providing power and 8600 DC load Series
for electronic products have provide this useful built-in
Power supply function for quick setup and
been discovered and are far
measurements testing. Battery discharge can
more complex than they were
(readings from power supply) also be tested with the
several decades ago. With
Voltage Current Mode increasing need in our society provided program under the
32.0001 V 0.00024 A CV for clean and efficient energy, “Software Examples” section
engineers have now turned of this note. Additionally,
31.9999 V 2.65178 A CV
their focus to develop small changes to the program
31.9999 V 2.99467 A CV will offer even greater control
applications that utilize, for
0.1569 V 2.99999 A CC example, fuel cells, for the test, allowing
supercapacitors, and measurements to be made
Table 1: Measured Data from B&K
Precision 9120A. photovoltaic energy. Due to under different modes and
the complexity in the design of settings. The following

7 of 16
describes the discharge test Test”.
setup for a consumer “AA” size
battery. Similar setups can
also be used for other types of Battery Internal
batteries. Resistances DC Load

The DC load is an effective


+ -
Setup
tool for measuring the internal
Connect the battery to the DC resistance of a battery. The
load. You can either solder battery is typically modeled as
wires to the battery or use a the dashed area in the circuit
battery holder. illustrated in Figure 8. The
voltage source Vo is considered + AA size battery -
ideal and is the open circuit
DC Load Setup voltage of the battery. The
The setup is controlled by the internal resistance Ri is used Figure 5. Battery Discharge Test
program, but be sure to to idealize the internal losses Setup
manually set the voltage and in the battery when current is
current range prior to running flowing. If the battery's temperature increases.
the test program. If the electrochemistry is regarded
current is reasonably large, as a network of voltage
you might also want to sources and resistances, then If VL is the voltage across the
suggest they use the remote Vo and Ri comprise the load, we have
voltage sensing feature of the Thevenin equivalent circuit.
For alkaline batteries, the V L =Vo iR i (2)
DC load.
internal resistance goes up as Thus,
the battery's chemical energy
Results is used up. The internal ∣V L−Vo∣
R i= (3)
Provided as an example is a resistance drops as the i
plot (see Figure 6) of the
battery discharge curve for the
AA Alkaline battery tested with
the setup in Figure 5. The
command line used to run the
program for the data is shown
in Figure 7. The settings of
the command are indicated in
order as set to com port 5 in
constant current mode with
0.5 A and a cut off voltage of
0.5 V. The file name for the
data file is aa_test and “78deg
F” is a string included at the
end of each line of the file.
Note: For more details on the
program commands and to
run the test, find the
instructions and use the
python script provided
towards the end of this
application note categorized
under “Battery Discharge
Figure 6. AA Alkaline Battery Discharge Curve

8 of 16
This gives us a way to python battery.py 5 cc 0.5 0.5 aa_test 78deg F
evaluate the internal
resistance using the DC load, Figure 7. Command Used to Run Program
either manually or by a
program.
Connect two wires as close to 3. Set load to CC mode at
For smaller batteries, a the battery terminals as 0.005 A.
programming approach is an possible and run these to the
4. Setup transient mode
advantage. Measurements remote sense terminals on the
with current levels from
can be made quickly, causing DC load (be sure to observe
0 A for 0.5 ms to 0.505
less drain on the battery. the proper polarity). Turn on
A for 2000 ms in pulse
Using an oscilloscope, a load with the configurations
mode.
millisecond-wide current pulse under “DC Load Setup” below.
can be used to make a useful Make sure the battery voltage
internal resistance has stabilized and write this Results
measurement. The approach down as the starting voltage
for measuring a “D” size V0. Then trigger the transient Using the test setup in Figure
battery's internal resistance is current levels and immediately 9, the stabilization voltage
observed in the following. watch the displayed voltage. (V0) for the measured battery
Note that this is only one of Within two seconds, make is 1.496 V. With 0.505 A load,
the practical ways for note of the lowest voltage the voltage (V) is 1.415 V.
measuring internal resistance. displayed and label this as V. Using equation (4) gives an
There are other methods not Use equation (4) to calculate internal resistance of 0.16 Ω.
mentioned here. the internal resistance. A
setup diagram is provided in
Figure 9 for the purpose of Batteries are complex
Approach nonlinear electrochemical
illustration.
devices. The two common
Measure the battery's voltage
electrical measurements of
at two different current loads.
DC Load Setup batteries used to gauge their
The remote sense capability of
state are the DC internal
the DC load will be used to 1. Turn on DC Load's
resistance and the AC internal
avoid errors due to wire remote sense feature.
impedance. In the "old" days,
resistances. The test method
2. Set trigger to AC characteristics of a battery
follows the recommendation of
immediate. were not terribly important for
[1] by applying a stabilization
current of 5 mA, measuring
the battery's voltage V0,
applying a current of 505 mA,
and measuring the voltage V.
The internal resistance is
measured as:
V o−V
Ri= (4)
0.5

Setup
Connect the battery to the DC
load. Use a battery holder or
solder wires to the battery if
necessary. If soldering wires,
do not overheat the battery
due to risk of rupture.
Figure 8. Circuit Model of Battery and Internal Resistance

9 of 16
DC operation. However,
modern digital electronic
PERFORMANCE 10% and 90% region, the
slew rate can be measured by
devices can draw sharp TESTING OF DC observing the steepest slope
current spikes from their portion. The indicated
power source (e.g., switching LOADS measured time would be used
a cell phone to transmit). In a to calculate the slew rate.
1 kW car audio system, Hence, the slew rate
currents can exceed 100 A and calculation is simply (rated
the AC behavior of batteries, max. current – 0 A) / T, where
stiffening capacitors, and stray T is the measured time from
inductances can all play a role. Just as it is important to have 10% to 90% region and rated
DC loads can be useful in a good power supply that will max. current is the specified
helping investigate the perform accurate maximum current of each
dynamic behavior of these measurements under various load. The following will
systems. test conditions, it is essential demonstrate how to test the
to have a DC load that is slew rate of a DC Load.
robust and perform under
The simple model of a battery required specifications and
as an ideal voltage source in test setups. Some of the most
series with a resistance common tests used for Approach
captures the first order verifying features of a DC load
behavior (see Figure 8). More include trigger delay, switching Set the DC load to transient
complex models have also time, and slew rate. mode and allow it to draw
been used. Using DC loads, current from 0 to maximum
Disclaimer: The following
batteries can be characterized rated current. Observe
sections include general
in a manner which will mirror current transition changes and
setups with some settings
their application and construct timing on an oscilloscope.
specified for the test
a model appropriate for the environment. Some details
design. are ignored, and therefore Setup
results may vary and may not
reflect exactly what is shown Three 50 A high current power
in the following sections. supplies are connected in
parallel. This can produce
enough current for a 120 A-
Slew Rate rated load to draw at its
maximum range. A handful of
Remote sense
The slew rate of a DC load is a shunt resistors rated at 5 W
performance measurement 0.22 ΩJ are connected in
+ -
that determines how quickly a parallel and are connected to a
DC Load DC load can draw current BNC-to-binding post adapter.
Setting: Immediate Trigger
within different ranges of A larger shunt can also be
Mode: CC at 0.005A
Transient: Pulse 0 to 0.505A current transition. In general, used to simplify the same
the slew rate for low current setup and reduce the
+ - temperature from heat
transitions, say 0 to 0.5 A, is
significantly lower than slew dissipation. Since high current
rate for current transitions will be drawn, it is important
from 30 to 70 A. Generally, to note here that heavy gauge
the appropriate way to test wires should be used to
+ D size battery - slew rate is to observe a connect the power supplies to
portion of the timing during each other and to the load.
maximum current transition. Connect the power supply to
Figure 9. Test Setup For Battery
Internal Resistance The graph in Figure 10 the DC load and shunt
illustrates this. Between the resistors as illustrated in

10 of 16
2. Adjust trigger level
until waveform trace is
captured.
3. Adjust vertical and
horizontal scale and the
trigger level and run
once again.
4. Repeat steps 2 and 3
until a good sampled
trace is captured.

Results
Observe the trace on the
oscilloscope and compare it to
Figure 10. Use the scope's
cursors to approximate the
10% and 90 % mark.
Observe the steepest slope in
between the cursor lines. A
rough estimate can be made
by taking the difference of the
two cursor lines. Since this
setup tests a current transition
Figure 10. Slew Rate Measurement Graph from 0 A to 120 A, slew rate
Figure 11. Connect the BNC mode. can be calculated by dividing
to binding post adapter into an the change in current over the
2. Set load to CC mode change in time; that is the
oscilloscope. Follow the setup
below for the DC load and 3. Turn on input for a difference of the cursors.
oscilloscope. short moment. Turn off
once oscilloscope setup
is complete. OTHER DC LOAD
DC Load Setup
APPLICATIONS
1. Setup transient mode Oscilloscope Setup
with current levels from
0 A for 0.5 ms to 120 A 1. Set to single run.
for 1000 ms in pulse

DC loads can be very


Power supply Oscilloscope resourceful for various tests
+ - Mode: Single Trigger and applications. Sometimes,
they may even act as a
different type of test
Power supply
instrument for measurement.
+ - A good example would be a
DC Load voltmeter. Other practical
Mode: CC
Power supply Shunt Transient: 0 A to 120 A applications that will be
+ - Resistance
+ - mentioned in this section is a
fuse. DC loads can also act as
a fuse in a circuit for
Figure 11. Slew Rate Test Setup monitoring current thresholds

11 of 16
to help prevent possible program codes to run this B&K Precision's website at:
damage from overcurrent or application can be found in the http://www.bkprecision.com/p
overpower. “Software Examples” section roducts/dc-electronic-
under “Fuse Application”. loads/8500-300-w-
Details of usage and operation programmable-dc-electronic-
are provided in the same load.html for successful
Voltmeter section. installation of the python
libraries. This must be set up
In any design or test correctly prior to using any of
Setup
environment, a voltmeter is the source codes provided in
required in one way or another Connect load in series with a this note. Be sure to also read
for measurements. It is one circuit. Be sure that remote the instructions under each
of the most useful test tool sense is off. Run the program software example for correct
today. For this reason, it is to monitor current. Threshold usage.
often convenient to have a DC value is set in the program.
load that can read voltages
when a voltmeter is not
around. For simplicity, a test Note: The DC load does not
program script has been behave like a pure resistance.
provided under “Software For this fuse application, it
Examples” at the end of the may be hard to test low
note under section labeled currents in the few mA range.
“Voltmeter Reading” to For example, on B&K
perform simple voltage Precision's 8500 load, there is
measurements and reading a turn-on threshold voltage of
rates of B&K Precision's 8500 around 0.1 volts before the
DC load. This load can load starts conducting current
measure with a millivolt and, thus, it may jump past a
resolution before indicating an low current setting. Thus,
overrange. Refer to the please test this fuse
section for detailed application carefully before
information on setting up and using it to protect valuable
running the software circuitry.
application.

Fuse
SOFTWARE
The application described in EXAMPLES
this section is to demonstrate
how to use a DC load as a fuse
in a circuit. Under program
control, the load can shut off
when either current, voltage,
or power measured exceeds a The following sections include
set value in the load. This is a the source codes for all
basic application for a fuse, software based applications
and due to some delays from and examples previously
the software control, it is not mentioned. If not done
recommended for use if fast already, please read the
responses are required. The documentation provided from

12 of 16
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 Port # Mode: Decimal value Cut off voltage Filename of Any string to
name for constant recorded data attach at end of
mode each line
python Name of the COM port # cc: constant Any value set Decimal value Files are saved Any strings of
python program used to connect current for the of cut off in same folder text can be
to PC cv: constant respective voltage to end as the python added for
voltage mode. (i.e. 0.5 program program file reference
cp: constant in cc mode is with .dat
power 0.5 A, 2 in cv extension
cr: constant mode is 2 V)
resistance

Table 2. Instructions on Command for Battery Discharge Test Script

battery.py
Data file: msg = '''Usage: %(name)s port mode value cov filename [docstring]
Header info: Test a battery with a DC load until the specified cut-off voltage is reached.
# Command line Arguments are:
# Date and time for start of test port
Entry info: COM port that the load is at.
time voltage current power mode
cc for constant current
time is in seconds since start of test cv for constant voltage
Other measurements are in V, A, and W cp for constant power
cr for constant resistance
We talk to a DC load using COM. value
''' Decimal value of desired constant mode value.
cov
import sys, dcload Cut-off voltage in volts.
from win32com.client import Dispatch filename
from string import join Data will be stored in filename.dat.
from time import time, sleep docstring
from msvcrt import kbhit, getch Any further text is just logged to the data file.
out = sys.stdout.write ''' % locals()
nl = "\n" print msg
interval_s = 1 # Interval between readings exit(1)

def Usage(): def ProcessCommandLine():


name = sys.argv[0] if len(sys.argv) < 6:

13 of 16
Usage() log("# Command line: %s\n" % join(sys.argv[1:]))
port = int(sys.argv[1]) 'log("# %s\n" % version)'
mode = sys.argv[2] msg = "# Test start time = " + load.TimeNow() + nl
value = float(sys.argv[3]) LogMsg(msg)
cov = float(sys.argv[4]) Set("Turn load on", load.TurnLoadOn())
filename = sys.argv[5] + ".dat" voltage, current, power = GetCurrentVoltagePower(load)
docstring = "" start_time = time()
if len(sys.argv) > 6: while voltage >= cov:
docstring = join(sys.argv[6:]) voltage, current, power = GetCurrentVoltagePower(load)
# Check values current_time = time() - start_time
assert(port >= 0) LogMsg("%9.2f %9.4f %8.4f %9.4f\n" % \
assert(mode in ("cc", "cv", "cp", "cr")) (current_time, voltage, current, power))
assert(value > 0) sleep(interval_s)
assert(cov > 0) if kbhit():
from os.path import exists c = getch()
assert(not exists(filename)) if c == "Q":
out("Mode = %s\n" % mode) break
out("Value = %s\n" % value) Set("Turn load off", load.TurnLoadOff())
out("cov = %s\n" % cov) LogMsg("# Test finish time = " + load.TimeNow() + nl)
out("filename = %s\n" % filename) load.SetLocalControl()
return port, mode, value, cov, filename, docstring
def main():
def Set(task, error_message): port, mode, value, cov, filename, docstring = ProcessCommandLine()
if error_message: load = Dispatch('BKServers.DCLoad85xx')
out("Error on task '%s':\n" % task) baudrate = 38400
out(error_message) load.Initialize(port, baudrate) # Open a serial connection
exit(1) log = open(filename, "w").write
RunTest(log, load, mode, value, cov)
def SetModeAndValue(load, mode, value):
# Set mode and value. Also check that the maximum setting is at main()
# least the value we want.
Set("Set to mode %s" % mode, load.SetMode(mode))
if mode == "cc":
max_current = float(load.GetMaxCurrent())
if max_current < value:
out("Max current setting is less than desired value" + nl)
exit(1)
Set("Set to value %g" % value, load.SetCCCurrent(value))
elif mode == "cv":
max_voltage = float(load.GetMaxVoltage())
if max_voltage < value:
out("Max voltage setting is less than desired value" + nl)
exit(1)
Set("Set to value %g" % value, load.SetCVVoltage(value))
elif mode == "cp":
max_power = float(load.GetMaxPower())
if max_power < value:
out("Max power setting is less than desired value" + nl)
exit(1)
Set("Set to value %g" % value, load.SetCWPower(value))
else:
Set("Set to value %g" % value, load.SetCRResistance(value))

def GetCurrentVoltagePower(load):
def get_value(f):
value, unit = f.split()
return float(value)
s = load.GetInputValues()
fields = s.split("\t")
voltage = get_value(fields[0])
current = get_value(fields[1])
power = get_value(fields[2])
return voltage, current, power

def RunTest(log, load, mode, value, cov):


def LogMsg(msg):
out(msg)
log(msg)
load.SetRemoteControl()
SetModeAndValue(load, mode, value)

14 of 16
Voltmeter Reading

In this section, the codes provided below are used for the “voltmeter” application using the DC
load. It provides a convenient and remote way to collect voltage readings into a data file to serve
its purpose.

Instructions
Two settings must be configured correctly to run the script. They are port and baudrate. In the
code of voltmeter.py, they are declared at the beginning as “port = 5” and “baudrate = 38400” by
default. Please change the values to match the port and baudrate settings used to interface on
the PC. Note: The DC load must have the same baudrate configurations as in the code, and port
number has to match the COM port on the PC used to connect to DC load.

voltmeter.py
import sys, dcload
from time import time
from win32com.client import Dispatch
from msvcrt import kbhit

port = 5
baudrate = 38400

load = Dispatch('BKServers.DCLoad85xx')
load.Initialize(port, baudrate) # Open a serial connection
load.SetRemoteControl()
of = open("fast.dat", "w")
start = time()
count = 1
while True:
msg = "%6d %8.2f s %s\n" % (count, time() - start, load.GetInputValues())
of.write(msg)
if kbhit():
break
count += 1
finish = time() - start
load.SetLocalControl()
of.write("\nReading rate = %.1f readings/second\n" % (count/finish))
print "\nReading rate = %.1f readings/second\n" % (count/finish)

Fuse Application

A practical feature in most DC loads is the overpower, overcurrent, and overvoltage protection.
With this, a DC load can behave like a fuse in a circuit, monitoring current, voltage, or power from
exceeding design specifications of the circuit. An excellent way to demonstrate this application is
to use a program. Provided in the following is an example python script for monitoring current
using B&K Precision's 8500 DC load.

Instructions
Two settings must be configured correctly to run the script. They are port and baudrate. In the
code of voltmeter.py, they are declared at the beginning as “port = 5” and “baudrate = 38400” by

15 of 16
default. Please change the values to match the port and baudrate settings used to interface on
the PC.
Here's an example to run the command:
python fuse.py 5
The value “5” represents the fuse value to set. In this example, it is 5 A. With slight
modifications to the script, the program can also monitor voltage and power.

fuse.py
import sys, dcload
from time import time
from win32com.client import Dispatch
from msvcrt import kbhit

port = 5
baudrate = 38400

def ReadCurrent(load):
fields = load.GetInputValues().split("\t") # Split on tab characters
current = float(fields[0].split()[0]) # Remove the "A"
return current

def main():
# Check the command line
if len(sys.argv) != 2:
print "Usage: %s fuse_value_in_A" % sys.argv[0]
exit(1)
# Get the desired fuse value from the command line
fuse_value_A = float(sys.argv[1])
assert(fuse_value_A) > 0
# Establish a load connection
load = Dispatch('BKServers.DCLoad85xx')
load.Initialize(port, baudrate) # Open a serial connection
load.SetRemoteControl()
load.SetMode("cc") # Set to constant current mode
load.SetCCCurrent(fuse_value_A) # We won't exceed this value
load.TurnLoadOn()
current = ReadCurrent(load)
while current < fuse_value_A:
if kbhit(): break
current = ReadCurrent(load)
load.TurnLoadOff()
load.SetLocalControl()

main()

Reference

[1] http://data.energizer.com/PDFs/BatteryIR.pdf A technical bulletin on internal resistance.

16 of 16

You might also like