From 482a9138976d0ff294a4555e98d8533b037f25d1 Mon Sep 17 00:00:00 2001 From: lambert Date: Wed, 24 May 2006 08:56:19 +0000 Subject: * barillet fonctionnel à 80% * retester en arrivant a la coupe * finir la vidange poubelle bon je vais aider tb a gerer lalogistique de depart --- n/es-2006/src/barillet.c | 85 +++++++++++++++++++++++++++++++++++------------- n/es-2006/src/barillet.h | 6 ++++ n/es-2006/src/main.c | 8 +++++ 3 files changed, 77 insertions(+), 22 deletions(-) diff --git a/n/es-2006/src/barillet.c b/n/es-2006/src/barillet.c index 733210c..87c3074 100644 --- a/n/es-2006/src/barillet.c +++ b/n/es-2006/src/barillet.c @@ -61,6 +61,9 @@ /* delai d'une µs pour la carte puissance */ #define DELAY_ 1 +/* delai de 500 µs pour la vidange */ +#define DELAY_VIDANGE_ 500 + /* Define de l'etat_en_cours_. * Lexique : * AV : trou avant. @@ -89,8 +92,12 @@ #define SLEEP (0x02) /** Prêt à agir. */ #define STAND_BY (0x03) -/** Prêt à agir sauf pour faire monter des balles. */ +/** Prêt à agir sauf pour faire monter des balles. les turbines sont au minimum */ #define STAND_BY_FULL (0x04) +/** il faudra remettre les turbines au minimum */ +#define STAND_BY_ARRET (0x05) + + #define ROTATION (0x10 | ETAT_ROTATION) #define ROTATION_FIN (0x11) #define AV_EX_VU (0x20) @@ -106,6 +113,9 @@ #define AR_DEP_VU (0x41) #define AR_DEP_PASSE (0x42) #define AR_DEP_FIN (0x43) +#define VIDANGE (0x50) +#define VIDANGE_VU (0x51) // cahnger les noms +#define VIDANGE_PASSE (0x52) /* at barillet. */ volatile uint8_t etat_en_cours_; @@ -118,8 +128,14 @@ volatile uint8_t pos_actuel_; volatile uint8_t pos_final_; volatile uint8_t pos_lenteur_; +/* variable de vidange */ +uint8_t vidange_; + +/* compteur de vidange */ +uint8_t compt_vidange; + /* Compteur utilisé pour les time out ou les passages de balle. */ -volatile uint8_t attente_; +volatile uint16_t attente_; /* fonctions static dans le fichier */ static void rotation_barillet (uint8_t pos_final, uint8_t etat); @@ -165,7 +181,7 @@ barillet_init (void) /* interruption autorisees INT7 INT6 INT5 INT4 à chaque changement logique */ EICRB = regv ( ISC71, ISC70, ISC61, ISC60, ISC51, ISC50, ISC41, ISC40, - 1, 0, 1, 0, 0, 1, 0, 1); + 0, 1, 0, 1, 0, 1, 0, 1); EIFR |= _BV(7) | _BV(6) | _BV(5) | _BV(4); EIMSK |= _BV(7) | _BV(6) | _BV(5) | _BV(4); @@ -177,6 +193,8 @@ barillet_init (void) etat_en_cours_ = RESET; attente_ = 0; fourche_barillet_prec_ = (PINE >> 4) & 3; + vidange_ = 0; + compt_vidange = 0; } @@ -195,11 +213,25 @@ barillet_init_zero (void) } } +/* Lancement des turbines en vitesse lente */ +void +barillet_debut_lancement (void) +{ + if (etat_en_cours_ == SLEEP || etat_en_cours_ == STAND_BY || etat_en_cours_ == STAND_BY_ARRET) + { + /* Commencer a faire tourner les turbines. */ + OCR_TURB_AVANT = VITESSE_TURB_MIN_; + OCR_TURB_ARRIERE = VITESSE_TURB_MIN_; + etat_en_cours_ = STAND_BY_FULL; + } +} + + /* Lance la procédure de collecte de toutes les balles de la table. */ void barillet_lancement (void) { - if (etat_en_cours_ == SLEEP || etat_en_cours_ == STAND_BY_FULL) + if (etat_en_cours_ == STAND_BY_FULL) { /* Commencer a faire tourner les turbines. */ OCR_TURB_AVANT = VITESSE_TURB_MAX_; @@ -208,7 +240,7 @@ barillet_lancement (void) } } -/* Dodo. */ +/* Dodo. - fin du match - */ void barillet_sleep (void) { @@ -252,6 +284,18 @@ depot_balle (void) } } +/* vidange total du barillet */ +void +vidange_barillet(void) +{ + if ( ( etat_en_cours_ == STAND_BY || etat_en_cours_ == STAND_BY_FULL ) ) + { + etat_en_cours_ = VIDANGE; + rotation_barillet( 0x26, VIDANGE ); + } +} + + void sequenceur_barillet() { static uint8_t old_pos_actuel = 0; @@ -272,8 +316,18 @@ void sequenceur_barillet() case SLEEP: break; case STAND_BY: + if ( vidange_ ) + { + vidange_barillet(); + } break; case STAND_BY_FULL: + if ( vidange_ ) + { + vidange_barillet(); + } + break; + case STAND_BY_ARRET: break; case ROTATION_FIN: // XXX ack @@ -312,7 +366,7 @@ void sequenceur_barillet() break; case AR_DEP_FIN: // XXX ack - etat_en_cours_ = STAND_BY_FULL; + etat_en_cours_ = STAND_BY_ARRET; break; default : break; } @@ -420,7 +474,7 @@ pos_bar (void) else if (etat_en_cours_ == INIT && (fourche == 3) && (PINF & 0x01)) { OCR_BAR = 0; - pos_actuel_ == 0; + pos_actuel_ = 0; etat_en_cours_ = SLEEP; } } @@ -466,19 +520,6 @@ void sens(uint8_t sens_rotat) } } -/* ****************************** - * EXTRACTION ET DEPOT DE BALLE * - * ******************************/ - -/* Si balle dans trou => Extraction */ -void extraction_balle(void) -{ - /* Ralentir la turbine avant */ - OCR_TURB_AVANT = VITESSE_TURB_MIN_; - /* Vitesse max de la turbine arriere */ - OCR_TURB_ARRIERE = VITESSE_TURB_MAX_; - etat_en_cours_ = AR_EX; -} /* *************** * INTERRUPTIONS * @@ -516,12 +557,12 @@ SIGNAL (SIG_INTERRUPT7) // dans le cas d'une descente, il se peut qu'il n'y ai // pas de balle etat_en_cours_ = AR_DEP_VU; - attente_ = 200; + attente_ = 400; } else if (etat_en_cours_ == AR_DEP_VU) { etat_en_cours_ = AR_DEP_PASSE; - attente_ = 200; + attente_ = 400; } } diff --git a/n/es-2006/src/barillet.h b/n/es-2006/src/barillet.h index 13d1af0..b396e1c 100644 --- a/n/es-2006/src/barillet.h +++ b/n/es-2006/src/barillet.h @@ -27,6 +27,7 @@ // }}} #include "common.h" +#include "servo_motor.h" /* fonction d'initialisation */ void barillet_init(void); @@ -35,6 +36,8 @@ void barillet_init(void); void barillet_init_zero (void); /* fonction appelee pour lancer le barillet */ +void barillet_debut_lancement (void); +/* fonction appelee juste apres */ void barillet_lancement (void); /* changement de vitesse turbine */ @@ -58,5 +61,8 @@ void depot_balle(void); /* Dodo. */ void barillet_sleep (void); +/* fonction pour vider le barillet */ +void vidange_barillet(void); + #endif diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c index 98d674f..4878f0d 100644 --- a/n/es-2006/src/main.c +++ b/n/es-2006/src/main.c @@ -208,6 +208,10 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) break; /* bon on commence - le jack est parti */ case c ('g', 0): + barillet_debut_lancement(); + break; + /* on passe en vitesse turbine rapide */ + case c ('h',0): barillet_lancement(); break; /* Coucouche panier. */ @@ -226,6 +230,10 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) case c ('t', 1): rotation(args[0]); break; + /* vidange du barillet */ + case c ('n', 0): + vidange_barillet(); + break; /* Unknown commands */ default: -- cgit v1.2.3