Skip to content

hollanderic/batteryTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Battery Test Script

A cross-platform Python script designed to test batteries and calculate Equivalent Series Resistance (ESR) using a Rigol DL3000 series programmable DC Electronic Load (like the DL3021A) over a LAN connection.

This tool provides standard constant-current discharge testing (with Ah/Wh calculations and cutoff voltage) as well as an advanced alternating-load ESR measurement mode with live plotting.

Requirements

  1. Python 3.x
  2. A Rigol DL3000 series electronic load connected to your network.

Dependencies

The script relies on pyvisa for instrument communication and matplotlib for live data plotting.

You can install the required packages using pip:

pip install pyvisa pyvisa-py matplotlib

Modes of Operation

1. Standard Discharge Mode

Performs a constant current discharge on a battery until it reaches a specified cutoff voltage. During the test, a live plot of Voltage and Capacity (Ah) is displayed and updated in real-time. Upon completion, a CSV log is generated and the plot is saved as a PNG.

Usage:

python battery_test.py --ip <IP_ADDRESS> --curr <CURRENT_A> --volt <CUTOFF_V> --out <LOG_FILE.csv>

Parameters:

  • --ip: The IP Address of your Rigol electronic load.
  • --curr: The constant discharge current in Amps (e.g., 2.5).
  • --volt: The termination/cutoff voltage (e.g., 10.5). When the battery hits this voltage, the test ends.
  • --out: The path/filename for the CSV log output (e.g., discharge_log.csv).

Example:

python battery_test.py --ip 192.168.1.100 --curr 2.0 --volt 11.0 --out battery_1_test.csv

2. ESR (Equivalent Series Resistance) Mode

This mode is used to calculate the internal resistance of the battery by pulsing the load on and off at defined intervals. It calculates both $R_{fast}$ and $R_{slow}$ values across the transition.

ESR Cycle:

  1. Lead In: Wait for lead_in_time seconds with the load OFF.
  2. Load ON: Turn the load ON at load_current Amps for load_on_time seconds.
  3. Load OFF: Turn the load OFF for load_off_time seconds.
    • Records $V_0$ just before turning off.
    • Records $V_1$ exactly 1 second after turning off.
    • Records $V_3$ at the end of the load_off_time.
  4. Calculates $R_{fast}$ (V1 - V0) / I and $R_{slow}$ (V3 - V1) / I.
  5. Repeat steps 2 through 4 until terminated by the user.

Usage:

python battery_test.py --ip <IP_ADDRESS> --out <LOG_FILE.csv> --esr <DELAY>,<LOAD_CURRENT>,<ON_TIME>,<OFF_TIME>

Parameters:

  • --ip: The IP Address of your Rigol electronic load.
  • --out: The base name for the output files. (Will generate <out>.csv and <out>_esr.txt).
  • --esr: Four comma-separated numbers specifying the ESR test timing and load constraints.
    1. Delay (lead_in_time): Seconds to wait before starting the first ON cycle.
    2. Load (load_current): Amps to pull during the ON cycle.
    3. On Time (load_on_time): Seconds to keep the load ON.
    4. Off Time (load_off_time): Seconds to keep the load OFF before repeating. (Note: Must be $\ge 1.0$s to allow for $V_1$ calculation).

Example:

python battery_test.py --ip 192.168.1.100 --out my_esr_test.csv --esr 5.0,2.0,1.0,3.0

In ESR mode, data is actively logged to the CSV file provided in --out, and a supplemental text file (e.g., my_esr_test_esr.txt) is generated containing only the measured voltages and calculated resistances for each cycle.

Control / Termination

  • ESR Pause (p): When running in ESR mode, you can press p (or P) on your keyboard at any time. This will immediately turn the load OFF and pause the test. While paused, pressing any key will safely exit the program.
  • Safe Exit (Ctrl+C): Pressing Ctrl+C in your terminal during either mode will catch the interrupt, turn the load OFF safely, attempt to save the final plot, and cleanly exit the program.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages