22 June 2017

Controlling a Tekpower TP3005P power supply from Python

I bought the Tekpower TP3005P power supply recently.  This goes for around $100.  That's not bad for a 30V, 5A, power supply with a USB interface. I've been impressed by the performance as well.  The accuracy data below was collected by controlling both the power supply and a UT61E meter via Python code. See my separate blog post for python code to control a UT61E meter.

The copy I have is reasonably accurate. The graphs show less than 0.5% error though out the voltage range under low or no-load conditions.

When the TP3005P is plugged in to a USB port, it maps in as a standard Com port. The default Windows driver can be used.

The TP3005P.py code uses the PySerial module to manage the serial port.  This must be downloaded and installed under Python before the power supply code can be run.  Other than PySerial, TP3005P.py should run on its own.  Un-comment the call to test() to run a short demo. 

Like most lab power supplies, at no load it is in voltage regulation mode.  The voltage will go to the commanded level.  If the current exceeds its set point, then the power supply changes to current regulation mode.  The voltage will drop below its set point to whatever level is necessary to prevent the current from exceeding its set point.

The power supply has commands to set the voltage and current set points that it will regulate to.  It also has commands to read back the set points.  Additionally, the power supply can measure the actual voltage and current at its output terminals.  Finally, there is a command to turn the power supply output on or off.

The voltage can be set and read at a resolution of 0.01 VDC.  The current can be set and read at a resolution of 0.001 ADC.

** 2021.10.20 Updated link to Google Drive **

TP3005P Python Code


  1. You should note the snaky issues this supply has:
    It needs a literal \n, not a newline, as most programmers would interpret the manual as saying. Glad I read python well enough to see what you did there (I'm programming in perl here).

    If you have more than one of these on the same machine, you are hosed. The USB bridge has the same default serial number (so linux can't tell which is which), and the ID is always the same. So if you're used to selecting a windows com port and comfortable with hoping the same one is assigned the same supply each time...you're fat. If you're going to use this in some more professional context, you are hosed in terms of being sure of sending commands to the correct unit.
    Please add this information to your comments for others.

  2. Regarding the serial number, the Silicon Labs Simplicity Studio tool lets you change it over the USB port. I really thought long and hard before I pressed enter, but it seemed to work fine with no other ill effects.