https://www.keysight.com/main/editorial.jspx?cc=CN&lc=chi&ckey=407788&nid=-32408.752542.02&id=407788&cmpid=94444windows
頻譜儀例子:https://www.keysight.com/upload/cmc_upload/All/SerAlign.csession
信號源:https://www.keysight.com/upload/cmcupload/All/MXASweep.cjsp
/********************************************************************* * SerAlign.c * Serial Poll Alignment Routine * Agilent Technologies 2001 * * Instrument Requirements: * PSA Series Spectrum Analyzer or * ESA Series Spectrum Analyers or * VSA Series Transmitter Tester * * This program demonstrates how to * 1) Perform an instrument alignment. * 2) Poll the instrument to determine when the operation is complete. * 3) Query to determine if the alignment was successfuly completed. * **********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <windows.h> #include "visa.h" void main () { /*program variables*/ ViSession defaultRM, viPSA; ViStatus viStatus = 0; ViUInt16 esr,stat; long lResult = 0; long lOpc = 0; char cEnter = 0; /*open session to GPIB device at address 18 */ viStatus=viOpenDefaultRM (&defaultRM); viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL,&viPSA); /*check opening session sucess*/ if(viStatus) { printf("Could not open a session to GPIB device at address 18!\n"); exit(0); } /*increase timeout to 60 sec*/ viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,60000); /*Clear the analyzer*/ viClear(viPSA); /*Clear all event registers*/ viPrintf(viPSA, "*CLS\n"); /* Set the Status Event Enable Register */ viPrintf(viPSA, "*ESE 1\n"); /*Initiate self-alignment*/ viPrintf(viPSA, "CAL:ALL\n"); /* Send the Operation complete command so that the stand event register will be set to 1 once the pending alignment command is complete */ viPrintf(viPSA, "*OPC\n"); /* print message to standard output */ printf("Performing self-alignment.\n"); /* Serial pole the instrument for operation complete */ while(1) { viQueryf(viPSA,"*ESR?\n","%ld",&esr); printf("."); if (esr & 1) break; //look for operation complete bit Sleep (1000); // wait 1000ms before polling again } /* Query the Status Questionable Condition Register */ viQueryf(viPSA,":STAT:QUES:CAL:COND?\n","%ld",&stat); /*Determine if alignment was successful*/ if (stat) printf("\nAlignment not successful\n\n"); else printf("\nAlignment successful\n\n"); /*reset timeout to 5 sec*/ viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,5000); /*print message to the standard output*/ printf("Press Return to exit program \n\n"); scanf("%c",&cEnter); /* Close session */ viClose (viPSA); viClose (defaultRM); }