PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Problem mit dem Auswerten der Liniensensoren



Jacob2
06.06.2007, 20:17
Hallo,
Bei mir funktioniert das Auswerten der Liniensensoren irgendwie nicht richtig :( . Ich hab erstmal zum ausprobieren den code so genommen wie er in der Anleitung steht. Die Fototransistoren (bzw. die Motoren) zeigen aber keine Reaktion (weder beim beleuchten noch beim verdunkeln).
Hier ist der Code, den ich aus der Anleitung hab(und so auch geflasht hab):


#include "asuro.h"

int main(void)
{
unsigned int data[2];
Init();
FrontLED(ON);
MotorDir(FWD,FWD);
while (1)
{
LineData(data);
if(data[0] > data[1])
{ MotorSpeed(200,150);}
else
{MotorSpeed(150,200);}
}
return 0;
}

Ich persöhnlich kann darin keinen Fehler sehen, aber vielleicht jemand anderes?!
Jacob 8-[

ehenkes
06.06.2007, 20:33
Versuch mal den hier:


#include "asuro.h"
#include <stdlib.h>

#define SPEED 100
#define SPEEDMAX 200
#define SPEEDMIN 20
#define IMAX 16000
#define IMAXALARM 15000

unsigned char speed, j;
int speedLeft,speedRight;
unsigned int lineData[2];
int x, xalt, kp, kd, ki, yp, yd, yi, drest=0, y, y2, isum=0, ADOffset;

void FollowLine (void)
{
unsigned char leftDir = FWD, rightDir = FWD;

LineData(lineData);
x = (lineData[LEFT] - lineData[RIGHT]) - ADOffset;

yp = x*kp; // P-Anteil

isum += x;
if (isum > IMAX) isum = IMAX;
if (isum < -IMAX) isum = -IMAX;
yi = isum / 625 * ki; //I-Anteil

yd = (x - xalt) * kd; // D-Anteil
yd += drest;
if (yd > 255)
{
drest = yd - 255;
}
else if (yd < -255)
{
drest = yd + 255;
}
else
{
drest = 0;
}

if (isum > IMAXALARM) BackLED(OFF,ON);
else if (isum < -IMAXALARM) BackLED(ON,OFF);
else BackLED(OFF,OFF);

y = yp + yi + yd; // PID
y2 = y / 2;
xalt = x;

speedLeft = speedRight = speed;
MotorDir(FWD,FWD);

if ( y > 0)
{
StatusLED(GREEN);
speedLeft = speed + y2;
if (speedLeft > SPEEDMAX)
{
speedLeft = SPEEDMAX;
y2 = speedLeft - speed;
}
y = y - y2;
speedRight = speed - y;
if (speedRight < SPEEDMIN)
{
speedRight = SPEEDMIN;
}
}

if ( y < 0)
{
StatusLED(RED);
speedRight = speed - y2;
if (speedRight > SPEEDMAX)
{
speedRight = SPEEDMAX;
y2 = speed - speedRight;
}
y = y - y2;
speedLeft = speed + y;
if (speedLeft < SPEEDMIN)
{
speedLeft = SPEEDMIN;
}
}
leftDir = rightDir = FWD;
if (speedLeft < SPEEDMIN + 5) leftDir = BREAK;
if (speedRight < SPEEDMIN + 5) rightDir = BREAK;
MotorDir(leftDir,rightDir);
MotorSpeed(abs(speedLeft),abs(speedRight));
}

int main(void)
{
Init();
FrontLED(ON);
for (j = 0; j < 255; j++) LineData(lineData);
LineData(lineData);
ADOffset = lineData[LEFT] - lineData[RIGHT]; // Helligkeitsunterschied links und rechts

MotorDir(FWD,FWD);
StatusLED(GREEN);

speed = SPEED;
speedLeft = speed;
speedRight = speed;

kp = 10; ki = 4; kd = 70; // Regler Parameter kd enthält bereits Division durch dt
/* 10(!) 4(!) 70(!) */ /*<=== gute Ausgangswerte*/

while(1)
{
FollowLine();
}
return 0;
}

Jacob2
07.06.2007, 16:02
Ok...
Ist auf jeden Fall um einiges umfangreicher!
ich werds gleich mal ausprobieren.
Jacob

Jacob2
11.06.2007, 18:12
Hallo,
so, da bin ich wieder!
das compilieren funktioniert nich( es gibt eine menge fehlermeldungen)!
Liegt das vielleicht an einer fehlenden datei ? weil ich ganz oben die zeile:
#INCLUDE <stdlib.h>
gesehen habe.
ist das vielleicht so eine "Library"?
hab den begriff hier schon öfters gelesen, weis aber nicht richtig was das ist oder wo man es herbekommt!
MfG Jacob

recycle
11.06.2007, 19:45
Hallo,
so, da bin ich wieder!
das compilieren funktioniert nich( es gibt eine menge fehlermeldungen)!
Liegt das vielleicht an einer fehlenden datei ?


Rate mal, warum ein Compiler Fehlermeldungen ausgibt? ;-)

ehenkes
11.06.2007, 20:31
Was beinhaltet die Fehlermeldung genau?

Jacob2
12.06.2007, 16:20
Hallo,
hier die fehler aus dem Fehler-Fenster (den ganzen inhalt konnte ich nicht schreiben weil über 20000 Zeichen):



test.c -o test.o
test.c:5:14: warning: ISO C requires whitespace after the macro name
test.c:6:17: warning: ISO C requires whitespace after the macro name
test.c:7:17: warning: ISO C requires whitespace after the macro name
test.c:8:13: warning: ISO C requires whitespace after the macro name
test.c: In function `FollowLine':
test.c:18: error: stray '\240' in program
test.c:18: error: stray '\240' in program
test.c:19: error: stray '\240' in program
test.c:20: error: stray '\240' in program
test.c:20: error: stray '\240' in program
test.c:21: error: stray '\240' in program
test.c:21: error: stray '\240' in program
test.c:21: error: `LEFT' undeclared (first use in this function)
test.c:21: error: (Each undeclared identifier is reported only once
test.c:21: error: for each function it appears in.)
test.c:21: error: `RIGHT' undeclared (first use in this function)
test.c:22: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:23: error: stray '\240' in program
test.c:24: error: stray '\240' in program
test.c:25: error: stray '\240' in program
test.c:25: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:26: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:27: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:28: error: stray '\240' in program
test.c:29: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:30: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:31: error: stray '\240' in program
test.c:32: error: stray '\240' in program
test.c:32: error: stray '\240' in program
test.c:33: error: stray '\240' in program
test.c:33: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:34: error: stray '\240' in program
test.c:35: error: stray '\240' in program
test.c:35: error: stray '\240' in program
test.c:36: error: stray '\240' in program
test.c:36: error: stray '\240' in program
test.c:37: error: stray '\240' in program
test.c:37: error: stray '\240' in program
test.c:38: error: stray '\240' in program
test.c:38: error: stray '\240' in program
test.c:38: error: stray '\240' in program
test.c:38: error: stray '\240' in program
test.c:39: error: stray '\240' in program
test.c:39: error: stray '\240' in program
test.c:40: error: stray '\240' in program
test.c:40: error: stray '\240' in program
test.c:41: error: stray '\240' in program
test.c:41: error: stray '\240' in program
test.c:42: error: stray '\240' in program
test.c:42: error: stray '\240' in program
test.c:42: error: stray '\240' in program
test.c:42: error: stray '\240' in program
test.c:43: error: stray '\240' in program
test.c:43: error: stray '\240' in program
test.c:44: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:45: error: stray '\240' in program
test.c:46: error: stray '\240' in program
test.c:46: error: stray '\240' in program
test.c:46: error: stray '\240' in program
test.c:47: error: stray '\240' in program
test.c:47: error: stray '\240' in program
test.c:48: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:49: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:50: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:51: error: stray '\240' in program
test.c:52: error: stray '\240' in program
test.c:53: error: stray '\240' in program
test.c:53: error: stray '\240' in program
test.c:54: error: stray '\240' in program
test.c:54: error: stray '\240' in program
test.c:55: error: stray '\240' in program
test.c:56: error: stray '\240' in program
test.c:56: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:57: error: stray '\240' in program
test.c:58: error: stray '\240' in program
test.c:58: error: stray '\240' in program
test.c:58: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:59: error: stray '\240' in program
test.c:60: error: stray '\240' in program
test.c:60: error: stray '\240' in program
test.c:60: error: stray '\240' in program
test.c:60: error: stray '\240' in program
test.c:60: error: stray '\240' in program
test.c:61: error: stray '\240' in program
test.c:61: error: stray '\240' in program
test.c:61: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:62: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:63: error: stray '\240' in program
test.c:64: error: stray '\240' in program
test.c:64: error: stray '\240' in program
test.c:64: error: stray '\240' in program
test.c:65: error: stray '\240' in program
test.c:65: error: stray '\240' in program
test.c:65: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:66: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:67: error: stray '\240' in program
test.c:68: error: stray '\240' in program
test.c:68: error: stray '\240' in program
test.c:68: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:69: error: stray '\240' in program
test.c:70: error: stray '\240' in program
test.c:70: error: stray '\240' in program
test.c:70: error: stray '\240' in program
test.c:71: error: stray '\240' in program
test.c:71: error: stray '\240' in program
test.c:72: error: stray '\240' in program
test.c:73: error: stray '\240' in program
test.c:73: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:74: error: stray '\240' in program
test.c:75: error: stray '\240' in program
test.c:75: error: stray '\240' in program
test.c:75: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:76: error: stray '\240' in program
test.c:77: error: stray '\240' in program
test.c:77: error: stray '\240' in program
test.c:77: error: stray '\240' in program
test.c:77: error: stray '\240' in program
test.c:77: error: stray '\240' in program
test.c:78: error: stray '\240' in program
test.c:78: error: stray '\240' in program
test.c:78: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:79: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:80: error: stray '\240' in program
test.c:81: error: stray '\240' in program
test.c:81: error: stray '\240' in program
test.c:81: error: stray '\240' in program
test.c:82: error: stray '\240' in program
test.c:82: error: stray '\240' in program
test.c:82: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:83: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:84: error: stray '\240' in program
test.c:85: error: stray '\240' in program
test.c:85: error: stray '\240' in program
test.c:85: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:86: error: stray '\240' in program
test.c:87: error: stray '\240' in program
test.c:87: error: stray '\240' in program
test.c:87: error: stray '\240' in program
test.c:88: error: stray '\240' in program
test.c:88: error: stray '\240' in program
test.c:89: error: stray '\240' in program
test.c:89: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:90: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:91: error: stray '\240' in program
test.c:92: error: stray '\240' in program
test.c:92: error: stray '\240' in program
test.c:93: error: stray '\240' in program
test.c:93: error: stray '\240' in program
test.c: In function `main':
test.c:98: error: stray '\240' in program
test.c:98: error: stray '\240' in program
test.c:99: error: stray '\240' in program
test.c:99: error: stray '\240' in program
test.c:100: error: stray '\240' in program
test.c:100: error: stray '\240' in program
test.c:101: error: stray '\240' in program
test.c:101: error: stray '\240' in program
test.c:102: error: stray '\240' in program
test.c:102: error: stray '\240' in program
test.c:102: error: `LEFT' undeclared (first use in this function)
test.c:102: error: `RIGHT' undeclared (first use in this function)
test.c:103: error: stray '\240' in program
test.c:104: error: stray '\240' in program
test.c:104: error: stray '\240' in program
test.c:105: error: stray '\240' in program
test.c:105: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:107: error: stray '\240' in program
test.c:108: error: stray '\240' in program
test.c:108: error: stray '\240' in program
test.c:108: error: stray '\240' in program
test.c:109: error: stray '\240' in program
test.c:109: error: stray '\240' in program
test.c:110: error: stray '\240' in program
test.c:111: error: stray '\240' in program
test.c:111: error: stray '\240' in program
test.c:111: error: stray '\240' in program
test.c:111: error: stray '\240' in program
test.c:111: error: stray '\240' in program
test.c:112: error: stray '\240' in program
test.c:112: error: stray '\240' in program
test.c:112: error: stray '\240' in program
test.c:113: error: stray '\240' in program
test.c:114: error: stray '\240' in program
test.c:114: error: stray '\240' in program
test.c:115: error: stray '\240' in program
test.c:115: error: stray '\240' in program
test.c:116: error: stray '\240' in program
test.c:116: error: stray '\240' in program
test.c:116: error: stray '\240' in program
test.c:117: error: stray '\240' in program
test.c:117: error: stray '\240' in program
test.c:118: error: stray '\240' in program
test.c:118: error: stray '\240' in program
test.c:120:1: warning: no newline at end of file
make: *** [test.o] Error 1

> Process Exit Code: 2


Vielleicht sagt das dir was, mir auf jeden fall nicht! 8-[
MfG Jacob

ehenkes
12.06.2007, 19:19
Kopiere asuro.h nach C:\WinAVR\avr\include und verwende bitte reinen ASCII-Text. Du hast irgendwo rtf-Format erwischt.

damaltor
13.06.2007, 15:11
stray fehler bedeuten meist dass ungültige zeichen verwendet wurden. öffne die datei mit notepad (dem editor unter windows) bzw mit nano, vi oder kate unter linux. kannst du die dateien vernünftig lesen oder sind blöcke, fehlende zeichen oder sowas im weg?

Jacob2
15.06.2007, 13:40
Wie bekommt man den Code eigentlich "richtig" aus dem Codefenster heraus?
Ich hab einfach alles markiert, in die zwischenablage und dann in eine datei eingefügt, aber das ist bestimmt nicht die feinste art oder?
Und dann gibt es da noch ein problem:
Ich bin hier nämlich auf einem uralten Mac unterwegs, und dem sein Word kann nicht viele Dateien erstellen, die der andere PC(von dem aus ich ASURO programmiere) lesen/erkennen kann (aber rtf eben).
Und wie ich da ASCII-Text verwenden soll, weis ich auch nicht.
nach dem kopieren von asuro.h bestand das problem weiterhin.
Und zu damaltor: ich kann die dateien gut lesen.
MfG Jacob

ehenkes
15.06.2007, 16:44
Dann wandele doch rtf in txt (Textdokument) um (z.B. mit Wordpad).

Jacob2
17.06.2007, 13:47
Hallo,


Ich bin hier nämlich auf einem uralten Mac unterwegs, und dem sein Word kann nicht viele Dateien erstellen, die der andere PC(von dem aus ich ASURO programmiere) lesen/erkennen kann (aber rtf eben).

Das stimmt doch nicht. Ich hab den Code heute mal auf dem Mac in allen möglichen Formaten gespeichert, die der PC aber alle nicht (zumindest nicht richtig) erkennen konnte. Auch rtf enthielt Blöcke und wirre Zeichen.
ich richte mir vielleicht bald einen internetzugang für den PC ein und dann ist mit solchen Sachen endlich schluss!(hoffentlich)!
ich weiß wirklich nicht, wie ich den Code "heile" rüberbringen soll.
MfG Jacob

ehenkes
17.06.2007, 14:01
Normalerweise in einem möglichst einfachen "Textformat" ohne besondere Steuerzeichen. Aber mit einem alten Apple Mac kenne ich mich nicht aus. Wozu auch?

Jacob2
19.06.2007, 14:24
Ich kenn mich hier zwar noch nicht so gut aus, aber kann man nicht an den Beitrag ein Attachment zum download anhängen?
Und wenn ja, könntest du mir den Code als "für den PC verständliches Format" (z.B. .txt) so mitschicken? Wäre wirklich nett! (wenns geht!)
MfG Jacob

ehenkes
19.06.2007, 15:59
Du kannst Deine Source-datei gerne hier anhängen, dann können wir uns diese ja mal anschauen, testen und evtl. alle "bösen" Zeichen entfernen.

damaltor
20.06.2007, 09:42
der apple wird doch wohl ein minimales text-format verstehen... nimm mal ein windows- .txt file und öffne es mit dem mac. dann siehst du welches programm du für die dateien nehmen solltest...

Jacob2
21.06.2007, 18:22
In der datei ist das was auf dem PC ankommt (Blöcke und wirre Zeichen vorne und hinten schon ausgeschnitten).

ehenkes
21.06.2007, 18:25
#include "asuro.h"
#include <stdlib.h>

#define SPEED 100
#define SPEEDMAX 200
#define SPEEDMIN 20
#define IMAX 16000
#define IMAXALARM 15000

unsigned char speed, j;
int speedLeft,speedRight;
unsigned int lineData[2];
int x, xalt, kp, kd, ki, yp, yd, yi, drest=0, y, y2, isum=0, ADOffset;

void FollowLine (void)
{
unsigned char leftDir = FWD, rightDir = FWD;

LineData(lineData);
x = (lineData[LEFT] - lineData[RIGHT]) - ADOffset;

yp = x*kp; // P-Anteil

isum += x;
if (isum > IMAX) isum = IMAX;
if (isum < -IMAX) isum = -IMAX;
yi = isum / 625 * ki; //I-Anteil

yd = (x - xalt) * kd; // D-Anteil
yd += drest;
if (yd > 255)
{
drest = yd - 255;
}
else if (yd < -255)
{
drest = yd + 255;
}
else
{
drest = 0;
}

if (isum > IMAXALARM) BackLED(OFF,ON);
else if (isum < -IMAXALARM) BackLED(ON,OFF);
else BackLED(OFF,OFF);

y = yp + yi + yd; // PID
y2 = y / 2;
xalt = x;

speedLeft = speedRight = speed;
MotorDir(FWD,FWD);

if ( y > 0)
{
StatusLED(GREEN);
speedLeft = speed + y2;
if (speedLeft > SPEEDMAX)
{
speedLeft = SPEEDMAX;
y2 = speedLeft - speed;
}
y = y - y2;
speedRight = speed - y;
if (speedRight < SPEEDMIN)
{
speedRight = SPEEDMIN;
}
}

if ( y < 0)
{
StatusLED(RED);
speedRight = speed - y2;
if (speedRight > SPEEDMAX)
{
speedRight = SPEEDMAX;
y2 = speed - speedRight;
}
y = y - y2;
speedLeft = speed + y;
if (speedLeft < SPEEDMIN)
{
speedLeft = SPEEDMIN;
}
}
leftDir = rightDir = FWD;
if (speedLeft < SPEEDMIN + 5) leftDir = BREAK;
if (speedRight < SPEEDMIN + 5) rightDir = BREAK;
MotorDir(leftDir,rightDir);
MotorSpeed(abs(speedLeft),abs(speedRight));
}

int main(void)
{
Init();
FrontLED(ON);
for (j = 0; j < 255; j++) LineData(lineData);
LineData(lineData);
ADOffset = lineData[LEFT] - lineData[RIGHT]; // Helligkeitsunterschied links und rechts

MotorDir(FWD,FWD);
StatusLED(GREEN);

speed = SPEED;
speedLeft = speed;
speedRight = speed;

kp = 10; ki = 4; kd = 70; // Regler Parameter kd enthält bereits Division durch dt
/* 10(!) 4(!) 70(!) */ /*<=== gute Ausgangswerte*/

while(1)
{
FollowLine();
}
return 0;
}

Jacob2
11.07.2007, 16:03
Hi,
entschuldigt die unterbrechung, aber unser internet schlappt gerade ein bisschen ab (wir haben immerhin noch ein 28k modem!!!)
Der apple hat zwar ein programm welches textdateien lesen kann, aber die damit erstellten textdokumente gefielen dem Pc immer noch nicht richtig.
ich hab mir jetzt einfach den code in programmers notepad abgetippt und es sind jetzt "nur" noch ein paar Fehler, die mir aber auch eher was mit dem inhaltlichen des Codes zu tun haben scheinen:


I:\Dokumente und Einstellungen\Jacob\Desktop\ASURO_src\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.

Size before:
test.elf :
section size addr
.text 1528 0
.data 0 8388704
.bss 1 8388704
.noinit 0 8388705
.eeprom 0 8454144
.stab 3144 0
.stabstr 1740 0
Total 6413


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 `FollowLine':
test.c:20: error: `LEFT' undeclared (first use in this function)
test.c:20: error: (Each undeclared identifier is reported only once
test.c:20: error: for each function it appears in.)
test.c:20: error: `RIGHT' undeclared (first use in this function)
test.c: In function `main':
test.c:98: error: parse error before ';' token
test.c:100: error: `LEFT' undeclared (first use in this function)
test.c:100: error: `RIGHT' undeclared (first use in this function)
test.c:118:1: warning: no newline at end of file
make: *** [test.o] Error 1

> Process Exit Code: 2

MfG Jacob

ehenkes
11.07.2007, 17:01
in der asuro.h sollte man Folgendes finden:

#define LEFT 0
#define RIGHT 1

einfach selbst ins Programm übernehmen.

... und am Schluss noch eine Leerzeile.

Jacob2
11.07.2007, 17:46
Ok,
in asuro.h finde ich diese Zeilen zwar nicht, aber wenn man es oben mit hinschreibt bleibt nur noch ein Fehler:

test.c:100: error: parse error before ';' token

und zwar in der zeile:

for (j = 0; j < 255; j++;) LineData(lineData);

Ansonsten Danke erstmal für die Antwort.
MfG Jacob

Jacob2
11.07.2007, 17:52
Ups...
Das sollte kein Smilie werden sondern ein ; und ein )

radbruch
11.07.2007, 18:43
Genau dieses ; vor der ) in der for-Anweisung nach j++ ist zuviel.

ehenkes
11.07.2007, 21:06
Geht das Programm nun?

Jacob2
12.07.2007, 07:17
Ja, es funktioniert!!!
Aber ASURO fliegt in den Kurven manchmal raus. Was kann man da verbessern?
MfG Jacob

damaltor
12.07.2007, 09:22
probier mal, das ganze etwas aufzudröseln:
[code]
for(j=0;j<255;++j){
LineData(lineData);
}
[code]

ehenkes
12.07.2007, 17:03
Was kann man da verbessern?Du kannst versuchen, die PID-Parameter Kp und Ki anzupassen.

Sternthaler
12.07.2007, 18:51
Hallo zusammen,
im main() ist die von damaltor angesprochene Schleife über die Funktion LineData() um die Variable ADOffset zu füllen.

Diese Variable wird in der Funktion FollowLine () (Der Ursprung ist im übrigen wohl von waste nicht wahr?) dazu benutzt, um nun die Helligkeitsdifferenz auf der Linie beim 'wackeln' zu korrigieren.

Steht der Asuro beim Starten des Programm nun nicht genau mittig auf der Linie, holen wir uns beim Start vom main() diese falsche Position in den Regler.
Die Variable ADOffset sollte nicht benutzt werden! Ohne sie sucht sich der Asuro die Mitte der Linie selber und kann dann an dieser Position den besten Konrast, und damit die kleinste Abweichung vom Idealwert, sehen.
Dann funktionieren die PID-Vorgaben, die waste mühevoll in diesem Thread (https://www.roboternetz.de/phpBB2/zeigebeitrag.php?t=11818) ermittelt hat, eigendlich extrem gut.

P.S.: Der original Code von waste, mit Kommentar, ist hier (https://www.roboternetz.de/phpBB2/zeigebeitrag.php?p=109451#109451) zu finden. Die PID-Parameter hatte waste ursprünglich mit: kp = 3; ki = 10; kd = 70; angegeben.
Hatt da jemand ki und kp vertauscht? ;-)
Allerdings gibt es von waste (für seinen Asuro) auch noch: kp=5; ki=5; kd=70; Damit läuft mein Asuro allerdings nicht so gut.
Diese Änderung, mit einer Codeverbesserung, hat waste hier (https://www.roboternetz.de/phpBB2/zeigebeitrag.php?p=110308) abgelegt.
Somit hat ehenkes Recht, wenn er schreibt, dass da gedreht werden kann/soll.

Jacob2
23.07.2007, 15:58
Äh..
Wenn ich das richtig verstanden habe sind ki und kp vertauscht!?
Also einfach die werte tauschen oder?
Das mit ADOffset hab ich jetzt nich ganz verstanden, aber ok. :wink:
MfG Jacob

Sternthaler
23.07.2007, 21:26
@Jacob2
Das mit dem getauschten ki und kp kommt daher, dass das Original von waste diese Werte gegenüber den Angaben, die ich in ehenkes Post gefunden habe, getauscht hat.
So einfach ist das nicht mit dem Tauschen. Wie ehenkes schon geschrieben hat, sind das Werte, bei denen man 'probieren' darf. Wenn du die richtigen Werte anhand des Threads von waste nicht berechnen kannst, bleibt eben nur probieren über. (Ich habe meine Werte auch nicht berechnet. Ich kann das auch nicht nachrechnen, was bei waste steht. Habe einfach seine Werte übernommen.)
(Die mit Smilie versehen Frage sollte auch eher an ehenkes gehen ;-) )

Das mit den ADOffset ist nicht so wichtig, wenn du den Asuro beim Starten sehr genau auf mittig auf die Linie stellst.

ehenkes
23.07.2007, 21:31
Bei mir lief das nur mit kp ca. 8 bis 10.

Sternthaler
23.07.2007, 21:39
Da kann man mal sehen, dass diese Werte wohl wirklich für jeden Asuro so ganz privat zu ermitteln sind.