|
 |
 |
 |
|
|
c't Projekte - c't-Bot und c't-Sim -
Mailinglisten
[Voriger (Datum)]
[Nächster (Datum)]
[Voriger (Thread)]
[Nächster (Thread)]
[Nach Datum][Nach Thread]
Absender: Achim Pankalla
Datum: Mi, 26.09.2007 10:57:10
hallo,
anbei findet ihr ein behaviour für die erweiterte auswertung des
Error-bit. es wertet das bit genauer aus und legt das detailierte
ergebnis in der neuen variable sensDError ab.
es ändert ausserdem die sensoren-anzeige von (Fehler)F=0/1 auf
(Status)S=0x0-0xB. dadurch werden die zustände servo überlast und
füllstand der batterie angezeigt näheres findet ihr im kommentarkopf der
funktion.
die anzeige ist bei mir sehr interesant und es wird schön ein
schwächerwerdener akku angezeigt.
ich bräuchte nur noch jemanden, der das mit den servo testet, die
entsprechende hw ist bei mir noch in einzelteilen...
gruss
achim
Index: E:/eclipse/ct-bot devel/ct-Bot/bot-logic/bot-logik.c
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/bot-logic/bot-logik.c (revision 1272)
+++ E:/eclipse/ct-bot devel/ct-Bot/bot-logic/bot-logik.c (working copy)
@@ -133,6 +133,10 @@
insert_behaviour_to_list(&behaviour, new_behaviour(251, bot_simple2_behaviour,INACTIVE));
#endif
+ #ifdef BEHAVIOUR_CHECK_ERROR_AVAILABLE
+ insert_behaviour_to_list(&behaviour, new_behaviour(240, bot_check_error_behaviour,ACTIVE));
+ #endif
+
#ifdef BEHAVIOUR_DELAY_AVAILABLE
// Delay-Routinen als Verhalten
insert_behaviour_to_list(&behaviour, new_behaviour(200, bot_delay_behaviour,INACTIVE));
Index: E:/eclipse/ct-bot devel/ct-Bot/bot-logic/behaviour_check_error.c
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/bot-logic/behaviour_check_error.c (revision 0)
+++ E:/eclipse/ct-bot devel/ct-Bot/bot-logic/behaviour_check_error.c (revision 0)
@@ -0,0 +1,76 @@
+/*
+ * c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+
+
+/*! @file behaviour_check_error.c
+ * @brief Routine ueberprueft ERROR Eingang und schluesselt Fehlerzustand feiner auf.
+ *
+ * @author Achim Pankalla (achim.pankalla@xxxxxx)
+ * @date 08.09.07
+*/
+
+
+#include "bot-logic/bot-logik.h"
+#include "sensor.h"
+#include "bot-local.h"
+
+#ifdef BEHAVIOUR_CHECK_ERROR_AVAILABLE
+
+uint8 sensDError=0; /*!< Detailierte Meldung ueber Motor oder Batteriefehler */
+
+/*!
+ * Dieses Verhalten ueberprueft den ERROR Eingang (Variable sensError) und setzt die
+ * Variable sensDError, die dann Detailierte Informationen ueber den Bot Zustand enthaelt.
+ * So werden nun folgende Zustaende unterschieden:
+ * 1) Servo
+ * Liegt eine ueberlast des Servo fuer die Klappe vor, so wird das Error Bit gesetzt.
+ * Diese Routine erkennt diese und schluesselt es ueber sensDError auf. (0xB)
+ * 2) Batterie leer
+ * Dies ist natuerlich ein schleichender Prozess, das Errorbit wird nicht schlagartig
+ * wegfallen, sondern durch die wechselnden Stromaufnahmen der verschiedenen Botkomponenten
+ * bei nachlassenden Batterien immer mal wieder mal auf Null und eins gehen. Die Routine
+ * fragt immer 100 mal das Bit ab und zaehlt wie oft es geloescht war. Der Prozentwert wird
+ * in 10er Schritte in sensDError abgelegt. Bei dem Wert 0xA ist das Bit dauernd geloescht
+ * die Batterien sind nahezu leer.
+ * ---
+ * sensDError Wert Bedeutung Kuerzel
+ * 0x0 Batterie 100% und Servo OK BOT_OK (Bot OK)
+ * 0x1 bis 0x9 Das Errorbit flackert, prozentuale
+ * Anzeige von Errorbit aus. 1=10% etc
+ * 0xA Batterie leer, Errorbit dauernd aus. BATT_LO (Batterie low)
+ * 0xB Servo zieht hohen Strom SRV_OVL (Servo overload)
+ */
+void bot_check_error_behaviour(Behaviour_t *data) {
+ static uint8 counter=0; //Zaehlt die Aufrufe des Behaviours
+ static uint8 batt_low=0; //Zaehlt, wie oft Errorbit geloescht ist.
+
+ if(counter++ == 100){ //Auswerten
+ sensDError=(10*batt_low)/counter;
+ counter=batt_low=0;
+ }
+ if(!sensError){ //Fehler wird gemeldet
+ if(servo_active)
+ sensDError = SRV_OVL;
+ else { //Andere Fehler checken
+ batt_low++; //Spannungsfehler zaehlen
+ }
+ }
+}
+
+#endif // BEHAVIOUR_CHECK_ERROR
Index: E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/behaviour_check_error.h
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/behaviour_check_error.h (revision 0)
+++ E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/behaviour_check_error.h (revision 0)
@@ -0,0 +1,45 @@
+/*
+ * c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+
+
+/*! @file behaviour_check_error.h
+ * @brief Auswertung des ERROR Eingang als Verhalten
+ *
+ * @author Achim Pankalla (achim.pankalla@xxxxxx)
+ * @date 08.09.07
+*/
+
+
+#ifndef BEHAVIOUR_CHECK_ERROR_H_
+#define BEHAVIOUR_CHECK_ERROR_H_
+
+//#include "ct-Bot.h"
+#include "bot-logic/bot-logik.h"
+
+#ifdef BEHAVIOUR_CHECK_ERROR_AVAILABLE
+
+extern uint8 sensDError;
+/*!
+ * Verhalten fuer Check Error
+ * @param data Der Verhaltensdatensatz
+ */
+void bot_check_error_behaviour(Behaviour_t *data);
+
+#endif // BEHAVIOUR_DELAY_AVAILABLE
+#endif /*BEHAVIOUR_DELAY_H_*/
Index: E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/available_behaviours.h
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/available_behaviours.h (revision 1272)
+++ E:/eclipse/ct-bot devel/ct-Bot/include/bot-logic/available_behaviours.h (working copy)
@@ -42,11 +42,13 @@
#define BEHAVIOUR_REMOTECALL_AVAILABLE /*!< Nehmen wir Remote-kommandos entgegen?*/
-//#define BEHAVIOUR_CALIBRATE_PID_AVAILABLE /*!< Kalibrierungsverhalten fuer Motorregelung vorhanden? */
+#define BEHAVIOUR_CALIBRATE_PID_AVAILABLE /*!< Kalibrierungsverhalten fuer Motorregelung vorhanden? */
//#define BEHAVIOUR_CALIBRATE_SHARPS_AVAILABLE /*!< Kalibrierungsverhalten fuer Distanzsensoren vorhanden? */
#define BEHAVIOUR_DELAY_AVAILABLE /*!< Delay-Routinen als Verhalten */
+#define BEHAVIOUR_CHECK_ERROR_AVAILABLE /*!< Wertet den ERROR-Eingang aus*/
+
/* Aufgrund einer ganzen reihe von Abhaengigkeiten sollte man beim Versuch Speicher
* zu sparen, zuerst mal bei den Hauptverhalten ausmisten, sonst kommen die
* Unterverhalten durch die Hintertuer wieder rein
@@ -98,6 +100,7 @@
#ifndef MCU
#undef BEHAVIOUR_CALIBRATE_PID_AVAILABLE
+ #undef BEHAVIOUR_CHECK_ERROR_AVAILABLE
#endif
#ifdef BEHAVIOUR_CALIBRATE_PID_AVAILABLE
@@ -161,5 +164,7 @@
#include "bot-logic/behaviour_delay.h"
+#include "bot-logic/behaviour_check_error.h"
+
#endif // BEHAVIOUR_AVAILABLE
#endif /*AVAILABLE_BEHAVIOURS_H_*/
Index: E:/eclipse/ct-bot devel/ct-Bot/include/bot-local.h
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/include/bot-local.h (revision 1272)
+++ E:/eclipse/ct-bot devel/ct-Bot/include/bot-local.h (working copy)
@@ -125,5 +125,9 @@
#define MAX_PILLAR_DISTANCE 200
#endif
+/* Konstanten fuer das bot_check_error_behaviour, Wert von sensDError*/
+#define BOT_OK 0x0 //Batterie und Servo OK
+#define SRV_OVL 0xB //Servo zieht hohen Strom
+#define BATT_LO 0xA //Batterie leer
#endif /*BOTLOCAL_H_*/
Index: E:/eclipse/ct-bot devel/ct-Bot/sensor.c
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/sensor.c (revision 1272)
+++ E:/eclipse/ct-bot devel/ct-Bot/sensor.c (working copy)
@@ -34,6 +34,8 @@
#include "sensor.h"
#include "mouse.h"
#include "log.h"
+#include "bot-logic/behaviour_check_error.h"
+
#ifdef SRF10_AVAILABLE
#include "srf10.h"
#endif
@@ -463,8 +465,11 @@
display_printf("B=%03X %03X L=%03X %03X ",sensBorderL,sensBorderR,sensLineL,sensLineR);
display_cursor(3,1);
- display_printf("R=%2d %2d F=%d K=%d T=%d ",sensEncL%10,sensEncR%10,sensError,sensDoor,sensTrans);
-
+ #ifdef BEHAVIOUR_CHECK_ERROR_AVAILABLE
+ display_printf("R=%2d %2d S=%X K=%d T=%d ",sensEncL%10,sensEncR%10,sensDError,sensDoor,sensTrans);
+ #else
+ display_printf("R=%2d %2d F=%d K=%d T=%d ",sensEncL%10,sensEncR%10,sensError,sensDoor,sensTrans);
+ #endif
display_cursor(4,1);
#ifdef RC5_AVAILABLE
static uint16 RC5_old;
Index: E:/eclipse/ct-bot devel/ct-Bot/Changelog.txt
===================================================================
--- E:/eclipse/ct-bot devel/ct-Bot/Changelog.txt (revision 1272)
+++ E:/eclipse/ct-bot devel/ct-Bot/Changelog.txt (working copy)
@@ -1,5 +1,7 @@
CHANGELOG fuer c't-Bot
======================
+2007-09-26 Achim Pankalla [achim.pankalla@xxxxxx]: Error Flag wird nun detailierter Ausgewertet und Ergebnis in sensDError abgelegt.
+
2007-09-23 Timo Sandmann [mail@xxxxxxxxxxxxxxx]: Linienverfolger ueberarbeitet und an Motorregelung angepasst. Auf die vorherige Version laesst sich mit #define OLD_VERSION zurueckgreifen.
2007-09-21 Timo Sandmann [mail@xxxxxxxxxxxxxxx]: Bei LINE_SENSE wird jetzt zwischen MCU und PC unterschieden.
|
|
|