Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oscilloscope FFT: Erratic Behavior #1532

Open
NanoExplorer opened this issue Jan 25, 2024 · 1 comment
Open

Oscilloscope FFT: Erratic Behavior #1532

NanoExplorer opened this issue Jan 25, 2024 · 1 comment
Labels

Comments

@NanoExplorer
Copy link

Environment:

  • OS: Mac 14.2.1
  • FW Version: 0.32
  • SW Version: 1.4.1-f4beeb1

Describe the bug
When viewing the oscilloscope with FFT selected, changing the time configuration or memory depth for the oscilloscope display affects the FFT panel in strange and unexpected ways.

To Reproduce
Steps to reproduce the behavior:

  1. I attached a random antenna to the oscilloscope probe via the BNC converter board. It easily picks up 60 Hz from the electricity mains.
  2. Open Oscilloscope and enable FFT in 'general settings'
  3. Set Time Base to 50 ms
  4. Click Run.
  5. 60 Hz waveform is shown on both ch1 and ch2, and both FFT channels show 60 Hz signal with harmonics at n*60 Hz. This is the expected behavior. See Fig. 1.
  6. Click + in time base selector to change base time to 100 ms. Now, FFT panel is frozen. Oscilloscope panel updates more slowly as expected, but FFT panel does not update.
  7. Change time base back to 50, then to 20, by clicking '-' twice.
  8. Now, FFT panel shows a vastly different spectrum, with peaks at 120 Hz and harmonics, with 60 Hz peaks and odd harmonics missing, even though the periodicity in the main oscilloscope panel is still showing a clear 60 hz periodicity. See Fig. 2.
  9. Change memory depth. If it is set to anything other than the lowest value, the FFT appears to only show noise. See Fig. 3

Expected behavior
FFT panel should not be this dependent on probe settings. Of course there will be issues such as aliasing at extreme probe settings, but here that is not the case.

Screenshots
Figure 1: 60 Hz wave with FFT showing peaks at 60 Hz and its harmonics.
image

Figure 2: 60 Hz wave with FFT showing no peaks at 60 Hz or its odd harmonics.
image

Figure 3: 60 Hz wave with high memory depth and FFT showing only noise.
image

Additional context
ini file: https://gist.github.com/NanoExplorer/dfbb60c1112eb3026c9360ec92be52fb
Sometimes the expected spectrum shows for a couple times after changing the time base, but it eventually goes back to the behavior I describe after a couple more changes. Or other strange things will happen, such as the primary harmonic becoming 15 Hz or 30 Hz depending on time base. Using the spectrum analyzer clearly shows no signal at these 15 Hz harmonics, but does show peaks at 60 Hz and its harmonics.

@NanoExplorer
Copy link
Author

NanoExplorer commented Jan 25, 2024

This could be the problem. In the function below, the x axis scale is only updated if the force parameter is true or the sample rate has changed. In my case I was probably triggering this function with the same sample rate and without force.

scopy/src/oscilloscope.cpp

Lines 2935 to 2945 in d23b5e2

void Oscilloscope::setFFT_params(bool force)
{
if(fft_plot.sampleRate() != getSampleRate() || force) {
fft_plot.setSampleRate(getSampleRate(), 1, "");
double start = 0;
double stop = getSampleRate() / 2;
fft_plot.setAxisScale(QwtAxis::XBottom, start, stop);
fft_plot.setAxisScale(QwtAxis::YLeft, -200, 0, 10);
fft_plot.zoomBaseUpdate();
}
}

The function is probably being called from here:

setFFT_params();

I might see if I can try getting the source code to compile so I can change this and test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant