Set Output Voltage and Make Measurements from a Keysight AgE3633A DC Power Supply Using the IVI-C Driver
This example shows how to initialize the driver, read a few properties of the driver, set output voltage, enable all outputs and measure the output voltage, disable all outputs and measure the output voltage by using Keysight™ Technologies E3633A DC power supply and output the result in MATLAB®.
Requirements
This example requires the following:
Keysight IO libraries version 17.1 or newer
Keysight E36xx DC Power Supply IVI version 1.2.0.0 or newer
Enumerate Available IVI-C Drivers on the Computer
This enumerates the IVI drivers that have been installed on the computer.
IviInfo = instrhwinfo('ivi');
IviInfo.Modules
ans = Columns 1 through 6 'Ag33220' 'Ag3352x' 'Ag34410' 'Ag34970' 'Ag532xx' 'AgAC6800' Columns 7 through 11 'AgE36xx' 'AgInfiniiVision' 'AgMD1' 'AgRfSigGen' 'AgXSAn' Columns 12 through 13 'KtRFPowerMeter' 'rsspecan'
Create MATLAB Instrument Driver And Connect to the Instrument
% Create the MATLAB instrument driver makemid('AgE36xx','AgE3633A.mdd') % Use icdevice with the MATLAB instrument driver name and instrument's % resource name to create a device object. In this example the instrument % is connected by GPIB at board index 0 and primary address 1. myInstrument = icdevice('AgE3633A.mdd', 'GPIB0::01::INSTR','optionstring','simulate=true'); % Connect driver instance connect(myInstrument);
Attributes and Variables Definition
% These values are defined in the driver's header file 'AgE36xx.h'
IVI_ATTR_BASE = 1000000;
IVI_CLASS_ATTR_BASE = IVI_ATTR_BASE + 250000;
AGE36XX_ATTR_VOLTAGE_LEVEL = IVI_CLASS_ATTR_BASE + 1;
AGE36XX_VAL_MEASURE_VOLTAGE = 1;
Get General Device Properties
Query information about the driver and instrument
DriverIdentification = get(myInstrument,'Inherentiviattributesdriveridentification'); InstrumentIdentification = get(myInstrument,'Inherentiviattributesinstrumentidentification'); Utility = get(myInstrument, 'Utility'); Revision = invoke(Utility, 'revisionquery'); Vendor = get(DriverIdentification, 'Specific_Driver_Vendor'); Description = get(DriverIdentification, 'Specific_Driver_Description'); InstrumentModel = get(InstrumentIdentification, 'Instrument_Model'); FirmwareRev = get(InstrumentIdentification, 'Instrument_Firmware_Revision'); % Print the queried driver properties fprintf('Revision: %s\n', Revision); fprintf('Vendor: %s\n', Vendor); fprintf('Description: %s\n', Description); fprintf('InstrumentModel: %s\n', InstrumentModel); fprintf('FirmwareRev: %s\n', FirmwareRev); fprintf(' \n');
Revision: 1.2.1.0 Vendor: Agilent Technologies Description: IVI driver for the Agilent E36xx family of programmable power supplies [Compiled for 64-bit.] InstrumentModel: E3633A FirmwareRev: Sim1.2.1.0
Set Output Voltage
Configuration = get(myInstrument, 'Configuration'); invoke(Configuration, 'configurevoltagelevel', 'Output1', 1.23); fprintf('Output 1 set to: 1.23 Volts \n');
Output 1 set to: 1.23 Volts
Enable All Outputs and Measure the Output Voltage
Outputs = get(myInstrument, 'Outputs'); set(Outputs, 'Enabled', true); fprintf('All outputs enabled \n'); % The measured voltage should read as the set value. Action = get(myInstrument, 'Action'); MeasVal = invoke(Action, 'measure', 'Output1', AGE36XX_VAL_MEASURE_VOLTAGE); fprintf('Output 1 Measurement = %.4g Volts\n', MeasVal);
All outputs enabled Output 1 Measurement = 1.23 Volts
Disable All Outputs and Measure the Output Voltage
set(Outputs, 'Enabled', false); fprintf('All outputs disabled\n'); % Since all outputs have been disabled, the measured voltage should be 0. MeasVal = invoke(Action, 'measure', 'Output1', AGE36XX_VAL_MEASURE_VOLTAGE); fprintf('Output 1 Measurement = %.4g Volts\n\n', MeasVal);
All outputs disabled Output 1 Measurement = 0 Volts
Display Any Errors from the Driver
% If there are any errors, query the driver to retrieve and display them. ErrorNum = 1; while (ErrorNum ~= 0) [ErrorNum, ErrorMsg] = invoke(Utility, 'errorquery'); fprintf('ErrorQuery: %d, %s\n', ErrorNum, ErrorMsg); end
ErrorQuery: 0, No error.
Disconnect the Device Object and Clean Up
disconnect(myInstrument);
% Remove instrument objects from memory.
delete(myInstrument);
Additional Information:
This example shows setting output voltage and making measurements on a DC power supply using the IVI driver. Once the measured voltage is retrieved from the instrument, MATLAB can be used to visualize and perform analyses on the data using the rich library of functions in the Signal Processing Toolbox™ and Communications Systems Toolbox™. Using Instrument Control Toolbox™, it is possible to automate control of instruments, and, build test systems that use MATLAB to perform analyses that may not be possible using the built-in capability of the hardware.