Tel: 886.2.2175 2930 Email: [email protected]
www.salukitec.com
263
Const char analyzerString [VI_FIND_BUFLEN] = "GPIB0::16::INSTR";
Const analyzerTimeout = 10000;
The constant analyzerString refers to the instrument descriptor,
“GPIB0"
refers to the controller, and "16" refers to the instrument
connected to the controller. Assuming that the instrument is connected LAN, the IP address is "192.168.1.1" and the port number is
"1024", the variable is:
Const char analyzerString [VI_FIND_BUFLEN] = "TCPIPO::192.168.1.1::1024::SOCKET";
9.3.2.2.
Controller Initialization
The following example shows how to establish the communication connection between the VISA library and instrument (with the
specified descriptor).
//Controller initialization: open the default resource manager and return the instrument handle to the analyzer.
void InitController()
{
ViStatus status;
status = viOpenDefaultRM(&defaultRM);
status = viOpen(defaultRM, analyzerString, VI_NULL, VI_NULL, &analyzer);
}
9.3.2.3.
Instrument Initialization
/*************************************************************************/
The following example shows the initialization of the default instrument state and clearing of the status register. "\n" refers to the
terminator. The character string of each command should be ended with ‘\n‘. This will not be described later.
/*************************************************************************/
void InitDevice()
{
ViStatus status; long retCnt;
status = viWrite(analyzer, "*CLS\n", 5, &retCnt); //reset status register
status = viWrite(analyzer, "*RST\n", 5, &retCnt); //reset instrument
}
9.3.2.4.
Query of Instrument Measurement Information
/*************************************************************************
/ The following example shows all measurements, windows and tracks defined at present.
/*************************************************************************/
void QueryMesaurement()
{
ViStatus status; long retCnt;
char rd_Buf_CW[VI_READ_BUFLEN]; // #define VI_READ_BUFLEN 20 char rd_Buf_LVL[VI_READ_BUFLEN];
// query all measurements of Channel 1