Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:6004a7230f87, committed 2014-12-16
- Comitter:
- singularity
- Date:
- Tue Dec 16 15:52:17 2014 +0000
- Commit message:
- Creation k22F
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Analyse.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,43 @@
+#include "Analyse.h"
+
+void seuil(unsigned short *v, bool *rslt, unsigned short seuil)
+{
+ for(int i= 0;i<128;i++){
+ if(v[i]>seuil){
+ rslt[i]=true;
+ }else{
+ rslt[i]=false;
+ }
+ }
+}
+
+//nbr doit etre impaire
+void moyenneGlissante(unsigned short *v, int nbr, unsigned short *rslt)
+{
+ int i;
+ int j = (nbr - 1)/2;
+
+ //Generation du premier terme
+ rslt[0] = (j+1)*v[0];
+ for( i = 1 ; i <= j ;i++) {
+ rslt[0]+= v[j];
+ }
+
+
+ //Generation des termes d'indice 1:j-1
+ for(i = 1 ; i < j ; i++) {
+ rslt[i] = rslt[i-1] - v[0] + v[j + i];
+ }
+
+ //Generation des termes d'indice j:NBR_PIXEL-nbr-1
+
+ for(i = j; i < NBR_PIXEL-nbr; i++) {
+ rslt[i] = rslt[i-1] - v[i-j] + v[i+j];
+ }
+
+ //Generation des termes d'indice NBR_PIXEL-nbr : 127
+ for(i = NBR_PIXEL-nbr; i < NBR_PIXEL-1; i++) {
+ rslt[i] = rslt[i-1] - v[i-j] + v[NBR_PIXEL-1];
+ }
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Analyse.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,6 @@ +#ifndef _ANALYSE_H +#define _ANALYSE_H + +#define NBR_PIXEL 128 + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Camera.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,54 @@
+#include "Camera.h"
+
+
+Camera::Camera(PinName pin_si, PinName pin_clk, PinName pin_ao, int periode_us) : ao(pin_ao),si(pin_si),clk(pin_clk)
+{
+ this->periode = periode_us;
+}
+
+/*Quelques infos
+Voir la doc de la cam
+On genere une impulsion sur SI pour terminer l'acquisition en cours et signaler que l'on va lire les valeurs des pixels
+La valeur d'un pixel est mis analogiquement sur AO apres chaque front montant d'horloge
+SI et clk sont en quadratures de phase
+Le temps d'intégration est le temps entre la lecture du 28 eme pixel et le prochain signal SI*/
+void Camera::capture(unsigned short *valeurs)
+{
+ //ENVOI DU SIGNAL DE START SUR SI(QUADRATURE DE PHASE AVEC CLK)
+ this->si.write(1);
+ wait_us(this->periode);
+ this->clk.write(1);
+ wait_us(this->periode);
+ this->si.write(0);
+ wait_us(this->periode);
+ this->ao.read_u16();
+ this->clk.write(0);
+
+ //RECUPERATION DES DONNEES
+ wait_us(this->periode);
+ for (int i = 0; i < 128; i++)
+ {
+ wait_us(this->periode);
+ wait_us(this->periode);
+ this->clk.write(1);
+ wait_us(this->periode);
+ wait_us(this->periode);
+ //this->ao.read(); pour avoir des flottants sur [0;1]
+ valeurs[i] = this->ao.read_u16();
+ this->clk.write(0);
+ }
+
+ //PROCEDURE DE TERMINAISON
+ wait_us(this->periode);
+ wait_us(this->periode);
+ this->clk.write(1);
+ wait_us(this->periode);
+ wait_us(this->periode);
+ this->clk.write(0);
+
+}
+
+void Camera::setPeriod(int periode)
+{
+ this->periode = periode;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Camera.h Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,23 @@
+#ifndef _CAMERA_H
+#define _CAMERA_H
+
+#include "mbed.h"
+
+//La periode de clk doit etre dans 0.5us - 200us
+//Le parametre periode passé en paramètre ds le constructeur et le setter corresponds a 1/4 de la période de la CLK!!
+
+class Camera
+{
+public:
+ Camera(PinName pin_si, PinName pin_clk, PinName pin_ao, int periode_us);
+ void capture(unsigned short *valeurs);
+ void setPeriod(int periode);
+private:
+ int periode;
+
+ AnalogIn ao;
+ DigitalOut clk;
+ DigitalOut si;
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,30 @@ +#ifndef _PINOUT_H +#define _PINOUT_H + +//PROPULSION +#define MOTD1_PIN PTD1 +#define MOTD2_PIN PTD2 +#define MOTG1_PIN PTD3 +#define MOTG2_PIN PTD0 +#define FBD_PIN PTB10 +#define FBG_PIN PTB11 +#define MOT_PERIOD 0.0001f +#define MOTD_CAPTEUR1_PIN PTA2 +#define MOTD_CAPTEUR2_PIN PTA2 +#define MOTG_CAPTEUR1_PIN PTA2 +#define MOTG_CAPTEUR2_PIN PTA2 + +//DIRECTION +#define DIR_PIN PTA1 + +//XBEE +#define XBEE_PIN_TX D1 +#define XBEE_PIN_RX D0 +#define XBEE_SPEED 9600 + +//CAMERA +#define P_SI PTA2 +#define P_AO PTB3 +#define P_CLK PTC2 + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Direction.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,31 @@
+#include "Direction.h"
+
+//INSTANCIATION DES INSTANCES GLOBALES
+PwmOut direction(DIR_PIN);
+
+void initDirection() {
+ direction.period(DIR_PERIOD);
+ setDirection(128);
+}
+
+/*en float : ~0.025 -> roues braquées a gauche
+ ~0.08 -> roues braquées a droite
+ en int : 0 -> gauche
+ 256 -> droite*/
+void setDirection(int dir) {
+ direction.write(((((float)dir)/256)*0.055f + 0.025f));
+}
+
+
+void testDirection() {
+ float vMoteur = 0.0;
+ for(int i=0;i<256;i++)
+ {
+ setDirection(i);
+ xbee.printf("i = %d ; direction = %f\n",i,direction.read());
+ wait(0.1f);
+ vMoteur = (i-128.0f) / 128.0f;
+ //setMoteurs(vMoteur,vMoteur);
+ xbee.printf("vitesse moteurs : %f\n\n",vMoteur);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Direction.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef _DIRECTION_H +#define _DIRECTION_H + +#include "mbed.h" +#include "Serie.h" + + +#define DIR_PERIOD 0.014286f + +extern PwmOut direction; + +void initDirection(); +void setDirection(int dir); +void testDirection(); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Init.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,7 @@
+#include "Init.h"
+
+void init() {
+ initSerie();
+ initDirection();
+ //initPropulsion();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Init.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,10 @@ +#ifndef _INIT_H +#define _INIT_H + +#include "Serie.h" +#include "Propulsion.h" +#include "Direction.h" + +void init(); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Moteur.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,145 @@
+#include "Moteur.h"
+
+//t_asserv en seconde
+Moteur::Moteur(PinName pin_pwm1, PinName pin_pwm2, PinName pin_feedback, PinName pin_capteur1, PinName pin_capteur2) :
+ m1(pin_pwm1),m2(pin_pwm2),
+ feedbackCurrent(pin_feedback),
+ capteur1(pin_capteur1),
+ capteur2(pin_capteur2),
+ tmr()
+{
+ this->derniere_mesure = 0;
+ //INIT DES PWM
+ this->m1.period(MOT_PERIOD);
+ this->m2.period(MOT_PERIOD);
+ this->setPuissance(0);
+
+ //INIT CAPTEUR
+ this->capteur1.rise(this,&Moteur::interruptCapteurRise);
+ this->capteur1.fall(this,&Moteur::interruptCapteurFall);
+}
+
+/*-1 : full marche arrière
+ 1 : full marche avant
+ */
+void Moteur::setPuissance(float p)
+{
+ if (p>0) {
+ this->m1.write(0);
+ this->m2.write(p);
+ }else{
+ this->m1.write(-p);
+ this->m2.write(0);
+ }
+}
+
+void Moteur::test1()
+{
+ //RAZ DES SORTIES
+ this->m1.write(0.0f);
+ this->m2.write(0.0f);
+
+ //DEBUT SEQUENCE DE TEST
+ xbee.printf("Debut Test Propulsion\n");
+ this->m1.write(0.5);
+ xbee.printf("M1 = 0.5\n");
+ wait(10.0f);
+ this->m1.write(0);
+ this->m2.write(0.5);
+ xbee.printf("M2 = 0.5\n");
+ wait(10.0f);
+ this->m2.write(0);
+ xbee.printf("Fin Test Propulsion\n");
+}
+
+void Moteur::test2()
+{
+ //RAZ DES SORTIES
+ this->m1.write(0.0f);
+ this->m2.write(0.0f);
+
+ //DEBUT SEQUENCE DE TEST
+ xbee.printf("Debut Test Propulsion\n");
+ this->m1.write(0.5);
+ xbee.printf("M1 = 0.5\n");
+ wait(10.0f);
+ this->m1.write(0);
+ this->m2.write(0.5);
+ xbee.printf("M2 = 0.5\n");
+ wait(10.0f);
+ this->m2.write(0);
+ xbee.printf("Fin Test Propulsion\n");
+}
+
+
+void Moteur::etalonnage() {
+ xbee.printf("ETALONNAGE\n");
+ for(int i=0;i<256;i++) {
+ this->m1.write((float)i/256.0f);
+ xbee.printf("D1 : %d\n",i);
+ wait(0.1f);
+ }
+}
+
+
+void Moteur::asserv()
+{
+ //Application de la nouvelle commande
+ this->setPuissance(regulateur.getCommande(this->erreur));
+}
+
+void Moteur::setKp(float k)
+{
+ this->regulateur.setKp(k);
+}
+void Moteur::setKi(float k)
+{
+ this->regulateur.setKp(k);
+}
+void Moteur::setKd(float k)
+{
+ this->regulateur.setKp(k);
+}
+
+
+void Moteur::interruptCapteurRise()
+{
+ this->mesure();
+ this->majErreur();
+ this->asserv();
+}
+
+void Moteur::interruptCapteurFall()
+{
+ this->mesure();
+ this->majErreur();
+ this->asserv();
+}
+
+void Moteur::mesure()
+{
+ this->derniere_mesure = 1/this->tmr.read();
+ if(this->capteur2) {
+ this->derniere_mesure = -this->derniere_mesure;
+ }
+ this->tmr.reset();
+}
+
+void Moteur::majErreur()
+{
+ float e_prec = this->erreur.p;
+
+ this->erreur.p = this->derniere_mesure - this->vitesse_consigne;
+ this->erreur.i += this->erreur.p;
+ this->erreur.d = this->erreur.p - e_prec;
+}
+
+float Moteur::getMesure()
+{
+ return this->derniere_mesure;
+}
+
+void Moteur::setVitesse(float v)
+{
+ this->vitesse_consigne = v;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Moteur.h Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,50 @@
+#ifndef _MOTEUR_H
+#define _MOTEUR_H
+
+#include "mbed.h"
+#include "Serie.h"
+#include "Pid.h"
+
+
+class Moteur
+{
+public:
+ Moteur(PinName pin_pwm1, PinName pin_pwm2, PinName pin_feedback, PinName pin_capteur1, PinName pin_capteur2);
+ void setVitesse(int v);
+ void setKp(float k);
+ void setKi(float k);
+ void setKd(float k);
+ void etalonnage();
+ void test1();
+ void test2();
+
+
+ void setVitesse(float v);
+ float getMesure();
+
+protected:
+ void setPuissance(float p);
+ void asserv();
+ void majErreur();
+ void interruptCapteurRise();
+ void interruptCapteurFall();
+ void mesure();
+
+ //IN-OUT
+ AnalogIn feedbackCurrent;
+ PwmOut m1;
+ PwmOut m2;
+ InterruptIn capteur1;
+ DigitalIn capteur2;
+
+ //MESURE
+ Timer tmr;
+ float derniere_mesure;
+
+ //REGULATION
+ Pid regulateur;
+ Erreur erreur;
+ float vitesse_consigne;
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Pid.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,40 @@
+#include "Pid.h"
+
+Pid::Pid()
+{
+ this->kp = 0;
+ this->ki = 0;
+ this->kd = 0;
+}
+
+Pid::Pid(float Kp, float Ki, float Kd)
+{
+ this->kp = Kp;
+ this->ki = Ki;
+ this->kd = Kd;
+}
+
+void Pid::setKp(float Kp)
+{
+ this->kp = Kp;
+}
+void Pid::setKi(float Ki)
+{
+ this->ki = Ki;
+}
+
+void Pid::setKd(float Kd)
+{
+ this->kd = Kd;
+}
+float Pid::getCommande(float p_erreur, float i_erreur, float d_erreur)
+{
+ return this->kp * p_erreur +
+ this->ki * i_erreur +
+ this->kd * d_erreur;
+}
+
+float Pid::getCommande(Erreur e)
+{
+ return this->getCommande(e.p,e.i,e.d);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Pid.h Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,30 @@
+#ifndef _PID_H
+#define _PID_H
+
+#include "mbed.h"
+
+struct Erreur {
+ float p;
+ float i;
+ float d;
+};
+
+class Pid
+{
+public:
+ Pid();
+ Pid(float Kp, float Ki, float Kd);
+ void setKp(float Kp);
+ void setKi(float Ki);
+ void setKd(float Kd);
+ float getCommande(float p_erreur, float i_erreur, float d_erreur);
+ float getCommande(Erreur e);
+
+private:
+ float kp;
+ float ki;
+ float kd;
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Propulsion.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,69 @@
+#include "Propulsion.h"
+
+Propulsion::Propulsion() :
+ moteurDroit(MOTD1_PIN,MOTD2_PIN,FBD_PIN,MOTD_CAPTEUR1_PIN,MOTD_CAPTEUR2_PIN),
+ moteurGauche(MOTG1_PIN,MOTG2_PIN,FBG_PIN,MOTG_CAPTEUR1_PIN,MOTG_CAPTEUR2_PIN)
+{
+ //Lors de leurs instanciations les moeturs ont leur puissance initialisée à 0.
+}
+
+//IMPLEMENTER LE DIFFERENTIEL ICI
+void Propulsion::setVitesse(float v)
+{
+ this->moteurDroit.setVitesse(v);
+ this->moteurGauche.setVitesse(v);
+}
+
+void Propulsion::testPropulsion1()
+{
+ this->moteurDroit.test1();
+ this->moteurGauche.test1();
+}
+
+void Propulsion::setDKp(float k)
+{
+ this->moteurDroit.setKp(k);
+}
+
+void Propulsion::setDKi(float k)
+{
+ this->moteurDroit.setKi(k);
+}
+
+void Propulsion::setDKd(float k)
+{
+ this->moteurDroit.setKd(k);
+}
+
+void Propulsion::setGKp(float k)
+{
+ this->moteurGauche.setKp(k);
+}
+
+void Propulsion::setGKi(float k)
+{
+ this->moteurGauche.setKi(k);
+}
+
+void Propulsion::setGKd(float k)
+{
+ this->moteurGauche.setKd(k);
+}
+
+
+/*
+void Propulsion::testPropulsion2()
+{
+ moteurD1.write(1);
+ wait(1.0f);
+ moteurG1.write(1);
+ wait(1.0f);
+ setPuissanceMoteurs(0.5,0.5);
+ wait(1.0f);
+ setPuissanceMoteurs(-0.5,-0.5);
+ wait(1.0f);
+ setPuissanceMoteurs(0,-0.5);
+ wait(1.0f);
+ setPuissanceMoteurs(0,0);
+}
+*/
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Propulsion.h Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,34 @@
+#ifndef _PROPULSION_H
+#define _PROPULSION_H
+
+#define T_ASSERV_DEFAULT 0.500
+
+#include "mbed.h"
+#include "Moteur.h"
+#include "Config.h"
+
+class Propulsion
+{
+public:
+ Propulsion();
+ void setVitesse(float v);
+ void testPropulsion1();
+ //void testPropulsion2();
+ void testMoteurDroit();
+ void testMoteurGauche();
+
+
+ void setDKp(float k);
+ void setDKi(float k);
+ void setDKd(float k);
+ void setGKp(float k);
+ void setGKi(float k);
+ void setGKd(float k);
+
+private:
+
+ Moteur moteurDroit;
+ Moteur moteurGauche;
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Serie.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,166 @@
+#include "Serie.h"
+
+//INSTANCIATION DES INSTANCES GLOBALES ET EXTERNES
+Serial xbee(XBEE_PIN_TX,XBEE_PIN_RX);
+
+//INSTANCES GLOBALES ET INTERNES
+char commande[TAILLE_COMMANDE];
+int curseur;
+bool wait_com;
+
+
+/* LA COMMANDE POUR PAPI BROSSARD
+reception d'un chaine :"Cam:23521/4521/451/.../6532/\n"
+Utilisation du split java avec pour delimiteur / et :
+String s="27/03/2008";
+String str[]=s.split("/");
+
+On peut eventuellement utilisé la classe Scanner de JAVA*/
+void envoyerCamera()
+{
+ xbee.printf("Cam:");
+ for(int i=0;i<128;i++) {
+ xbee.printf("%u/",valeurs[i]);
+ }
+ xbee.printf("\n");
+}
+
+typedef enum IdVar IdVar;
+enum Idvar {CAM1,TASSERV,VPROP,};
+
+//Si quelqu'un trouve pourquoi un parametre de type enumeration n'est pas accepte par le compilo
+/*void getVar(IdVar id) {
+ switch(id) {
+ case CAM1 :
+ envoyerCamera();
+ break;
+
+ }
+}*/
+
+void getVar(int id) {
+ switch(id) {
+ case CAM1 :
+ envoyerCamera();
+ break;
+ }
+}
+void help() {
+}
+
+void traiter(char commande[]) {
+ switch(commande[0]) {
+ case 'G':
+ getVar(commande[1]);
+
+ break;
+
+ case 'S':
+ int t;
+ sscanf(commande, "S%d\n",t);
+ //setTIntegration(t);
+
+ break;
+ case 'D':
+ float t;
+ char a,b;
+ sscanf(commande,"%c%c%f\n",&a,&b,&t);
+
+ switch(commande[2]) {
+ case 'P':
+ propulsion.setDKp(t);
+ break;
+ case 'I':
+ propulsion.setDKi(t);
+ break;
+ case 'D':
+ propulsion.setDKd(t);
+ break;
+ }
+ break;
+ case 'L':
+ float w;
+ char a,b;
+ sscanf(commande,"%c%c%f\n",&a,&b,&w);
+
+ switch(commande[2]) {
+ case 'P':
+ propulsion.setGKp(w);
+ break;
+ case 'I':
+ propulsion.setGKi(w);
+ break;
+ case 'D':
+ propulsion.setGKd(w);
+ break;
+ }
+ break;
+
+ case 'C':
+ setDirection(((float)commande[1])/(2000*256.0f));
+ float a1 = (float)commande[1]/(2000*256.0f);
+ float a2 = (commande[2]-128.0f)/128.0f;
+ float a3 = (commande[3]-128.0f)/128.0f;
+ //setPuissanceMoteurs((commande[2]-128.0f)/(128.0f),(commande[3]-128.0f)/(128.0f));
+ xbee.printf("Commande (C)ontrol reconnue\n");
+ xbee.printf(" C:%s dir(int):%d M1(int):%d M2(int):%d\n",commande[0],commande[1],commande[2],commande[3]);
+ xbee.printf(" Valeur: Dir(float)%f\n",direction.read());
+ xbee.printf("%f %f %f\n\n\n",a1,a2,a3);
+
+ break;
+
+ default:
+ xbee.printf("Commande non reconnue\n");
+ break;
+ }
+ xbee.printf(" Commande(ASCII) : %s\n",commande);
+}
+
+void callbackSerie() {
+ int donne;
+
+ while(xbee.readable())
+ {
+ donne = xbee.getc();
+
+ if(wait_com) {
+ /*On ecoute la commande*/
+
+ if(donne == '\n') {
+ /*Fin de la commande*/
+ if(curseur != 0) {
+ commande[curseur] = '\n';
+ traiter(commande);
+ }
+ wait_com = false;
+ } else {
+ if(curseur >= TAILLE_COMMANDE) {
+ xbee.printf("Xbee Freescale: Buffer overflown");
+ wait_com = false;
+ } else {
+ commande[curseur] = donne;
+ curseur++;
+ }
+ }
+
+ } else {
+ /*On attends le symbole START pour prendre commande*/
+ if(donne == 'S') {
+ wait_com = true;
+ curseur = 0;
+ }
+ }
+ }
+}
+
+
+void initSerie() {
+ for(int i=0 ; i< TAILLE_COMMANDE ; i++) {
+ commande[i] = 0;
+ }
+ xbee.baud(XBEE_SPEED);
+ xbee.printf("Xbee Freescale: Hello...\n");
+ xbee.attach(&callbackSerie);
+ curseur = 0;
+ wait_com = false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Serie.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,20 @@ +#ifndef _SERIE_H +#define _SERIE_H + +#define SERIAL_SPEED +#define TAILLE_COMMANDE 10 + + +#include "mbed.h" +#include "Direction.h" +#include "Propulsion.h" +#include "Config.h" + +#include "main.h" + +extern Serial xbee; + +void initSerie(); +//void callbackSerie(); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Dec 16 15:52:17 2014 +0000
@@ -0,0 +1,57 @@
+#include "main.h"
+
+
+//VOIR LA PRIORITE DES INTERRUPTIONS
+//INTERRUPTION SUR LES CLICKS DES CAPTEURS DE VITESSE DOIT AVOIR UNE PRIORITE PLUS IMPORTANTE
+//QUE LA CAMERA OU LE RESTE
+
+// COMMANDE: 53 43 FF FF FF 0A
+// Freescale de merde
+
+Propulsion propulsion;
+DigitalOut led_run(LED_RED);
+Camera cam(P_SI,P_CLK,P_AO,5);
+Ticker timer;
+Timer t;
+int begin,end;
+int t_int;
+bool acquisition;
+
+unsigned short valeurs[128];
+
+void call() {
+ acquisition = true;
+}
+
+void setTIntegration(int t)
+{
+ timer.detach();
+ timer.attach_us(&call,t);
+}
+
+//TEMPS INTEGRATION 0.065-100 ms
+int main()
+{
+ init();
+ t.start();
+ acquisition = false;
+ t_int = 10000;
+ timer.attach_us(&call,t_int);
+ /*Attente active !! Argh ! */
+
+ /*Ou est ce que tu vois une attente active, il n'y a qu'un pauvre vieux test a chaque passage*/
+ /*De plus, je te paie une bière si tu me codes un OS pour Freescale qui me gère la préemption et le réveil de Thread*/
+
+ while (true) {
+ if(acquisition) {
+ led_run = !led_run;
+
+ //Lancement acquisition
+ begin = t.read_us();
+ cam.capture(valeurs);
+ end = t.read_us();
+
+ acquisition = false;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef _MAIN_H +#define _MAIN_H + +#include "mbed.h" +#include "Init.h" +#include "Serie.h" +#include "Camera.h" +#include "Config.h" +#include "Propulsion.h" + + +extern Propulsion propulsion; +extern unsigned short valeurs[128]; +void setTIntegration(int t); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file