4-36
Example Program
SR844 RF Lock-In Amplifier
void main (void) {
// *******************************************************************
// You can see the commands received by the SR844 using the [Setup] key
// to show the receive queue on the displays. The hex values of the received
// characters will be shown.
// *******************************************************************
int nPts,nCount,i,j,test;
double xval, yval, rval, pval;
double ch1val, ch2val;
printf ("\nSR844 Example Program\n");
// ***** Initialize your GPIB card here *****
initialize (21,0);
// ***** Set the SR844 output interface to GPIB! *****
TxSr844 ("*CLS");
// Clear all status registers.
TxSr844 ("OUTX1");
// Direct SR844 responses to GPIB interface.
// ***** Set the Standard Event Enable register to catch EXE and CMD
// Command errors will set the ESB bit in the Serial Poll Status
TxSr844 ("*ESE48"); // set bits 4 and 5
// ***** Check communication by querying the SR844 IDN string
GetSr844 ("*IDN?");
printf ("[GPIB IDN] = %s\n", recv);
printf ("Reset SR844...");
TxSr844 ("*RST");
// Reset the SR844 to the default state.
printf ("done\n");
// Communication parameters are unchanged.
TxSr844("REST");
// Reset data buffers.
TxSr844("SRAT10; SEND0");
// Set sample rate (64 Hz), stop at end.
TxSr844("DDEF1,0; DDEF2,0");
// Buffers store CH1 (X) and CH2 (Y) displays
printf ("Initialization done ... Change settings here if desired.");
GetSpace ();
// Pause to change setup.
// *******************************************************************
// ***** Read outputs normally *****
// Read values sequentially. If the outputs are changing rapidly, the values
// of X,Y,R and phase may not agree.
// OUTP does not include the output expand.
GetSr844 ("OUTP?1"); xval = atof(recv);
// read X
GetSr844 ("OUTP?2"); yval = atof(recv);
// read Y
GetSr844 ("OUTP?3"); rval = atof(recv);
// read R
GetSr844 ("OUTP?5"); pval = atof(recv);
// read phase
printf ("OUTP? :\n");
printf (" X Y R Phase \n");
printf (" %14.6E %14.6E %14.6E %14.6E\n", xval, yval, rval, pval);
// **********
// Read display values (including expands). These values are read sequentially.
GetSr844 ("OUTR?1"); ch1val = atof(recv);
// read CH1 display (with expand)
GetSr844 ("OUTR?2"); ch2val = atof(recv);
// read CH2 display (with expand)
printf ("OUTR? :\n");
printf (" CH1 CH2 \n");
printf (" %14.6E %14.6E\n", ch1val, ch2val);
// **********
// Read X,Y,R,phase simultaneously. These values agree much better for rapidly
// changing outputs.
GetSr844 ("SNAP?1,2,3,5");
// Read X,Y,R,phase at same time.
// Result is a string with 4 values separated
// by commas.
sscanf (recv,"%lf,%lf,%lf,%lf",&xval,&yval,&rval,&pval);
printf ("SNAP? :\n");
Summary of Contents for SR844
Page 10: ...viii SR844 RF Lock In Amplifier...
Page 12: ...1 2 Getting Started SR844 RF Lock In Amplifier...
Page 32: ...2 2 SR844 Basics SR844 RF Lock In Amplifier...
Page 60: ...3 2 Operation SR844 RF Lock In Amplifier...
Page 102: ...3 44 Shift Functions SR844 RF Lock In Amplifier...
Page 108: ...4 6 Index of Commands SR844 RF Lock In Amplifier...
Page 144: ...4 42 Example Program SR844 RF Lock In Amplifier...
Page 146: ...5 2 Performance Tests SR844 RF Lock In Amplifier...
Page 150: ...5 6 Performance Tests SR844 RF Lock In Amplifier...
Page 156: ...5 12 Performance Tests SR844 RF Lock In Amplifier...
Page 158: ...5 14 Performance Tests SR844 RF Lock In Amplifier...
Page 162: ...5 18 Performance Tests SR844 RF Lock In Amplifier...
Page 166: ...5 22 SR844 Test Record SR844 RF Lock In Amplifier...
Page 168: ...6 2 Circuitry Parts Lists and Schematics SR844 RF Lock In Amplifier...
Page 246: ...Parts Lists SR844 RF Lock In Amplifier 6 80 Schematic Diagrams...