Oscilloscope Software Project


A personal programming project made up 70% of the mandatory programming course in the computer science minor at Aalto, and naturally, I chose an oscilloscope as my topic as it combined nicely my early studies of electrical engineering and audio signals.

It turned out quite nicely (well, I did spend way over a hundred hours on it), and I learned Qt pretty well doing it. The software was done with Python (which was dictated by the course) and PyQt5. It has all the features of a traditional analog oscilloscope and then some 😉 I have also developed it a little bit further from the requirements the school course had for it, for example I added support for WAV audio files.

It looks like this:

Oscilloscope

 

Here’s a nice demo of it in action using the X-Y mode, which draws channel two as the function of channel one, meaning channel one values map to the horizontal axis and channel two to the vertical axis. Instead of a static image, I’m drawing a Lissajous figure, where the frequency of the sine waves rises from exponentially from 0,05 Hz to 20 Hz. That way we can see clearly how the pattern actually forms and at the same time see that the oscilloscope is working well 🙂

 

 

The Lissajous signals seen in the video were made with Matlab (code below), together with a comprehensive set of other classic signals for testing and demonstration.


%% Lissajous changing freq

Fs = 48000;
Ts = 1/Fs;
t = 0:Ts:10-Ts;

f = logspace(-1.3,1.3,max(size(t))); % f = 10^-1.3 ... 10^1.3

a = 3;
b = 4;
phi = pi/2;

x = 4*sin(2*pi.*f*a.*t + phi);
y = 4*sin(2*pi.*f*b.*t);

lissajousX = roundn(x',-6);
dlmwrite('lissajous_34_X_muuttuva.csv',lissajousX);

lissajousY = roundn(y',-6);
dlmwrite('lissajous_34_Y_muuttuva.csv',lissajousY);

I have “compiled” the code to an executable (for Windows 64 bit) so it is easy to test without having to have or install PyQt. This was done with cx_Freeze using a distutils setup script:


import sys
from cx_Freeze import setup, Executable

setup(
 name = "Oscilloscope",
 executables = [Executable("Oscilloscope.py", base = "Win32GUI", targetName="Oscilloscope.exe", icon="Media/icon.ico")],
 options = {'build_exe': {'include_files': ['Media/about.png', 'Media/color.png', 'Media/exit.png', 'Media/icon.png', 'Media/open.png']}})

It is used from the command line by navigating to the folder containing the code and invoking “python setup.py build”.

 

You can download the executable packaged together with some test signals, and the code itself can be found in GitHub.

Leave a Reply