Hallo alle zusammen.....
habe ein kleines Problem mit dem Programm von meinem Asuro, aber vill könnt ihr mir ja weiter helfen.
So sieht das Programm aus.....
Code:#include "asuro.h" int DriveCircle( int angel, unsigned char Dir) { Encoder_Init(0,0); int segments_left; int segments_right; unsigned char MotorDr_Left = FWD; unsigned char MotorDr_Right = RWD; int MotorSpdLeft = 120; int MotorSpdRight = 120; if (angel == 45) { segments_left = 13; segments_right = 13; } else if (angel == 90) { segments_left = 27; segments_right = 27; } else if (angel == 180) { segments_left = 53; segments_right = 53; } else if (angel == 360) { segments_left = 107; segments_right = 107; } else { StatusLED(RED); // Statusleuchtdiode Rot schalten } Encoder_Set(0,0); if(Dir == RIGHT) { MotorDr_Left = FWD; MotorDr_Right = RWD; } if(Dir == LEFT) { MotorDr_Left = RWD; MotorDr_Right = FWD; } while((encoder[LEFT] < segments_left)||(encoder[RIGHT] < segments_right)) { MotorDir(MotorDr_Left,MotorDr_Right); MotorSpeed(MotorSpdLeft,MotorSpdRight); if(encoder[LEFT] >= segments_left) { MotorSpdLeft = 160; } if(encoder[RIGHT] >= segments_right) { MotorSpdRight = 160; } if(encoder[LEFT]&&encoder[RIGHT] >= segments_left) { MotorSpeed(BREAK, BREAK); Msleep(300); MotorSpeed(0,0); // Kollision! Sofort anhalten } } return 0; } int DriveLength( int length, unsigned char MotorDr, int MotorSpd) { Encoder_Init(); int diff; float cycles; int segments_left; int segments_right; int MotorSpdLeft = MotorSpd; int MotorSpdRight = MotorSpd; unsigned char schalter; cycles = length / 12,2; // Umdrehungen des linken Reifens = zu fahrende Strecke links / Reifen-Umfangs (Umfang = 12,2 cm !!!) segments_left = cycles * 40; // Anzahl der zu fahrenden Segmente = Umdrehungen * Anzahl der Segmente pro Umdrehung (40) segments_right = cycles * 40; Encoder_Set(0,0); while((encoder[LEFT] < segments_left)||(encoder[RIGHT] < segments_right)) { MotorDir(MotorDr,MotorDr); MotorSpeed(MotorSpdLeft,MotorSpdRight); schalter = PollSwitch(); PrintInt(schalter); if(( schalter > 0)&&(MotorDr == FWD)) { MotorSpeed(0,0); MotorDir(BREAK,BREAK); Msleep(300); return encoder[LEFT]; } diff = encoder[LEFT]-encoder[RIGHT]; if ((diff > 0)&&(encoder[LEFT] < segments_left)&&(encoder[RIGHT] < segments_right)) { MotorSpdRight = MotorSpdRight + (MotorSpdRight / 100 * 2.5); MotorSpdLeft = MotorSpd; } else if ((diff < 0)&&(encoder[LEFT] < segments_left)&&(encoder[RIGHT] < segments_right)) { MotorSpdLeft = MotorSpdLeft + (MotorSpdLeft / 100 * 2.5); MotorSpdRight = MotorSpd; } else if ((diff == 0)&&(encoder[LEFT] < segments_left)&&(encoder[RIGHT] < segments_right)) { MotorSpdLeft = MotorSpd; MotorSpdRight = MotorSpd; } if(encoder[LEFT] >= segments_left) { MotorSpdLeft = 0; } if(encoder[RIGHT] >= segments_right) { MotorSpdRight = 0; } } MotorSpeed(0,0); return encoder[LEFT]; } int main(void) { Init(); StatusLED(GREEN); int blink = 0; float cycles; int way = 0; int segments; unsigned char endschalt; while(way < 1000) { segments = DriveLength(100, FWD, 120); cycles = segments / 40; way = way + (cycles * 12.2); endschalt = PollSwitch(); PrintInt(endschalt); if (( endschalt == 2)||( endschalt == 16)||( endschalt == 18 )) { DriveLength(10, RWD, 120); DriveCircle(90, RIGHT); } else if ( endschalt == 32) { DriveCircle(45, RIGHT); } else if ( endschalt == 1) { DriveCircle(45, LEFT); } } while(1) { if (blink == 0) { blink = 1; StatusLED(OFF); Msleep(300); } else if(blink == 1) { blink = 0; StatusLED(GREEN); Msleep(300); } } return 0; }
Folgende Fehler treten auf:
Code:C:\WinAVR\Asuro\FirstTry>make all set -e; avr-gcc -MM -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst test.c \ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > test.d; \ [ -s test.d ] || rm -f test.d -------- begin -------- avr-gcc --version avr-gcc (GCC) 3.3.1 Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. avr-gcc -c -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst test.c -o test.o test.c: In function `DriveCircle': test.c:4: warning: implicit declaration of function `Encoder_Init' test.c:43: warning: implicit declaration of function `Encoder_Set' test.c:61: error: `encoder' undeclared (first use in this function) test.c:61: error: (Each undeclared identifier is reported only once test.c:61: error: for each function it appears in.) test.c:61: error: `LEFT' undeclared (first use in this function) test.c:61: error: `RIGHT' undeclared (first use in this function) test.c:79: warning: implicit declaration of function `Msleep' test.c: In function `DriveLength': test.c:106: error: `encoder' undeclared (first use in this function) test.c:106: error: `LEFT' undeclared (first use in this function) test.c:106: error: `RIGHT' undeclared (first use in this function) test.c:111: warning: implicit declaration of function `PrintInt' test.c: In function `main': test.c:188: error: `RIGHT' undeclared (first use in this function) test.c:196: error: `LEFT' undeclared (first use in this function) make: *** [test.o] Error 1 > Process Exit Code: 2
Wäre echt cool wenn ihr mir bei meinem Problem helfen könntet....
Gruß
2stoned







Zitieren

Lesezeichen