Example
Program
5-133
SR785 Dynamic Signal Analyzer
octreal = 0.04467*0.04467; //(44.67 mV)^2 real part
octimag = 0.0; //no imaginary part
//This section needs to be modified for your GPIB interface
printf ("Loading Trace 5...");
TxGpib (SR785,"TASC? 5,34"); //use TxGpib (no wait for IFC RDY)
//TASC downloads ASCII data,
//use TLOD to download binary data.
transmit("mla talk 10",&status); //make SR785 a talker, pc a listener
rarray (&ack, 4, &length, &status); //binary read 4 bytes (long int)
//return value should be 1
printf ("%d bytes recvd [val=%ld]...",length,ack);
// TASC (TLOD) replaces the data in an existing Trace (5).
// The Trace measurement and length are not changed!
// Download 34 bins of data (real, imaginary) with commas to separate,
// and EOI at the end.
// First 33 bins are the spectrum, last bin is the Total Power bin.
// All points are complex.
// For an octave measurement, the imaginary parts are all zero.
transmit("mta listen 10",&status); //make SR785 a listener, pc a talker
for (i=0; i<33; i++) {
//download 33 octave bins
sprintf (cmd,"DATA '%lf, '", octreal); //real part
transmit (cmd,&status);
sprintf (cmd,"DATA '%lf, '", octimag); //imaginary part
transmit (cmd,&status);
}
// last bin is the total power bin
sprintf (cmd,"DATA '%lf, '", octreal*33); //real part of total power bin
transmit (cmd,&status);
sprintf (cmd,"DATA '%lf' END", 0.0); //imag part of total power bin,
transmit (cmd,&status); //last value, terminate with EOI!
WaitIFC (); //serial poll until IFC set, ok to continue
printf ("done\n");
TxSR785 ("RCTR 1,5"); //recall Trace 5 to DisplayB to view the new data
/* ***************************************************** */
/* ****** Define a User Function ****** */
// define Func1 = Oct(1)/Trace5
TxSR785 ("USRO 1,36,-5,5"); //36=Oct(1), -5=divide, 5=Trace5
TxSR785 ("MEAS 0,37"); //DisplayA measures UserFunc1
TxSR785 ("YMAX 0,40"); //Change the top graph scale.
//Func1 is Oct(1) normalized by Trace5.
//The amplitudes are approximately 0 dB.
//The Total Power bin is calculated from the
//sum of the octave bins in the function,
//(it is not normalized to Trace5).
// ****** end of main program
}
/* ********************************************************************* */
void TxGpib (int address,char *command)
// routine to transmit command to a GPIB address
// modify this routine for your GPIB interface
{
send (address,command,&status); // send() is the CEC routine to send
// a string to an address.
// Sets status = 0 to indicate result OK
if (status != 0) {
// handle transmit errors here
printf ("\nCommand = %s\n",command);
printf ("Error at device %d : status = %d\n",address,status);
GetSpace ();
}
Summary of Contents for SR785
Page 4: ...ii ...
Page 10: ...viii ...
Page 80: ...1 64 Exceedance Statistics ...
Page 158: ...2 78 Curve Fitting and Synthesis SR785 Dynamic Signal Analyzer ...
Page 536: ...5 136 Example Program SR785 Dynamic Signal Analyzer ...