Hallo,
ich versuche gerade ein einfaches Programm für die Linienfolge über die beiden Liniensensoren zu programmieren. Da ich komplett neu auf diesem Gebiet bin, stoße ich auf einige Probleme.
Für die Motoransteuerung hatte ich zuerst die
copro_setSpeed(); verwendet. Es funktionierte teilweise, nur hat man das gefühl das sich der Nibo immer wieder selbst aus der Bahn wirft. Die Sensoren schalten rechtzeitig nur die Räder reagieren zu träge, sogar auf gerader Strecke. Kurvenfahrt funktioniert noch gar nicht??
Nun hab ich es mit einer anderen Monteransteuerung versucht, fehlt denn noch irgendein wichtiges detail, weil die Motoren nun nicht mehr ansprechen. Der Nibo soll nur einer Weißen Linie auf scharzen Untergrund folgen.
So sieht mein Program aus:
#include <nibo/niboconfig.h>
#include <nibo/display.h>
#include <nibo/gfx.h>
#include <nibo/copro.h>
#include <nibo/delay.h>
#include <nibo/iodefs.h>
#include <nibo/bot.h>
#include <avr/interrupt.h>
#include <nibo/spi.h>
#include <stdio.h>
#include <nibo/leds.h>
#include <nibo/floor.h>
#include "nibo/pwm.h"
#include "nibo/adc.h"
#include <avr/interrupt.h>
#include <stdint.h>
#include <avr/pgmspace.h>
#define sense 60
int16_t speed_l = 0;
int16_t speed_r = 0;
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();
char text [20]="-- -- -- -- --";
// Bodensensoren
floor_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)
{
speed_l = 250; speed_r = 250;
leds_set_status(2, 4);
leds_set_status(2, 5);
}
if ((floor_relative[LINE_LEFT])<sense && (floor_relative[LINE_RIGHT])>sense)
{
speed_l = 350; speed_r = 0;
leds_set_status(2, 5);
leds_set_status(0, 4);
}
if ((floor_relative[LINE_LEFT])>sense && (floor_relative[LINE_RIGHT])<sense)
{
speed_l = 0; speed_r = 350;
leds_set_status(2, 4);
leds_set_status(0, 5);
}
// 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;
}
wäre sehr froh um eure Hilfe.
Gruß Patte