Main Content

Measure Power on Keysight RF Power Meter Using IVI-C Driver

This example shows how to initialize the KtRFPowerMeter IVI-C driver, read a few properties of the driver, make power measurements using Keysight™ E4416A RF Power Meter, and display the result in MATLAB®.

Requirements

To run this example, you must have the following installed on your computer:

  • Keysight IO libraries version 2021 or newer

  • Keysight RF Power Meter IVI version 1.6.0.0

View Installed IVI-C Drivers

View a list of the IVI-C drivers and associated MATLAB drivers that are installed on your computer using ividriverlist.

list = ividriverlist
list=15×4 table
             VendorDriver          MATLABDriver            IVIClass                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              SupportedModels                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
          __________________    __________________    __________________    _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

    1     "IviACPwr"            "IviACPwr"            "IVIACPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    2     "IviCounter"          "IviCounter"          "IVICounter"          {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    3     "IviDCPwr"            "IviDCPwr"            "IVIDCPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    4     "IviDigitizer"        "IviDigitizer"        "IVIDigitizer"        {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    5     "IviDmm"              "IviDmm"              "IVIDmm"              {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    6     "IviDownconverter"    "IviDownconverter"    "IVIDownconverter"    {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    7     "IviFgen"             "IviFgen"             "IVIFgen"             {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    8     "IviPwrMeter"         "IviPwrMeter"         "IVIPwrMeter"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    9     "IviRfSigGen"         "IviRfSigGen"         "IVIRfSigGen"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    10    "IviScope"            "IviScope"            "IVIScope"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    11    "IviSpecAn"           "IviSpecAn"           "IVISpecAn"           {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    12    "IviSwtch"            "IviSwtch"            "IVISwtch"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    13    "IviUpconverter"      "IviUpconverter"      "IVIUpconverter"      {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ]}
    14    "KtRFPowerMeter"      "KtRFPowerMeter"      "IVIPwrMeter"         {["8481A"    "8481B"    "8481D"    "8481H"    "8482A"    "8482B"    "8482H"    "8483A"    "8485A"    "8485D"    "8487A"    "8487D"    "E4416A"    "E4417A"    "E4418B"    "E4419B"    "E9325A"    "E9326A"    "E9327A"    "L2051XA"    "L2052XA"    "L2053XA"    "L2054XA"    "L2055XA"    "L2056XA"    "L2057XA"    "L2061XA"    "L2062XA"    "L2063XA"    "L2064XA"    "L2065XA"    "L2065XT"    "L2066XA"    "L2066XT"    "L2067XA"    "L2067XT"    "N1911A"    "N1912A"    "N1913A"    "N1914A"    "N1921A"    "N1922A"    "N432A"    "N8262A"    "U2000A"    "U2000B"    "U2000H"    "U2001A"    "U2001B"    "U2001H"    "U2002A"    "U2002B"    "U2002H"    "U2004A"    "U2021XA"    "U2022XA"    "U2041XA"    "U2042XA"    "U2043XA"    "U2044XA"    "U2049XA"    "U2051XA"    "U2052XA"    "U2053XA"    "U2054XA"    "U2055XA"    "U2056XA"    "U2057XA"    "U2061XA"    "U2062XA"    "U2063XA"    "U2064XA"    "U2065XA"    "U2066XA"    "U2067XA"    "U8481A"    "U8485A"    "U8487A"    "U8488A"    "U8489A"]}
    15    "niScope"             "niScope"             "IVIScope"            {["NI PCI-5105"    "NI PCI-5114"    "NI PCI-5122"    "NI PCI-5124"    "NI PCI-5142"    "NI PCI-5152"    "NI PCI-5153"    "NI PCI-5154"    "NI PCI-5922"    "NI PCIe-5155"    "NI PXI-5105"    "NI PXI-5114"    "NI PXI-5122"    "NI PXI-5124"    "NI PXI-5124EX"    "NI PXI-5142"    "NI PXI-5152"    "NI PXI-5153"    "NI PXI-5154"    "NI PXI-5900"    "NI PXI-5922"    "NI PXI-5922EX"    "NI PXIe-5105"    "NI PXIe-5110"    "NI PXIe-5111"    "NI PXIe-5113"    "NI PXIe-5114"    "NI PXIe-5122"    "NI PXIe-5160"    "NI PXIe-5160 (2CH)"    "NI PXIe-5160 (4CH)"    "NI PXIe-5162"    "NI PXIe-5162 (2CH)"    "NI PXIe-5162 (4CH)"    "NI PXIe-5163"    "NI PXIe-5164"    "NI PXIe-5170R (4CH)"    "NI PXIe-5170R (8CH)"    "NI PXIe-5171R (8CH)"    "NI PXIe-5172 (4CH - 325T)"    "NI PXIe-5172 (8CH - 325T)"    "NI PXIe-5172 (8CH - 410T)"    "NI PXIe-5185"    "NI PXIe-5186"    "NI PXIe-5622"    "NI PXIe-5622 (25MHz DDC)"    "NI USB-5132"    "NI USB-5133"                                            ]}

In this example, you use the KtRFPowerMeter MATLAB driver.

Connect to Instrument

Connect to a simulated Keysight RF power meter using ividev with the instrument's MATLAB driver name and resource name. This example uses the KtRFPowerMeter driver's simulation mode to run without physically connecting any hardware. Since simulation mode is enabled, the resource name can be specified as empty.

dev = ividev("KtRFPowerMeter","",Simulate=true)
dev = 
  KtRFPowerMeter with properties:

                    Model: "E4416A" 
             Manufacturer: "Keysight Technologies" 
             SerialNumber: "" 
             ResourceName: "" 
             VendorDriver: "KtRFPowerMeter" 
                 Simulate: 1 

               ChannelIDs: ["A", "B", "C", "D"] 
           MeasurementIDs: ["1", "2", "3", "4"] 
              TimeGateIDs: ["Gate1", "Gate2", "Gate3", "Gate4"] 
                WindowIDs: ["Lower", "Upper"] 

    InherentIVIAttributes: [1x1 InherentIVIAttributes] 
           AveragingCount: [1x1 AveragingCount] 
           BasicOperation: [1x1 BasicOperation] 
                DutyCycle: [1x1 DutyCycle] 
       InstrumentSpecific: [1x1 InstrumentSpecific] 
              ManualRange: [1x1 ManualRange] 
      ReferenceOscillator: [1x1 ReferenceOscillator] 
                  Trigger: [1x1 Trigger] 

Show all functions

Get General Device Properties

Query information about the driver and its attributes. You can explore properties and sub-properties of the object by clicking on the property links from the object output display.

dev.InherentIVIAttributes
ans = 
  InherentIVIAttributes with properties:

    AdvancedSessionInformation: [1x1 AdvancedSessionInformation] 
            DriverCapabilities: [1x1 DriverCapabilities] 
          DriverIdentification: [1x1 DriverIdentification] 
      InstrumentIdentification: [1x1 InstrumentIdentification] 
                   UserOptions: [1x1 UserOptions] 

dev.InherentIVIAttributes.DriverIdentification
ans = 
  DriverIdentification with properties:

    SpecificDriverClassSpecMajorVersion: 2 
    SpecificDriverClassSpecMinorVersion: 0 
              SpecificDriverDescription: "IVI Driver for the RF PowerMeter and Power Sensor family of instruments [Compiled for 64-bit.]" 
                   SpecificDriverPrefix: "KtRFPowerMeter" 
                 SpecificDriverRevision: "1.6.0.0" 
                   SpecificDriverVendor: "Keysight Technologies" 

Configure Power Meter

Perform default preset on the power meter.

systemPreset(dev);

Wait until all instrument operations complete or until maxTimeMilliseconds has expired.

maxTimeMilliseconds = 20000;
systemWaitForOperationComplete(dev,maxTimeMilliseconds);

Disable continuous triggering for channel A.

setAttributeViBoolean(dev,"A","KTRFPOWERMETER_ATTR_CHANNELS_ITEM_TRIGGER_CONTINUOUS_ENABLED",false);

Get number of channels available on the instrument.

channelCount = dev.BasicOperation.ChannelCount
channelCount = 4

Get the model number or name reported by the physical instrument.

instrumentModel = dev.InherentIVIAttributes.InstrumentIdentification.InstrumentModel
instrumentModel = 
"E4416A"
if (channelCount >= 2) && not(strcmpi(instrumentModel,'N1913A')) && not(strcmpi(instrumentModel,'N1914A'))
    % Disables continuous triggering for channel B
    setAttributeViBoolean(dev,"B","KTRFPOWERMETER_ATTR_CHANNELS_ITEM_TRIGGER_CONTINUOUS_ENABLED",false);
end

Enable power reference output.

setAttributeViBoolean(dev,"A","KTRFPOWERMETER_ATTR_CALIBRATOR_ENABLED",true);

Make Measurements

Initiate measurement on all enabled channels.

initiate(dev);

Wait until all instrument operations complete or maxTimeMilliseconds has expired.

systemWaitForOperationComplete(dev,maxTimeMilliseconds);

Perform power measurement. The measured output values are all 0 because this example is running with simulated hardware.

maxTime = 50000; % millisec
for iLoop = 1:4
    % Specifying an offset to be added to the measured value in units of dB
    setAttributeViReal64(dev,"A","KTRFPOWERMETER_ATTR_OFFSET",-10*iLoop);
    % Initiate a measurement
    readResult = measurementsItemRead(dev,"1",maxTime); 
    % Disable the display offset
    setAttributeViBoolean(dev,"1","KTRFPOWERMETER_ATTR_MEASUREMENTS_ITEM_OFFSET_ENABLED",false);
    % Fetch the result of a previously initiated measurement
    fetchResult = measurementsItemFetch(dev,"1",maxTime);
    % Enable the display offset
    setAttributeViBoolean(dev,"1","KTRFPOWERMETER_ATTR_MEASUREMENTS_ITEM_OFFSET_ENABLED",true);
    % Perform a power measurement
    measResult = measurementsItemMeasure(dev,"1",maxTime);
    fprintf('Read result: %.3f, Fetch Result: %g, Measure Result: %g\n', readResult, fetchResult, measResult);
end
Read result: 0.000, Fetch Result: 0, Measure Result: 0
Read result: 0.000, Fetch Result: 0, Measure Result: 0
Read result: 0.000, Fetch Result: 0, Measure Result: 0
Read result: 0.000, Fetch Result: 0, Measure Result: 0

Query and Display Any Errors

If there are any errors, query the driver to retrieve and display them.

errorNum = 1;
while (errorNum ~= 0)
    [errorNum,errorMsg] = error_query(dev);
    fprintf('ErrorQuery: %d, %s\n',errorNum,errorMsg);
end
ErrorQuery: 0, No error.

Clean Up

Disconnect and clear the ividev object from the workspace.

clear dev

See Also

| |

Related Topics