Stanford Research Systems SR810 Manual page 103

Dsp lock-in amplifier
Table of Contents

Advertisement

printf("\n%d bytes received.\nPress <Enter> to continue.",i);
getch(); printf("\n");
printf("Reading Results in IEEE Binary Format\n");
txLia("SPTS?");
ibrd(lia,tstr,20L);
sscanf(tstr,"%d",&nPts);
printf ("SPTS?=%d\n",nPts);
sprintf(tstr,"TRCB?0,%d",nPts);
ibwrt(lia,tstr,strlen(tstr));
ibrd(lia,(char *)rfBuf,(long)nPts*4L); /* read directly into a FLOAT array, 4 bytes per point */
printf ("\nReceived %d bytes in IEEE binary format\n",ibcnt);
printOutIEEEResults();
printf ("Press <Enter> to continue");
getch(); printf("\n");
printf("Reading Results in LIA Binary Format\n");
sprintf(tstr,"TRCL?0,%d",nPts);
ibwrt(lia,tstr,strlen(tstr));
ibrd(lia,(char *)rfBuf,(long)nPts*4L); /* read into FLOAT array but the values are NOT floats! */
printf ("\nReceived %d bytes in LIA binary format\n",ibcnt);
printOutLIAResults();
printf ("End of Program");
}
void printOutBinaryResults(void)
{
/* calculates the first 10 values of R based on the X and Y values taken in FAST mode by the SR810 */
int i;
float x,y,r;
int *ptr;
printf("\n\n");
ptr = rxBuf; /* ptr points to the first X,Y pair of values. X and Y are each integers. */
for (i=0;i<10;i++)
x = (float) (*ptr++) /(float) 30000.0; /* 30000 is full scale which is 1 V in this case */
y = (float) (*ptr++) /(float) 30000.0; /* for other scales, multiply by the full scale voltage */
r = (float) sqrt(x*x + y*y);
printf("%d %e\n",i,r);
}
}
void printOutIEEEResults(void)
{
/* prints the first 10 values of R transferred in IEEE floating point format by the SR810 */
int i;
/* how many points in CH1 (R) buffer? */
/* get the answer */
/* convert from a string to an int */
/* use TRCB? to read the points in IEEE floating point format */
/* note that we cannot use txLia here because the IFC RDY bit will
not be set until the transfer is complete! */
/* format and print results */
/* use TRCL? to read the points in LIA floating point format */
/* note that we cannot use txLia here because the IFC RDY bit will
not be set until the transfer is complete! */
/* format and print results */
{
/* compute R from X and Y */
Remote Programming
5-29

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents