Stanford Research Systems SR830 Manual page 110

Dsp lock-in amplifier
Table of Contents

Advertisement

i=(int)ibcnt;
txLia("PAUS");
printOutBinaryResults();
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?1,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?1,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 SR830 */
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;
y = (float) (*ptr++) /(float) 30000.0;
r = (float) sqrt(x*x + y*y);
printf("%d %e\n",i,r);
}
}
/* save total number of bytes read */
/* pause the data storage so no new points are taken */
/* format and print the results */
/* 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 */
{
/* 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 */
Remote Programming
5-27

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents