Control Program for BK Precision 8500 DC Electronic Load

This post will be somewhat different to others, but I consider it interesting enough and useful enough to share on the blog. Over the past years I have used MATLAB quite a lot for communicating with instrumentation/test boards I’ve designed. Due to a number of reasons I’ve recently decided that gradually transitioning to use of Python instead is a good idea. My needs are typically quite basic, some communication with external instrumentation/test boards, data recording, data analysis, and finally generating some nice looking figures to summarize the results. Since the best way to learn is do, I’ve decided writing a control software for a DC electronic load I own would be a nice first project. The code is finally complete, so I’ve decided to share it with others so that anyone who owns an instrument from this series could use it.

The BK Precision 8500 series of instruments (not to be confused with the newer 8500B series), was reasonably popular on the forums, as did a few Chinese brands that seemed to offer similar instruments. I own the 8500 model from the 8500 series (120V/30A/300W instrument), and its an excellent tool to have on hand when working on power supplies or measuring battery capacity. One drawback with the 8500, as I see it for my needs, is that the remote controls capabilities are somewhat limited. For starters, it has its own control language over serial (no USB/LAN) which must use an externally isolated adapter, and lacks SCPI support (which has been corrected in the later 8500B series).  Second, the remote control interface is slightly limited and seems to be missing a few commands which can only be accomplished via the instrument front panel. This includes reading the AH value in battery mode, range switching, and setting VOLTAGE ON/OFF SET parameters of the instrument. There might be others, but these are the limitations I came across while communicating with the device via serial. There are some workaround to practically all of them as will be explained below.

I have attached the source files as well as a windows executable at the bottom of this post. Feel free to download and use/modify them as you wish. Feel free to contact me if you have any additions to the code that will increase functionality or otherwise improve usability.
Since coding isn’t my daily job, this code is probably not on par with what a proper programmer would have come up with. The fact this is my first go at Python probably makes that even more so. However, as someone once told me: “engineers treat code as a tool, if it gets the job done, its good enough”.

Control Program (BK8500 Instrument Controller) GUI:
The GUI is split into 3 main sections:
1 – Instrument Monitor
2 – Config/Control tabs
3 – Command log

1 – The top frame is used as the instrument monitor:
– Will become active once the instrument is connected. It will display the current selected mode (CC/CV/CW/CR) for normal operation, for “Transient” operation it will display (TR-CC/TR-CV/TR-CW/TR-CR), and for a simulated short operation it will display (Short).
– The input can be turned on/off via the Enable/Disable Input button.
– Status “lights” will display the instruments current status. This includes over-current/voltage/power/temp and reverse-polarity input voltage detection

2 – The central portion is split into 2 main tabs: Config/Control:
Config:
– “COM settings” to connect to the instrument. Please note this section includes a box to insert the instrument address as defined in the instrument settings. The default value is ‘0’ in app.py as is the case for the 8500 instrument
– “Instrument information” frame which will update with the instrument model/version/serial number once connected.
“Absolute maximum ratings” reading is derived from the model reported, and not read from the instrument
– “Instrument Configuration” can be used to control the configuration for remote sensing, enabling/disabling control override from the front panel of the instrument, and selection of the trigger source. Limits (voltage/current/power) can also be set from this frame.
Note that the 8500 series has no ability to directly control the voltage/current range via remote control, only from the front panel. However, if you modify the appropriate limit value to a value that is within the lower range it will change the instrument reading range accordingly. For example, for the 8500 setting the voltage limit to 18.0 V or lower will switch the instrument to a lower range and will provide with one more digit after the decimal point
– “Instrument config store/recall” allows storing or recalling the instrument configuration to one of 25 slots for future use. This uses the instruments internal storage, therefore can also be used from the front panel

Control:
– “Mode selection” includes 2 sub frames:
– “Mode” is used to set the desired mode to CC/CV/CW/CR
– “Function” controls the current function used:
– Fixed for static operation with user defined values until programmed otherwise
– Transient for switching between 2 different values, the “Mode” selected will be the one used for the Transient function as well as Fixed function
– Short is meant to simulate a short across the input
Note that 2 additional functions the instrument supports aren’t included here:
– Battery function is quite limited in the 8500 as it only support “CC” mode, and doesn’t allow readback of the resulting capacity (AH) via remote control. This is therefore implemented differently as will be described later in the “Capacity meter” section
– List function which support up to 1000 pre-defined steps. The list commands are implemented in bk8500.py module included in this download, but the app.py GUI doesn’t include a tab that uses these commands. This might be added in the future
– “Set C/V/W/R” allows setting desired value for these parameters.
– “Capacity meter” is a somewhat more capable method of measuring capacity compared with the instruments internal “battery” function, but it does have some limitations. The capacity meter is implemented in app by accumulating the AH and WH values read from the instrument. This will continuously accumulate the values, even if the mode/function is changed or the output is turned off and then back on again. This gives quite a bit of flexibility which isn’t provided by the instrument on its own.
To reset the integration simply press the “reset” button.
Since the instrument reading is only read ~2 times per second, the app has no ability to track changes which are shorter than that. Therefore, if for example a transient of 10ms will occur in between samples, the instrument will not report this to the app and the app will assume the value was constant for the entire duration between the previous readout and the current readout.
Due to the lack of “VOLTAGE ON SET” and “VOLTAGE OFF SET” setting command in the 8500 series, there’s no ability to limit the discharge voltage using this option without operating via front panel. Therefore, a software “Vmin” limit is available. If enabled, this will turn the load off once the readout voltage drops below the last set Vmin value.
Vmin is included in the “Capacity meter” frame mostly for convenience as its most likely to be used for battery capacity measurements. However, it can obviously be used for other use cases too.
– “Transient Parameters” is where you can set the 2 values (C/V/W/R) and their duration, as well as the mode of Transient operation. “Continuous” will continuously switch between these 2 states after the defined time has passed.
“Pulse” will stay at value1 until a trigger is detected, at which point it will switch to value2 for the defined time for T2.
“Toggle” will switch states when a trigger is detected.
The “Trigger” button is used to send a “BUS” trigger to control the “Pulse”/”Toggle” modes. Note that “trigger source” must be set to “BUS” in the Config menu for the instrument to respond to this trigger source
– “Load Timer” uses the instruments internal timer to limit the maximum continuous on time of the load input

3 – The bottom frame is the Command Log:
It includes a scrolled text box (200 lines max) which will present messages generated by the program as commands are implemented in response to user inputs.

.py source files:
There are 4 python code files include in the download:
bk8500.py – this is a python module implementing most control commands for the BK Precision 8500 series of electronic loads.
The commands follow the information given in the 8500 manual version: 100814, with the exception of the commands nested under “Calibration” group which weren’t implemented in this module as they have no command structure documentation in the manual
example.py – this is simple example code that uses the functions inside of bk8500.py. When using it make sure you modify the COM port parameters at the beggining of the file according to your setup. This file doesn’t use every single command and option that was implemented in bk8500.py, but does include a vast portion of these
app.py – this is a complete control code (with basic GUI using tkinter) which is using bk8500.py to communicate with the instrument
app_info.py– used by app.py includes mostly static configurations as well as a few additional supporting functions

Edit March 25, 2021:

V1.1 of the control program is now available. The change log for this version:
– C/V/W readings have trailing zeros even if current value can be represented with a lower number of digits. If instrument is at higher range, last digit will be ‘0’ at all times
– Added measurements (C/V/W) logging. Logging starts when instrument is connected, and ends automatically when its disconnected. New connection will overwrite log file. Log file named “readings_log.txt” placed in same library as the run file
– Added plot of V/I history in a new tab (“Plot”)
– Added right click menu to V/I plot to clear history (plot and readings log file) and to save plot to snapshot

End of edit

Edit April 9, 2024:

Version 1.11 is now available for download below.  This one has a minor update to the app.py file. I’ve recently had a need for a long log of battery discharge (>48hours), and noticed the program wasn’t running stable. Seems that in some cases the wait time for the instrument was insufficient, which has caused incorrect serial data to be received. I’ve modified the update rate to 2.5s per refresh instead of the lower previous value, to alleviate this. This seems to be more than sufficient, and so far I’ve had no fails with this setting after >50hours of recording. For these who have an older version and don’t want to re-download, simply modify:

update_prd = 0.5

to:

update_prd = 2.5

at the variable definition in the top most part of app.py.
End of edit

Download links (.zip):
version 1.0:
bk8500_controller
bk8500_controller_py_src_files
version 1.1:
bk8500_controller_v1p1
bk8500_controller_py_src_files_v1p1
version 1.11:
bk8500_controller_v1p11
bk8500_controller_py_src_files_v1p11

Leave a Reply

Your email address will not be published. Required fields are marked *