Programming Examples
How to Measure Power using FETCH and READ
errStatus = viOpenDefaultRM (&defaultRM);
if(errStatus < VI_SUCCESS)
{
printf("Failed to open VISA Resource manager\n");
exit(errStatus);
}
errStatus = viOpen (defaultRM, "GPIB::20::INSTR", VI_NULL,VI_NULL,&vi);
if(errStatus < VI_SUCCESS)
{
printf("Failed to open instrument\n");
exit(errStatus);
}
/*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);
148