Werte aus dem Hyperterminal für diff speed_l speed_rCode:#include <stdlib.h> #include "asuro.h" #include "myasuro.h" void MyGo ( int distance, int speed) { uint32_t enc_count; int tot_count = 0; int diff = 0; int l_speed = speed, r_speed = speed; unsigned char text[8]; // calculation tics/mm enc_count=abs(distance)*10000L; enc_count/=MY_GO_ENC_COUNT_VALUE; EncoderSet(0,0); // reset encoder MotorSpeed(l_speed,r_speed); if (distance<0) MotorDir(RWD,RWD); else MotorDir(FWD,FWD); while (tot_count<enc_count) { tot_count += encoder[RIGHT]; //im Original LEFT ehenkes diff = encoder[LEFT] - encoder[RIGHT]; if (diff > 0) { //Left faster than right if ((l_speed > speed) || (r_speed > 244)) l_speed -= 10; else r_speed += 10; } if (diff < 0) { //Right faster than left if ((r_speed > speed) || (l_speed > 244)) r_speed -= 10; else l_speed += 10; } EncoderSet(0,0); // reset encoder MotorSpeed(l_speed,r_speed); itoa(diff, text, 10); SerPrint(text); SerPrint(" "); itoa(l_speed, text, 10); SerPrint(text); SerPrint(" "); itoa(r_speed, text, 10); SerPrint(text); SerPrint("\r\n"); /* Zeilenvorschub */ Msleep(1); } MotorDir(BREAK,BREAK); Msleep(200); } int main(void) { Init(); EncoderInit(); SerPrint("\r\nMYGo Test\r\n"); while (1) { int i; for(i=0;i<10;++i) { MyGo(150,150); StatusLED(RED); Msleep(1000); StatusLED(GREEN); } StatusLED(YELLOW); } }
9 150 230
8 150 240
9 150 250
8 140 250
8 130 250
8 120 250
8 110 250
8 100 250
6 90 250
6 80 250
4 70 250
4 60 250
4 50 250
3 40 250
1 30 250
1 20 250
0 20 250
0 20 250
0 20 250
0 20 250
0 20 250
0 20 250
0 20 250
0 20 250
Was kann man daraus schließen?
Den Hinweis von stochri habe ich leider noch nicht verstanden.







Zitieren

Lesezeichen