Erneut hi @ all
Ich habe es nun geschafft das mein Roboter einer Schwarzen Linie folgen kann.
Allerdings macht er dies manchmal noch recht ruckartig und es kann passieren das er von der Linie abkommt und er soll eine strecke abfahren und am ende im Ziel stehen bleiben aber aufgrund der ruckartigen Bewegungen bleibt er stehen sobald keiner der beiden Sensoren die Schwarzen Linie noch erfassen kann.
kann mir jemand sagen, wie ich es schaffe dass er Sauberer und ohne von der Linie zu kommen fährt?
hier Mein Quellcode:
#include <niboconfig.h>
#include <display.h>
#include <gfx.h>
#include <copro.h>
#include <delay.h>
#include <iodefs.h>
#include <bot.h>
#include <avr/interrupt.h>
#include <spi.h>
#include <stdio.h>
#include <leds.h>
#include <floor.h>
#include "pwm.h"
#include "adc.h"
#include <avr/interrupt.h>
#include <stdint.h>
#include <avr/pgmspace.h>
#define sense 19
int main()
{
sei();
bot_init();
spi_init();
floor_init();
display_init();
gfx_init();
leds_init();
pwm_init();
gfx_move (22, 0);
gfx_set_proportional (1);
gfx_print_text ("Linie folgen");
gfx_set_proportional (0);
gfx_move (5, 10);
gfx_print_char ('R');
gfx_move (118, 10);
gfx_print_char ('L');
copro_ir_startMeasure();
delay (10);
copro_setSpeedParameters(5, 6, 7);
while (1==1)
{
floor_update();
copro_update();
char text [20]="-- -- -- -- --";
// Bodensensoren
floor_update();
copro_update();
sprintf(text, "%02x %02x %02x %02x",
(uint16_t) (floor_relative[FLOOR_RIGHT]/
,
(uint16_t) (floor_relative[FLOOR_LEFT]/
,
(uint16_t) (floor_relative[LINE_RIGHT]/
,
(uint16_t) (floor_relative[LINE_LEFT]/
);
gfx_move(22, 30);
gfx_print_text(text);
if ((floor_relative[LINE_LEFT])<sense && (floor_relative[LINE_RIGHT])<sense)
{
copro_setSpeed(20,20);
}
if ((floor_relative[LINE_LEFT])>sense && (floor_relative[LINE_RIGHT])<sense)
{
copro_setSpeed(15,0);
}
if ((floor_relative[LINE_LEFT])<sense && (floor_relative[LINE_RIGHT])>sense)
{
copro_setSpeed(0,15);
}
if ((floor_relative[LINE_LEFT])>sense && (floor_relative[LINE_RIGHT])>sense)
{
copro_setSpeed(0,0);
}
// Spannung
bot_update();
float volt = 0.0166 * bot_supply - 1.19;
sprintf(text, "%3.1fV", (double)volt);
gfx_move(30, 10);
gfx_set_proportional (1);
gfx_print_text("supply: ");
gfx_set_proportional (0);
gfx_print_text(text);
}
return 0;
}