/* 8090 Demo Compiler: MSC 6.0 Compile mode: large Project file: 8090.c ..\Lib\8000L.Lib ..\Lib\8090L.Lib [20/May/2003] by Kevin */ #include #include "..\Lib\8000.h" #include "..\Lib\8090.h" void main (void) { int i,iTemp,iRet,iQuit; unsigned char cSlot,cMode[3]; unsigned int iEncoder_Value[3]; unsigned char sTemp[20]; Puts("/*******************/\n\r"); Puts("/* 8090 demo */\n\r"); Puts("/* */\n\r"); Puts("/* [20,May,2003] */\n\r"); Puts("/*******************/\n\r"); Puts("\n\r"); while(1) { Puts("Slot(0~3 or 0~7)="); // For BC //Scanf("%d",&cSlot); // For MSC LineInput(sTemp,20); cSlot=atoi(sTemp); for(i=0;i<3;i++) { switch(i) { case 0: Puts("\n\rMode of X axis\n\r"); break; case 1: Puts("\n\rMode of Y axis\n\r"); break; case 2: Puts("\n\rMode of Z axis\n\r"); break; } Puts(" 0) QUADRANT\n\r"); Puts(" 1) CW CCW\n\r"); Puts(" 2) PULSE DIR\n\r"); Puts(" Please choose(0~2):"); // For BC //Scanf("%d",&iTemp); // For MSC LineInput(sTemp,20); iTemp=atoi(sTemp); switch(iTemp) { case 0: cMode[i]=ENC_QUADRANT; break; case 1: cMode[i]=ENC_CW_CCW; break; case 2: cMode[i]=ENC_PULSE_DIR; break; } } iRet=i8090_INIT_CARD(cSlot,cMode[0],cMode[1],cMode[2]); if(iRet) { Print("Initial 8090 error:%d (Action mode of axis error)\n\r",iRet); Delay(10); exit(0); } Puts("Press 'r' or 'R' to reset encoder, other key to stop loop\n\r\n\r"); iQuit=0; while(!iQuit) { iEncoder_Value[X_axis]=i8090_GET_ENCODER(cSlot,X_axis); iEncoder_Value[Y_axis]=i8090_GET_ENCODER(cSlot,Y_axis); iEncoder_Value[Z_axis]=i8090_GET_ENCODER(cSlot,Z_axis); Print("X=%05u Y=%05u Z=%05u\r",iEncoder_Value[X_axis], iEncoder_Value[Y_axis], iEncoder_Value[Z_axis]); if(Kbhit()) { sTemp[0]=Getch(); if(sTemp[0]=='r' || sTemp[0]=='R') { i8090_RESET_ENCODER(cSlot,X_axis); i8090_RESET_ENCODER(cSlot,Y_axis); i8090_RESET_ENCODER(cSlot,Z_axis); Puts("\n\rReset encoders\n\r"); } else iQuit=1; } } Puts("\n\rPress 'q' or 'Q' to quit, other key to continue...."); sTemp[0]=Getch(); if(sTemp[0]=='q' || sTemp[0]=='Q') exit(0); Puts("\n\r\n\r"); } }