/* LAB3.C */ /* DC motor with proportional control and sin. input */ #include #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 */ #define twopi 6.2831852 /* 2 pi */ #define tablelength 2000 /* Length of sin table */ float sintable[tablelength],flindex,mag,om,angle,phase; int index,ncycles; FILE *fp; char fname[]="DATA.M"; float ref[maxpoints],vol[maxpoints],pos[maxpoints]; float keybin,y,r,e,u,uda,kp,kd,ki,kdd,kid,em,dst,ist; int clock,npoints; /* Keyboard routine */ void user_interface() { scanf("%f",&keybin); } /* Initialization routine */ void user_init() { put_da(0,0.); encoder_init(); for (index=0;indextablelength-1) {index=tablelength-1;} r=mag*sintable[index]; e=r-y; u=kp*e; uda=u/ampgain; put_da(0,uda); if (clock