//-------------------------------------------------------------------- // demo1.cpp for I-8091 card // // This a simple program to test I-8091 command // i8091_INTP_LINE() // i8091_INTP_LINE02() //-------------------------------------------------------------------- // v1.0 6/20/2001 // //-------------------------------------------------------------------- #include #include #include "8000.h" #include "i8091.h" #define i8090 0x0d #define i8091 0x0e #define i8092 0x0f #define NOCARD 0x00 #define BasePort 0x0080 #define SlotOffset 0x0020 #define IDPort 0x0000 #define CARD1 1 #define MAX_SLOT_NO 8 unsigned int PortAddress[8]={0x080, 0x0a0, 0x0c0, 0x0e0, 0x140, 0x160, 0x180, 0x1a0}; //--------------------------------------------------------------------- typedef struct { int address; unsigned char DDA,AD; unsigned int LSP,HSP; unsigned char xmode,ymode; unsigned char xdir,ydir; unsigned char xson,yson; unsigned char NCmode; } i8091CardType; i8091CardType card1; unsigned char i8091Slot; //-------------------------------------------------------------------- void ShowLedValue(long value,unsigned char axis) { long j; unsigned char negative_value; if (value<0) negative_value=1; else negative_value=0; value=labs(value); j=value-10*(value/10); if (negative_value) Show5DigitLedWithDot(0x05, j); else Show5DigitLed(0x05, j); value=value/10; j=value-10*(value/10); Show5DigitLed(0x04, j); value=value/10; j=value-10*(value/10); if (axis==Z_axis) Show5DigitLedWithDot(0x03, j); else Show5DigitLed(0x03, j); value=value/10; j=value-10*(value/10); if (axis==Y_axis) Show5DigitLedWithDot(0x02, j); else Show5DigitLed(0x02, j); value=value/10; j=value-10*(value/10); if (axis==X_axis) Show5DigitLedWithDot(0x01, j); else Show5DigitLed(0x01, j); } //--------------------------------------------------- void ShowCardName(unsigned char SlotNum) { unsigned char temp; Show5DigitLed(0x05, SlotNum); //temp=inportb(BasePort+SlotNum*SlotOffset); temp=inportb(PortAddress[SlotNum]); switch (temp) { case i8090: //i8090 3-axis encoder card Show5DigitLedSeg (0x01, 0x7F); Show5DigitLedSeg (0x02, 0x7E); Show5DigitLedSeg (0x03, 0x7B); Show5DigitLedSeg (0x04, 0x7E); break; case i8091: //i8091 2-axis stepping card Show5DigitLedSeg (0x01, 0x7F); Show5DigitLedSeg (0x02, 0x7E); Show5DigitLedSeg (0x03, 0x7B); Show5DigitLedSeg (0x04, 0x30); break; case i8092: //i8092 Show5DigitLedSeg (0x01, 0x7F); Show5DigitLedSeg (0x02, 0x7E); Show5DigitLedSeg (0x03, 0x7B); Show5DigitLedSeg (0x04, 0x6D); break; default: Show5DigitLedSeg (0x01, 0x01); Show5DigitLedSeg (0x02, 0x01); Show5DigitLedSeg (0x03, 0x01); Show5DigitLedSeg (0x04, 0x01); break; }; } //--------------------------------------------------- unsigned char CardSearch(unsigned char SlotNum) { unsigned char temp; //temp=inportb(BasePort+SlotNum*SlotOffset); temp=inportb(PortAddress[SlotNum]); ShowCardName(SlotNum); switch (temp) { case i8090: //i8090 3-axis encoder card Print("Slot %d = i8090\r\n",SlotNum); return i8090; case i8091: //i8091 2-axis stepping card Print("Slot %d = i8091\r\n",SlotNum); return i8091; case i8092: //i8092 Print("Slot %d = i8092\r\n",SlotNum); return i8092; default: Print("Slot %d = No Card\r\n",SlotNum); return NOCARD; }; } //--------------------------------------------------- void stop_process() { i8091_STOP_ALL(CARD1); i8091_SET_VAR(CARD1, card1.DDA, card1.AD, card1.LSP, card1.HSP); i8091_SET_DEFDIR(CARD1, card1.xdir, card1.ydir); i8091_SET_MODE(CARD1, card1.xmode, card1.ymode); i8091_SET_SERVO_ON(CARD1, card1.xson, card1.yson); i8091_SET_NC(CARD1, card1.NCmode); Delay(50); } //--------------------------------------------------- void main () { unsigned char j; i8091Slot=99; for (j=0; j