Skip to content

Commit aad84da

Browse files
Update README.rst
1 parent 84a9ac1 commit aad84da

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

README.rst

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
.. image:: https://img.shields.io/badge/License-MIT-purple.svg
99
:target: https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo/blob/master/LICENSE.txt
1010

11-
DvG_Arduino_PyQt_multithread_demo
12-
=================================
11+
Arduino PyQt multithread demo
12+
=============================
1313

1414
Demonstration of multithreaded communication, real-time plotting and logging of live Arduino data using PyQt/PySide and PyQtGraph.
1515

1616
This demo needs just a bare Arduino(-like) device that, for demonstration purposes, will act as a numerical waveform generator. The source files are included and they should compile over a wide range of Arduino boards. Connect the Arduino to any USB port on your computer and run this Python demo. It should automatically find the Arduino and show you a fully functioning GUI with live data at a stable acquisition rate of 100 Hz.
1717

18-
Alternatively, you can simulate the Arduino by running ``python demo_A_GUI_full.py simulate``.
18+
::
19+
20+
Alternatively, you can simulate the Arduino by running `python demo_A_GUI_full.py simulate`.
1921

2022
It features a graphical user-interface, with a PyQtGraph plot for fast real-time plotting of data. The main thread handles the GUI and redrawing of the plot, another thread deals with acquiring data from the Arduino at a fixed rate and a third thread maintains a thread-safe queue where messages to be sent out to the Arduino are managed.
2123

@@ -29,7 +31,21 @@ Other depencies you'll need for this demo can be installed by running::
2931

3032
pip install -r requirements.txt
3133

32-
PyQtGraph performance
33-
=====================
34+
PyQtGraph & OpenGL performance
35+
==============================
36+
37+
Enabling OpenGL for plotting within PyQtGraph has major benefits as the drawing will get offloaded to the GPU, instead of being handled by the CPU. However, when PyOpenGL is installed in the Python environment and OpenGL acceleration is enabled inside PyQtGraph as such in order to get full OpenGL support::
38+
39+
import pyqtgraph as pg
40+
pg.setConfigOptions(useOpenGL=True)
41+
pg.setConfigOptions(enableExperimental=True)
42+
43+
the specific version of PyQtGraph will have a major influence on the timing stability of the DAQ routine, even though it is running in a separate dedicated thread. This becomes visible as a fluctuating time stamp in the recorded log file. Remarkably, I observe that ``PyQtGraph==0.11.1 leads to a superior timing stability`` of +/- 1 ms in the recorded time stamps, whereas ``0.12.x`` and ``0.13.1`` are very detrimental to the stability with values of +/- 20 ms. The cause for this lies in the different way that PyQtGraph v0.12+ handles `PlotDataItem()` with PyOpenGL. I suspect that the Python GIL (Global Interpreter Lock) is responsible for this, somehow. There is nothing I can do about that and hopefully this gets resolved in future PyQtGraph versions.
44+
45+
Recommendation
46+
--------------
47+
48+
``Stick with pyqtgraph==0.11.1`` when OpenGL is needed and when consistent and high (> 10 Hz) DAQ rates are required. Unfortunately, ``0.11.1`` only supports PyQt5 or PySide2, not PyQt6 or PySide6 which get supported from of version ``0.12+``.
49+
50+
Note: ``pyqtgraph==0.11.0`` has a line width issue with OpenGL curves and is stuck at 1 pixel, unless you apply my monkeypatch found at https://github.com/Dennis-van-Gils/python-dvg-pyqtgraph-monkeypatch
3451

35-
The specific version of PyQtGraph *can* have major influence on the timing stability of the DAQ routine whenever OpenGL is enabled, visible as a fluctuating time stamp in a recorded log file. I observe that ``PyQtGraph==0.11`` leads to a great timing stability of +/- 1 ms, whereas ``0.12.4`` and ``0.13.1`` are very detrimental to the stability with values of +/- 20 ms. The reason for this is still unknown. I have to investigate further.

0 commit comments

Comments
 (0)