/* LAB1.C */ /* Test of DC motor */ #include #include #include #include #include #include /* Declaration of user variables and constants */ #define ampgain 5. /* Amplifier gain */ #define maxpoints 4000 /* Number of points to be stored on disk */ FILE *fp; char fname[]="DATA.M"; float ref[maxpoints],pos[maxpoints],vol[maxpoints]; float keybin,y,u,uda; int clock,npoints; /* Keyboard routine */ void user_interface() { scanf("%f",&keybin); } /* Initialization routine */ void user_init() { put_da(0,0.); encoder_init(); freq=500.; clock=0; printf("Enter desired motor voltage, type Ctrl-Break to stop:\n"); scanf("%f",&keybin); } /* Data storage on disk -- File readable by MATLAB, simply typing "data" */ void write_data() { npoints=clock; fp=fopen(fname,"w"); fprintf(fp,"t=[\n"); for (clock=0;clock