• 0

Low frequency FFT/CZT refresh rate, trace color opacity, time-based chart generation



I'm an absolute beginner with WaveForms, I've just started to play around with it last week. I think it's brilliant, there are only a few questions I'd like to ask.

1, When I use the Spectrum's FFT or CZT and I set the stop frequency to something low (like 200 Hz) and the sample to something high (like 8.192k) the response rate of the chart will get very slow (it takes 20 seconds to refresh).


My guess is that Analog Discovery 2 has to fill its buffer fully before sending it for the FFT/CZT and since the sample rate is 400 Hz only it takes a lot of time. If I understand it correctly I would need a big buffer if I wanted to measure the very low frequency regions (at least 400 samples for 1 Hz, 800 samples for 0.5 Hz, etc.) so I would prefer to not lower the sample count. On the other hand a higher refresh rate would be nice. Could you add the option to use a FIFO buffer for FFT/CZT, where a small number of samples of the recently captured values would be frequently added to the buffer that is used for the FFT/CZT, so the FFT/CZT would be always highly responsive independently from the buffer size/score rate?


2, I'm trying to visually show the changes of a signal using the Spectrum with 3 different exponential dB average traces on the same channel with 5, 100 and 1000 weights. It looks alright, but since I can't set the opacity level of the different trances they overlap each other. As a small feature request, could you add opacity option to the color setting dialog?



3, Do I understand it correctly that if I wanted to measure the cumulative power of a certain frequency region (like the theta, alpha, beta, gamma brainwaves) I need to write a script to do the math and plot the values? Is it possible to create a continuously updating chart which shows the different measurements over time this way?


Thank you,


Share this post

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Szia András,

1. The Spectrum Analyzer captures a buffer worth of data before processing it. For 200Hz it needs 400Hz capture of 8192 samples which takes 20 seconds. Reducing the number of samples to 1024 it will take 2.5 seconds.
For slow progressive analysis you could use the FFT view in Scope with Scan Shift capture.


2. You can find the transparency option under WaveForms/Settings/Options.
Also choosing light analog color might help in transparency.


3. You could do with a script like this eeg.dwf3work


const neeg = 4 // sections
const ceeg = 100 // history
var rghistory = new Array(neeg); // history array
for (var i = 0; i < neeg; i++) { // initialize array
    rghistory[i] = new Array(100);
    for(var j = 0; j < ceeg; j++) {
        rghistory[i][j] = 0
{ // configure plot
    plot1.X.Units.text = ""
    plot1.X.Offset.value = -ceeg/2
    plot1.X.Range.value = ceeg
    plot1.Y1.AutoScale.checked = false
    plot1.Y2.AutoScale.checked = false
    plot1.Y3.AutoScale.checked = false
    plot1.Y4.AutoScale.checked = false
    const vmax = 20
    plot1.Y1.Offset.value = -vmax/2
    plot1.Y2.Offset.value = -vmax/2
    plot1.Y3.Offset.value = -vmax/2
    plot1.Y4.Offset.value = -vmax/2
    plot1.Y1.Range.value = vmax
    plot1.Y2.Range.value = vmax
    plot1.Y3.Range.value = vmax
    plot1.Y4.Range.value = vmax
while(wait(0.5)){ // 0.5 second update rate
    var rgmag = Scope1.Channel1.fftmagnitude
    var rghz = Scope1.Channel1.fftfrequency
    var c = rgmag.length
    var rgeeg = [0,0,0,0]
    for(var i = 0; i < c; i++){ // calculate section power
        var hz = rghz[i]
        if(hz<4)        rgeeg[0] += rgmag[i]
        else if(hz<7.5) rgeeg[1] += rgmag[i]
        else if(hz<12)  rgeeg[2] += rgmag[i]
        else if(hz<30)  rgeeg[3] += rgmag[i]
    for(var i = 0; i < neeg; i++){ // shift history arrays
    plot1.Y1.data = rghistory[0] // yellow
    plot1.Y2.data = rghistory[1] // blue
    plot1.Y3.data = rghistory[2] // red
    plot1.Y4.data = rghistory[3] // green


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now