//------------------------------------------- // Sip 1X // Made by:Crisan Vasile-Rares 2001 // cvr@email.ro // ------------------------------------------- #include #include #include #include int port=0x378; unsigned char bit[4] = {0x41,0x84,0x42,0x88} /* ---------------------- | D7 | 0 | 1 | 0 | 1 | | D6 | 1 | 0 | 1 | 0 | | D5 | 0 | 0 | 0 | 0 | | D4 | 0 | 0 | 0 | 0 | | D3 | 0 | 0 | 0 | 1 | | D2 | 0 | 1 | 0 | 0 | | D1 | 0 | 0 | 1 | 0 | | D0 | 1 | 0 | 0 | 0 | ---------------------- |data|41h|84h|442h|88h| ---------------> + <--------------- - */ void step_fwd(void); void step_bwd(void); void clear_port(void); int rst; int index=0; int f; // frequency int T; // period float coord; float no_steps; float increment=0.397; float er_poz; main() { clear_port(); jmp1: clrscr(); #include "c:\sip1x\antet.h" printf("\n\n \xAF Give coordinate between (0,220mm] "); scanf("%f",&coord); if(coord>220||coord<=0) { printf("\n\t\t ERROR!!!"); delay(1000); goto jmp1; } jmp2: printf(" \xAF Give frecquency of pulses between [10Hz;250Hz] "); scanf("%d",&f); if(f<10||f>250) { printf("\n\t\t ERROR!!!\n"); delay(1000); clrscr(); #include"c:\borlandc\stepper\antet.h"printf("\n\n"); goto jmp2; } clrscr(); #include"c:\borlandc\stepper\antet.h" T=1000/f; // in ms printf("\n\n \xAF Coord. is %g mm ",coord); printf("\n \xAF Frequency is %d Hz",f); printf("\n \xAF Period is %d ms",T); no_steps=coord/increment; float j,k; k=no_steps; j=abs(no_steps); printf("\n\n\t\t\t\t\t \xAE Number of steps: %g",j); k=k-j; er_poz=k*increment; printf("\n\t\t\t\t\t \xAE Positioning error is: %g mm ",er_poz); int i; for(i=1;i<=j;i++) { step_fwd(); } printf("\n\n\n\t\t........ For moving back press any key"); getch(); for(i=1;i "); scanf("%d",&rst); if(rst==1) { goto jmp1; } else { printf("\n\t Press any key for end of program!"); getch(); } return(0); } void step_fwd() { if(++index==4) index=0; outp(port,bit[index]); delay(T); } void step_bwd() { if(--index<0) index=3; outp(port,bit[index]); delay(T); } void clear_port() { outp(port,0x0); delay(T); } // antet.h { int w; printf("\xC9"); for(w=1;w<79;w++) { printf("\xCD"); } printf("\xBB"); printf("\xBA SISTEM INCREMENTAL DE POZITIONARE SIP1x ver1.0 \xBA"); printf("\xC8"); for(w=1;w<79;w++) { printf("\xCD"); } printf("\xBC"); }