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


21 June 2017

UNI-T UT61E DMM with serial interface - Python code

The UT61E is a pretty nice meter for the money.  It has 22000 count resolution (4.5 digit) and a nice selection of ranges.  But the selling point for me was the computer interface.  The point of this post is to show an example of how to reliably get data from the computer interface.  As seemingly simple as it is, there are few tricks to it.

AC and DC Volts - 0.01 mV to 1000V
AC and DC Amps - 0.01 µA to 10A
Frequency - 0.01 Hz to at least 50 MHz
Capacitance - 1 pF to 0.22 F
Resistance - 0.01 Ω to 220 MΩ

The interface is optically isolated, and comes with a cable that ends with a DB9 RS-232 connector. The meter transmits data once every 0.5 seconds.  It accepts no commands. The data that it outputs is a little obscure, but thankfully someone else has created a Python module (es51922.py) to convert the responses from the meter to usable data. I'm using this module without modifications.

To connect to the meter, I'm using a very cheap USB to RS-232 cable purchased from Amazon. I'm using the default Windows (Win10) driver. I believe that really any USB to RS-232 converter should work with this code. The only trick to working with this meter is properly managing the RS-232 control signals.

I'm using PySerial to manage the Com port. You will need to obtain and install this module to use this code.  I've linked to a copy of ES51922.py file for reference.

The UT61E code is simple to use.  Call the init_comm() function with a string that represents the name of the comm port that the meter is connected to ("Com5:" for instance).  Call get_one_reading() to return a numeric result.  There is considerably more data that is available (range, overload, etc.).  This code was primarily meant to show how to manage the serial port.

To try the example code, first download and install PySerial.  Then, create a project for the UT61E module.  Drop the ES51922.py file in the same folder as UT61E.py.  Run it.

** 2021.10.20 Updated links to Google Drive **

UT61E Example Serial Comm Python Code

ES51922 Data Parsing Python Code