Stanford Research Systems SR844 User Manual page 140

Rf lock-in amplifier
Table of Contents

Advertisement

4-38 Example Program
// *******************************************************************
// ***** Acquire data, then transfer data *****
printf("AcquireData.");
test = 0;
TxSr844 ("REST");
TxSr844 ("STRT");
j = 0;
do {
GetSr844 ("SPTS?");
i = atoi(recv);
if (i/64 > j) {printf ("."); j++;}
}
while (i<640);
TxSr844 ("PAUS");
GetSr844("SPTS?");
nPts = atoi(recv);
printf ("SPTS=%d.",nPts);
// ***** Read all points in IEEE float format *****
printf("IEEE.");
sprintf(cmd,"TRCB?1,0,%d",nPts); // (CH1, start at bin 0, all points)
TxGpib (sr844,cmd);
transmit ("MLA TALK 8", &status);
rarray ((char *)rfBuf, nPts*4, &nCount, &status);
// Read directly into a FLOAT array rfBuf, 4 bytes per point
if ( nCount != nPts*4 ) {
printf ("\nERROR: expected %d bytes, received %d bytes",nPts*4,nCount);
test=1; GetSpace ();
}
else printf ("1.",nCount);
sprintf(cmd,"TRCB?2,0,%d",nPts); // (CH2, start at bin 0, all points)
TxGpib (sr844,cmd);
transmit ("MLA TALK 8", &status);
rarray ((char *)pfBuf, nPts*4, &nCount, &status);
// Read directly into a FLOAT array pfBuf, 4 bytes per point
if ( nCount != nPts*4 ) {
printf ("\nERROR: expected %d bytes, received %d bytes",nPts*4,nCount);
test=1; GetSpace ();
}
else printf ("2.",nCount);
// ****** Read all points in LIA float format ******
printf("LiaFlt.");
sprintf(cmd,"TRCL?1,0,%d",nPts); // (CH1, starting with bin 0, all points)
TxGpib (sr844,cmd);
transmit ("MLA TALK 8", &status);
rarray ((char *)rLiaBuf, nPts*4, &nCount, &status);
// Read into int array rLiaBuf, 2 ints or 4 bytes per point
if ( nCount != nPts*4 ) {
printf ("\nERROR: expected %d bytes, received %d bytes",nPts*4,nCount);
test=1; GetSpace ();
}
else printf ("1.",nCount);
sprintf(cmd,"TRCL?2,0,%d",nPts); // (CH2, starting with bin 0, all points)
TxGpib (sr844,cmd);
transmit ("MLA TALK 8", &status);
rarray ((char *)pLiaBuf, nPts*4, &nCount, &status);
// Read into int array pLiaBuf, 2 ints or 4 bytes per point
if ( nCount != nPts*4 ) {
printf ("\nERROR: expected %d bytes, received %d bytes",nPts*4,nCount);
SR844 RF Lock-In Amplifier
// Keep track of errors in variable test
// Reset buffers
// Start data storage
// Read how many points taken so far?
// Until 640 points taken (10 seconds)
// Pause acquisition
// How many points in buffer?
// Send cmd and don't wait for IFC ready!
// Make sr844 the talker
// CH1 ok
// Send cmd and don't wait for IFC ready!
// Make sr844 the talker
// CH2 ok
// Send cmd and don't wait for IFC ready!
// Make sr844 the talker
// CH1 ok
// Send cmd and don't wait for IFC ready!
// Make sr844 the talker
// Show progress every 64 points

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents