Wir checken zunächst Dein Ultraschallortungssystem:
Code:
#include "asuro.h"
int abstand=0;
int main(void)
{
Init();
SerWrite("\r\n --- ultrasonic test ---",29);
Msleep(1000);
do
{
abstand=Chirp();
SerWrite("\r\n distanz in cm: ",20);
Msleep(500);
PrintInt(abstand);
}
while(1);
return 0;
}
Probiere mal, welche Werte bei Dir ankommen, und justiere Dein System so, dass die angegebenen Werte der Realität entsprechen.
Zitat:
wie justieren? womit?
das programm läuft, ergebnis - entfernung 0
Vielleicht musst Du auch noch an dem 1MOhm-Trimmer des RC-Gliedes drehen. Bei mir steht der Widerstand etwa in der Mitte.
Zitat:
das ist ja das einzige was an der us-erweiterung "justierbar" ist...trotz verstellungen am poti, StatusLED leuchtet grün, entfernung 0 wird im hyperterminal geschrieben, sonst nix...
Dann vielleicht das hier:
Code:
#include "asuro.h"
#define MAXDIFF 90
int main(void)
{
int abstand, abstand_alt, diff, zaehler=0;
Init();
abstand = Chirp();
while(TRUE)
{
abstand_alt = abstand;
abstand = Chirp(); ++zaehler;
diff = abstand - abstand_alt;
if( (abstand>15) && (abs(diff)<MAXDIFF) )
{
StatusLED(GREEN);
MotorDir(FWD, FWD);
MotorSpeed(150, 150);
}
else if( (abstand>10) && (abstand<=15) && (abs(diff)<MAXDIFF) )
{
StatusLED(YELLOW);
MotorDir(FWD, FWD);
MotorSpeed(150, 100);
Msleep(10);
}
else
{
StatusLED(RED);
MotorDir(RWD, RWD);
MotorSpeed(150, 100);
Msleep(10);
}
if (zaehler > 800)
{
StatusLED(RED);
BackLED(ON,ON);
MotorDir(RWD, RWD);
MotorSpeed(200, 250);
Msleep(10);
BackLED(OFF,OFF);
}
if (zaehler > 810)
{
StatusLED(RED);
BackLED(ON,ON);
MotorDir(RWD, RWD);
MotorSpeed(250, 200);
Msleep(10);
BackLED(OFF,OFF);
if(zaehler > 820)
zaehler = 0;
}
}
return 0;
}
Zitat:
hier leuchtet die StatusLED rot, die räder drehen so als wollte der asuro nach hinten fahren, von zeit zu zeit - ziemlich regelmäßig - leuchten die BackLED´s kurz auf, die motoren drehen kurz auf und dann geht das ganze von vorne los...