How are Jupyter notebooks used in industry?

Automation of measurement technology with Python

In the Mechatronics Bachelor course, students learn how measurement technology is used in automated systems. Even in their practical semester, many students work on automated test benches or final tests, in which the LabVIEW software is often used. For this reason, LabVIEW is also used in the metrology lab at Reutlingen University, where DAQs and oscilloscopes are read out or controlled, and their measurement data are processed and graphically displayed.

LabVIEW as well as MATLAB are de facto standards in the industry and are therefore associated with very high software license costs that are often not affordable in the private sector or in small businesses. Octave is a good open source alternative for MATLAB. Unfortunately, there are no serious open source alternatives to the graphics-based programming languages ​​Simulink or LabVIEW.

If LabVIEW is not available, Python can be used to control and read out measuring devices and to process their measurement data.

Python programming

Python is a scripting language that runs on a "virtual machine" in a platform-independent manner, similar to Java. The following program examples refer to the current version 3 of Python. (Attention: Many programmers still use the old version Python 2, which uses some commands with a different syntax.) Unlike Java, Python can even be executed interactively in the so-called "Python Shell" in "interpreter mode". Python is completely open source, free and runs on Windows, Mac and Linux. Python is very suitable for programming beginners and has a large number of very good open source libraries. Python makes it very easy to access interfaces, which is a basic requirement for communication with measuring devices. The Python library also includes numPy Math functions similar to those of MATLAB. With the python library Matplotlib measurement data can be visualized similar to MATLAB. Finally, with the Python library tkinter a platform-independent user interface can be created very easily.
Everything together then results in measuring software that communicates with the measuring device, reads out its data, processes it, and graphically displays or stores it. This is comparable to the basic functionality of LabVIEW.

A recommended textbook specially tailored to the engineering sector is available from Hanser-Verlag: Hans-Bernhard Woyand: Python for engineers and scientists.
Hanser-Verlag also has a very good Python3 book for those who switch to C and to look up: Bernd Klein: Introduction to Python3.

Two examples for the use of Python in measurement technology as described above are presented below.

Readout and graphic display of the measured values ​​from a digital multimeter

The digital multimeter (DMM) Voltcraft (manufacturer Metex) ME-42 from the 1990s has a serial data interface (RS-232C). With a 5 euro interface converter (turquoise dongle on top of the DMM) it becomes a modern USB interface. A user interface opens in the Python program "ME-42_GUIplot", in which you first enter the interface on the PC under which the interface converter appears as a virtual COM port (here on a Windows PC "COM42").
Communication to the DMM is established by clicking on the "Connect COM interface" button. Now you can either take a single measurement or a series of measurements. The DMM can only be read but not parameterized. It outputs the current measured value with unit and type of measured variable as an ASCII character string.

In the case of a series of measurements, the course of the measured values ​​is then displayed graphically, as well as the mean value and the standard deviation.

Control and readout of a low cost power supply

The Korad KD3005P power supply unit is sold under various names, e.g. by the distributor Reichelt or ELV. It costs around € 70 and has a USB as well as an RS-232 interface. This can be used to set the voltage and current of the power supply unit, the output or an overcurrent protection can be switched on and off, and the current supplied can be read out.

In contrast to the digital multimeter, different ASCII commands are sent to the measuring device, see comments in the Python program "KoradKD3005P".

Live display of the signal curve of the AD converter values ​​of an Arduino Uno

Matplotlib window during the live display of the measured values ​​recorded by the Arduino

Similar to the digital multimeter, measured values ​​converted by an Arduino Uno can also be displayed on the PC using a Python program. The picture shows how the measured values ​​recorded by the analog input are displayed in a live plot similar to an oscilloscope for a sampling rate of approx. 20 S / s.

The Matplotlib and pySerial libraries are also used for this.

The source codes for both the Arduino and the Python program can be found below in the download area of ​​this page.

Automated measurement with Python and the IVI (VISA) standard (internship measurement technology, Bachelor mechatronics)

In the meantime, Python has also found its way into the metrology internship in the bachelor's degree in mechatronics in addition to LabVIEW.

There is a Jupyter notebook under GitHub that students use to prepare for the internship. In the download area you will find a PDF of the internship instructions.

Download source codes and internship instructions