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.


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
    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'))
    % poll the instrument for completion of this command
    % because adjusting a new wavelength takes some time
%     errStatus = viQueryf(vi,"*OPC?\n","%d",&cmdDone);
    while resp==0
        resp = fscanf(laser);
        pause(1e-3) % [s]

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