Specifications
ZVx Programming Examples
1043.0009.50 D.11 E-2
Programming example:
In the following C program example, a single sweep is started on the device with the IP address
89.10.38.97 and subsequently a marker is set to maximum level. Prior to the search for maximum, a
synchronization to the end of the sweep is performed. For this purpose the command "*OPC"
(Operation complete) is used to create a service request at the end of the sweep, for which the
control program waits with the function RSDLLWaitSrq(). Then the maximum is determined
("CALC:MARK:MAX") and the level read out ("Y?").
#define MAX_RESP_LEN 100
short ibsta, iberr;
unsigned long ibcntl;
short ud;
short srq;
char MaxPegel[MAX_RESP_LEN];
char spr;
// Determine handle for instrument
ud = RSDLLibfind( "89.10.38.97", &ibsta, &iberr, &ibcntl );
// if instrument exists
if ( ud >= 0 )
{
// Set timeout for RSDLLWaitSrq() to 10 seconds
RSDLLibtmo( ud, 10, &ibsta, &iberr, &ibcntl );
// Activate SRQ generation via event status register (ESR)
// and enable ESB bit in SRE register
RSDLLibwrt( ud, "*ESE 1;*SRE 32", &ibsta, &iberr, &ibcntl );
// Set single sweep, trigger sweep and use "*OPC" to cause
// the generation of a service request at the end of the sweep
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)
{
// then set marker to first maximum and query the level
RSDLLibwrt( ud, "CALC:MARK:MAX;Y?", &ibsta, &iberr, &ibcntl );
RSDLLilrd( ud, MaxPegel, MAX_RESP_LEN, &ibsta, &iberr, &ibcntl );
MaxPegel[ibcntl] = 0;
}
// End connection to instrument
RSDLLibonl (ud, 0, &ibsta, &iberr, &ibcntl ) ;
}
else
{
; // Error Instrument not found
}