Hallo erstmal zusammen,
ich habe mir versucht nachdem ich das Tuturial durchgemacht habe, mein erste Programm zu Linienverfolgung zu schreiben.
Leider folgt er doch nicht so der Linie wie ich das gerne hätte, zwar zeigen die Sensoren abweichungen an, aber er folgt nicht der Linie.
Hier mein kleines Programm, hoffe ihr könnt mir helfen. Danke:
#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)
{
copro_setSpeed(speed_l, speed_r);
speed_l = 20; speed_r = 20;
leds_set_status(2, 4);
leds_set_status(2, 5);
}
if ((floor_relative[LINE_LEFT])<sense && (floor_relative[LINE_RIGHT])>sense)
{
copro_setSpeed(speed_l, speed_r);
speed_l = 20; speed_r = 0;
leds_set_status(2, 5);
leds_set_status(0, 4);
}
if ((floor_relative[LINE_LEFT])>sense && (floor_relative[LINE_RIGHT])<sense)
{
copro_setSpeed(speed_l, speed_r);
speed_l = 0; speed_r = 20;
leds_set_status(2, 4);
leds_set_status(0, 5);
}
Bin momentan echt etwas ratlos
// 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;
}