В этом примере показано, как инициализировать драйвер, считайте несколько свойств драйвера и использования частоты меры Keysight Technologies 532xx Счетчик Частоты и выведите результат в MATLAB®.
Этот пример требует следующего:
Версия 17.1 библиотек Keysight IO или более новый
Keysight 532xx Счетчик Частоты IVI версий драйвера 1.0.11.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('Ag532xx','Ag532xx.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('Ag532xx.mdd', 'GPIB0::01::INSTR','optionstring','simulate=true'); % Connect driver instance connect(myInstrument);
% These values are defined in the driver's header file 'Ag532xx.h'
AG532XX_VAL_SLOPE_POSITIVE = 1;
AG532XX_VAL_TRIGGER_SOURCE_IMMEDIATE = 0;
AG532XX_VAL_ARM_MEASUREMENT_TYPE_FREQUENCY = 0;
AG532XX_VAL_ARM_SOURCE_ADVANCED = 3;
AG532XX_VAL_IMMEDIATE_ARM_TYPE = 1;
AG532XX_VAL_DELAY_HOLD_OFF_SOURCE_TIME = 1;
Запросите информацию о драйвере и инструменте
InherentIviAttributesDriverIdentification = get(myInstrument,'Inherentiviattributesdriveridentification'); InherentIviAttributesInstrumentIdentification = get(myInstrument,'Inherentiviattributesinstrumentidentification'); Utility = get(myInstrument, 'Utility'); Revision = invoke(Utility, 'revisionquery'); Vendor = get(InherentIviAttributesDriverIdentification, 'Specific_Driver_Vendor'); Description = get(InherentIviAttributesDriverIdentification, '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');
Revision: 1.0.11.0 Vendor: Agilent Technologies Description: IVI Driver for Agilent 532xx family of Counters. [Compiled for 64-bit.] InstrumentModel: 53230A FirmwareRev: Sim1.0.11.0
fprintf('\nBasic Frequency Measurement \n'); % Configure the counter for a frequency measurement on the specified % channel InstrumentSpecificFrequency = get(myInstrument,'Instrumentspecificfrequency'); invoke(InstrumentSpecificFrequency, 'frequencyconfigure', 1E6,1E-4,1); % Sets the number of triggers that will be accepted by the instrument % before returning to the "idle" trigger state InstrumentSpecificTrigger = get(myInstrument,'Instrumentspecifictrigger'); set(InstrumentSpecificTrigger, 'Trigger_Count', 1); % Sets trigger source for measurements. % IMMediate (continuous) source immediately issues the trigger set(InstrumentSpecificTrigger, 'Trigger_Source', AG532XX_VAL_TRIGGER_SOURCE_IMMEDIATE); % Sets slope of the trigger signal on the rear-panel Trig In BNC set(InstrumentSpecificTrigger, 'Trigger_Slope', AG532XX_VAL_SLOPE_POSITIVE); % Initiates a measurement based on the current configuration. MeasurementLowLevelMeasurement = get(myInstrument,'Measurementlowlevelmeasurement'); invoke(MeasurementLowLevelMeasurement, 'initiate'); % Does not return until previously started operations complete or more % MaxTimeMilliseconds milliseconds of time have expired. InstrumentSpecificSystem = get(myInstrument,'Instrumentspecificsystem'); invoke(InstrumentSpecificSystem, 'systemwaitforoperationcomplete', 10000); % Retrieves the result from a previously initiated measurement. RetVal = invoke(MeasurementLowLevelMeasurement, 'fetch'); fprintf('Data: %0.15g\n', RetVal);
Basic Frequency Measurement Data: 0
Получает математическое среднее значение (среднее значение) всех измерений, проведенных с прошлого раза, когда статистические данные были очищены. Цель использовать усреднение функции состоит в том, чтобы увеличить надежность и отношение сигнал-шум измерений.
fprintf('\nAveraging \n'); % Configures the counter for a frequency measurement on the specified % channel invoke(InstrumentSpecificFrequency, 'frequencyconfigure', 1E6,1E-4,1); % Sets the number of triggers that will be accepted by the instrument % before returning to the "idle" trigger state set(InstrumentSpecificTrigger, 'Trigger_Count', 1); % Sets trigger source for measurements. % Immediate (continuous) source immediately issues the trigger set(InstrumentSpecificTrigger, 'Trigger_Source', AG532XX_VAL_TRIGGER_SOURCE_IMMEDIATE); % Sets the number of measurements samples the instrument will take per trigger set(InstrumentSpecificTrigger, 'Trigger_Sample_Count', 3); % Sets slope of the trigger signal on the rear-panel Trig In BNC set(InstrumentSpecificTrigger, 'Trigger_Slope', AG532XX_VAL_SLOPE_POSITIVE); % Enables all calculate commands InstrumentSpecificMath = get(myInstrument, 'Instrumentspecificmath'); set(InstrumentSpecificMath, 'Math_Enabled', true); % Enables statistics computation InstrumentSpecificMathStatistics = get(myInstrument,'Instrumentspecificmathstatistics'); set(InstrumentSpecificMathStatistics, 'Statistics_Enabled', true); % Initiates a measurement based on the current configuration. invoke(MeasurementLowLevelMeasurement, 'initiate'); % Does not return until previously started operations complete or more % MaxTimeMilliseconds milliseconds of time have expired. invoke(InstrumentSpecificSystem, 'systemwaitforoperationcomplete', 10000); % Gets the mathematical average (mean) of all measurements taken since % the last time statistics were cleared Average = get(InstrumentSpecificMathStatistics, 'Statistics_Average'); fprintf('Average : %0.15g \n', Average);
Averaging Average : 1000000
Измерения метки времени записывают ребра сигнала частоты, когда они происходят на встречных входных каналах
fprintf('\nTime Stamp Measurement \n'); % Set all measurement parameters and trigger parameters to default % values selectively for timestamp measurements, then immediately % trigger a measurement. InstrumentSpecificTimeStamp = get(myInstrument,'Instrumentspecifictimestamp'); % [VAL,VALACTUALSIZE] = INVOKE(OBJ,'timestampmeasure',COUNT,CHANNEL,VALBUFFERSIZE,VAL) [Val, ValActualSize] = invoke(InstrumentSpecificTimeStamp, 'timestampmeasure', 10,1,10,zeros(10)); fprintf('%d Data Points: \n',ValActualSize); for i= 1:ValActualSize fprintf('%0.15g\t\n', Val(i)); end
Time Stamp Measurement 10 Data Points: 0 1e-06 2e-06 3e-06 4e-06 5e-06 6e-06 7e-06 8e-06 9e-06
Измерение запускается на положительном (возрастающем) ребре на канале 1 и останавливается на положительном ребре на канале 2.
fprintf('\nTime Intervals Measurement with delay \n'); % Configures instrument for a time interval measurement on the specified % channels InstrumentSpecificTimeInterval = get(myInstrument,'Instrumentspecifictimeinterval'); invoke(InstrumentSpecificTimeInterval, 'timeintervalconfigure', 1,2); % Set the gate source for frequency measurement InstrumentSpecificArm = get(myInstrument,'Instrumentspecificarm'); invoke(InstrumentSpecificArm, 'armsetsource', AG532XX_VAL_ARM_MEASUREMENT_TYPE_FREQUENCY,AG532XX_VAL_ARM_SOURCE_ADVANCED); % Configures the Start Arm for armed measurements. Configuration = get(myInstrument,'Configuration'); invoke(Configuration, 'configurestartarm', AG532XX_VAL_IMMEDIATE_ARM_TYPE); % Set the source used to delay the arm start InstrumentSpecificArmStartExternal = get(myInstrument,'Instrumentspecificarmstartexternal'); set(InstrumentSpecificArmStartExternal,'Start_External_Delay_Source', AG532XX_VAL_DELAY_HOLD_OFF_SOURCE_TIME); % Set the delay, in seconds, used after an external armed measurement % has been armed. Arming = get(myInstrument,'Arming'); set(Arming, 'External_Start_Arm_Delay', 0.1); % Configure the Stop Arm for armed measurements. invoke(Configuration, 'configurestoparm', AG532XX_VAL_IMMEDIATE_ARM_TYPE); % Set the source used to hold off enabling the stop Arm source InstrumentSpecificArmStopExternal = get(myInstrument,'Instrumentspecificarmstopexternal'); set(InstrumentSpecificArmStopExternal, 'Stop_External_Hold_Off_Source', AG532XX_VAL_DELAY_HOLD_OFF_SOURCE_TIME); % Specify the delay, in seconds, after the External Arm Stop event % has occurred until the measurement stops. set(Arming, 'External_Stop_Arm_Delay', 0.25); % Sets the number of triggers that will be accepted by the instrument % before returning to the "idle" trigger state set(InstrumentSpecificTrigger, 'Trigger_Count', 1); % Sets the number of measurements samples the instrument will take per trigger set(InstrumentSpecificTrigger, 'Trigger_Sample_Count', 3); % Initiates a measurement based on the current configuration. invoke(MeasurementLowLevelMeasurement, 'initiate'); % Wait until initialization operation complete or 50000 milliseconds % of time have expired invoke(InstrumentSpecificSystem, 'systemwaitforoperationcomplete', 50000); % Retrieves the result from a previously initiated measurement. RetVal = invoke(MeasurementLowLevelMeasurement, 'fetch'); fprintf('Data: %0.15g\n', RetVal); fprintf('\n');
Time Intervals Measurement with delay Data: 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, чтобы выполнить исследования, которые не могут быть возможным использованием встроенной возможности оборудования.