FSE Programming Examples
1065.6016.12 7.11 E-16
Programming example:
In the following C program, a single sweep is started on the instrument with the IP address
89.10.38.97 and a marker is set to the maximum level. Before the maximum level can be
determined, the sweep must be terminated. Synchronization to the end of the sweep is made by
triggering a service request at the end of the sweep with command "*OPC" (operation complete).
The control program waits for the SRQ with the function RSDLLWaitSrq(). Then the maximum
level is determined ("CALC:MARK:MAX") and the level is read out ("Y?"). Prior to readout a check
is made with serial poll whether data are available (MAV bit set in status register(only for instruments
with Windows NT controller).
Note: Address ’@local’ and DLL rsib.dll must be used for instruments with MS-DOS controller.
#define MAX_RESP_LEN 100
short ibsta, iberr;
unsigned long ibcntl;
short ud;
short srq;
char Maxlevel[MAX_RESP_LEN];
char spr;
// Determining the handle for the instrument
ud = RSDLLibfind( "89.10.38.97", &ibsta, &iberr, &ibcntl );
// If instrument exists
if ( ud >= 0 ) {
// Setting timeout for RSDLLWaitSrq() to 10 seconds
RSDLLibtmo( ud, 10, &ibsta, &iberr, &ibcntl );
// Activate SRQ generation through event status register (ESR)
// and enable ESB bit of SRE register
RSDLLibwrt( ud, "*ESE 1;*SRE 32", &ibsta, &iberr, &ibcntl );
// Set single sweep, trigger sweep
// and generate SRQ at the end of the sweep with "*OPC"
RSDLLibwrt( ud, "INIT:CONT off;INIT;*OPC", &ibsta, &iberr, &ibcntl );
// Wait for SRQ (end of sweep)
RSDLLWaitSrq( ud, &srq, &ibsta, &iberr, &ibcntl );
// Clear RQS/MSS bit
RSDLLibrsp( ud, &spr, &ibsta, &iberr, &ibcntl );
// If sweep is terminated
if (srq) {
// Set marker to first maximum and query level
RSDLLibwrt( ud, "CALC:MARK:MAX;Y?", &ibsta, &iberr, &ibcntl );
// Check if data are available (MAV bit in status register set)
RSDLLibrsp( ud, &spr, &ibsta, &iberr, &ibcntl );
if (spr & 0x10) {
// then read out data
RSDLLilrd( ud, MaxPegel, MAX_RESP_LEN, &ibsta, &iberr, &ibcntl );
}
}
// end connection to instrument
RSDLLibonl (ud, 0, &ibsta, &iberr, &ibcntl ) ;}
else {
; // Error - instrument not found
}