Main Content

Set Output Voltage and Make Measurements on Keysight AC6801A Power Supply Using IVI-C Driver

This example shows how to initialize the AgAC6800 IVI-C driver, read a few properties from the driver, measure voltage, current, and power using Keysight™ Technologies AC6801A power supply, and output 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 AC6800 AC Power Supplies IVI and MATLAB Instrument Drivers version 1.1.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=16×4 table
             VendorDriver          MATLABDriver            IVIClass                                                                                                                                                                                                                                                                                                                                                        SupportedModels                                                                                                                                                                                                                                                                                                                                                
          __________________    __________________    __________________    ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

    1     "Ag3446x"             "Ag3446x"             "IVIDmm"              {["34460A"    "34461A"    "34465A"    "34470A"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ]}
    2     "AgAC6800"            "AgAC6800"            "IVIACPwr"            {["AC6801A"    "AC6801B"    "AC6802A"    "AC6802B"    "AC6803A"    "AC6803B"    "AC6804A"    "AC6804B"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ]}
    3     "IviACPwr"            "IviACPwr"            "IVIACPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    4     "IviCounter"          "IviCounter"          "IVICounter"          {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    5     "IviDCPwr"            "IviDCPwr"            "IVIDCPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    6     "IviDigitizer"        "IviDigitizer"        "IVIDigitizer"        {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    7     "IviDmm"              "IviDmm"              "IVIDmm"              {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    8     "IviDownconverter"    "IviDownconverter"    "IVIDownconverter"    {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    9     "IviFgen"             "IviFgen"             "IVIFgen"             {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    10    "IviPwrMeter"         "IviPwrMeter"         "IVIPwrMeter"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    11    "IviRfSigGen"         "IviRfSigGen"         "IVIRfSigGen"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    12    "IviScope"            "IviScope"            "IVIScope"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    13    "IviSpecAn"           "IviSpecAn"           "IVISpecAn"           {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    14    "IviSwtch"            "IviSwtch"            "IVISwtch"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    15    "IviUpconverter"      "IviUpconverter"      "IVIUpconverter"      {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ]}
    16    "NIFGEN"              "NIFGEN"              "IVIFgen"             {["NI PCI-5401"    "NI PCI-5402"    "NI PCI-5406"    "NI PCI-5411"    "NI PCI-5412"    "NI PCI-5421"    "NI PCI-5431"    "NI PXI-5401"    "NI PXI-5402"    "NI PXI-5404"    "NI PXI-5406"    "NI PXI-5411"    "NI PXI-5412"    "NI PXI-5421"    "NI PXI-5422"    "NI PXI-5431"    "NI PXI-5441"    "NI PXIe-5413 (1CH)"    "NI PXIe-5413 (2CH)"    "NI PXIe-5423 (1CH)"    "NI PXIe-5423 (2CH)"    "NI PXIe-5433 (1CH)"    "NI PXIe-5433 (2CH)"    "NI PXIe-5442"    "NI PXIe-5450"    "NI PXIe-5451"    "PCI_5402"    "PCI_5406"    "PCI_5412"    "PCI_5421"    "PXI_5402"    "PXI_5404"    "PXI_5406"    "PXI_5412"    "PXI_5421"    "PXI_5422"    "PXI_5441"    "PXIe_5442"    "PXIe_5450"    "PXIe_5451"]}

Connect to Instrument

Connect to a simulated Keysight AC6801A Power Supply using ividev with the instrument's MATLAB driver name and resource name. This example uses the AgAC6800 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("AgAC6800","",Simulate=true)
dev = 
  AgAC6800 with properties:

                    Model: "AC6801A" 
             Manufacturer: "Keysight Technologies" 
             SerialNumber: "" 
             ResourceName: "" 
             VendorDriver: "AgAC6800" 
                 Simulate: 1 

           MeasurementIDs: "Measurement1" 
           OutputPhaseIDs: "OutputPhase1" 

    InherentIVIAttributes: [1x1 InherentIVIAttributes] 
        CurrentProtection: [1x1 CurrentProtection] 
             DCGeneration: [1x1 DCGeneration] 
       InstrumentSpecific: [1x1 InstrumentSpecific] 
                   Output: [1x1 Output] 
                  Outputs: [1x1 Outputs] 
               PhaseAngle: [1x1 PhaseAngle] 

Show all functions

Define Variables

Specify the frequency, current, and voltage parameters.

acVolts = 120;
acAmps = 4;
freq = 50;
loVolt = 0.9 * acVolts;
hiVolt = 1.1 * acVolts;
dcVolts = 5;
dcAmps = 1;

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: 1 
    SpecificDriverClassSpecMinorVersion: 2 
              SpecificDriverDescription: "IVI Driver for AC68xx family of Power Supplies [Compiled for 64-bit.]" 
                   SpecificDriverPrefix: "AgAC6800" 
                 SpecificDriverRevision: "1.1.0.0" 
                   SpecificDriverVendor: "Keysight Technologies" 

dev.InherentIVIAttributes.InstrumentIdentification
ans = 
  InstrumentIdentification with properties:

    InstrumentFirmwareRevision: "Sim1.1.0.0" 
        InstrumentManufacturer: "Keysight Technologies" 
               InstrumentModel: "AC6801A" 

Enable Auto-Ranging and Configure Output Parameters

Enable the voltage auto range to supply maximum current for the voltage setting.

dev.InstrumentSpecific.OutputPhase("OutputPhase1").Voltage.AutoRange = 1
dev = 
  AgAC6800 with properties:

                    Model: "AC6801A" 
             Manufacturer: "Keysight Technologies" 
             SerialNumber: "" 
             ResourceName: "" 
             VendorDriver: "AgAC6800" 
                 Simulate: 1 

           MeasurementIDs: "Measurement1" 
           OutputPhaseIDs: "OutputPhase1" 

    InherentIVIAttributes: [1x1 InherentIVIAttributes] 
        CurrentProtection: [1x1 CurrentProtection] 
             DCGeneration: [1x1 DCGeneration] 
       InstrumentSpecific: [1x1 InstrumentSpecific] 
                   Output: [1x1 Output] 
                  Outputs: [1x1 Outputs] 
               PhaseAngle: [1x1 PhaseAngle] 

Show all functions

Set voltage level to 120 V.

dev.Output.VoltageLevel = acVolts;

Set output phase current limit to 4 A.

configureCurrentLimit(dev,"OutputPhase1",acAmps);

Set output phase frequency level to 50 Hz.

configureFrequency(dev,freq);

Configure Phase Voltage Soft Limit

The AC sources also allow you to set protection features. The first one is soft limits. For this example, the limits will be +/- 10%.

Set output phase voltage soft limit lower limit to 108 V.

dev.InstrumentSpecific.OutputPhase("OutputPhase1").Voltage.SoftLimit.LowerLimit = loVolt;

Set output phase voltage soft limit upper limit to 132 V.

dev.InstrumentSpecific.OutputPhase("OutputPhase1").Voltage.SoftLimit.UpperLimit = hiVolt;

Enable the output phase voltage soft limit.

setAttributeViBoolean(dev,"OutputPhase1","AGAC6800_ATTR_OUTPUT_PHASE_VOLTAGE_SOFT_LIMIT_ENABLED",true);

Configure Output DC Voltage and Current

Set output voltage generation mode to AC Plus DC. Set the DC voltage level to 5 V.

dev.DCGeneration.Mode = "MODE_AC_DC";
dev.DCGeneration.DCVoltageLevel = dcVolts;

Set the output phase current DC limit to 1 A.

dev.InstrumentSpecific.OutputPhase.Current.DCLimit = dcAmps;

Enable Current Protection Feature and Turn Output On

Enable the current protection.

setAttributeViBoolean(dev,"OutputPhase1","AGAC6800_ATTR_PROTECTION_CURRENT_PROTECTION_ENABLED",true);

Enable output.

dev.Output.Enabled = true;

Wait for operation to complete.

systemWaitForOperationComplete(dev, 1000); % Wait for 1000 ms maximum

Make Voltage Measurements

Fetch and display voltage measurements. The measured output values are all 0 because this example is running with simulated hardware.

voltAc = measurementMeasure(dev,"Measurement1","MEASUREMENT_TYPE_VOLTAGERMS");
voltDc = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_VOLTAGEDC");
voltACDC = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_VOLTAGEACDC");
fprintf(['Voltage Measurements\n',...
    'Measured AC Voltage= %0.15g V\n', ...
    'Fetched DC Voltage = %0.15g V\n',...
    'Fetched AC+DC Voltage = %0.15g V rms\n'],...
    voltAc,voltDc,voltACDC);
Voltage Measurements
Measured AC Voltage= 0 V
Fetched DC Voltage = 0 V
Fetched AC+DC Voltage = 0 V rms

Make Current Measurements

Fetch and display current measurements. The measured output values are all 0 because this example is running with simulated hardware.

currAc = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_CURRENTRMS");
currDc = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_CURRENTDC");
currACDC = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_CURRENTACDC");
peakCurr = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_CURRENT_PEAK");
cresFact = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_CREST_FACTOR");
fprintf(['Current Measurements\n',...
    'Fetched AC Current = %0.15g A rms\n', ...
    'Fetched DC Current = %0.15g A\n',...
    'Fetched AC+DC Current = %0.15g A rms\n',...
    'Fetched Peak Current = %0.15g A\n',...
    'Fetched Crest Factor = %0.15g\n'],...
    currAc,currDc,currACDC,peakCurr,cresFact);
Current Measurements
Fetched AC Current = 0 A rms
Fetched DC Current = 0 A
Fetched AC+DC Current = 0 A rms
Fetched Peak Current = 0 A
Fetched Crest Factor = 0

Make Power Measurements

Fetch and display power measurements. The measured output values are all 0 because this example is running with simulated hardware.

realPow = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_REAL");
apparPow = measurementFetch(dev,"Measurement1", "MEASUREMENT_TYPE_POWERVA");
reactPow = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_REACTIVE");
dCPow = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWERDC");
powFact = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_FACTOR");
realPowACDC = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_REALACDC");
apparPowACDC = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWERVAACDC");
reactPowACDC =  measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_REACTIVEACDC");
powFactACDC = measurementFetch(dev,"Measurement1","MEASUREMENT_TYPE_POWER_FACTORACDC");
fprintf(['Power Measurements\n',...
    'Fetched AC Real Power = %0.15g W\n', ...
    'Fetched AC Apparent Power = %0.15g VA\n',...
    'Fetched AC Reactive Power = %0.15g VAR\n',...
    'Fetched DC Power = %0.15g W\n',...
    'Fetched Power Factor = %0.15g\n',...
    'Fetched AC+DC Real Power = %0.15g W\n',...
    'Fetched AC+DC Apparent Power = %0.15g VA\n',...
    'Fetched AC+DC Reactive Power = %0.15g VAR\n',...
    'Fetched AC+DC Power Factor = %0.15g\n'],...
    realPow,apparPow,reactPow,dCPow,powFact,realPowACDC,apparPowACDC,reactPowACDC,powFactACDC);
Power Measurements
Fetched AC Real Power = 0 W
Fetched AC Apparent Power = 0 VA
Fetched AC Reactive Power = 0 VAR
Fetched DC Power = 0 W
Fetched Power Factor = 0
Fetched AC+DC Real Power = 0 W
Fetched AC+DC Apparent Power = 0 VA
Fetched AC+DC Reactive Power = 0 VAR
Fetched AC+DC Power Factor = 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