From 5aa767f2db173d9071297dd6b0b4d1c5337b4361 Mon Sep 17 00:00:00 2001 From: burg Date: Sun, 1 May 2005 20:57:41 +0000 Subject: Ajout du sub-module capteurrf --- n/es/src/Makefile | 2 +- n/es/src/capteurf.c | 46 ++++++++++++++++++++++++++++++++++++++++ n/es/src/capteurf.h | 34 ++++++++++++++++++++++++++++++ n/es/src/main.c | 60 ++++++++++++++++++++++++++++++++++++++--------------- n/es/src/tourelle.c | 1 - 5 files changed, 124 insertions(+), 19 deletions(-) create mode 100644 n/es/src/capteurf.c create mode 100644 n/es/src/capteurf.h (limited to 'n') diff --git a/n/es/src/Makefile b/n/es/src/Makefile index 9ffa7b8..52bbf48 100644 --- a/n/es/src/Makefile +++ b/n/es/src/Makefile @@ -1,5 +1,5 @@ PROGS = es -es_OBJECTS = main.o rs232.o tourelle.o adc.o twi_slave.o proto.o ascenseur.o +es_OBJECTS = main.o rs232.o tourelle.o adc.o twi_slave.o proto.o ascenseur.o capteurf.o DOC = EXTRACTDOC = MODULES = n/avr/rs232 n/avr/carte_capteur n/avr/utils n/avr/adc n/avr/proto n/avr/twi-slave diff --git a/n/es/src/capteurf.c b/n/es/src/capteurf.c new file mode 100644 index 0000000..1672d45 --- /dev/null +++ b/n/es/src/capteurf.c @@ -0,0 +1,46 @@ +/* tourelle.c*/ +/* Detector on a ATmega8535. {{{ + * Copyright (C) 2005 Burg Thomas + * + * Robot APB Team/Efrei 2005. + * Web: http://assos.efrei.fr/robot/ + * Email: robot AT efrei DOT fr + * + * 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. + * }}} */ + +#include "capteurf.h" +#include "n/avr/utils/utils.h" + +#define CAPTEUR_DROIT 0x3 +#define CAPTEUR_GAUCHE 0x4 + +uint16_t capteurf_droit ; +uint16_t capteurf_gauche ; + +void read_capteurf(void ) +{ + // Lecture capteur droit + adc_start(CAPTEUR_DROIT); + while (adc_checkf() !=0); + capteurf_droit = adc_read(); + + //Lecture capteur gauche + adc_start(CAPTEUR_GAUCHE); + while (adc_checkf() !=0); + capteurf_gauche = adc_read(); +} + + diff --git a/n/es/src/capteurf.h b/n/es/src/capteurf.h new file mode 100644 index 0000000..15241f6 --- /dev/null +++ b/n/es/src/capteurf.h @@ -0,0 +1,34 @@ +/* capteurf.h */ +/* Detector on a ATmega8535. {{{ + * + * Copyright (C) 2005 Burg Thomas + * + * Robot APB Team/Efrei 2005 + * 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. + * + * }}} */ + +#ifndef capteurf_h +#define capteurf_h +/* inclusion */ + +#include "n/avr/twi-slave/twi_slave.h" +#include "n/avr/adc/adc.h" + +extern uint16_t capteurf_droit ; +extern uint16_t capteurf_gauche ; + +void read_capteurf(void); + +#endif diff --git a/n/es/src/main.c b/n/es/src/main.c index bc8cb41..f17aa55 100644 --- a/n/es/src/main.c +++ b/n/es/src/main.c @@ -18,8 +18,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Contact : - * Web: http://perso.efrei.fr/~schodet/ - * Email: * }}} */ #include "tourelle.h" @@ -29,6 +27,8 @@ #include "avr/io.h" #include #include "ascenseur.h" +#include "capteurf.h" + /* +AutoDec */ /* -AutoDec */ @@ -53,8 +53,14 @@ uint16_t stockage_valeur_pont[4][3]; uint8_t nombre_valeur_tourelle = 0; uint8_t action_tourelle; +// ascenseur uint8_t ascenseur; +// ventouse uint8_t ventouse; +// capteur de front +uint8_t capteurf = 0; +uint8_t capteurf_cpt = 0; + uint8_t pont; uint8_t nb_valeur_socle = 0; @@ -84,6 +90,7 @@ int main (void) uint8_t temp_sens = 1; uint8_t compteur = 0; uint16_t tableau_sharp[3]; + uint8_t cpt; uint8_t renvoie_tourelle; /// intialisation @@ -100,10 +107,11 @@ int main (void) tourelle_init (prescaler); ascenseur_init (); pont_init (); - // adc_init (); + adc_init (); ascenseur = 1; pont = 0; action_tourelle = 0; + capteurf = 1; etat = 1; clk = 1; @@ -193,9 +201,9 @@ int main (void) for(compteur=0;compteur<3;compteur++) { - adc_start (compteur); // pin selectionnee - while(!adc_checkf()){} - stockage_valeur_pont[0][compteur]=adc_read(); + adc_start (compteur); // pin selectionnee + while(!adc_checkf()){} + stockage_valeur_pont[0][compteur]=adc_read(); } @@ -229,15 +237,15 @@ int main (void) if (socle == 1) // active les fonctions liées au socle. { - adc_start (pin_socle1); // pin socle1 sélectionnée - - while(!adc_checkf()){} - valeur_socle1 = adc_read(); - - adc_start (pin_socle2); // pin socle2 sélectionnée - - while(!adc_checkf()){} - valeur_socle2 = adc_read(); + adc_start (pin_socle1); // pin socle1 sélectionnée + + while(!adc_checkf()){} + valeur_socle1 = adc_read(); + + adc_start (pin_socle2); // pin socle2 sélectionnée + + while(!adc_checkf()){} + valeur_socle2 = adc_read(); nb_valeur_socle++; if(valeur_socle1 > SEUIL_SOCLE || valeur_socle2 > SEUIL_SOCLE) @@ -273,8 +281,17 @@ int main (void) } - - + if (capteurf) + { + for(cpt=0;cpt