image thumbnail
from Agilent 86141B Optical Spectrum analyzer -data acquisition by vishnu
Program to extract data from Agilent 86141B spectrum analyzer

agilent_86141B_Optical_spec_analyzer.m
clear all;close all;clc;

%In this program the requires wavelength to be set manually 
%Pl turn on light source before executing this program
%Pl enter the primary address of agilent 86141B spectrum analyzer

% instrument data %Enter primary address of OSA
  g = instrfind('Type', 'gpib', 'BoardIndex', 7, 'PrimaryAddress', 23, 'Tag', '');
  get(g,{'EOSMode','EOIMode'});
  if isempty(g)
  g = gpib('AGILENT', 7, 23);
  else
  fclose(g);
  end
  set(g, 'InputBufferSize', 20000); 
  set(g, 'Timeout', 20.0);
  fopen(g);
  fprintf(g,'*IDN?');
  idn = fscanf(g) ;

%start wavelength,stop wavelength,sensitivity,resolution
  fprintf(g, 'sens:wav:star 1400nm');
  fprintf(g, 'sens:wav:stop 1500nm');
  fprintf(g, 'sens:pow:dc:rang:low -60dBm');
  fprintf(g, 'sens:bwid:res 5nm');

%
  fprintf(g, 'init:imm');
  fprintf(g, 'trac:data:y? tra');
  t = fscanf(g) ;
  r=str2num(t);
%   figure(1)
%   plot(r)

% 
  fclose(g);
  
%Data processing
sizer=size(r);
wavelength=linspace(1400,1500,sizer(2));
figure(2)
plot(wavelength,r)
xlabel('wavelength');
ylabel('Transmittance (dBm)')
title('Transmittance Vs Wavelength')
%saving data
data_saved=[wavelength ;r];
save('data','data_saved')

Contact us at files@mathworks.com