В этом примере показано, как инициализировать драйвер, прочитать несколько свойств драйвера и выполнить измерения мощности с помощью Keysight RF Power Meter и вывести результат в MATLAB ®.
Этот пример требует следующего:
Библиотеки ввода-вывода Keysight (Agilent) версии 17.1 или новее
Keysight (Agilent) RF Power Meter IVI версии 1.0.9.0 или новее
Здесь перечисляются драйверы IVI, установленные на компьютере.
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 the MATLAB instrument driver makemid('KtRFPowerMeter','KtRFPowerMeter.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('KtRFPowerMeter.mdd', 'GPIB0::01::INSTR','optionstring','simulate=true'); % Connect driver instance connect(myInstrument);
% These values are defined in the driver's header file 'KtRFPowerMeter.h' IVI_ATTR_BASE = 1000000; IVI_CLASS_ATTR_BASE = IVI_ATTR_BASE + 250000; IVI_SPECIFIC_ATTR_BASE = IVI_ATTR_BASE + 150000; KTRFPOWERMETER_ATTR_CALIBRATOR_ENABLED = IVI_SPECIFIC_ATTR_BASE + 189; % 1150189 KTRFPOWERMETER_ATTR_OFFSET = IVI_CLASS_ATTR_BASE + 5; % 1250005 KTRFPOWERMETER_ATTR_CHANNELS_ITEM_TRIGGER_CONTINUOUS_ENABLED = IVI_SPECIFIC_ATTR_BASE + 49; KTRFPOWERMETER_ATTR_MEASUREMENTS_ITEM_OFFSET_ENABLED = IVI_SPECIFIC_ATTR_BASE + 79;
Запросите информацию о драйвере и приборе
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.0.9.0 Vendor: Keysight Technologies Description: IVI Driver for KtRFPowerMeter [Compiled for 64-bit.] InstrumentModel: E4416A FirmwareRev: Sim1.0.9.0
% Perform the default preset on the power meter InstrumentSpecificSystem = get(myInstrument, 'Instrumentspecificsystem'); invoke(InstrumentSpecificSystem, 'systempreset'); % Wait until all instrument operations complete or until MaxTimeMilliseconds has expired invoke(InstrumentSpecificSystem, 'systemwaitforoperationcomplete', 20000); % Disables continuous triggering AttributeAccessors = get(myInstrument, 'Attributeaccessors'); invoke(AttributeAccessors, 'setattributeviboolean', 'A', KTRFPOWERMETER_ATTR_CHANNELS_ITEM_TRIGGER_CONTINUOUS_ENABLED, 0); % Get the number of channels available on the instrument BasicOperation = get(myInstrument, 'Basicoperation'); ChannelCount = get(BasicOperation, 'Channel_Count'); % Get the model number or name reported by the physical instrument InherentIviAttributesInstrumentIdentification = get(myInstrument, 'Inherentiviattributesinstrumentidentification'); InstrumentModel = get(InherentIviAttributesInstrumentIdentification, 'Instrument_Model'); if (ChannelCount >= 2) && not(strcmpi(InstrumentModel,'N1913A')) && not(strcmpi(InstrumentModel,'N1914A')) % Disables continuous triggering invoke(AttributeAccessors, 'setattributeviboolean', 'B', KTRFPOWERMETER_ATTR_CHANNELS_ITEM_TRIGGER_CONTINUOUS_ENABLED, 0); end % Enables the POWER REF output invoke(AttributeAccessors, 'setattributeviboolean', 'A', KTRFPOWERMETER_ATTR_CALIBRATOR_ENABLED, 1);
% Initiates a measurement on all enabled channels MeasurementLowLevelMeasurement = get(myInstrument, 'Measurementlowlevelmeasurement'); invoke(MeasurementLowLevelMeasurement, 'initiate'); % Wait until all instrument operations complete or MaxTimeMilliseconds has expired invoke(InstrumentSpecificSystem, 'systemwaitforoperationcomplete', 10000); for iLoop = 1:4 % Specifying an offset to be added to the measured value in units of dB invoke(AttributeAccessors, 'setattributevireal64', 'A', KTRFPOWERMETER_ATTR_OFFSET, -10*iLoop); % Initiates a measurement InstrumentSpecificMeasurement = get(myInstrument, 'Instrumentspecificmeasurement'); ReadResult = invoke(InstrumentSpecificMeasurement, 'measurementsitemread', '1',50000); % Disable the display offset invoke(AttributeAccessors, 'setattributeviboolean', '1', KTRFPOWERMETER_ATTR_MEASUREMENTS_ITEM_OFFSET_ENABLED,0); % Fetch the result of a previously initiated measurement FetchResult = invoke(InstrumentSpecificMeasurement, 'measurementsitemfetch', '1',50000); % Enable the display offset invoke(AttributeAccessors, 'setattributeviboolean', '1', KTRFPOWERMETER_ATTR_MEASUREMENTS_ITEM_OFFSET_ENABLED,1); % Perform a power measurement MeasResult = invoke(InstrumentSpecificMeasurement, 'measurementsitemmeasure', '1',50000); fprintf('Read result: %.3f, Fetch Result: %g, Measure Result: %g\n', ReadResult, FetchResult, MeasResult); end fprintf('\n');
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
% 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(myInstrument);
% Remove instrument objects from memory.
delete(myInstrument);
Этот пример показывает настройку и измерение степени от радиочастотной степени счетчика с помощью драйвера IVI. После извлечения измеренных данных из прибора MATLAB может использоваться, чтобы визуализировать и выполнить анализ данных с помощью богатой библиотеки функций в Toolbox™ Signal Processing Toolbox™ и коммуникационных систем. Используя Instrument Control Toolbox™, можно автоматизировать управление инструментами, и, создать тестовые системы, которые используют MATLAB для выполнения анализа, который может быть невозможен с помощью встроенной возможности оборудования.