AnsweredAssumed Answered

8164A Lightwave Measurement System

Question asked by ralphie02 on Feb 13, 2011
Latest reply on Apr 16, 2012 by andywhite
Hi Everyone,

I am currently having problems coding with Matlab. I am suppose to send/sweep a series of wavelengths through a photonic chip and scan it on the other end. Everything is fine but it is taking longer than I want it to. Please look at the code below and tell me if I should change something in order to make it run faster.

Thanks,
Ralph

PS~~i did not implement this code, I am suppose to edit it to make it run faster. Ive run test and figured that the wave part of the loop takes the longest time.

for i=1:floor(num_pts)+1
    % query the power
    fprintf(laser,'fetch3:chan2:pow?')
    power(i) = str2double(fscanf(laser));

    % record time
    time(i) = etime(clock,t0);

    % get celsius temp
    fprintf(tc, 'TTRD?')
    temp(i) = str2double(fscanf(tc));

    % increase the wavelength
    wav = wav+step;                                                          --------> takes about 0.35s while the whole loop is around 0.535s
    fprintf(laser,cat(2,'source0:wav ',num2str(wav),'nm'))
    fprintf(laser,'source0:wav?')
   
   
    % poll the instrument for completion of this command
    % because adjusting a new wavelength takes some time
%     errStatus = viQueryf(vi,"*OPC?\n","%d",&cmdDone);
    resp=0;
    while resp==0
        fprintf(laser,'*OPC?')
        resp = fscanf(laser);
        pause(1e-3) % [s]
    end
end

Edited by: mkelly on Mar 15, 2012 4:24 AM  

Outcomes