From Wiki of the E-Business and Web Science Research Group
Jump to: navigation, search
The current page contains information about the » WOW MakerLab at the Universität der Bundeswehr «.
See also the list of all Makerlab-related pages.

Automating Measurement Tasks with PyVISA

Jupyter Notebooks on Github:


Most of our test and measurement equipment can be controlled from script languages and software tools via USB on the basis of SCPI (see also here) commands and the VISA interface, which is an I/O API for the test and measurement domain. On this page, we give an overview of resources.

Temporary Collection of Links

Exercises and Examples

Exercise 1: Measure the discharge behavior of a battery

As a first example, we are going to discharge a battery by a connecting a small light bulb or a sufficiently rated resistor and measure the decreasing cell voltage over time. In this example, we only have to control a single measurement device, in this case a digital voltmeter.

Task: Measure the discharge curve for a Duracell QU1500 AA battery at 200 and 500 mA. To do so, connect the Rohde & Schwarz HMC8012 digital multimeter and a suitable resistor parallel to the battery. Then, write a Python script to measure the cell voltage over time. You do not need to measure the discharge current, as it is directly related to the cell voltage as I = U/R at any moment in time. Plot the result with Matplotlib in an Jupyter notebook. Finally, compare it with the datasheet.


  1. Do not use rechargeable batteries, namely not Lithium-based batteries. They can develop very high discharge currents that can cause fires and other hazzards.
  2. When using a resistor care must be taken to choose a sufficient power rating.
    • Example: When you use a 1.5 V AA battery, you need a resistor of R1=1.5 V / 0.2A = 7.5 Ohms and of R2=1.5 V / 0.5A = 3 Ohms.
    • The 7.5 Ohms resistor needs to be rated P = 1.5V * 0.2A = 0,3 W and the 3 Ohms resistor needs to be 1.5V *0.5A = 0.75 W.
    • Both values are available in the E12 series of values, and you should use a 1 W version to be on the safe side.
  3. The resistor can get hot even within its power rating. Handle with care!

Block Diagram and Setup: To be added

Jupyter Notebook:

Exercise 2: Measure the properties of a diode

In diodes, like the popular 1N4001, the flow of current depends on the voltage applied. Each diode has a characteristic relationship between two, called the current-voltage curve. By combining a computer-controlled voltage and a both a voltmeter and an amperemeter, we can trace this curve from a Python script.

Task: Use the setup from here and connect it to the Rohde & Schwarz HMC 8042 programmable power supply and the Rohde & Schwarz HMC8012 digital multimeter. Then, write a Python script to increase the voltage of the power supply in small steps and measure the flow of current. Plot the result with Matplotlib in an Jupyter notebook. Compare it with the datasheet.


  1. You must stay within the voltage and current rating of the diode. For the 1N4001, this means a maximum current of 1A, which will be reached at ca. 0.9V. By adding a series resistor (e.g. 100 Ohms), the voltage and thus the resolution of the measurement can be improved.
  2. The diode can get hot during the measurement. Take precautions!

Block Diagram and Setup: To be added

Jupyter Notebook: