Stanford Research Systems SR850 User Manual page 211

Dsp lock-in amplifier
Table of Contents

Advertisement

printOutBinaryResults();
printf("\n%d bytes received.\nPress <Enter> to continue.",ibcnt);
getch(); printf("\n");
printf("Reading Results in IEEE Binary Format\n");
txLia("SPTS?3");
ibrd(lia,tstr,20L);
sscanf(tstr,"%d",&nPts); /* convert from a string to an int */
sprintf(tstr,"TRCB?3,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 Reults in LIA Binary Format\n");
sprintf(tstr,"TRCL?3,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 takes in FAST mode by the SR850 */
int i;
float x,y,r;
int *ptr;
printf("\n\n");
ptr = rxBuf;
for (i=0;i<10;i++) {
x = (float) (*ptr++) /(float) 30.000;
y = (float) (*ptr++) /(float) 30.000;
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 SR850 */
int i;
/* format and print the results */
/* how many points in trace 3 (R) ?*/
/* get the answer */
/* 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 */
/* ptr points to the first X,Y pair of values. X and Y are each integers. */
Remote Programming
/* 30000 is full scale which is 1 V in this case */
/* for other scales, multiply by the full scale voltage */
/* compute R from X and Y */
6-35

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents