Measurement Setup

The following C# example demonstrates how to set up a modulation distortion measurement.

See the Modulation Distortion commands.

See Other SCPI Example Programs

using System;

using System.Collections.Generic;

using System.IO;

using System.Numerics;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace mod_tests

{

    partial class Vna

    {

        [TestMethod]

        public void Case01()

        {

            // Test Conditions:

            // - External source is named as "MXG";

            // - On PNA, file "D:\Symphony\FR1_100M_64QAM.mdx" is used

            // - PNA Port 1 connects to DUT Input, PNA Port 2 connects to DUT Output;

            _fmtIO.Cmd("syst:fpr");

            // add traces

            _fmtIO.Cmd("disp:wind1:stat on");

            string[] trNames = new string[] { "PIn1", "POut2", "MDist2" };

            int idx = 1;

            foreach (var n in trNames)

            {

                _fmtIO.Cmd(string.Format("calc:cust:def 'ch1_{0}','Modulation Distortion','{0}'", n));

                _fmtIO.Cmd(string.Format("disp:wind1:trac{0}:feed 'ch1_{1}'", idx, n));

                ++idx;

            }

            // hold sweep

            _fmtIO.Cmd("sens:swe:mode hold");

            string str;

            // Setup Sweep

            _fmtIO.Cmd("sens:DISTortion:SWEep:CARRier:FREQuency 1e9");

            _fmtIO.Cmd("sens:freq:cent 1e9");

            _fmtIO.Cmd("sens:freq:span 400e6");

            _fmtIO.Cmd("sens:DISTortion:SWEep:POWer:CARRier:LEVel:PORT DOUT2");

            _fmtIO.Cmd("sens:DISTortion:SWEep:POWer:CARRier:LEVel -15");

            _fmtIO.Cmd("sens:DISTortion:SWEep:POWer:SPARam:LEVel -25");

            str = _fmtIO.CmdQry("sens:freq:cent?");

            str = _fmtIO.CmdQry("sens:freq:span?");

            str = _fmtIO.CmdQry("sens:DISTortion:SWEep:CARRier:FREQuency?");

            str = _fmtIO.CmdQry("sens:DISTortion:SWEep:POWer:CARRier:LEVel:PORT?");

            str = _fmtIO.CmdQry("sens:DISTortion:SWEep:POWer:CARRier:LEVel?");

            str = _fmtIO.CmdQry("sens:DISTortion:SWEep:POWer:SPARam:LEVel?");

            // RF Path

            _fmtIO.Cmd("sens:dist:path:dut:inp 1");

            _fmtIO.Cmd("sens:dist:path:dut:outp 4");

            str = _fmtIO.CmdQry("sens:dist:path:dut:inp?");

            str = _fmtIO.CmdQry("sens:dist:path:dut:outp?");

            str = _fmtIO.CmdQry("sens:dist:path:dut:nom:gain?");

            str = _fmtIO.CmdQry("sens:dist:path:dut:nom:nf?");

            _fmtIO.Cmd("sens:dist:path:sour:nom:ampl 10");

            _fmtIO.Cmd("sens:dist:path:dut:nom:gain 10");

            _fmtIO.Cmd("sens:dist:path:dut:nom:nf 3");

            str = _fmtIO.CmdQry("sens:dist:path:sour:nom:ampl?");

            str = _fmtIO.CmdQry("sens:dist:path:dut:nom:gain?");

            str = _fmtIO.CmdQry("sens:dist:path:dut:nom:nf?");

            _fmtIO.Cmd("sens:dist:path:sour:nom:ampl 0");

            _fmtIO.Cmd("sens:dist:path:dut:nom:gain 0");

            _fmtIO.Cmd("sens:dist:path:dut:nom:nf 0");

            // Modulate

            _fmtIO.Cmd("SYST:CONF:EDEV:STAT 'MXG',ON");

            _fmtIO.Cmd("sens:DISTortion:MODulate:SOURce 'MXG'");

            _fmtIO.Cmd(@"SOURce:MODulation:LOAD 'D:\Symphony\FR1_100M_64QAM.mdx'");

            _fmtIO.Cmd("SOURce:MODulation:STATe 1");

            str = _fmtIO.CmdQry("sens:DISTortion:MODulate:SOURce?");

            str = _fmtIO.CmdQry("SOURce:MODulation:FILE?");

            str = _fmtIO.CmdQry("SOURce:MODulation:STATe?");

            // Measure

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND1:NAME?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND1:TYPE?");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND1:NAME 'TEST1'");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND1:TYPE NPR");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND1:NOTCh:OFFS?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND1:NOTCh:IBW?");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND1:NOTCh:OFFS 20e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND1:NOTCh:IBW 10e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND:ADD");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:NAME 'TEST2'");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:TYPE ACP");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND2:ACP:LOW:OFFS?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND2:ACP:LOW:IBW?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND2:ACP:UPP:OFFS?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND2:ACP:UPP:IBW?");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:ACP:LOW:OFFS -90e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:ACP:LOW:IBW 90e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:ACP:UPP:OFFS 90e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND2:ACP:UPP:IBW 90e6");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND1:DEL");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND:INIT");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND:CARR:OFFS?");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND:CARR:IBW?");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND:CARR:OFFS 0");

            _fmtIO.Cmd("sens:DISTortion:MEASure:BAND:CARR:IBW 90e6");

            str = _fmtIO.CmdQry("sens:DISTortion:MEASure:BAND:COUNt?");

            // do a full sweep (noise, s21 and measurement)

            _fmtIO.Cmd("sens:swe:mode single");

            _fmtIO.CmdQry("*OPC?", TimeOuts._2min);

            // display scale

            _fmtIO.Cmd("disp:wind:trac:y:scal:coup:meth wind");

            _fmtIO.Cmd("disp:wind1:trac:y:scal:coup on");

            _fmtIO.Cmd("disp:wind1:y:auto");

            // change Test Receiver Attenuation

            _fmtIO.Cmd("sour:pow4:att:rec:test 10");

            _fmtIO.Cmd("sens:swe:mode single");

            _fmtIO.CmdQry("*OPC?", TimeOuts._2min);

            // change DUT Analysis BW

            str = _fmtIO.CmdQry("sens:dist:meas:corr:aper:auto?");

            str = _fmtIO.CmdQry("sens:dist:meas:corr:aper?");

            _fmtIO.Cmd("sens:dist:meas:corr:aper 20e6");

            str = _fmtIO.CmdQry("sens:dist:meas:corr:aper:auto?");

            str = _fmtIO.CmdQry("sens:dist:meas:corr:aper?");

            _fmtIO.Cmd("sens:swe:mode single");

            _fmtIO.CmdQry("*OPC?", TimeOuts._2min);

            _fmtIO.Cmd("sens:dist:meas:corr:aper:auto 1");

            

            // change ADC Filter Type

            str = _fmtIO.CmdQry("sens:dist:adc:filt:type?");

            _fmtIO.Cmd("sens:dist:adc:filt:type NARR");

            _fmtIO.Cmd("sens:swe:mode single");

            _fmtIO.CmdQry("*OPC?", TimeOuts._2min);

            _fmtIO.Cmd("sens:dist:adc:filt:type AUTO");

            // re-use linear sweeps, change power and do measurement sweep

            str = _fmtIO.CmdQry("sens:dist:swe:lin:reus?");

            _fmtIO.Cmd("sens:dist:swe:lin:reus 1");

            int pwr = -30; // power start

            while (pwr <= -10) // power stop

            {

                _fmtIO.Cmd(string.Format("sens:DISTortion:SWEep:POWer:CARRier:LEVel {0}", pwr));

                _fmtIO.Cmd("sens:swe:mode single");

                _fmtIO.CmdQry("*OPC?", TimeOuts._2min);

                pwr += 5; // power step

            }

            _fmtIO.Cmd("sens:dist:swe:lin:reus 1");           

        }

    }

}