This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Configure Output Signal on Keysight® RF Signal Generator Using the IVI-C Driver

This example shows how to initialize the driver, read a few properties of the driver and configure output signal using Keysight Technologies RF Signal Generators and output the result in MATLAB®.


This example requires the following to be installed on the computer:

  • Keysight IO libraries version 17.1 or newer

  • Keysight RF Signal Generators IVI driver version 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');
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 Simulated Instrument

% Create the MATLAB instrument driver

% 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('AgRfSigGen.mdd', 'GPIB0::01::INSTR','optionstring','simulate=true');

% Connect driver instance

Attributes and Variables Definition

% These values are defined in the driver's header file 'AgRfSigGen.h'

Get General Device Properties

Query information about the driver and instrument

DriverIdentification = get(myInstrument,'Inherentiviattributesdriveridentification');
InherentIviAttributesInstrumentIdentification = 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(InherentIviAttributesInstrumentIdentification, 'Instrument_Model');
FirmwareRev = get(InherentIviAttributesInstrumentIdentification, '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');
Vendor:          Agilent Technologies
Description:     IVI Driver for Keysight Technologies RF Signal Generator [Compiled for 64-bit.]
InstrumentModel: E4428C
FirmwareRev:     Sim1.5.0.0

Output 1GHz/0dBm (1 milliwatt) Carrier Signal

fprintf('Carrier Signal:\n\t1GHz/0dBm (1 milliwatt)\n');
invoke(Utility, 'reset');
% Specifies the frequency of the generated RF output signal.
Rf = get(myInstrument,'Rf');
set(Rf, 'Frequency', 1E9); % 1 GHz
% Specifies the amplitude (power/level) of the RF output signal.
set(Rf, 'Power_Level', 0); % 0 dB
% Enable RF output signal.
set(Rf, 'Output_Enabled', true);
Carrier Signal:
	1GHz/0dBm (1 milliwatt)

Disable AM,FM and PM Modes

% Disable amplitude modulation (AM) of the RF output signal
AnalogModulationAM = get(myInstrument,'Analogmodulationam');
set(AnalogModulationAM, 'AM_Enabled', false);
% Disable frequency modulation (FM) of the RF output signal
AnalogModulationFM = get(myInstrument,'Analogmodulationfm');
set(AnalogModulationFM, 'FM_Enabled', false);
% Disable phase modulation (PM) of the RF output signal
AnalogModulationPM = get(myInstrument,'Analogmodulationpm');
set(AnalogModulationPM, 'PM_Enabled', false);

Enable Amplitude Modulation (AM) Output

fprintf('Enable Amplitude Modulation (AM)\n\n');
% Get the analog modulation source name
NameBufferSize = 256;
ConfigurationLfGenerator = get(myInstrument, 'Configurationlfgenerator');
Lfg = invoke(ConfigurationLfGenerator, 'getlfgeneratorname', 1,NameBufferSize);
% Set Lfg as amplitude modulation (AM) source
set(AnalogModulationAM, 'AM_Source', Lfg);
% Set Lfg as active LF generator
LfGenerator = get(myInstrument, 'Lfgenerator');
set(LfGenerator, 'Active_LFGenerator', Lfg);
% Generate a 2 kHz sine waveform modulation signal
invoke(ConfigurationLfGenerator, 'configurelfgenerator', 2000, AGRFSIGGEN_VAL_LF_GENERATOR_WAVEFORM_SINE);
% Enable amplitude modulation (AM) mode
set(AnalogModulationAM, 'AM_Enabled', true);
Enable Amplitude Modulation (AM)

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);
ErrorQuery: 0, No error. 

Disconnect Device Object and Clean Up

% Remove instrument objects from memory

Additional Information:

This example shows the setup and configuring output signal on a RF signal generator using the IVI driver. 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.

Was this topic helpful?