summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--n/es/src/Makefile2
-rw-r--r--n/es/src/capteurf.c46
-rw-r--r--n/es/src/capteurf.h34
-rw-r--r--n/es/src/main.c60
-rw-r--r--n/es/src/tourelle.c1
5 files changed, 124 insertions, 19 deletions
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: <contact@ni.fr.eu.org>
* }}} */
#include "tourelle.h"
@@ -29,6 +27,8 @@
#include "avr/io.h"
#include <stdint.h>
#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<capteurf_cpt;cpt++)
+ {
+ read_capteurf();
+ proto_send2w('C',capteurf_droit,capteurf_gauche);
+ }
+
+ }
+
+
}
return 0;
}
@@ -303,6 +320,7 @@ void proto_callback (uint8_t cmd, uint8_t size,uint8_t* args)
etat = 0;
}break;
+ /* ascenseur */
case c ('m',0): { // ordre de monter l'ascenseur
etat = 1;
ascenseur = 1;
@@ -338,6 +356,13 @@ void proto_callback (uint8_t cmd, uint8_t size,uint8_t* args)
ventouse = args[0];
PORTB |= _BV (1);
}break;
+ /* capteurf */
+ case c ('C',1): { // parametre le nombre de
+ // mesure à faire dans une
+ // boucle
+ capteurf_cpt = args[0];
+ }break;
+ /* generic */
case c ('F',1): {
// reset du message de
// l'ascenseur.
@@ -346,6 +371,7 @@ void proto_callback (uint8_t cmd, uint8_t size,uint8_t* args)
default:
proto_send0 ('?');
+ return ;
}
proto_send (cmd, size, args);
}
diff --git a/n/es/src/tourelle.c b/n/es/src/tourelle.c
index a6d7473..a904304 100644
--- a/n/es/src/tourelle.c
+++ b/n/es/src/tourelle.c
@@ -160,7 +160,6 @@ void TournerTourelle(void)
int16_t mesurer(void)
{
- adc_init();
adc_start(pin_sharp);
while(!adc_checkf()){}
return adc_read();