В этом примере показано, как инициализировать драйвер, считайте несколько свойств драйвера и сделайте измерения мощности с помощью Метра ВЧ-мощности Keysight и выведите результат в MATLAB®.
Этот пример требует следующего:
Версия 17.1 библиотек Keysight (Agilent) IO или более новый
Метр ВЧ-мощности Keysight (Agilent) 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 может использоваться, чтобы визуализировать и выполнить исследования данных, пользующихся богатой библиотекой функций в Signal Processing Toolbox™ и Системах связи Toolbox™. Используя Instrument Control Toolbox™, возможно автоматизировать управление инструментов, и, создать системы тестирования, которые используют MATLAB, чтобы выполнить исследования, которые не могут быть возможным использованием встроенной возможности оборудования.