#include #include #include #include #include int hb,lb,eoc_int,eoc_calls; #include /* include A to D driver */ main() { long enc_cnt; int v_in; double x,y,z,time; char a,oper; long t1,t2; long l1,i,j; a = 'y'; while(a=='y') { clrscr(); printf("Quanser Consulting MULTIQ Board\n"); printf("Execution speed testing program\n\n"); printf("Enter the operation:\n\n"); printf("0: 'for' loop with no operations\n"); printf("1: A/D acquisition\n"); printf("2: D/A output\n"); printf("3: Encoder read\n"); printf("4: Digital input\n\n"); flushall(); l1 = 100000; /* number of operations */ oper = getch(); if(oper == '0') { printf("Performing %10ld 'for' loops \n",l1); printf("Please wait\n"); t1 = biostime(0,0); for (j=1;j<=l1;j++); } if(oper == '1') { printf("Performing %10ld A/D conversions\n",l1); printf("Please wait\n"); t1 = biostime(0,0); for (j=1;j<=l1;j++)v_in = adin(0); } if(oper == '2') { printf("Performing %10ld D/A outputs\n",l1); printf("Please wait\n"); t1 = biostime(0,0); for (j=1;j<=l1;j++) daout(0,2048); } if(oper == '3') { printf("Performing %10ld Encoder reads\n",l1); printf("Please wait\n"); t1 = biostime(0,0); for (j=1;j<=l1;j++)enc_cnt = enc_in(0); } if(oper == '4') { printf("Performing %10ld Digital inputs\n",l1); printf("Please wait\n"); t1 = biostime(0,0); for (j=1;j<=l1;j++) v_in = digin(); } if( (oper == '0') |(oper == '1')|(oper == '2')|(oper == '3')|(oper == '4') ) { t2 = biostime(0,0); time = (t2-t1)/18.2; printf("Time for entire loop %f seconds\n\n",time); time = 1000000*time/l1; printf("Time per operation type %c is %f micro seconds\n\n\n",oper,time); printf("Another test?(y/n)"); while(kbhit() == 0); a = getch(); } nosound(); }/*end while*/ }/*end main*/