Author Topic: Rigol DHO914S Bode plot  (Read 83726 times)

0 Members and 3 Guests are viewing this topic.

Online mawyatt

  • Super Contributor
  • ***
  • Posts: 6089
  • Country: us
Re: Rigol DHO914S Bode plot
« Reply #200 on: December 06, 2024, 02:31:58 pm »
He's talking about extreme cases.

Nope!!

To the best of our knowledge all "Quality" Frequency Response Analyzers (Bode Plot Functions) employ some form of correlated sampling and/or stimulus frequency filtering to mitigate unwanted outside influences which include simple noise. Even the Analog Discovery AD2 does this :-+

Since the FRA or Bode Function has the driving stimulus source available, why not use this for some form of correlation & filtering which pays huge dividends in signal processing and measurement fidelity.

Guess if your interest is limited to single pole RC filters and such maybe this isn't important, but some folks are looking into popular SMPS use which we wouldn't consider "Extreme"  ;)

Best
Curiosity killed the cat, also depleted my wallet!
~Wyatt Labs by Mike~
 
The following users thanked this post: gf

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #201 on: December 06, 2024, 02:55:46 pm »
Creating the Quality Bode is a long way to go. In order to start people have to master basic prerequisites (a lot of them).
After the primitive version with capturing Vpp and phase will work (off the 800/900 with an external generator), the next step is to implement more demanding process.
It has none sense to start with a complicated stuff at this stage, as there is nothing done yet except posting ideas..
« Last Edit: December 06, 2024, 02:57:23 pm by iMo »
Readers discretion is advised..
 
The following users thanked this post: Fungus

Offline TimFoxTopic starter

  • Super Contributor
  • ***
  • Posts: 11901
  • Country: us
  • Retired, now restoring antique test equipment
Re: Rigol DHO914S Bode plot
« Reply #202 on: December 06, 2024, 02:57:46 pm »
That could be done, but it would return sub-par results as explained by mawyatt above.

He's talking about extreme cases.
TimFox has said they're OK and the real problem is in settling time.  :-//
Either way, they're a easy way to kickstart the coding and to experiment with.

You can't say that "these functions are ok" -- whether they are adequate will depend totally on the measurement conditions.

In a perfect world without background noise they will work; in many real-world scenarios they won't. Note that the output from the DUT can become a rather low-level signal outside of its passband, while any mains hum, switching-power-supply interference etc. will stay at a constant level during the scan. You don't want your amplitude and phase measurements to respond to these.

But I agree that it should be straightforward to experiment with these -- just write a Python script which talks to your signal generator and your scope, drives the frequency sweep and captures measurements from the scope.

I said that the magnitude and phase measurements seem to work, if one allows sufficient settling time.
The Bode plot function as supplied "compiles, didn't it?" and gives a graph, but it is very inaccurate even for a simple one-pole low-pass filter in the audio range.
 
The following users thanked this post: ebastler

Offline mrisco

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: pe
    • Github Profile
Re: Rigol DHO914S Bode plot
« Reply #203 on: December 06, 2024, 04:43:05 pm »
SCPI command to request data:
Code: [Select]
MEASure:STATistic:ITEM? AVER,RRPHase,CHAN1,CHAN2

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #204 on: December 06, 2024, 07:41:37 pm »
FYI - the DS1062CA HP3310b experiment..
Mag +0.7db off and the phase is spot on..
Interestingly the scpi (here the jupyter notebook in win7) returns more digits than on the display..
« Last Edit: December 06, 2024, 08:06:14 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #205 on: December 07, 2024, 11:29:35 am »
I said that the magnitude and phase measurements seem to work, if one allows sufficient settling time.

In any case, sufficient dwell time must be allowed for each frequency point. While the settling time of the generator and detector may be predictable, the settling time of the DUT is unknown. So the dwell may need to be configurable (or it must be estimated, which adds to the complexity the procedure).
« Last Edit: December 07, 2024, 09:37:52 pm by gf »
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #206 on: December 07, 2024, 02:07:49 pm »
Maybe Rigol has implemented that properly in their built-in Bode plot on the DHO900S, maybe not. But I think it will be impossible to make a DHO800 do it properly via its onboard measurement and filtering options. The bandpass filters available in the Math menu are far too wide. -- Hmm, maybe one can cobble a Math function together which correlates and averages the CH1 and CH2 signals in a suitable way? But off the cuff I don't see how.

I also don't see that built-in measurements are suitable.

If you have the samples of the two traces, then a frequency-selective detector is not very difficult, e.g. like this (just drafted from the scratch, not tested, so please forgive any errors). The provided window function and number of samples determine the shape and RBW of the bandpass filter. I'd use a window function with low side lobes / high stop band attenuation, say 100dB, maybe even more.

[ EDIT: For example, a Kaiser window with beta=16 gives you more than 120dB stop band attenuation, and a RBW-3dB of about 2.18*fs/num_samples, where fs is the sample rate. ]

The sin/cos (cexp) evaluation for each sample is of course computationally expensive. Since exp(x*k) = exp(x*(k-1))*exp(x), a less expensive, recursive calculation is possible, but you must take care of numerical error accumulation when you apply it to a large number of samples.
« Last Edit: December 07, 2024, 02:27:51 pm by gf »
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #207 on: December 08, 2024, 10:26:57 am »
In the meantime I've quickly assembled a python stuff such I can get data off my vintage DS1062CA and perform a "primitive" version of myBode..
The script does "Auto", waits couple of secs and performs say 100 measurements and uses the averages for Mag and Phase then.
What I've learned so far - with the Magnitude with averaging I get stable 3 digits, but there is an issue with Phase - after "Auto" the scope often returns the "delay between CH1 and CH2 rising edges" shifted by a period, thus you get a 360deg shift. Also with smaller phase differences it returns strings like "<20us" (based on the time scale).
But the CH1 and CH2 waveforms are downloaded as well and ready for some math..
Readers discretion is advised..
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #208 on: December 08, 2024, 11:25:20 am »

I also don't see that built-in measurements are suitable.

If you have the samples of the two traces, then a frequency-selective detector is not very difficult, e.g. like this (just drafted from the scratch, not tested, so please forgive any errors). The provided window function and number of samples determine the shape and RBW of the bandpass filter. I'd use a window function with low side lobes / high stop band attenuation, say 100dB, maybe even more.

[ EDIT: For example, a Kaiser window with beta=16 gives you more than 120dB stop band attenuation, and a RBW-3dB of about 2.18*fs/num_samples, where fs is the sample rate. ]

The sin/cos (cexp) evaluation for each sample is of course computationally expensive. Since exp(x*k) = exp(x*(k-1))*exp(x), a less expensive, recursive calculation is possible, but you must take care of numerical error accumulation when you apply it to a large number of samples.

Perhaps this will work?:

Code: [Select]
vin = complex(0)
vout = complex(0)
ts = 1.0 / SAMPRATE
k = len(data1)

wink = signal.windows.kaiser(k, beta=5, sym=True)

for i in range(0, k-1):
    vin = vin + data1.astype(complex)[i] * wink[i] * np.exp(-2.0*np.pi*freq*ts*i*1j)
    vout = vout + data2.astype(complex)[i] * wink[i] * np.exp(-2.0*np.pi*freq*ts*i*1j)
    print("%d  %1.5e %1.5e    %1.5e %1.5e" %(i, vin.real, vin.imag, vout.real, vout.imag) )
   

xgain = vout / vin;
xmagnitude = np.abs(xgain)
xmagnitude_DB = 20.0 * np.log10(xmagnitude)
xphase = np.angle(xgain)
print("xgain is %1.5e %1.5e" %(xgain.real, xgain.imag) )
print("xmagnitude  is %1.5e" %xmagnitude )
print("xMag dB is %1.5e" %xmagnitude_DB)
print("xPhase  is %1.5e" %xphase)
« Last Edit: December 08, 2024, 12:47:17 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #209 on: December 08, 2024, 12:47:13 pm »
Perhaps this will work
[...]

* I miss the the imaginary unit inside exp(...)
* xphase = np.abs(xgain) ==> I think this should be np.angle(...)
* In numpy, you would not loop over the elements (slow), but operate directly on the vectors

Try this one:

Code: [Select]

import numpy as np

k = 65536 # number of samples
freq = 12345
SAMPRATE = 1e6

# simulate captured data
data1 = np.sin(2.0*np.pi*freq*np.arange(0,k)/SAMPRATE)
# -40dB, phase=pi/8
data2 = 0.01*np.sin(2.0*np.pi*freq*np.arange(0,k)/SAMPRATE + np.pi/8)

k = len(data1)
ts = 1.0 / SAMPRATE
xwin = np.kaiser(k, 14)
data1 = data1 - np.mean(data1)
data2 = data2 - np.mean(data2)
vin = np.sum(data1 * xwin * np.exp(-2.0j*np.pi*freq*ts*np.arange(0,k)))
vout = np.sum(data2 * xwin * np.exp(-2.0j*np.pi*freq*ts*np.arange(0,k)))

xgain = vout / vin;
xmagnitude = np.abs(xgain)
xmagnitude_DB = 20.0 * np.log10(xmagnitude)
xphase = np.angle(xgain)
print("xMag dB is %1.5g" %xmagnitude_DB)
print("xPhase  is %1.5g" %xphase)


Edit: Added mean subtraction

« Last Edit: December 08, 2024, 09:36:14 pm by gf »
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #210 on: December 08, 2024, 12:54:06 pm »
Yep, forgot the *1j in the complex exp..

I get now (my code above):

Sample rate Hz is 1000000.0
Timescale is 1.0e-04 sec / div

From scope readings 50 averg:

freq Hz is 4.375e+03
period secs is 2.195e-04
ref_ampl V is 4.985e+00
dut_ampl V is 7.115e-01
delay secs is 3.528e-05
Mag dB is -1.691e+01
Phase deg is -5.786e+01

From scope waves (single sweep within above meas)

xgain is 1.19831e-01 -1.68624e-02
xmagnitude  is 1.21012e-01
xMag dB is -1.83434e+01
xPhase  is -1.39799e-01
xPhase deg is -5.03278e+01


freq Hz is 1.010e+04
period secs is 9.506e-05
ref_ampl V is 4.975e+00
dut_ampl V is 6.478e-02
delay secs is 2.436e-05
Mag dB is -3.771e+01
Phase deg is 9.225e+01
vs
xgain is 1.47492e-02 4.11434e-03
xmagnitude  is 1.53123e-02
xMag dB is -3.62992e+01
xPhase  is 2.72038e-01
xPhase deg is 9.79338e+01

« Last Edit: December 08, 2024, 01:10:58 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #211 on: December 08, 2024, 01:02:33 pm »
Btw, note that I did not care to scale vin and vout properly, since the scaling cancels out when the ratio vout/vin is calculated.
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #212 on: December 08, 2024, 01:10:54 pm »
From scope waves (single sweep within above meas)

What was the record length? How many samples?
Which "freq" value are you using? The nominal frequency, to which the generator was tuned, or the measured one (from scope measurements)?
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #213 on: December 08, 2024, 01:15:09 pm »
Data record length is 598 samples in each channel.
Sampling rate above was 1MegHz.
Freq is from the oscilloscope reading (all scope readings except the waveforms are 50x and average). My current HP3310B generator is vintage analog..

Another one (Rigol DS1062CA and HP3310B, DUT is an RLC circuit):

Sample rate Hz is 2000000.0
freq Hz is 1.010e+04
period secs is 9.506e-05
ref_ampl V is 4.975e+00
dut_ampl V is 6.478e-02
delay secs is 2.436e-05
Mag dB is -3.771e+01
Phase deg is 9.225e+01
vs
xgain is 1.47492e-02 4.11434e-03
xmagnitude  is 1.53123e-02
xMag dB is -3.62992e+01
xPhase  is 2.72038e-01
xPhase deg is 9.79338e+01
« Last Edit: December 08, 2024, 01:22:01 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #214 on: December 08, 2024, 01:34:08 pm »
Data record length is 598 samples in each channel.

598 samples at 1MSa/s are not enough for 4.4kHz. With the given window function, the detector needs about >= 5 full periods of data. It does not need to be an integer multiple of a period, though.

But why 598? A width of 10div at 100µs/div and 1MSa/s should be 1000 samples :-//

Quote
Freq is from the oscilloscope reading (50 averages).

Use the nominal (expected) frequeny for the detector calculation.
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #215 on: December 08, 2024, 01:46:49 pm »
That is what the scope returns after Auto. Number of periods aprox 4.
This vintage scope has got 10kB for both channels.
I will do the manual scope setting, we will see..  :D
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #216 on: December 08, 2024, 04:53:33 pm »
That is what the scope returns after Auto. Number of periods aprox 4.

After a closer look at the frequency response, a detector with a Kaiser(14) window needs at least 4.55 periods to keep DC out of the filter's passband. So my conservative gut feeling of >= 5 was not too far off.

To deal with very small signals sitting on a large DC offset, an additional mean value subtraction is certainly useful before calculating vin and vout

    data1 = data1 - np.mean(data1)
    data2 = data2 - np.mean(data2)

Quote
This vintage scope has got 10kB for both channels.

Oh :scared: I was assuming a DHO8xx/9xx. But that should still allow 5k points per channel.
598 points is still strange. Could these be screen data (perhaps re-sampled to get one sample per screen pixel)?
Have you tried plotting data1 and data2?
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #217 on: December 08, 2024, 08:37:38 pm »
I've been indicating the experiments are with the DS1062CA. It is Rigol's scope from around 2005 (2ch 60Mhz, 2GSps, the highest 1302 model is 300MHz, hackable??), it has got a single scpi waveform download command.
I've been using pyvisa (win10) which downloads 600 points (something like 7.4bits signed) always. Those data are the display data.
The scope's memory depth per channel is 5120 of bytes I assume. No idea how to download them.
Anyhow, I've refreshed python a little bit during this Sunday afternoon, waiting on the DHO804 :)
« Last Edit: December 08, 2024, 08:42:32 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #218 on: December 08, 2024, 09:18:26 pm »
I've been indicating the experiments are with the DS1062CA

Sorry, I missed that.

Quote
I've been using pyvisa (win10) which downloads 600 points (something like 7.4bits signed) always. Those data are the display data.

Is the sample rate correct then?
If the full width of 1ms is covered by only 600 points, then it's no longer 1MSa/s, but rather resampled to 600kSa/s?

When you plot the downloaded data, do you see the same waveform as on the screen?
Or is the trace truncated, so that you only see 60% of the full width?
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #219 on: December 08, 2024, 09:44:50 pm »
I've been printing all data related..
Here is with Keiser_Bessel_derived window.
Added the offset removal.
Anyhow, there is an subtle issue with the Phase in your math, getting usually fully off results after all tweakings.
Of course the Phase interpretation - below the DUT phase is leading by 70deg. Now, it is a game with the 360 shift..
But still, I get hairy Phases off your math.
Tried beta 5 and 14 (note it is beta, not alpha)..
The basic Simple version returns always the same Mag and Phase with 3 digits precision (but the Phase shifts by a cycle based on scope settings, when set it is constant).
:PS those 598 data points - it was the standard bug in the for loop, it is 0..599=600
« Last Edit: December 08, 2024, 10:11:18 pm by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #220 on: December 08, 2024, 10:17:43 pm »
I've been printing all data related..
Here is with Keiser_Bessel_derived window.
Added the offset removal.
Anyhow, there is an subtle issue with the Phase in your math, getting usually fully off results after all tweakings. Tried beta 5 and 14 (note it is beta, not alpha)..
The basic Simple version returns always the same Mag and Phase with 3 digits precision.
:PS those 598 data points - it was the standard bug in the for loop, it is 0..599=600

It works with simulated data, so I think something must be still wrong with the inputs.
If SAMPRATE or freq are wrong, the filter is centered at a wrong frequency, and what you get is just noise divided by noise.

The acquisition sample rate may be 500000, but what matters is the the sample rate of the downloaded vectors data1 and data2 (display data), which is obviously only 600Sa/0.0024s=250000Sa/s.
==> Use SAMPRATE=250000 for the calculation

Which frequency do you set on the signal generator?
==> set the variable freq to the same value (not to the measured value)
« Last Edit: December 08, 2024, 10:39:32 pm by gf »
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #221 on: December 08, 2024, 10:41:32 pm »
Ok, the SAMPRATE - I will try with 250000..
The generator itself is set to a fixed frequency and amplitude (quite stable).
The  "freq" is used in both Simple and GF versions, it is coming from the internal scope measurement on CH1 (all inputs come from the scope). All input data except the 2 waveforms are captured 50x and averaged.
What I need is to get stable results (even when a bit off but stable) from your version after each measurement (still not the case).
The Simple version is quite stable here with optimal signal settings, but not suitable for Quality Bode under any settings, sure..
« Last Edit: December 08, 2024, 10:48:06 pm by iMo »
Readers discretion is advised..
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #222 on: December 08, 2024, 11:59:40 pm »
Below plz find the .csv file with a series of measurements..
PS: added a Bode of manually swept LC circuit and clicking python, Keiser with beta=14, none averaging, otherwise as above..

« Last Edit: December 09, 2024, 11:11:59 am by iMo »
Readers discretion is advised..
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1826
  • Country: de
Re: Rigol DHO914S Bode plot
« Reply #223 on: December 09, 2024, 09:21:23 am »
Below plz find the .csv file with a series of measurements..

What is the difference between colums F,G,H and K,L,M which have the same name?

Can you also post the contents of the data1 and data2 arrays? (for one measurement, or maybe for two)?

What was the frequency set on the generator? (please give a number, not "fixed" ;) )
Does this scope also have a built-in frequency counter (not the frequency measurement)? If yes, what does it read?
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6895
  • Country: li
Re: Rigol DHO914S Bode plot
« Reply #224 on: December 09, 2024, 09:31:47 am »
Quote
1. What is the difference between colums F,G,H and K,L,M which have the same name?
2. Can you also post the contents of the data1 and data2 arrays? (for one measurement, or maybe for two)?
3. What was the frequency set on the generator? (please give a number, not "fixed" ;) )
4.Does this scope also have a built-in frequency counter (not the frequency measurement)? If yes, what does it read?

1. FGH should be without "x" - it is the Simple Bode method..
2. later perhaps this evening
3. the freq set on generator is the freq in column A - measured by scope, none counter used, look at the HP3310B spec, you will get how the freq is set :)
4. nope, there is none special counter built in, it just returns a coarse freq in column A
freq = float(scope.query(':MEASure:FREQ? CHAN1'))

The Keiser GF method works, see above Bode of an LC I did within 2 minutes manually (Keiser beta=14, none averaging, just turning a knob on the HP3310 and click into jupyter-lab cell).

A couple of times I changed time base and channel 2 (DUT out) vertical such I got those "optimal minimal" 5-12 periods with maxed CH2 amplitude inside the screen (this must be automated in the future App!!).

The CH2 measurement above 20-30kHz was already noisy as the LC was built on flying leads and crocodiles and bananas..  ;D

With a modern scope and generator it is the way to go, indeed..  :-+

PS: added above the DUT sim - you may compare the SIM and myBode results..  8)
« Last Edit: December 09, 2024, 11:45:15 am by iMo »
Readers discretion is advised..
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->