Programming Examples 53
SR620 Universal Time Interval Counter
if ( !strlen (input))break;
/* quit if no number */
sscanf
(input,"%d",&samples);
if (samples > 5000)continue;
/* try again if # too large */
/* set up parameters for dma input */
mode = 0x2105; /* set mode for dma input */
count = 8*samples; /* number of bytes */
/* set up TIC */
sprintf (cmd,"BDMP%d",samples); /* set binary dump mode of n samples */
TxGpib (sr620,cmd); /* send command to TIC */
TalkGpib (sr620); /* make TIC a talker */
dma2
(&status,&mode,&count,data,&seg);
/* read data via DMA */
StatCheck (sr620); /* check status */
/* get mode so we'll know which conversion factor to use */
TxGpib
(sr620,"MODE?;EXPD?");
GetGpib (sr620);
/* read answer */
sscanf (recv,"%d ; %d",&tmode,&texpd); /* skip semicolon separator */
/* convert data and print both binary and converted form */
Convert
(tmode,texpd,samples);
printf ("\n data\n");
for (i =0; i <samples ; i++)
printf ("%2x%2x%2x%2x converted = %16.15lE %s\n",data[4*i+3],
data[4*i+2],data[4*i+1],data[4*i],fdata[i],units[tmode]);
}
}
/* ******************************************************************* */
void Convert (int mode,int expd,int samples)
{
int i,j,sign;
unsigned int words[4];
static double factors[] = {1.05963812934E-14,1.05963812934E-14,
1.05963812934E-14,1.24900090270331E-9,1.05963812934E-14,
8.3819032E-8,.00390625}; /* conversion factors */
for ( i = 0 ; i < samples ; i++ )
{
sign
=
0;
fdata[i] = 0.0;
/* get 8 data bytes ( 4 *2 bytes each ) */
for ( j = 0 ; j < 4 ; j ++)words[j] = data[ 4*i +j];
if ((int)words[3] < 0) /* if answer < 0 convert to magnitude and sign */
{
sign = 1; /* sign of answer */
for ( j = 0 ; j < 4 ; j++) words[j] = ~words[j]; /* take 1's complement */
}
/* convert to floating point */
for ( j = 0 ; j < 4 ; j++)fdata[i] = fdata[i]*65536.0 + (double)words[3-j];
Содержание SR620
Страница 2: ...SR620 Universal Time Interval Counter...
Страница 6: ...iv Table of Contents SR620 Universal Time Interval Counter...
Страница 8: ...vi Safety and Preparation for Use SR620 Universal Time Interval Counter...
Страница 12: ...x Specifications SR620 Universal Time Interval Counter...
Страница 58: ...42 Programming Commands SR620 Universal Time Interval Counter...
Страница 72: ...56 Programming Examples SR620 Universal Time Interval Counter...
Страница 76: ...60 Troubleshooting Tips SR620 Universal Time Interval Counter...
Страница 82: ...66 Performance Test SR620 Universal Time Interval Counter...
Страница 90: ...74 Calibration Procedure SR620 Universal Time Interval Counter...
Страница 102: ...86 Circuit Description SR620 Universal Time Interval Counter...
Страница 124: ...108 Parts List SR620 Universal Time Interval Counter...