REMOTE PROGRAMMING
4-18
void main(void)
{
int i, b;
double rmeas, q;
char
string[80];
InitGpib();
/
*
init GPIB controller
*
/
TxGpib (lcr, "
*
RST;MMOD1;PMOD1;BCLR"); /
*
reset LCR, triggered mode, measure R and Q,
clear all bins
*
/
/
*
set up the bins
*
/
Clear();
/
*
clear screen
*
/
printf ("Bin values for the LCR:\n\n");
printf (" Bin # Nominal value Tolerances\n");
for
(i=0;i<8;i++)
{
/
*
send nominal bin value, upper and lower limits to LCR
*
/
sprintf (string, "BNOM%d,%lf;BLIM0,%d,%lf;BLIM1,%d,%lf\n", i, nom[i], i, ulim[i], i, llim[i]);
TxGpib (lcr, string);
/
*
send nominal, upper and lower limit of bin i
*
/
/
*
print limits on the screen also
*
/
printf (" %d
%7.1lf +%2.1lf/%2.1lf\n", i, nom[i], ulim[i], llim[i]);
}
/
*
Now send nominal QDR fail value to the LCR and the screen
*
/
sprintf (string, "BNOM8,%lf", nom[8]);
TxGpib (lcr, string);
printf("\nQDR fail value = %7.5lf\n", nom[8]);
GetSpace();
TxGpib(lcr,
"BING1");
/
*
turn on binning
*
/
Clear();
/
*
clear screen
*
/
/
*
measurement cycle
*
/
while
(1)
{
Printxy (2,0,0, "Insert resistor into the LCR fixture ('q'to quit).\n");
GetSpace();
Erase(2,1);
printf ("Measuring...\n");
TxGpib (lcr, "STRT;
*
WAI;XALL?"); /
*
start a measurement, wait until finished, query the
results
*
/
GetGpib (lcr);
/
*
get resistance, q, and bin values
*
/
sscanf (recv, "%lf,%lf,%d", &rmeas, &q, &b); /
*
scan received string for values
*
/
Erase(10,2);
sprintf (string, "Resistor measures %7.2lf ohms. Q = %7.5lf\n", rmeas,q);
Printxy(10,0,0,string);
if (b==9) printf ("Resistance out of bin tolerances! FAILED. \n");
else if (b==8) printf ("Q is out of tolerance\n");
else
printf ("Value falls into bin %d.\n", b);
bin[b]++; /
*
increment number of elements in that bin
*
/
/
*
Now print out updated table of bins
*
/
Gotoxy (20,0);