Software advice: Basic dynamic signal analyser - Page 1
Forum section: electronics / projects

author: David
author_rank: Frequent Contributor
timestamp: August 01, 2020, 01:25:41 pm
content: Hi all,I have been developing some hardware which essentially consists of a low noise front end and a 24 bit ADC for the purpose of a simple dynamic signal analyser. The hardware has an ethernet interface and streams the data via TCP. Now, when it comes to PC application software I immediately start to shiver... What I am looking to do is essentially perform a dynamic FFT on the incoming data and have some basic averaging and window functions. I don't want to re inevent the wheel nor do I have the software skills to particularly do this (unless it's possible in VB.net, even then it still make me nervous!). Does anyone know of any open source framework or anything else that could be adapted to do the job? I can change the "protocol" I'm using over TCP if needed.Cheers,Dave

author: OM222O
author_rank: Frequent Contributor
timestamp: August 01, 2020, 01:35:11 pm
content: use python + numpy / scipyEasy support for Ethernet and sockets, data analysis, etc. takes you 10 min to learn everything.

author: David
author_rank: Frequent Contributor
timestamp: August 01, 2020, 03:46:45 pm
content: Forgive my ignorance, would I be able to create a GUI and an executable with python?

author: FenTiger
author_rank: Regular Contributor
timestamp: August 01, 2020, 03:48:58 pm
content: Jupyter Notebook makes a great GUI for Python etc:https://jupyter.org/I haven't tried their new JupyterLab thing. I should give it a go.

author: OM222O
author_rank: Frequent Contributor
timestamp: August 01, 2020, 03:50:24 pm
content: a GUI yes, you can use TKinter for that , however an exe is very unstable / janky. the end user needs to have a python complier on their computer. (it's not really a compiler but I'm not sure what to call it, python runs dynamically on the computer, so no "pre compiled code" is used, hence the jankiness of the exe files).

author: Marco
author_rank: Super Contributor
timestamp: August 01, 2020, 05:22:40 pm
content: Quote from: OM222O on August 01, 2020, 03:50:24 pmPackaging executables for distribution is a pain at the best of time. There's a variety of freeze based methods which just include the whole python environment you work with together with the script, like pyinstaller. No dependency on installed python, just large and potentially slow to start.

author: David
author_rank: Frequent Contributor
timestamp: August 01, 2020, 08:52:49 pm
content: Thanks for the replies. I've dived into Python and Qt...wish me luck!

author: David
author_rank: Frequent Contributor
timestamp: August 14, 2020, 06:32:21 pm
content: Ok, so I've got somewhere with using Python, QT and Matplotlib but would appreciate some help please. At the moment I have the following which connects to a device (well it connects to a dummy server I've knocked up) and can do some basic comms so that's the ethernet side ticked off for now. I have added a matplotlib chart as shown and at the moment it is just generating random numbers and scrolling (just lifted some tutorial code). I have two main objectives; the first is to -stream the samples from my ADC and view them in an oscilliscope type chart, the second is to view the same data in a seperate chart doing a 'real-time' FFT. At the moment I just want to focus on the first objective. Now I am not after anything fancy and I don't need to make accurate measurements of the incoming data (the real aim of all of this is to analyse the FFTs). The idea is just to have some visual idea of what the hardware is sampling. To keep things simple lets assume my ADC is sampling data at 100kHz on a single channel (in reality it won't be any faster than this). Lets also assume that my hardware is taking the samples and then streaming this data as fast as possible to the PC over ethernet. What would be the best way to handle the data once it arrives in my Python program and how should I handle updating the chart to maintain the correct timebase information? At the moment the tutorial code I have just adds new data to a Python List structure and drops off the first element then redraws the canvas. This is triggered by an internal timer at a set interval. I feel like I need some sort of circular buffer but I am getting my head in a twist over timings and buffering data.Any suggestions or help of any kind would be very much appreciated!

author: David
author_rank: Frequent Contributor
timestamp: August 18, 2020, 02:47:59 pm
content: I'm still confusing myself hereI think I am over-complicating the problem but then again I'm still trying to learn Python...

author: OM222O
author_rank: Frequent Contributor
timestamp: August 18, 2020, 11:59:36 pm
content: matplotlib has a function that allows you to "animate" which basically updates the chart in fixed time intervals (don't try to update faster than 100FPS, aka 10mS since it'll lag and become unusable. If you have a 60Hz monitor, 16mS should be plenty fast enough).If you're ok with that limitation then it's really easy to show the last N samples, but if you want proper scope functionality (trigger, x time / division, etc) it'd be nightmare to implement.Assuming you just want to show the last N samples and the new data is added to a list called buffer:data = data + bufferdata = data[len(data)-N:]buffer = []if you use numpy arrays it's a lot more efficient when you try to do FFT but you need to use the .stack (or if you already know the shapes of the matrices, either hstack or vstack, depending on how you're structuring the data) in order to add them together, otherwise if you just do A + B on a numpy array, it just adds the elements of the two arrays together instead of appending them.For the time issue: your best bet is to encode the time data and send it over serial too, for example I know arduino has a millis and micros function that returns you the elapsed time. I'm sure when you send that over, adding or removing some offset and then doing cumulative sum (np.cumsum) allows you to get actual time for your x axis.

author: ebclr
author_rank: Super Contributor
timestamp: August 20, 2020, 04:00:58 am
content: Just is case you wana evaluate another pathhttp://www.lohninger.com/fourier.htmlThis with embarcadero Delphi or C++ is relatively easy to implement, But is not open source, But is professional and on the end you will have a instalable executable, Not a bunch of code lines typed to install