Author Topic: Oscilloscope frequency response correction program  (Read 4122 times)

0 Members and 1 Guest are viewing this topic.

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Oscilloscope frequency response correction program
« on: June 13, 2020, 11:39:21 pm »
Hello,

This project github page:
https://github.com/joaocarvalhoopen/Oscilloscope_frequency_response_correction_program

What is the problem that I am trying to solve?

When you see a signal on the scope, that it is made with components with frequencies of up to 10 % or 20 % of the bandwidth of the scope, the signal will be correctly represented on the scope screen.

But if the signal, although appearing to be a low frequency signal, has some high frequency components in it, along the lower frequency components, all its components will be summed up and generate the final shape of the signal. But those high frequency components will suffer more with two forms of distortion. They will have a lower amplitude (lower volts, greater attenuation) and they will have a greater phase-shift (in time. That means that they will take more time to arrive at the scopes ADC while running along the signal path, when comparing to the lower frequency signal components).


Because all those sinusoids are summed up at the same time instant, when the ADC takes a sample, "a photograph in as instant", if some of them have their peaks and lower parts of the wave with different amplitudes for different frequencies (different attenuations by frequency) and if their peaks and lower parts of the wave are not synchronized in time, the final signal that you will see will not be a very accurate representation of the real signal that you are trying to measure at the tip of the scope probe or the tip of the coaxial cable.


To demonstrate this problem  I made the following experiment.

The same signal is compared in the same oscilloscope, when the frequencies if their components are much lower than the bandwidth of the scope and when they are high when compared to the bandwidth of the scope. To make this test I used the fact that the scope can save a wave form in channel REF_A and that and that the oscilloscope as an option to lower its bandwidth.


Do the following test.

Test with the scope Siglent SDS2104-X Plus or any other scope.

I have a Siglent SDG2042X , so I can generate a fundamental frequency and up until the 16 harmonic in a simple way, so I have generated a fundamental tone of 2 MHz 500mV and some high harmonics of order 8, 9, 10, 11, 12, with 500mV in frequencies of 16MHz, 18 MHz, 20 MHz 22 MHz and 24 MHz, with some phase shift’s for diversity.

I used only the 8 bit mode, then I set to full 580 MHz bandwidth, averaged and recorded in REFA (Green trace in image).

I used only the 8 bit mode also, then I reduced the bandwidth to 20 MHz bandwidth, average and recorded in REFB (Blue trace image).

The scope is triggered on the second channel of the AWG with a lower frequency, so I have no problems with the triggering of this difficult wave forms and have consistent results.

Has you can see, there is a considerable difference in amplitude and phase shift of the different components of the signal, and all components summed up give a very different wave form.

My little procedure would correct this effect from 0 Hz up to 950 Mhz and would give a more correct and real wave form as a result, because each component sinusoidal would be more correct in terms of amplitude and phase. And that is why it needs to have the correct characterization of the scope frequency response in terms of amplitude and phase.

Best regards,
João Carvalho
« Last Edit: June 16, 2020, 11:01:47 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #1 on: June 13, 2020, 11:42:33 pm »
This will try to be a program to correct the effects of the frequency response of a scope in the signal. The main idea is that it should correct the amplitude attenuation and the phase shifts of each frequency in the frequency domain and reconstruct a more correct and real representation of the signal in the time domain.

The majority of the scopes don't have a flat amplitude response, it is an increasing amplitude attenuation with frequency, but each frontend design as it's own curve.
There is also a phase-shift that increases with the increase in frequency. Both are not linear, they are not a simple graph with a straight line.

Don't forget that any signal like for example a slow wave of a person talking wiggling up and down (in the time domain Voltage vs time) can be decomposed into the many sinusoidal functions of different amplitudes, that if summed up at a synchronized instant (time) can recreate the original signal wiggling up and down.
Remember the case of a square wave that is made of the fundamental sinusoidal wave frequency and of greater odd harmonics at higher frequency. But the same general principal of decomposition into sinusoidals is true for any form or shape of signal.

The FFT (Fast Fourier Transform) can separate a time domain signal (Voltage vs time) into a frequency domain signal (amplitude vs frequency and phase vs frequency at the bin central frequencies).

If with a PC program connected to the scope you grab the buffer from the scope, then you can process it on the PC and recreate a more correct (more truth to the real) signal that the sampled signal by the scope, because it will inverting the transfer function of the analog system made by the combined effect of the band limited probe or coaxial cable, analog low noise amplifier anti-aliasing filter and the ADC characteristics.

The bandwidth frequency of a scope ex: 100 MHz (where the signal as a -3dB attenuation), isn't a brick wall, it starts affecting the scope precision well before it's specified value of -3 dB (that's the -3dB point for a 1 Volt real signal that means you will see on the scope only a 0.707 Volts signal if you inject a pure sinusoidal signal). The effects are bigger as you go over the frequency of ex: 100 MHz -3 dB limit and go all the way to the limit were you cannot see the signal because of even greater attenuation ex: 400MHz to 500 MHz for a 1 G sample scope. But you can possibly correct for a 100 MHz scope example in the interval of 0Hz to 400MHz. So the analog frequency response isn't a brick wall (not a step down) at the scope bandwidth limit, but a slow increasing attenuation and phase-shift curve, that deteriorates the signal. Something close related to a low pass filter in terms of amplitude attenuation and phase-shift.   

There are differences between channels of the same scope and naturally between scopes of the same brand, but they are much smaller then between amplitude and phase corrected (complex equalized) and a not corrected one.
For example in an entry level 100 MHz scope from many manufactures, one can see signals even at higher frequencies like 300 MHz or 400 MHz, and because normally they have a 1 Giga Sample / second ADC the Nyquist theoretical frequency limit is the 500 MHz.

The actual limit that you stop to see signal depend of the combination of the signal original amplitude, it depending on the probe bandwidth, on the scope low noise amplifier, on the band limit filter / anti-aliasing filter and the ADC analog characteristics.

But all this can be measured and corrected for.
This is called FDE - Frequency Domain Equalization and is used for example in MIMO WIFI Routers, in SC-FDE (single carrier FDE), in 5G (for equalizing the effects of multi-path reflections), and I think that in OFDM systems.

A continues time varying signal (wiggling voltage) is sampled by the ADC into a discreet buffer of samples equally distant time between them.

1 - This buffer can be obtained by a PC program at least for Siglent, Rigol, Hantek and many others (for example with the lib PyVisa).   

2 - You can make a FFT (ex: Python) of the signal buffer (sequence of real values in the time domain) and obtain the sequence of complex values (in the frequency domain. Normally one uses a window applied to the signal ex: Hanning to change same proprieties of the mapping of from the frequency domain, fatter with vs amplitude vs leakage of other bins, and for removing the discontinuities of the start and finish signal.   

3 - In the frequency domain, you will have each bin with a central frequency and it has a direct method of calculating the corresponding amplitude and the phase for that frequency bin. You can directly make the correction to the amplitude and the phase for each central frequency of each bin. it's a little more complicated for the case that you have a frequency component of the signal in between the FFT bins. The simple approach will generate some error that can be quantified. But that can be mitigated by one of two options, first by having more bins (bigger buffer ex: 1 Meg to 200 Meg), by having zero padding and by choosing a different window function and the second option by making the numerical mapping between the FFT output buffer and measured amplitude attenuation and phase-shift interpolated values for frequencies in ex: 50 MHz increments (ex: for a 1 GHz Nyquist limit) to the input buffer of a signal reconstruction IFFT (inverse FFT). Using a learned function mapping with a Machine Learning method, like for example a Neural Network. The training and test data can be easily automatically generated and it can be designed to be valid for all frequency bin with any valid used range of amplitude attenuation and phase-shifting.  This mapping would only have to be done once for each profile and used for the normal measurements and for each type, Prob_A 100 MHz, Probe_B  200MHz, Coaxial cable and others.

4 - The IFFT (the inverse FFT is applied) and the time domain corrected (complex equalized) signal is reconstructed.

5 - The signal is shown on the PC.

6 - The signal is sent to the REF_A of the scope, via LAN or USB, for comparison against other signals.

For this to happen one needs a way to measure the amplitude attenuation of the scope with a good signal generator like for example a Marconi with an error much lower than the +-3dB. This should be made by a kind soul that would share it in the forum.

One also needs to measure the phase-shift with something like the moded cheap PlutoSDR that can generate signals from 46 MHz up to 1 GHz. The phase shift is calculated between the average off all samples on all it's internal buffer. So, even if it starts coming with a 25 ppm clock an is moded to an 0.5 ppm clock, because the method of detecting the phase-shift (explained in the version 3 post that follows somewhere below) uses the phase shift of the two distant bin centered tones over all the buffer samples. The error is averaged out by the plus and minus change in the error, giving a much more exact value of phase shift. By calculating that after the FFT she gives that averaging to us for free.   

Both this methods can be made for a scope, call it a general or a specific calibration and used for any scope owner with the program.
In the process you can also calibrate the amplitude of PlutoSDR, with the frequency, after calibrating the scope.

I will try to make the open source program generic so that anyone can apply the calibration for any scope, but I will try to do this for the two scopes that I have the 100MHz entry level Rigol DS1104Z (maybe 0 Hz to 300 MHz or 400 MHz) and the Siglent SDS2104X Plus (0 Hz up to 950 Mhz). And maybe, for a friends Rigol DS1052E (50 MHz), a friends Siglent SDS1104X-E 100MHz and other friends Hantek 100 MHz.

Any signal can be affected by this way that the scopes work, it can exist on any signal that is acquired that is apparently a slow signal but that as high frequency content (not only single tone high frequency signals or square waves, steps, or fast impulses), it will be attenuated in same parts and phase shifted in other parts, or more rounded, I give a small example in a scope image in the following posts.

The following are posts were I started thinking about this, from the "Siglent SDS2104X Plus" thread that I moved to this thread.
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg3090482/#msg3090482


Note 1: This is nothing new and is a simple idea that I don't understand why the manufacturers don't do on their entry level scopes. I think that some high end scopes do this inside them in hardware.

Note 2: I created this new thread on recommendation of senior members of the forum.

Thank you.

Best regards,
João Carvalho
« Last Edit: June 17, 2020, 09:06:30 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #2 on: June 13, 2020, 11:53:02 pm »
For the Siglent SDS2000X Plus.

Try the following with an AWG of 120 MHz and the scope.
Turn on Vpp measurements and in the aquire menu, set to 8 bits and for each frequency see both Vpp values for 8 bit’s and 10 bit’s, see the delta.
Manually go from frequencies from 10 MHz to 120 MHz in 10 MHz steps.
What do you see?
Do you see stability in 8 bit mode but an increasing in the delta of 8 bit to 10 bit mode?
Is this increase normal? Is it only explained by the 100MHz -3dB, but if so, it should only have an effect after 50 MHz? Right?

I’m well aware of the -3db at 100 MHz for the 10 bit’s mode I was speaking about it in my post, but I had the perception that it only started to affect the measurement after half the bandwidth 50 MHz.

Knowing that the chip that makes the bandwidth limitation in hardware as a 100 MHz stop value, among others and that it is in the ~180MHz zone for the 100MHz stock scope.  I was hoping that the 10 bit would not be an exact digital filter of 100 MHz, and that it would not start making it’s effect on the accuracy of the measured Vpp of the signal before 50 Mhz, half the bandwidth.   

Because of this mode (I know that there are other, like the 20 MHz and the 200 MHz), we have effetely two scopes inside one to compare.

So I took the following measurements of 1 Vpp at 8 bits and at 10 bits:
10MHz  8: 1.027V – 10: 1.0067V -> delta:  20.3mV
20MHz  8: 1.027V – 10: 1.000V -> delta:  27mV
30MHz 8: 1.031V – 10: 990mV -> delta:  41mV
40MHz 8: 1.033V – 10: 974mV -> delta:  59mV
50MHz 8: 1.030V – 10: 948mV -> delta:  82mV
60MHz 8: 1.031V – 10: 921mV -> delta:  110mV
70MHz 8: 1.032V – 10: 889mV -> delta:  143mV
80MHz 8: 1.028V – 10: 850mV -> delta:  178mV
90MHz 8: 1.029V – 10: 812mV -> delta:  217mV
100MHz 8: 1.025V – 10: 770mV -> delta: 255mV
110MHz 8: 1.032V – 10: 732mV -> delta:  300mV
120MHz 8: 1.030V – 10: 677mV  -> delta:  353mV

Then I measured that it is not flat in the 20 MHz bandwidth limit, I compared the 20 MHz range against the Full bandwidth 550MHz range in this post.
https://www.eevblog.com/forum/testgear/oscilloscope-frequency-response-correction-program/msg3095760/#msg3095760


I have seen the post by TK that shows that the 550 MHz Full bandwidth is flat in this post:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg3088883/#msg3088883

Is measurement were taken with a good Marconi 2024 signal generator.
“10MHz 0dbm loss
100MHz 0dBm loss
200MHz 0dBm loss
500MHz 0dBm loss
550MHz -3dBm
700MHz -6dBm
900MHz -10dBm
1GHz -20dBm or greater attenuation.  Signal not reliably visible at any vertical scale”

I only have means of testing up to 120Mhz with a Siglent AWG and I measured that it is flat on my scope.

So what I am trying to do is to have a way  in this scope model, of correcting on the PC the following:
1 - Correct the 10 bit mode horrible transfer function. (Why do you have a 10 bit mode if the measurements aren’t anything close to the real value?)
2 - Correct the 8 bit mode 20 MHz transfer function.
3 - Correct the 8 bit 200 MHz transfer function.
4 - As a bonus correct the 8 bit full bandwidth mode (550 MHz) transfer function from 0 Hz up to 950 MHz or 1 GHz (if possible).
5 - As a bonus the same program that correct atenuation and phase, do complex equalization, could be configured and used in other scopes brands and models.

For doing this we need full characterization of amplitude attenuation and phase shifts from 0 Hz to 1 GHz in steps of 50 MHz for the full bandwidth (for doing the amplitude part one needs something like a good Marconi signal generator because you need a flat amplitude signal generator at all frequencies as a reference) and for the phase measurements I have been thinking of many different ways to measure it and come to the conclusion that one could do the measurement with a cheap Pluto. As a bonus after a calibrated scope, in the process you would have a amplitude calibrated Pluto signal generator from 50 Mhz up to 1 GHz (it goes more than that but I’m talking of something that could be compared to some degree to the scope range).

I described all steps of the process in details to mitigate the problem for this scope, not only for me but for other owners of this scope.

Note: I compared the same signal in my entry level Rigol of 100 MHz and I could not belieave that the Siglent scope would not be flat in this modes.
I even used a fast sampling Rigol 6.5 multimeter and low frequency signal to compare the signal amplitude.

So I regard this as a problem and I'm trying to find a solution to mitigate it.


The member Tautech posted in the post:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg3095304/#msg3095304

That in the post:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg2787168/#msg2787168

There were a graph with the frequency response from 0 Hz to 1 GHz of the scope taken with a high acuractlly signal generator.

Best regards,
João Carvalho

« Last Edit: June 17, 2020, 09:08:18 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #3 on: June 13, 2020, 11:56:09 pm »
Regarding the differences in amplitude and in phase of the 8 bits in comparison to the 10 bits, that “in spirit” should be similar to a low pass filter, I already measured the amplitude and was trying to measure the phase shift in the range from 10MHz to 120 MHz in 10 MHz steps for the 10 bits.

I was trying to measure the 10Mhz sinusoidal signal zero crossing (triggering on this channel) and changing the other channel on to all the other frequencies to measure the time and then I would have to make some calculations to determine the phase shift in regard to each frequency, but it doesn’t work because my AWG is a DDS. So I don’t know it witch part of the DDS cycle I’m triggering on, they should be only 2 one cycle burst one for each channel but I can’t do that with my AWG from Siglent at 120MHz.
Then I think that there is the single fast step function, from for example a AUT or ACT logical gate, but currently I don’t have the component and it would go in all frequency ranges.

So my question is, how to you measure the phase response of a scope (amplitude is “easy” if you have a signal source, but phase)?

My idea, that I’m sure that can’t be new, because it a very simple idea.

Determine the amplitude frequency response of all scope analog path as one. (probe->low noise amplifier, anti-aliasing filter and ADC analog characteristic) from 0Hz to 1 GHz (half sample rate).

Determine the phase frequency response, the phase shift at each frequency, points in  the middle could be interpolated.

Knowing that each signal that you see at a scope is made of the sum of components at different frequencies and that even an apparent low frequency signal can have high frequency content. The simple example is a square wave, but this applies to any wave form that as different components and some of them are more than ~ 10% of the max scope bandwidth -3dB, and all the way to Nyquist limit. What you see in the as the wave form is always distorted in the sum of several sinusoidal amplitudes and phase.  And it’s effect is easy comparable if you generate a wave form with several content that is between 10MHz and 120MHz or more in the 10 bit’s mode, and compare it to the 8 bit mode. But what I will suggests can be made inclusive for the range between 580MHz and the 1GHz of the top of half the sample rate (Nyquiest). For example at 900 MHz you have a -10db in amplitude and an unknow phase shift at that frequency. So the sum off all wave tops and bottoms aren’t on the same sincronized and correct place, making the resulting wave obviously different. But this procedure in principal could correct a great part of it.

Connect a PC to Siglent, Rigol, Hanteq or any other scope using Python and get the internal buffer content with PyVisa. 100M or 200M points.

Apply window function and do a 100 M or 200 M Point FFT on all the buffer, on all the points.

For each central frequency of the bucket in the FFT, apply the correction given by the correct boast in amplitude (correcting the attenuation) and apply the inverse of the phase shift at each FFT bucket frequency using the table with interpolation for the frequency response of the scope analog system.

Do the inverse FFT for the same number of points.

Show the result corrected in amplitude and phase as a wave form on the PC.

The program load's the Wave form on the Vref so you can analyze on the scope and compare.

In theory any scope could greatly benefit from this simple calculations or program if it could be characterized from 0 Hz to the frequency of half the sample limit.

I have explained this idea to several people and nobody seems to think that it is a good idea, but I really think it is a simple and good idea worth trying. This could be applied to any cheap scope, or any scope for that matter! And the scope frequency response could be characterized by someone with good equipment and publish the result and the program could be used by anyone with only the scope and the program.

But thinking in the other side, I see that scope manufactures don’t do this, so I must have an error of thinking in my simple idea, but I can’t see why it shouldn’t work! I really can't see why!

Never forget that the frequency response of a scope is not a brick wall and it's more like a slowing decaying of signal fidelity in each frequency component, but like I have posted the decaying signal fidelity can start at ~10% of the -3dB of the scope with a 2% in amplitude (I don’t know how to measure scope phase differences, but they also exist) and go all the way to half the maximum sampling rate, but in terms of frequency. In practical terms it would be something like for a 580 MHz -3dB scope, the decaying of signal fidelity would start at 10% 60 MHz or 20% 120MHz and go all the way until almost 950 MHz or 1 GHz. This procedure would not correct everything, but at least it would be more similar to the actually real signal waveform.

Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #4 on: June 14, 2020, 12:00:12 am »
I have test a little more and found that I can make with my AWG a burst of one cycle of a sinusoidal at frequencies up to 120 MHz. It has both channels synchronized so we can make phase shift measures of both channels, especially in the case of a 20 MHz channel limit (used here as an example) because it’s dependent on the channel and not globally to the scope, like the acquisition bit deep 8 bits and 10 bits. The small fixed AWG inter-channel was measured and accounted for, in the data appears as corr (correction) and was of 1.05 nS.
   
But all my measures of phase shift where made comparing Channel 1 with Full Bandwidth with Channel 2 with 20 MHz limited bandwidth.  I used math channels for both real channels with averaging and the phase measures between different bandlimit channel can’t be made with the Measurements menu, they had to be done by hand.
Note: I don’t know why the scope doesn’t permit inter bandwidth limit vs full bandwidth channel measurements.

The amplitude was also measured for the same channel with and without the bandlimit.

The connection between the scope and the AWG was a BNC 50 Ohms coaxial cable.

Please see the image and the excel file for the data.

There are considerable amplitude attenuations and considerable phase shifts as was expected.

The simple idea that I proposed is the correction of this effect and in this case I think that it could give a correction for the 20 MHz band limit of at least up to 40 MHz. In a normal 1 G sample scope the 20 MHz would be the 100 Mhz scope bandwith and the 40 Mhz would be the 500 Mhz Nyquiest limit. You have to use your imagination here :-D Like I said this can be made for any scope, for any bandwith, because it is made against the frequency response of the scope.

I use the 20 MHz band limit as an example and not as the final object, that is to correct for 0 Hz up to 1 GHz (950 MHz), but I don’t have a signal generator capable of hitting those high frequencies, I’m limit to what I have and that is a 40 Mhz Siglent AWG hacked to 120 MHz.

But I think that there is a way to make the phase frequency characterization of up to 1 GHz using a signal generator of a one single channel.
The ideia is that a low frequency sinusoidal signal ex: a 50 Mhz (10 %) for a 580 MHz scope are only really residually affected by a phase shift, and that high frequency signal is highly affected (phase shifted). So we have to find a way to compare the delta in time of the slow frequency wave top to the high frequency phase top, but we have to take out the part that is related to the fact the one wave is faster than the other, so we have to take out 1/4 period of the high freq wave times the frequency ratio between freq_ref_slow and freq_fast. And configure the channel of the fast signal wave to deskew for that delta. The result phase shift will be the real phase shift between the signals of different frequencies.  To better measure use coursers and invert the channel, comparing top Ref_A (slow) to Channel B (fast).   

1 - First get the trigger to the oscilloscope from the trigger output port of the signal generator.

2 – Generate a 50 MHz tone with +13dBm (1.4 V, if you have more then better) in single cycle burst, do average and record it in REF_A.

3 – At all the frequencies in the freq range:

3.1 - Generate a sinusoidal of one cycle in a burst mode.

3.2 – Calculate the time delta for the frequency delta of the number of cycles for the relation between each signal A (REF_A low frequency and not affected by the scope frequency response) and Signal B (at 50 MHz, 100 MHz, 150, 200, …. 900, 950, 1 GHz )1/4  of Wave. Configure the scope channel skew to go backward in time only the number of cycles in the difference between frequencies ex: 50 Mhz to 100 Mhz or 1 GHz.

3.3 – Measure the time delta( then calculate the phase delta difference) difference between the two tops of the two sinusoids.

3.4 - Record the data.
 
Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #5 on: June 14, 2020, 12:04:27 am »
The real scope bandwidth is around the 570 to 580 MHz for 2 channels of the four (anyone of the first pair (1 or 2) and anyone of the second pair (3 or 4)), in this way you will have a 2 G Sample / sec ADC for each channel, and almost a 4 to 1 ratio.

And at 900 MHz you will have a -10dB attenuation on the signal.

I didn’t try high frequencies, because I don’t have any signal source so high, but one forum member said that for a 1 GHz signal at +13dB (1.4 V) sometimes didn’t a appeared reliably, so it sometimes appear, and he said that it must have a -20dB or more attenuation at 1GHz.

What I would like is that someone with a high frequency (1 GHz) and high accuracy single channel signal generator could characterize this scope front end in terms of amplitude and phase the frequency response of the scope. I propose a method a possible method in my previous posts and a reason to do it.

---------

The thing is that the signal generator has to be calibrated and have a small error so you can really on it when you specify that it is giving out a sinusoidal in a burst with a specific amplitude constant on all frequencies and a small error in the phase.

Then with that characterization data you can connect a PC to the scope using LAN or USB and get the signal buffer data, calculate the FFT for high number of points fast. Apply a “scalling factor” to correct the attenuation at each frequency and a phase shift in the opposite direction to correct the phase shift at each frequency. Then do an IFFT and reconstruct the original buffer but corrected for the phase response of the scope from 0 Hz to 950 Mhz. The nice thing is that -2dB, -3dB, -10dB is all the same thing, is just an amplitude correction of each frequency and an equal simple phase correction. But the resulting signal will be more close reconstructed to the reality even when compared with the bandwidth below the -3dB, and that would be nice. But I don’t know why scope manufactures don’t do this simple thing. Maybe I have a really big flaw in my thinking, But OFDM Radios use this all day in modern WIFI routers in equalization for example.   

Best regards,
João Carvalho


« Last Edit: June 17, 2020, 09:09:23 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #6 on: June 14, 2020, 12:05:19 am »
I certainly can be wrong, because I never had a spectrum analyzer with a tracking generator, but for amplitude you could measure the correct amplitude with the spectrum analyzer and then connect to the scope and measure the amplitude attenuation with it. Point-by-point. Then normalize in Excel. But that only solves half of the problem, the “easy part”.

After thinking a little bit about the problem I taught of a simple method for measuring the phase shift of the scope at each frequency. But to get it to work you need a single channel signal generator, with a output clock or output trigger connected to the input trigger of the scope, and the signal generator must generate a single cycle sinusoidal burst. The scope will measure a low frequency signal in REF_A in terms of time delta against a varying high frequency signal. Do some averages, and you must use the coursers to compare the 1/4 wave top’s.  You have to correct for the fact that you are comparing the phase of two different frequency signals. The logic is that the low frequency signal will be residually affected by the scope transfer function when compared to the high frequency signal, so you can use it as a reference for phase measurements.

Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #7 on: June 14, 2020, 12:11:14 am »
Really crazy idea to measure cheaply the phase-shift of the frequency response of the scope from 50MHz to 1 GHz.

I have being thinking about the process of measuring the phase shift with Signal Generators like the Marconi one that exist in second hand. For me they continue to be crazy expensive, so I will not buy one, but I have seen that the majority of them came with only one channel (2 channel are even more expensive) but they don’t have a burst mode and my previous method for measuring needed a burst mode in the signal generator like I have on my AWG generator that is 40 MHz hacked to 120 MHz. That is nowhere near 1 GHz. So for amplitude there are already graph in the forum but one can ask for a kind soul to make a precise amplitude measure with frequency with a real signal generator at +13 dBm or higher. From 0 Hz to 1 GHz in 50 MHz steps, recording the amplitude values of an average.

So the question is how to cheaply measure phase-shift?
And I came up with a plan :-) hehehehe

Using a good and cheap SDR RX and TX (transmitter), the Analog Devices PlutoSDR it costs on Mouser  133 euros. The signal is not high dbm but it has low spurs signal noise. Stock it goes from 325 MHz to 3.8 GHz, 12 bits ADC/DAC full duplex and a 20 MHz instantaneous bandwidth with 50 Ohms output and input. The Pluto SDR (as any SDR with TX) permits you to send a buffer, an array for amplitude values (in I/Q) over its transmitter channel. Its amplitude isn’t level by any means, but its frequency and its phase is really stable and can be even more stable with the following hacks. (keep reading that it will become even more interesting)

What one could to is the following:

A1 – There is a small hack that you can make that in theory make it go from 70 MHz to 6 GHz and it’s really a small hack but in reality it starts transmitting even at 46 MHz up to 6 GHz and the instantaneous bandwidth goes up from 20 MHz to 56 MHz (remember this value). Note: you can also enable the second CPU core inside it (ZynQ).

A2 – It comes with a 25ppm oscillator and you can easily change to a 0.5ppm or better. There are videos on youtube explaining how to do it, just search for “Pluto SDR hack” and “Pluto SDR Oscillator”. You can also do the ground hack.

ABRACON  ASTX-13-C-40.000MHz-I05-T   Oscillator  TCXO 40MHz 1.8V .5ppm -40C +85C

ADALM Pluto TCXO Mod (QO100 ES-Hail2) - more accurate TCXO (Abracon 0.5ppm)



A3- Write a small and simple program in Python with API’s to send repeatedly your own “cooked” buffer values with your signal.

libiio/examples/ad9361-iiostream.c
https://github.com/analogdevicesinc/libiio/blob/master/examples/ad9361-iiostream.c

ADI SDR Adalm Pluto programmatic control via libiio in Windows.


Video of 46 MHz with PlutoSDR.


A little bit of theory so you can understand my thinking and how to “cook” the buffer.

So with the Pluto you can make a single channel arbitrarily wave (you can write offline to the buffer) signal generator for an interval of frequencies of up to 56 MHz that can be shifted over the frequency range from 46 MHz to 6 GHz. And you have a high degree of frequency stability and of phase stability between the samples of the buffer played in sequence, right?

So, knowing this how can you devise a method to determine the phase shift of a scope over a large range of frequencies?

B1 – First you know that in the frequency response, low frequencies (10% of max scope bandwidth) are not significantly attenuated in amplitude and not significantly shifted in frequency, right? So they can be used as base reference, in this case 50 MHz for a 550 MHz scope.

Now to compare inter buffer shifts, you can send a slow frequency quarter wave of say 1 MHz and followed by a faster quarter wave at frequency  51 MHz higher. What you will see in the scope is a less affected wave followed by a more affected wave, right? So you measure the time between the quarter wave tops with coursers and make some calculations to discount the fact that you are comparing waves at different frequencies and find out the phase shift.
The samples for the DAC have to be created in I/Q quadrature in a small Python program, but you can find easily on the web how to calculate I/Q quadrature this from simple sin functions that describe waves. The signal output will appear as a normal sinusoidal.  Record the starting or central frequency ex: 50 MHz and record the frequency of each wave (the slow and the fast) record the delta in time and calculate the phase shift between them in Excel.

B2 – Then repeat the same procedure for the frequencies between 50 MHz and 1 GHz in steps of 50 MHz. And record all the previous values.

B3 – In Excel calculate the accumulated phase shifts between the different frequencies in regard to the lower one of 50 MHz or even better do the measures from 1 MHz to 50 MHz with a normal AWG and add those ones to the beginning of the accumulated phase shift. And you have a characterization of the phase shift of your scope with the frequency

---

C1 - Now join with the measurements of amplitude from a kind soul that as a real signal generator that goes to 1 GHz and you will have the full frequency characterization of the frequency response of the scope.

C2 – Now, as a bonus you can measure the amplitude on the scope of your Pluto TX signal and correct it with the ratio given by the real signal generator and also have a full characterized Pluto SDR signal generator up to 950 MHz or 1 GHz.

Then the software part of this all idea of correcting the frequency response of the scope on the PC from 0 Hz to 950 MHz can be made.

The nice thing is that anyone can test if the idea works by repeating this procedure with an AWG from 0 MHz to 40 MHz and using the 20 MHz band limit of the scope, using the PC correcting program, and comparing the output with the full 550 MHz bandwidth wave form shape. If it is a very similar wave it works if it isn’t it doesn’t work.

With this you can also write a Python program to correct the Pluto SDR to generate a flat signal response from 50 Hz to 1 GHz a flat signal.   
 
Best regards,
João Carvalho
« Last Edit: June 17, 2020, 09:10:38 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #8 on: June 14, 2020, 12:13:20 am »
Hello,

Measuring the phase shift of the response frequency of the scope - Version 3.
 
I was thinking a little bit more about it and there is a better way of doing the phase measurement that can be fully automated and is several times more precise.

In the previous way I used cursors because the scope doesn’t do the measurements between different frequency waves, and not between different channels with different band limits and not between different bit deeps (8 bits vs 10 bits).

But if you use the “magic of FFT” you can do it and with even more precision in the phase and amplitude measurement, taking into account all the wave length, all the wave points :-D

1 - The process is equal to the previous but instead of generating a slow quarter wave followed by a fast quarter wave and measuring the inter-wave tops and correcting for the fact that one wave is faster than the other. Because the fast one, would be more affected by a phase shift than the slow one.

2 - I propose that we generate for the buffer 2 sinewaves at frequencies of 1 MHz and 51 MHz corrected infrequency to be exactly centered in the FFT bins of the nearest frequency bin, this will limit leakage. Obtain a single value for each sample by add those two frequencies mathematically. Then we encode it in I/Q quadrature for the buffer. Fill the buffer and send it to the Pluto SDR. So we automate this process of generating the buffer for each freq. range ex: 50 MHz, the sending of the buffer to the Pluto SDR and the start transmitting of the buffer. The buffer will cycle; when it ends it will start on the first sample.

3 – In the scope, we automate the fetching the buffer of the capture sequence for a long sequence, so we have a much lower noise because the phase shift will be average between many points and not only two wave tops.

4 – In processing we apply a Hanning window for example and do big a FFT(window(signal buffer)), you will have two tones, that are centered on two bins corresponding two the two bins of the different frequencies. Then you calculate the phase shift of this two signals in regard to the beginning of the buffer that is triggered on an amplitude, but better than this you see the difference in phases between the samples (corrected for the fact that you are comparing different frequencies) directly from the FFT calculation of phase for each signal and because you set it to zero on the Pluto I/Q buffer. So you can measure it easily on the PC from the scope buffer data.

5 – The program would repeat the process for the all the range from 50 MHz to 1 GHz and acumulate all the phase shift's at different frequencies.

This will give an automated phase shift measurement in a small time maybe 5 minutes, and because after the procedure of obtaining the scope amplitude general calibration, you will also have the characterization from the kind soul that as a real signal generator. You will have the Pluto calibrated for the amplitude at each frequency (by comparing to the corrected scope value) and can use the Pluto in a fully automated to measure with high precision given by the FFT method (like an average in the buffer of each of the phase shifts between the fast and the slow sinusoidal component).

So you can add to the final program, that does the correct reconstruction of the signal, easily, a calibration for probe A  100 MHz, for probe B 200 MHz, probe C 300 MHz, probe D 500 MHz, Coaxial cable, SMA cable, the all glory of all the interconnects, band limits and bit deeps.

Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #9 on: June 14, 2020, 12:16:09 am »
Just a quick note,

What I have being describing here about inverting the effect of the response in amplitude and in phase of the scope to recreate a more real signal on the PC from the data of the scope (connected by USB or LAN) is nothing new.
It is simply FDE – Frequency Domain Equalization and is used in MIMO Wifi routers, ODFM and 5G, it is not new. Normally the name that is given is SC-FDE (single carrier FDE).

But I don’t know why it isn’t applied in real time in cheap scopes on the FPGA, because if you can calibrate it, it should work fine, and correct the signal from 10% or 20% of the bandwidth of the scope all the way to the scope limit (and not only the -3dB point). This will be given by the quality of the probe and frontend, the anti-aliasing low pass filter in front of the ADC, and last but not least by the sampling frequency, that in a 100 MHz scope is normally 1 G sample /sec with a Nyquist limit of 500 MHz.

I have found this video that explains FDE in a simple way.
Just imagine, that as input and output, instead of a continue math function you have a memory buffer, a simple 1D array of with sampled values.

Frequency domain – tutorial 11: equalization



In MIMO WIFI or 5G you have to equalize different paths and different antenna channels (multipath reflections) and you will have a dynamic system because there can be movement between the WIDFI router and the person with the mobile phone. In the case of a scope, is a static system and what we will be inverting is the influence of the scope on the signal and it is always the same for a specific frequency in amplitude and in phase-shift.

Just as a curiosity, the high frequency scope probes are high cost, right?

But if you see the book

High-Speed Digital Design – A handbook of Black Magic
By Johnson and Graham

On page 98 to 101, you have the description of how to make a probe from a 6 ft of ordinary 50 Ohms coax cable that as a fantastic raise time of 206ps, they study it in detail. But like David Johns said in one video about probes, the problem is that its frequency response is all over the place. So depending on the frequency it would have different attenuation and different phase shifts that don’t follow a predictive trend.
But that is precisely what the simple method of applying FDE to a scope would correct.
So in theory you could use cheap home-made fast probes from ordinary 50 Ohms coaxial cable.
 
Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #10 on: June 14, 2020, 12:34:03 am »
The member Tautech posted in the post:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg3095304/#msg3095304

That in the post:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg2787168/#msg2787168

There were a graph with the frequency response from 0 Hz to 1 GHz of the scope taken with a high acuracy signal generator.

Best regards,
João Carvalho
« Last Edit: June 14, 2020, 01:26:43 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #11 on: June 14, 2020, 12:35:04 am »
Thank you very much tautech,

I have read literally, all the posts of this thread in a long long night without sleep and that was the reason I bought this scope.

I didn’t remember that a FFT graph in the range from 0 Hz to 1 GHz for this scope, taken with a high precision signal generator was in one of the posts.

With that I can now start doing my “homework”!
Buy the PlutoSDR and do my part by writing all the needed code for Pluto to generate the “cooked” waveforms, for connecting to the scope to retrieve the data, for the final program and for the mathematical validation of the code of the FDE – Frequency Domain Equalizer.

When the open source program is finished, I will post a link for it here to the github project and try to validate all the procedure and results with the lower bandwidth of 20 MHz 8 bits (up to 40 MHz) and up to 120MHz in the 10 bit mode. If that works, the community can then confirm if it works well, all the way up to 950 MHz. My target platforms will be Linux and Windows, but it will be made in Python and maybe a bit of C so in principal it will also work for MAC.

Thank you very much, the ball and the hot plate is on my side now.   

Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #12 on: June 14, 2020, 07:17:21 am »
Tautech posted a very interesting link that is relevant to this thread topic about probe attenuation and matching to scope with some interesting graphs.

See:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg3095880/#msg3095880

The link to post,with graphs that it points to is:
https://www.eevblog.com/forum/testgear/siglent-sds1104x-e-in-depth-review/msg1434665/#msg1434665

Best regards,
João Carvalho
 
The following users thanked this post: Martin72

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #13 on: June 16, 2020, 01:36:05 am »
For the scope Siglent SDS2000X Plus, regarding this thread project, I made an open source Python program to extract an amplitude attenuation CSV table file with all the data points from the PNG image of the FFT attenuation plot. The scope  screenshoot was taken by EEVBlog member  Performa01 with an RF Signal Generator, and I think that it is a very accurate signal generator.

The image was posted here:
https://www.eevblog.com/forum/testgear/siglent-sds2000x-plus-coming/msg2787168/#msg2787168
 
The program extraction is also very accurate, I explain it and show exactly that, in the github page of the project:
https://github.com/joaocarvalhoopen/Oscilloscope_frequency_response_correction_program

It uses interpolation to get the “Inter-pixel” point value and I extracted 3 table CSV files.
-Attenuation data extracted directly from the image with the range 0 Hz to 1 GHz (no interpolation).
-Attenuation data interpolated from 0 Hz to 1 GHz in steps of 10 MHz.
-Attenuation data interpolated from 0 Hz to 1 GHz in steps of 1MHz.
https://github.com/joaocarvalhoopen/Oscilloscope_frequency_response_correction_program/tree/master/Siglent_SDS2104_Plus/Extract_attenuation_values_from_scope_FFT_image/output_out

For example for the 570 MHz with  -2.99 dBV mark . The data isn´t even on the image plot line because the wide marker is over it, but I have extracted automatically all the points including the point to the left and to the right of the marker and the result was:
Measured by the scope in text in the image................: 570 MHz ->  -2.99 dBV
Extracted from pixels and interpolated by my program : 570 MHz ->  -2.9725 dBV
.........................................................................Error:......................0.0275 dBV

The program work by searching a list of zones, in this case only two zones were needed to extract all the points.

Feel free to use it to extract other FFT plots for the Siglent, the license is MIT open source license.

The code file is this:
https://github.com/joaocarvalhoopen/Oscilloscope_frequency_response_correction_program/blob/master/Siglent_SDS2104_Plus/Extract_attenuation_values_from_scope_FFT_image/extract_attenuation_values_from_scope_fft_image.py   

Tip:
Keep an eye on this project github because I will continue to post there the code that I am making.

Best regards,
João Carvalho
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #14 on: June 18, 2020, 09:55:57 am »
Hello,

The central component of this project is the complex equalization of the input signal converted from the time domain to the frequency domain.  What I said that will make the correction or the process of revert the natural effect of distortion in the scope path on the signal and try to obtain a more real representation of the original signal.

To do this you need the “powers” of the FFT – Fast Fourier Transform.
I would like to give here some links and info so that all can follow the concepts for this project journey as it is being made.

Note: I know that the majority of you know much more about Systems and Signals, about DSP – Digital Signal Processing, about Control Theory that I could even dream off knowing. But for the ones that know less than me or for the ones that want to refresh their knowledge, I have put here what I think are nice pointers and nice sources of info about FFT and DSP in general.

Start with this nice video about FFT:
Discrete Fourier Transform - Simple Step by Step




Then see the following video from 3Blue1Brown:
But what is the Fourier Transform? A visual introduction.




Then see the following youtube play list about the FFT Transform, there are really good videos on here, they are well worth your time:




And if you want to go deeper see the following Fourier Analysis 36 videos list from Steve Brunton.




Then hit the books …… there are three books that I highly recommend, specially the first one, and they are all well worth reading:

1 - Understanding Digital Signal Processing 3rd Edition
      by Richard G. Lyons

2 - Digital Signal Processing in Modern Communication Systems
      by Andreas Schwarzinger

3 – The Fast Fourier Transform FFT and its applications
      By E. Oran Brigham

And there are five free DSP book authors and they also cover the FFT very well:

1 - The Scientist & Engineer's Guide to Digital Signal Processing
by Steven W. Smith
http://www.dspguide.com/

2 - Introduction to Signal Processing
by Sophocles J. Orfanidis
https://www.ece.rutgers.edu/~orfanidi/intro2sp/

3 - Mathematics of the discrete Fourier transform (DFT) with audio applications, Second edition
by Julius O. Smith III
https://ccrma.stanford.edu/~jos/mdft/

4 - Introduction to digital filters with audio applications
by Julius O. Smith III
https://ccrma.stanford.edu/~jos/filters/

5 - Spectral audio signal processing
by Julius O. Smith III
https://ccrma.stanford.edu/~jos/sasp/

Note: The last three should be read by the order they are listed.

Thank you,

Best regards,
João Carvalho
« Last Edit: July 05, 2020, 10:19:33 pm by Joao Carvalho »
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3256
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #15 on: June 18, 2020, 10:17:08 am »
João,

In the end can your program give a "rating" of how much correction does it need to apply to one scope?  (Don't know what I'm talking about... :) )

What I mean: if one could compare 2 scopes to see which has a greater fidelity in representing the "true" signal? (and give them a João Carvalho's "fidelity rating" :) )
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #16 on: June 18, 2020, 10:56:39 am »
Hello TV84,

For the program to work, we need to have the attenuation and the phase-shift frequency response (for each frequency) of the specified scope model.
Those two curves alone will be the real measure of fidelity of a scope to the real signal that it’s being measured. And that as nothing to do with my program, if one have the equipment one can measure it.

But, if there were many accurate and independent community measurements [for example with the stock probe or a “standard” coaxial cable], one could also put a number on the variance. That means a number quantifying the spread from those curves for a particular model (and between channels). That could also be a sign of fidelity and that could be measured over time to determine the effect on aging on the curve spread.
 
But in terms of a fidelity rating number, out of my head, one could imagine to make a sum of the RMS of differences in amplitude and phase at each frequency divided into three separate ratings:

1 -  One for the range from 0 Hz up to manufacturer labeled bandwidth in MHz.

2 -  One for the range from the manufacturer labeled bandwidth in MHz up to max effective bandwidth (that can be used by the correction program in an 8 bit ADC, it will be a threshold in dBV).

3 -  One for the full range from 0Hz up to max effective bandwidth that can be effectively used by the program.

Best regards,
João Carvalho
« Last Edit: June 18, 2020, 11:02:54 am by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #17 on: June 21, 2020, 07:11:08 am »
A method of doing the Complex Equalization applied to the scope data buffer.


Objective:

The frequency response of a scope (attenuation and phase-shift in frequency that can be seen in the two parts Bode Plot) affects / modifies / transforms the real analog signal at the tip of the scope probe during its analog path up to the sampling location inside de 8 bit ADC.

Our objective here is to reverse the modifications or transformations in the PC with mathematics inside a program and reconstruct the real signal on the screen of the PC.

One could do this, only for the 0 HZ up to the scope -3 dB corresponding frequency, but why stop there?
There is no difference for a 100 MHz scope for doing this from 0 to 100 Hz, then doing it from 0 Hz up to the limit where the signal disappears  ... that is 300 MHz or 400 MHz (the theoretical limit would be 500 MHz for a 1 Gig Sample / sec  ADC.  But normally you couldn't reach that far, although some scopes like this Siglent that have a 2 G sample / sec ADC, so a  1 GHz Nyquist limit, they appears that we could do this all the way up to 950 MHz).

This would produce a flat frequency response in terms of amplitude and phase-shift.

How would we implement this?

Steps to implement this:

A - Characterize the scope model frequency response in terms of attenuation and phase-shift for each frequency ex: 50 MHz steps. But it could be less. Produce a table, for amplitude use the method of FFT on the scope and the program of this project, for the phase shift use the idea talked about in a previous message post Version 3.

Freq. | -dBV | phase-shift in degree or radians

B - With the table that for each frequency we make a function, that do a interpolation, that can give a good approximation for amplitude and phase shift for each exacta needed frequency by the input of the IFFT (Inverse Fast Fourier Transform), given the measured points.

Interpolate( table, freq )

C - From the frequency response table in the frequency domain convert to the impulse response in the time domain.
Change the sign of each value, if it is negative change to positive and vice versa.
With the complex magnitude equation and phase equation generate the complex representation of the value point.
 
Impulse response h(x) = IFFT( complex ( - frequency response) )

Note: That is, depending on the number of points of the buffer that is convenient (we have to try some values and test its error, one could also do some zero padding) in to make the invert FFT. With the values that we get from the interpolation function of the attenuation and phase-shift, we obtain and fill each complex value of the input buffer of frequency domain to the IFFT.

D - The impulse response samples are the way that for example a room response to an impulse (an infinitely high amplitude and infinitely narrow impulse) saved in a buffer with a microphone. That in the real world can be a gun powder shoot that is recorded, made by an acoustic engineer to characterize the room. What we are looking for is how the room shapes or change the sound of the impulse made inside that room, its impulse response.

E - With the recorded impulse response (we can call it h(x), but it's a simple buffer with samples in the time domain, volts vs time) we can convolve it in the time domain (make a mathematical operation called convolution) with any sound. For example a piano playing some music with out echoes, and the output would be the sound of the piano as it would sound if it was inside that room. Imagine for a moment that you could play a piano at home and hear in the phones the sound of your piano playing inside a great historical concert room.

F - We will do exactly that but with the impulse response of the inverted sign of the frequency response to invert it's effects, and that will make the oscilloscope inverse transformation that the analog part of the scope is doing on the signal, It will reconstruct the original signal that was at the tip of the probe.

This would be equivalent, with the room analogy, if the piano playing in an anechoic chamber (a chamber without echoes) being the signal at the tip of the probe, the signal affected by the room that makes the piano sound that one can record on the room, as the scope ADC sample value that we see in the scope screen.  And with this convolution of the impulse response of the inverse sign of the frequency response we would get the sound of the original clean piano inside the chamber, like it would sound on an anechoic room, without echoes.

Impulse response h(x) = IFFT(- complex frequency response )
Original Signal at the probe tip = convolution( Signal Buffer given by scope ADC, Impulse response h(x) )


G - Just as general knowledge there is a simple operation that is the correspondent, in the frequency domain to the convolution time domain. That is a simple multiplication.

Convolution(A,B) = FFT(A) * FFT(B)

The implementation of the convolution in the frequency domain for high point counts is more efficient and is called Fast Convolution.

Important note: From my little research to achieve our objective the convolution will be the most precise way of doing this, but I have found another way of doing this in high speed (low CPU resources) with the design and creation of a precise fine-tuned FIR filter. To see this method explained please see the book:

Streamlining Digital Signal Processing, Second Edition
A Tricks of the trade guidebook.
edited by Richard G. Lyons

On page 59, chapter 7 – Precise Filter Design  by Greg Berchin.
There you have a really nice and simple method of designing a filter to match any frequency response you would like, for this propose you just have to match de time -1 of the frequency response. But this method is not as precise as the method of the convolution, and with the PC CPU we have the power to do it.

If you don’t have the book, see the following thesis of this FIR design method creator.

G. Berchin, “A New Algorithm for System Identification from Frequency Response Information.” Master’s Thesis, University of California- Davis, 1988
   
Best regards,
Joao Carvalho
« Last Edit: June 21, 2020, 08:05:04 am by Joao Carvalho »
 

Offline 2N3055

  • Super Contributor
  • ***
  • Posts: 6981
  • Country: hr
Re: Oscilloscope frequency response correction program
« Reply #18 on: June 21, 2020, 09:01:53 am »
Maybe of interest:
https://nvlpubs.nist.gov/nistpubs/jres/122/jres.122.035.pdf

Also a book:
Kluwer international series in engineering and computer science : Dominique Dallet, Jose Machado da Silva - Dynamic Characterisation of Analogue-to-Digital Converters
 
The following users thanked this post: Joao Carvalho, gf

Offline gf

  • Super Contributor
  • ***
  • Posts: 1302
  • Country: de
Re: Oscilloscope frequency response correction program
« Reply #19 on: June 21, 2020, 11:30:12 am »
In order to undo the effect of the frequency response, you would need to divide by the (complex) frequency response (or multiply with the inverse frequency response) in the frequency domain. In the time domain, this corresponds to a deconvolution by the impulse response. This can be an ill-posed inverse problem if the frequency response is not invertible at some frequencies, but also in the presence of noise. So only an approximate solution may be feasible. Furthermore, particularly for a scope (which is primarily supposed to display the waveform) it is IMO very important to ensure that an optimization of the frequency response does not end up in time domain artifacts (e.g. ringing), eventually.

EDIT: Also keep in mind that boosting high frequences also boosts the noise present in the hight frequency bands, so the corrected signal is supposed to be (possibly even much) noisier than the uncorrected one.
« Last Edit: June 21, 2020, 12:01:37 pm by gf »
 
The following users thanked this post: Joao Carvalho

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #20 on: June 21, 2020, 12:37:41 pm »
Hello,

thanks 2N3055 and gf for both posts!

As gf said, we can also have the 3º option, in the frequency domain, we can divide the FFT(Signal) by the complex frequency response and that also corresponds to the deconvolution of the impulse response. Then do the IFFT() and to reconstruct the signal.

In what referers to the part that gf writes, “This can be an ill-posed inverse problem if the frequency response is not invertible at some frequencies, but also in the presence of noise.”, I have to look better at the ill-posed inverse problem case, and see why it happens and what are the conditions that will cause it to happen.

But the nice thing about those methods is that I can generate almost infinite test data for different cases. And even for large number of random curve variations of the same type, and also add noise. That will allow testing the procedure very thoroughly to try to make all the problems and bugs appear, quantify the error and I hope to identify the corner cases, with that decide on the next directions that I should tale to address them.

Then gf also said, “ …it is IMO very important to ensure that an optimization of the frequency response does not end up in time domain artifacts (e.g. ringing), eventually.” and that is another ball park that I have also to address with tests because that is Gibbs phenomena problem in the context of FFT.
See the following video.

Fourier Series and Gibbs Phenomena by Steve Brunton




Best regards,
Joao Carvalho
« Last Edit: June 21, 2020, 04:59:44 pm by Joao Carvalho »
 

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #21 on: June 21, 2020, 01:50:07 pm »
Hello,

In response to what gt posted in is EDIT about the increase in the signal noise:
”EDIT: Also keep in mind that boosting high frequencies also boosts the noise present in the high frequency bands, so the corrected signal is supposed to be (possibly even much) noisier than the uncorrected one.

There will be at least, two types of noise that will be added to the signal:

The fact that it’s something normal that if you have a larger bandwidth (ex: from 20 MHz to 550 MHz) you will have more noise in the measured signal because of the contribution to the noise present in the high frequencies. Larger bandwidth causes larger noise.

But also for another reason, in the last frequency, the worst case, the other are better, you have for a 945 MHz the following attenuations (for more information please see the tables that I have created at: ):
https://github.com/joaocarvalhoopen/Oscilloscope_frequency_response_correction_program/tree/master/Siglent_SDS2104_Plus/Extract_attenuation_values_from_scope_FFT_image/output_out

900.46 MHz   -11.87 dBV   0.2548 Volts scale factor
................        ....................               ..................
944.96 MHz   -13.77 dBV   0.2048 Volts scale factor

This error, is the error caused by the sampling of the ADC for a 8 bit, 256 points resolutions over a 1 Volt scale that samples a signal component of only 0.2048 Volts value and then it is scaled up in the processing to 1Volt. This will also introduce some error.  The 8 bit ADC error would be increased 4 to 5 times for the range from 900 MHz to 950 MHz components of the signal.

But the nice thing is that you can test for all of that and you will always have the screen of the scope to see Siglent’s original bandwidth without correction and for the members that have a better scope (for example a 1 GHz or 1.5 GHz scope) can always compare with it. And the members that have access to a 1 GHZ RF Signal Generator can also always compare it and test it.

The different profile calibration data will be in separate files that are read by the program so you could always put your own different cases …..  different scopes, different probes and different coaxial cable calibration in the program, because it will just be a different frequency response profile that will be corrected.

Note: There is also always the possibility to show in the PC the original signal from the scope buffer (uncorrected) and the corrected frequency response signal and compare the two, in the same way that you normally compare two different channels. This would not be different in any way of having a channel 1 and a math channel calculated from channel 1.

Best regards,
Joao Carvalho
« Last Edit: June 21, 2020, 01:52:20 pm by Joao Carvalho »
 

Offline gf

  • Super Contributor
  • ***
  • Posts: 1302
  • Country: de
Re: Oscilloscope frequency response correction program
« Reply #22 on: June 21, 2020, 04:33:13 pm »
One method to deconvolve noisy data is Wiener deconvolution (https://en.wikipedia.org/wiki/Wiener_deconvolution). Yet another one is the Richardson–Lucy algorithm. In the literature you'll find several others, too.
 
The following users thanked this post: Joao Carvalho

Offline Joao CarvalhoTopic starter

  • Contributor
  • Posts: 39
  • Country: pt
Re: Oscilloscope frequency response correction program
« Reply #23 on: July 05, 2020, 09:17:57 pm »
Hello,

I programed 9 python test signal generators to use in the testes of the code (DSP processing algorithms) in this project that connects to the oscilloscope.
I have given it, a separate small repository because they are generic, and there you can see the plots of the function and the FFT spectrogram of each function. The idea is not to use the python program directly, but it was a program to develop those functions and to then use the function on any project that I or others wish.

Test signal generators
https://github.com/joaocarvalhoopen/Test_signal_generators

Best regards,
Joao Carvalho
 

Offline Weston

  • Regular Contributor
  • *
  • Posts: 218
  • Country: us
Re: Oscilloscope frequency response correction program
« Reply #24 on: July 06, 2020, 10:25:12 pm »
Cool project!

One thing to think about is that the frequency response of an oscilloscope probe depends on the load impedance. For the inductance of a spring clip + typical probe capacitance the resistance for critical damping is ~ 50 ohms (This is just something I have calculated and measured, I don't think it really relates to 50 ohm transmission lines being standard). Additionally, the probe capacitance loads the circuit.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf