ultra

Dependencies:   SRF05 mbed pixy

Files at this revision

API Documentation at this revision

Comitter:
qj604184
Date:
Fri Jun 09 23:21:14 2017 +0000
Commit message:
cachanNRCultra

Changed in this revision

SRF05.lib Show annotated file Show diff for this revision Revisions of this file
fct.cpp Show annotated file Show diff for this revision Revisions of this file
fct.h Show annotated file Show diff for this revision Revisions of this file
globals.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
pixy.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b3230a65c9b1 SRF05.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SRF05.lib	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/SRF05/#e758665e072c
diff -r 000000000000 -r b3230a65c9b1 fct.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fct.cpp	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "fct.h"
+
+void Vitmoteur(float VitG, float VitD)
+{
+    if(VitG<0) {
+        VitG=-1*VitG;
+        cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001
+    } else {
+        cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche
+    }
+    if(VitD<0) {
+        VitD=-1*VitD;
+        cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100
+    } else {
+        cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit
+    }
+    monI2C.write(ADR_PCF,&cmdI2C,1);
+    MotG.pulsewidth(((100-VitG)/100.0)*PERIOD);
+    MotD.pulsewidth(((100-VitD)/100.0)*PERIOD);
+}
+void init(void)
+{
+    if(C1.read()>0.5) {
+        captL1=0;
+    } else {
+        captL1=1;
+    }
+    if(C3.read()>0.5) {
+        captL3=0;
+    } else {
+        captL3=1;
+    }
+    
+    
+
+}
diff -r 000000000000 -r b3230a65c9b1 fct.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fct.h	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,48 @@
+#ifndef FCT_H
+#define FCT_H
+extern char cmdI2C ;// CS vbat x x x SensG SensD CS_G CD_D, sens moteur positif CS à 0.
+extern PwmOut MotD;
+extern PwmOut MotG;
+extern int captL1;
+extern int captL3;
+//GLOBALES
+extern BusOut leds;
+
+extern Serial CamPixy;
+
+extern DigitalOut trig1;//US1
+extern InterruptIn echo1;
+extern DigitalOut trig2;//US2
+extern InterruptIn echo2;
+extern DigitalOut trig3;//US3
+extern InterruptIn echo3;
+
+extern I2C monI2C;
+extern PwmOut Servo;
+
+extern AnalogIn SD_1; // capteur de distance courte droite
+extern AnalogIn SD_2; // capteur de distance courte gauche
+extern AnalogIn LD_1; // capteur de distance longue droite
+extern AnalogIn LD_2; // capteur de distance longue gauche
+
+extern InterruptIn I_D;
+extern InterruptIn I_G;
+
+extern SPI spi;
+
+extern AnalogIn C1;// capteur de ligne blanche 1
+extern AnalogIn C3;// capteur de ligne blanche 3 
+//-- le capteur de ligne 2 est sur un MCP3201(spi) dont le CS est sur p13
+extern DigitalOut CS_C2;
+
+
+
+//CONSTANTES
+#define ADR_PCF 0x70
+#define PERIOD 0.0001
+
+
+//PROTOTYPES
+void init(void);
+void Vitmoteur(float,float);
+#endif
diff -r 000000000000 -r b3230a65c9b1 globals.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/globals.cpp	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+char cmdI2C=0xF3 ;// CS vbat x x x SensG SensD CS_G CD_D, sens moteur positif CS à 0.
+PwmOut MotD(p25);
+PwmOut MotG(p22);
+
+BusOut leds(LED1,LED2,LED3,LED4);
+
+Serial CamPixy(p28,p27);
+
+DigitalOut trig1(p11);//US1
+InterruptIn echo1(p12);
+DigitalOut trig2(p8);//US2
+InterruptIn echo2(p24);
+DigitalOut trig3(p26);//US3
+InterruptIn echo3(p23);
+
+I2C monI2C(p9,p10);
+PwmOut Servo(p21);
+
+AnalogIn SD_1(p19); // capteur de distance courte droite
+AnalogIn SD_2(p20); // capteur de distance courte gauche
+AnalogIn LD_1(p17); // capteur de distance longue droite
+AnalogIn LD_2(p18); // capteur de distance longue gauche
+
+InterruptIn I_D(p30);
+InterruptIn I_G(p29);
+
+SPI spi(p5,p6,p7);
+
+AnalogIn C1(p15);// capteur de ligne blanche 1
+AnalogIn C3(p16);// capteur de ligne blanche 3 
+//-- le capteur de ligne 2 est sur un MCP3201(spi) dont le CS est sur p13
+DigitalOut CS_C2(p13);
+
+
+int captL1;
+int captL3;
\ No newline at end of file
diff -r 000000000000 -r b3230a65c9b1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "fct.h"
+#include "Pixy.h"
+#include "PixyLink.h"
+#include "SRF05.h"
+
+#define V_max 25
+#define V_recherche 25
+#define K 0.1
+DigitalOut cs(p13);
+DigitalIn bp(p14);
+Serial pc (USBTX,USBRX);
+SRF05 us_arr(p8,p24);
+
+int main()
+{
+    MotG.period(PERIOD);
+    MotD.period(PERIOD);
+    float us_arriere;
+    Vitmoteur(0.0,0.0);
+    while(1) {
+        
+        //printf("Us_arriere : %.1f\n\r", us_arr.read());
+        us_arriere=us_arr.read();
+        if(us_arriere>20) {
+            Vitmoteur(-30,-30);
+        }
+        else{
+            Vitmoteur(0,0);
+            }
+    }
+
+}
+
+
+
+
diff -r 000000000000 -r b3230a65c9b1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0f02307a0877
\ No newline at end of file
diff -r 000000000000 -r b3230a65c9b1 pixy.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixy.lib	Fri Jun 09 23:21:14 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/pirottealex/code/pixy/#e7cb59aaf759