Question

Hi, I'm having some little trouble with WF. It's complex software so maybe missing something, but may be actual problems, two of them:

1) Wfm math in FFT window is acting little different than expected. I'm doing 0-50MHz sine sweep with ext gen on some filter and would like to see normalized response graph. For that I first create Ref 1 trace using Peak Hold Continuous. Then create filter response trace. Now try to get final plot using Math 1. No desired result since it calculates on current values, not the PHC plots!

AD2_FFT_problem.thumb.png.29f725ae0982a296d24159956f768f40.png

2) Persistence window is not taking into account interpolation setting. It should be doing sin(x)/x but instead is doing linear. Also it would be helpful if interpolation setting is not deep in the menu but more easily accessible and perhaps could be individually steered for both Scope and Persistence window. Min/Max is also acting bit weird with low sample counts.

AD2_decimated.thumb.png.4d1d6edb11b6a7d626e57fed45d3c38d.png

Edited by lab!fyi
Inline images were messed up.

Share this post


Link to post
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Hi @lab!fyi

1. I think for your experiment you should use the Network Analyzer interface of the WaveForms application.
Connect the Scope channel 1 to your filter input and channel 2 to the output. By default, the analyzer plots the magnitude and phase of channel 2 relative to 1. This will give the characteristics of your filter.
In the NA under Wavegen gear menu select channel external (let you use external or custom wavegen control) and frequency extended (to let you use up to 50MHz).
image.png.a8deeb4185d5604f79afb1fc6a429fee.png

The Scope Math channel is performed on the time domain data not on the FFT.

2. The persistence view will be update with the next software version to handle curve interpolation option as well the min/max sampling.

Share this post


Link to post
Share on other sites
  • 0
14 hours ago, attila said:

The Scope Math channel is performed on the time domain data not on the FFT.

Hi, thanks for info, any plans for math on FFT? This would be very useful in some cases.

Share this post


Link to post
Share on other sites
  • 0

Hi @lab!fyi

We could add math to the Spectrum Analyzer interface.

At the moment you could use Script with plot for such purpose.

image.thumb.png.ceb0728142e24c568354a51e2b177fc0.png

Collect the data in Spectrum Trace 1 and 2, in Script tool View/Add plot and Run the following script:

plot1.X.Units.text = "Hz"
plot1.Y1.Units.text = "dB"
plot1.X.data = Spectrum1.Trace1.frequency
var t1 = Spectrum1.Trace1.magnitude
var t2 = Spectrum1.Trace2.magnitude
var c = t1.length
var d = []
for(var i = 0; i < c; i++){
    d.push(t2[i]-t1[i])
}
plot1.Y1.data = d

 

Share this post


Link to post
Share on other sites
  • 0
On 9/21/2018 at 12:49 PM, attila said:

We could add math to the Spectrum Analyzer interface.

That would be fun to play with :) And thanks for code snippet! However I started messing with SA and instantly hit brick wall due to 20MS/s / 10MHz limit (I understand why it is good for generic user), but maybe little "Extended" option could fix it for enthusiastic ones making full sampling rate available, after all it is available in Scope anyway? Or is there already way to "unlock"? Another handy improvement would be adding dBm + ohm ref to unit choices like on some other scopes.

Edit: Did try NA on little different filter with external gen. Overall works but cannot fully normalize vs ref due to no math. More interesting experiment was with TDR. It also certainly works but again cannot fully normalize and also seemningly no way to switch off unneeded traces on FFT plot.

Edit 2: Did not find built-in derivative or integral functions or even someone missing them on the Internet. Do I have to write own scripts for these or there is something around and I just did not find it?

AD2_NA.thumb.png.55f36919cffd4d568d7ec804b76c087a.png


AD2_TDR.thumb.png.ee2d00c3e07ff599ae6a568973284229.png

function doScope()
{
    print("Running Scope script");
    Scope1.single();
    if (!Scope1.wait())
        return;

    Scope1.Ref1.Clone(Scope1.Channel1);
    Scope1.Ref2.Clone(Scope1.Channel2);

    var aR1 = Scope1.Ref1.data;
    var aR2 = Scope1.Ref2.data;

    var aC1 = Scope1.Channel1.data;
    var aC2 = Scope1.Channel2.data;

    for (var i = 0; i < (aC1.length - 1); i++)
    {
        aR1[i + 1] = aC1[i + 1] - aC1[i];
        aR2[i + 1] = aC2[i + 1] - aC2[i];
    }
    aR1[0] = 0;
    aR2[0] = 0;
    aR1[aC1.length - 1] = 0;
    aR2[aC2.length - 1] = 0;
    Scope1.Ref1.data = aR1;
    Scope1.Ref2.data = aR2;
}

if(!('Scope1' in this))
    throw("Please open a Scope instrument");

//for (var i = 0; i < 10; i++)
    doScope();

 

Edited by lab!fyi
New data

Share this post


Link to post
Share on other sites
  • 0

Hi @lab!fyi

In the Network Analyzer extended option lets you use Wavegen channels at up to 20MHz and with external up to 50MHz.
In the Spectrum Analyzer you can select frequency range up to 10MHz but with auto option lets you set Stop frequency up to 50MHz.

Selecting the dB unit will let you specify custom reference, for dBm I think it should be 0.316V

 

Share this post


Link to post
Share on other sites
  • 0

Hi, thanks for info. Seems then currently only way to get normalized FFT trace is in SA then, got it working:

AD2_FFT_normalized.thumb.png.fc3ec8fa5f346443d7b717acee82b28c.png

As improvements would look for cursors in script plot window and possibility to write trace back into SA window like with Scope. 

Currently writing little "math engine" for derivation/integration and suffered some due to lack of documentation. Is this + built in best there is?
https://reference.digilentinc.com/reference/software/waveforms/waveforms-3/reference-manual#script1
There is no section for SA at all for example. 

Share this post


Link to post
Share on other sites
  • 0

Hi @lab!fyi

The Script/Spectrum is added to the Help of beta version.
Please use the Help of the application since this is the most up to date resource.
https://forum.digilentinc.com/topic/8908-waveforms-beta-download/

You could use Ctrl+Space, code completion: 
https://forum.digilentinc.com/topic/15433-more-meta-data-wanted/?do=findComment&amp;comment=37724

Beside this the code is JavaScript: 
http://www.ecma-international.org/publications/standards/Ecma-262.htm
https://www.w3schools.com/jsref/jsref_obj_math.asp

For next software version added support to set trace data from script.

 

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

I'm playing around with the new Spectrum1.Trace3.setMagnitude(d); command and I'd need some help.

I used your script and made some changes to it to generate the 3rd trace signal in the Spectrum Analyzer:

plot1.X.Units.text = "Hz"
plot1.X.data = Spectrum1.Trace1.frequency

plot1.Y1.Units.text = "dB"
plot1.Y1.AutoScale.checked = false;
plot1.Y1.Range.value = 40;
plot1.Y1.Offset.value = 100;

//while (true)
{
    var t1 = Spectrum1.Trace1.magnitude
    var t2 = Spectrum1.Trace2.magnitude
    var c = t1.length
    var d = []

    for(var i = 0; i < c; i++){
        d.push(t1[i]-t2[i]-100)
    }
    plot1.Y1.data = d
    Spectrum1.Trace3.setMagnitude(d);
//    Spectrum1.wait();
}

I have 3 traces in the Spectrum Analyzer:

Trace1 (C1, Exponential dB Average, 10)

Trace2 (C2, Exponential dB Average, 100)

Trace3 (Hold, Sample)

 

The first strange thing is that when I run the Spectrum Analyzer and then I click on the Play sign next the the "Script" label at the tab's top, the script runs, but both averaging functions reset for Trace1 and Trace2. Is that the intended behavior?

image.png.e56d8517c3b1a3117177e1ef21914e7e.png

Also, I would like to make the script above a continuously running one (that's why I used the "do (while)" and ".wait()" methods), but I wasn't successful. Could you help me out with this?

The third thing I wonder: will it be possible to run an averaging function on Trace3 (like the Exponential dB Average) if it's values are set by the Spectrum1.Trace3.setMagnitude() method?

Thanks!

Edited by Andras

Share this post


Link to post
Share on other sites
  • 0

Hi @Andras

The averagings and difference of these can be performed in the script like this:

image.thumb.png.7c73aae509b13f480e592375bcd73cb1.png

Spectrum1.run()
var first = true
for(var k = 0; Spectrum1.wait(); k++){
    if(first){ // initialize trace info, min/max freq
        first = false;
        Spectrum1.Trace3.Clone(Spectrum1.Trace1)
        Spectrum1.Trace4.Clone(Spectrum1.Trace2)
        Spectrum1.Trace5.Clone(Spectrum1.Trace1)
    }

    var t1 = Spectrum1.Trace1.magnitude
    var t2 = Spectrum1.Trace2.magnitude
    var t3 = Spectrum1.Trace3.magnitude
    var t4 = Spectrum1.Trace4.magnitude
    var t5 = []
   
    var c = t1.length

    for(var i = 0; i < c; i++){
        t3[i] = 0.9*t3[i] + 0.1*t1[i]   // exp 10
        t4[i] = 0.99*t4[i] + 0.01*t2[i] // exp 100
        t5.push(t3[i]-t4[i]-110)        // diff -110
    }
    Spectrum1.Trace3.setMagnitude(t3)
    Spectrum1.Trace4.setMagnitude(t4)
    Spectrum1.Trace5.setMagnitude(t5)
    print(k)
}
Spectrum1.stop()

 

For exponential average of difference you can use:

Spectrum1.run()
var t3 = []
var first = true
for(var k = 0; Spectrum1.wait(); k++){
    var t1 = Spectrum1.Trace1.magnitude
    var t2 = Spectrum1.Trace2.magnitude
    var c = t1.length

    if(first){ // initialize trace info, min/max freq
        first = false;
        Spectrum1.Trace3.Clone(Spectrum1.Trace1)
        t3 = []
        for(var i = 0; i < c; i++) t3[i] = 0
    }

    for(var i = 0; i < c; i++){
        t3[i] = (t3[i]*99+ t1[i]-t2[i])/100 // exp 100
    }

    Spectrum1.Trace3.setMagnitude(t3)
    print(k)
}
Spectrum1.stop()

 

Share this post


Link to post
Share on other sites
  • 0

Hi Attila,

      I think for accuracy you would have to account for the fact these is RMS measurements you are averaging. Typically if you are trying to average uncorrelated noise you would have to take the square root of the sum of the squares of the values being averaged then divide by n. 

      Thanks for your examples I am just learning about how to use this.

John Alexander

Share this post


Link to post
Share on other sites
  • 0

Szia @attila,

Thanks again for the excellent script, it works nearly :) perfectly.

I noticed that when I run the script you recommended for the exponential average of difference and I keep the source Trace1 and Trace2 visible the Spectrum Analyzer, they both are shown as if they had a "Sample" type, and it make no difference if I choose any other type for them.

Is this the intended behavior?

Share this post


Link to post
Share on other sites
  • 0

Szia @Andras

For the earlier examples Trace 1 and 2 should be in Sample mode, without any averaging. The script takes the data from these and calculates the average and difference for traces 3, 4, 5

Having Hold as Channel source the Type has no effect since the trace is not updated by the Spectrum interface. In the above examples traces 3,4,5 are in hold and updated by the script.

Share this post


Link to post
Share on other sites
  • 0

@attila,

thanks for averaging workarounds. Is it planned in some future release that script can access GUI-averaged trace also (and have still access to raw if wish)? There is also related problem. When perform any manual operation on traces eg just enable-disable Ref trace averaging process always resets. Eg if wanted to create snapshot of long exp averaging process you lose accumulated data on source channel.


Second little issue is with trace interpolation. There is automation that in some cases switches from linear interpolation to discrete when in log scale mode, probably due to performance considerations.  However when linear averaging it makes wrong decision for most cases because graphing performance becomes irrelevant. It would be much helpful to have manual control on this eg dropdown with [Auto|Linear|Discrete] option.

Also, it would be interesting to have phase trace option like on some high-end scopes + script access from script to real and imaginary components.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now