#include "libsurf.h" #include "ljackv112.h" #include #include #include #include #define NSAMP 100 #define STRLEN 100 static void usage () { fprintf(stderr, "calib: usage: calib -c chn board\n"); } int main (int argc, char **argv) { int i; int chn; char c; long id = 0; long ov; char bname[STRLEN] = { 0 }; float v; while ((c = getopt(argc, argv, "c:b:")) != -1) { switch (c) { case 'c': chn = atoi(optarg); break; case ':': strncpy(bname, optarg, STRLEN - 1); bname[STRLEN - 1] = 0; break; default: strncpy(bname, optarg, STRLEN - 1); bname[STRLEN - 1] = 0; break; case '?': usage(); } } fprintf(stderr, "Calibrating board %s, chn %d\n", bname, chn); for (i = 0; i < 0x100; ++i) { int j; float sum = 0; if (surf_brd_set_anl_dac(bname, chn, i) < 0) return 2; printf("RDAC %d:", i); /* allow some time to settle */ sleep(1); for (j = 0; j < NSAMP; ++j) { if (EAnalogIn(&id, 0, 0, 0, &ov, &v)) return 3; sum += v; } printf(" %.3f\n", sum / (double)NSAMP); } return 0; }