Projekte
Georg
Motorsensortest
main.c
Projekte
Forum
Doku
Öffentliche Projekte
Startseite
Beispielprogramme
Projekte von anderen
Welcome
Username
Passwort
Eingeloggt bleiben
Zugangsdaten vergessen?
Registrieren
Projektverwaltung
⇨ Please choose! ⇦
——————————————————
✎ Create new project...
★ Browse existing projects...
——————————————————
⚬ MotorTest#1
⚬ C Tutorial 8#1
⚬ NIBO2 C Project#1
⚙ C Tutorial 15#1
⚬ 2010_11_18_el_test001#1
Motorsensortest
main.c
Project details
Compiler settings
Nachrichten
Sie sind nicht eingeloggt.
Neuigkeiten
★
NiboRoboLib 3.6
2017-01-17: Neue Version 3.6
★
NiboRoboLib 3.4.1
2016-04-16: Neue Version 3.4.1
★
Coding Tutorial
2015-11-22: Jetzt auch für den NIBO burger!
Site-Statistic
7426 private projects
385 public projects
16180353 lines compiled
58212 builds
NIBO
@
motorsensortest/main.c [read only]
/* NIBO2 C project */ #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> uint16_t time; int16_t copro_speed_l; int16_t copro_speed_r; int16_t copro_ticks_l; int16_t copro_ticks_r; int16_t copro_current_l; int16_t copro_current_r; /*********** * Makkros * ***********/ #define LOBYTE(x) (uint8_t)((uint16_t)x) //Makkro zum Maskieren des Lowbytes #define HIBYTE(x) (uint8_t)(((uint16_t)x)>>8) //Makkro zum Maskieren des Highbytes /***************************** * Prozeduren und Funktionen * *****************************/ //Byte (8-Bit Wert) in Hexadezimaler Form (zwei Hex-Ziffern) auf dem Display ausgeben void gfx_print_hex(uint8_t val) { char c1=val/16; char c2=val%16; if (c1<10) c1+='0'; else c1+='a'-10; if (c2<10) c2+='0'; else c2+='a'-10; gfx_print_char(c1); gfx_print_char(c2); } //16-Bit Wert in Hexadezimaler Form (vier Hex-Ziffern) auf dem Display ausgeben void gfx_print_hex16(uint16_t val) { gfx_print_hex(HIBYTE(val)); gfx_print_hex(LOBYTE(val)); } int main() { uint8_t temp; sei(); bot_init(); spi_init(); display_init(); gfx_init(); gfx_move(62, 0); gfx_set_proportional(1); gfx_print_text("motion"); gfx_set_proportional(0); gfx_move(5, 0); gfx_print_char('R'); gfx_move(118, 0); gfx_print_char('L'); delay(50); copro_ir_startMeasure(); copro_setSpeedParameters(5, 6, 7); int counter=0; while (1==1) { delay(10); char text[20]=""; bot_update(); float volt = 0.0166 * bot_supply - 1.19; sprintf(text, "%3.1fV", (double)volt); gfx_move(25, 0); gfx_print_text(text); switch(++counter) { case 200: copro_resetOdometry(0,0); copro_update(); copro_setSpeed(20, 20); break; case 400: copro_stop(); if (copro_update()) { //erste Zeile: Ticks gfx_move(0,11); temp = copro_ticks_r % 256; sprintf(text,"%3i",temp); gfx_print_text(text); //gfx_print_hex16(copro_ticks_r); //Ticks rechts auf dem Display ausgeben gfx_move(50,11); gfx_print_text("Hin"); gfx_move(105,11); temp = copro_ticks_l % 256; sprintf(text,"%3i",temp); gfx_print_text(text); //gfx_print_hex16(copro_ticks_l); //Ticks links auf dem Display ausgeben } break; case 600: copro_resetOdometry(255,255); copro_update(); copro_setSpeed(-20, -20); break; case 800: if (copro_update()) { copro_stop(); //erste Zeile: Ticks gfx_move(0,17); temp = 255 - (copro_ticks_r % 256); sprintf(text,"%3i",temp); gfx_print_text(text); gfx_move(50,17); gfx_print_text("Rueck"); gfx_move(105,17); temp = 255 - (copro_ticks_l % 256); sprintf(text,"%3i",temp); gfx_print_text(text); } counter=0; break; } } return 0; }
Compiler results:
Werbung
Online
donruckman48916
GeraldSoota
lienduigan4502045
nanniemacintyre38142