A versatile, tiny oscilloscope + spectrum analyser in Python/qwt
dualscope123
is a fork of Roger
Fearick's dualscope.py
.
The interface, based on qwt, uses a 'knob based' layout, similarly to that found in an analogue scope.
This tool may be employed to quickly inspect the data from digital-output devices, such as an ADC testbench.
It is here distributed in the hope that it may be useful.
- Acquisition of two traces,
- Level-based triggering,
- Power spectrum,
- Averaging, in the time and frequency domain,
- Autocorrelation,
- A cross hair status display permits the reading of values,
- Print, generate PDFs and CSV data dumps.
The traces can be averaged to reduce influence of noise. The cross-correlation between the inputs can be computed. The spectrum analyser has both log (dB) scale and linear scale. A cross hair status display permits the reading of values off the screen.
The digital input data is provided by software probes.
Different probes may be used, according to what the user wishes to
accomplish. All supplied probes are located in the submodule
dualscope123.probes
.
-
A simple, example probe -- named
audio
-- reading the input jack of the audio card is provided. This probe requirespyaudio
. -
I use a different probe, designed to run
dualscope123
oscilloscope as a crude-but-fast debugging tool for prototype ADCs: a ctypes-based module namedeth_nios
to read-out over TCP-IP the data buffer of an FPGA located in the ADC testbench (not part of this project). This probe is included as well: although it will be of little to no use to anybody else, as is, it may be used as inspiration to write simliar network-based software probes.
The probes have a standard interface and new probes can be easily coded.
Look into the audio
probe and the generic
probe for examples.
Which probe is employed is selected through a config INI file named
~/.dualscope123
, read once, at start-up time.
The default configuration is:
[DEFAULT]
verbose = false
[probes]
probe = audio
which contains all configuration base options and is rather self-explanatory.
A probe may require some configuration, in the form of a section named as the probe containing the relevant options.
numpy
-- numerics, fftPyQt4
,PyQwt5
-- gui, graphics
Installing PyQwt5
may be complicated the first time one faces the task. Neither PyQt4
nor PyQwt5
are on the PYPI.
Straight forward on Linux, on Mac OS X it is greately simplified by using Homebrew.
brew install qt qwt portaudio wget
If you have the virtualenv
wrapper installed:
mkvirtualenv env_qwt
or, if you are on Mac and use Anaconda:
conda create -n qwt_env setuptools
source activate qwt_env
If you use another Python environment / package manager please check how to make a virtual environment. Installing in a separate environment allows keeping the changes separate and reistalling in a sec.
pip install numpy
or, if you are on Mac and use Anaconda:
conda install numpy
As of writing, the latest SIP
version is 4.15.6-snapshot
. Make sure to check on the SIP website if there is a newer one!
Make sure you configure SIP
with --incdir=YOUR_INCLUDE_PATH
. With virtualenv, that is likely $HOME/.virtualenvs/env_qwt/include
, with Anaconda, /anaconda/envs/qwt_env/include/
.
Then:
wget http://www.riverbankcomputing.com/static/Downloads/sip4/sip-4.15.6-snapshot-0c1b13e45887.tar.gz
tar zxf sip-4.15.6-snapshot-0c1b13e45887.tar.gz
cd sip-4.15.6-snapshot-0c1b13e45887/
python configure.py --incdir=$HOME/.virtualenvs/env_qwt/include
make
make install
cd ..
Remember that if you update SIP
, you need to reinstall the following packages as well.
Make sure to download the latest version for your platform. As of writing, link for linux, link for Mac. You may want to check if newer versions are available!
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.4/PyQt-x11-gpl-4.10.4.tar.gz
tar zxf PyQt-x11-gpl-4.10.4.tar.gz
cd PyQt-x11-gpl-4.10.4/
python configure.py
make -j9
make install
cd ..
wget "http://downloads.sourceforge.net/project/pyqwt/pyqwt5/PyQwt-5.2.0/PyQwt-5.2.0.tar.gz
tar xvzf PyQwt-5.2.0.tar.gz
cd PyQwt-5.2.0/configure
python configure.py -Q ../qwt-5.2
make -j9
make install
cd ../..
Check that PyQwt5 works with:
python -c 'from PyQt4 import Qwt5'
No errors? woohoo, it works!
Credit: David Balbert's pyqwt gist.
The original dualscope.py
tool, also included in this package
is:
Copyright (C) 2008, Roger Fearick, University of Cape Town
All subsequent additions, see dualscope123
are:
Copyright (C) 2010-2014, Giuseppe Venturini
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.