Agilent Technologies 8166A User Manual

Page of 274
VISA Programming Examples
How to Measure Power using FETCh and READ
196
Agilent 8163A/B, 8164A/B & 8166A/B Mainframes, Fifth Edition
            }
        /*set  timeout  to  20  sec;  this  should  work  for  all  commands
            except  zeroing  */
    errStatus = viSetAttribute(vi,VI_ATTR_TMO_VALUE,20000);
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
        /*  make  sure  that  the  reference  is  not  used  */
    errStatus = viPrintf(vi,"SENS1:CHAN1:POW:REF:STATE 0\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
    /* clear the error queue */
        errStatus  =  viPrintf(vi,"*CLS\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
        /*  turn  auto  range  on  */
    errStatus = viPrintf(vi,"SENS1:CHAN1:POW:RANGE:AUTO 1\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
        /*  change  the  power  unit  to  watt  */
    errStatus = viPrintf(vi,"SENS1:CHAN1:POW:UNIT W\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
    /*set the averaging time for measuring to 0.5s*/
        averagingTime  =  0.5;
    errStatus = viPrintf(vi,"SENS1:CHAN1:POW:ATIME 
%f\n",averagingTime);
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
        /*  turn  continous  measuring  off  */
        errStatus  =  viPrintf(vi,"INIT1:CHAN1:CONT  0\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
                /*  trigger  a  measurement  */
        errStatus  =  viPrintf(vi,"INIT1:CHAN1:IMM\n");
        if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
       
        /*  read  10  values  and  display  the  result;  */
        for  (i  =  0;  i  <  10;  i++)
            {
  /* Now because an averaged value is available, the value will be 
fetched */ 
                errStatus  = 
viQueryf(vi,"%s","%s","FETCH1:CHAN1:POW?\n",replyBuf);
                if  (errStatus  <  VI_SUCCESS)  checkError(vi,errStatus);
  /* two consecutive values are compared; if they are equal it will be 
marked; because no evaluation is triggered, all values will be the same 
*/
                if(i)