diff --git a/main.c b/main.c index b97d3cd..72b051c 100644 --- a/main.c +++ b/main.c @@ -41,7 +41,7 @@ * 1: NFC test * 2: motioncontroller test */ -#define TEST 1 +#define TEST 0 const uchar STEP_PINS = BIT4 | BIT5; const uchar DIRr_PIN = BIT3; @@ -53,16 +53,21 @@ const ulong halfRound = 2800; void stap(uint n, ulong t){ ulong d = t; + uint s = n-100; while(n != 0){ n--; P2OUT |= STEP_PINS; P2OUT &= ~STEP_PINS; - d=t; + if(s < n || n < 100) + d = 100; // a crude way of a accaleration + else + d=t; while(d != 0){ d--; __delay_cycles(160); } } + __delay_cycles(160000); } void dir(enum Direction d){ @@ -105,35 +110,35 @@ int main(void) for(ii=2; ii>0; ii--){ dir(Forward); - stap(16000, v); - __delay_cycles(160000); + stap(10000, v); dir(RightTurn); stap(halfRound, v*2); - __delay_cycles(160000); dir(Forward); - stap(16000, v); - __delay_cycles(160000); + stap(10000, v); dir(LeftTurn); stap(halfRound, v*2); - __delay_cycles(160000); } for(ii=2; ii>0; ii--){ - for(i=4; i>0; i--){ + for(i=5; i>0; i--){ dir(Forward); stap(1600, v); - __delay_cycles(160000); dir(RightTurn); stap(halfRound/2, v*2); - __delay_cycles(160000); } - for(i=4; i>0; i--){ + dir(Forward); + stap(1600, v); + dir(RightTurn); + stap(halfRound, v*2); + for(i=5; i>0; i--){ dir(Forward); stap(1600, v); - __delay_cycles(160000); dir(LeftTurn); stap(halfRound/2, v*2); - __delay_cycles(160000); } + dir(Forward); + stap(1600, v); + dir(LeftTurn); + stap(halfRound, v*2); } #endif