programme ines avce xbee

Dependencies:   MMA8451Q mbed xbee_lib

Fork of Programme_course by Freescale_Cachan

Committer:
inesmas3
Date:
Fri Mar 17 14:18:13 2017 +0000
Revision:
2:ddf9879f0e25
Parent:
1:4a9196bcf97a
Programme ines avce le xbee

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Freescale_cup 0:3ec7fc598e48 1
Freescale_cup 0:3ec7fc598e48 2
Freescale_cup 0:3ec7fc598e48 3 #ifndef TEST
Freescale_cup 0:3ec7fc598e48 4 #define TEST
Freescale_cup 0:3ec7fc598e48 5
Freescale_cup 0:3ec7fc598e48 6 #include "mbed.h"
Freescale_cup 0:3ec7fc598e48 7 #include "MMA8451Q.h"
Freescale_cup 0:3ec7fc598e48 8 #include "motor.h"
inesmas3 2:ddf9879f0e25 9 #include "xbee.h"
Freescale_cup 0:3ec7fc598e48 10
Freescale_cup 0:3ec7fc598e48 11 #define MMA8451_I2C_ADRESS (0x1d<<1)
Freescale_cup 0:3ec7fc598e48 12
Freescale_cup 0:3ec7fc598e48 13 #define FRQ_CLK 15000
Freescale_cup 0:3ec7fc598e48 14 #define FRQ_CYC 6000
Freescale_cup 0:3ec7fc598e48 15 #define AMIDTAB 64
Freescale_cup 0:3ec7fc598e48 16 #define BMIDTAB 63
Freescale_cup 0:3ec7fc598e48 17 #define BANDSIZE 4
Freescale_cup 0:3ec7fc598e48 18 #define MIN_INTE 0
Freescale_cup 0:3ec7fc598e48 19 #define MAX_INTE FRQ_CYC-500
Freescale_cup 0:3ec7fc598e48 20 #define INCREM_BALANCE 300
Freescale_cup 0:3ec7fc598e48 21 #define MARGE_LIGNE 5
Freescale_cup 0:3ec7fc598e48 22 #define MARGE_DISTANCE_LIGNE 10
Freescale_cup 0:3ec7fc598e48 23 #define LUMI_MOYENNE 80
Freescale_cup 0:3ec7fc598e48 24 #define CORRECTION_VIRAGE 1
Freescale_cup 0:3ec7fc598e48 25 #define MAX_BATTERY 1.3
Freescale_cup 0:3ec7fc598e48 26 #define SEUIL_NB_DERRIVEE 25
inesmas3 2:ddf9879f0e25 27 //#define KD 600 //valeur de base 400
inesmas3 2:ddf9879f0e25 28 //#define KI 3
inesmas3 2:ddf9879f0e25 29
inesmas3 2:ddf9879f0e25 30 /* Constantes de prépro relatives à Xbee*/
inesmas3 2:ddf9879f0e25 31
inesmas3 2:ddf9879f0e25 32 #define NB_CARAC 4
inesmas3 2:ddf9879f0e25 33 #define VIT1 101
inesmas3 2:ddf9879f0e25 34 #define KD1 102
inesmas3 2:ddf9879f0e25 35 #define KP1 103
inesmas3 2:ddf9879f0e25 36 #define KI1 104
inesmas3 2:ddf9879f0e25 37
Freescale_cup 0:3ec7fc598e48 38
Freescale_cup 0:3ec7fc598e48 39 #define BOSSE_ACTIVE S2
Freescale_cup 0:3ec7fc598e48 40
Freescale_cup 0:3ec7fc598e48 41 #define VITESSE 40
Freescale_cup 0:3ec7fc598e48 42 /***********************FONCTIONS**********************/
Freescale_cup 0:3ec7fc598e48 43 /**/ /****************CAMERA****************/ /**/
Freescale_cup 0:3ec7fc598e48 44 /**/ void F_GetData(); /**/
Freescale_cup 0:3ec7fc598e48 45 /**/ void F_CLK(); /**/
Freescale_cup 0:3ec7fc598e48 46 /**/ void Impulse_SI(); /**/
Freescale_cup 0:3ec7fc598e48 47 /**/ /**/
Freescale_cup 0:3ec7fc598e48 48 /**/ /***************SHIELD*****************/ /**/
Freescale_cup 0:3ec7fc598e48 49 /**/ void moteurs_arriere(); /**/
Freescale_cup 0:3ec7fc598e48 50 /**/ void test_servo(int time); /**/
Freescale_cup 0:3ec7fc598e48 51 /**/ void Get_pot_value(); /**/
Freescale_cup 0:3ec7fc598e48 52 /**/ /**/
Freescale_cup 0:3ec7fc598e48 53 /**/ /**********TRAITEMENT_IMG************/ /**/
Freescale_cup 0:3ec7fc598e48 54 /**/ void F_TraitementImage(); /**/
Freescale_cup 0:3ec7fc598e48 55 /**/ void F_BalanceBlancs(); /**/
Freescale_cup 0:3ec7fc598e48 56 /**/ void Gestion_bosse(); /**/
Freescale_cup 0:3ec7fc598e48 57 /**/ void T_image(); /**/
Freescale_cup 0:3ec7fc598e48 58 /**/ /**/
Freescale_cup 0:3ec7fc598e48 59 /**/ /**/
Freescale_cup 0:3ec7fc598e48 60 /**/ /***********AUTRES_FCT***************/ /**/
Freescale_cup 0:3ec7fc598e48 61 /**/ char middle_3(char *tab); /**/
Freescale_cup 0:3ec7fc598e48 62 /**/ int middle_3U(int *tab); /**/
Freescale_cup 0:3ec7fc598e48 63 /**/ float middle_3F(float *tab); /**/
Freescale_cup 0:3ec7fc598e48 64 /**/ void tri_a_bulle(char* t, int const size); /**/
Freescale_cup 0:3ec7fc598e48 65 /**/ void tri_a_bulleU(int* t, int const size); /**/
Freescale_cup 0:3ec7fc598e48 66 /**/ float tri_a_bulleF(float*t, int const size);/**/
Freescale_cup 0:3ec7fc598e48 67 /**/ unsigned char Moyenne(unsigned char *tab); /**/
Freescale_cup 0:3ec7fc598e48 68 /**/ char Moyenne2(char *tab, int nb); /**/
Freescale_cup 0:3ec7fc598e48 69 /**/ void menu(); /**/
Freescale_cup 0:3ec7fc598e48 70 /**/ void init_bary(); /**/
inesmas3 2:ddf9879f0e25 71 /**/ void fin_course(); /**/
inesmas3 2:ddf9879f0e25 72 /***** XBEE***/
inesmas3 2:ddf9879f0e25 73 int Xbee_receive();
inesmas3 2:ddf9879f0e25 74 void Xbee_send(int data);
inesmas3 2:ddf9879f0e25 75 void Xbee_init();
inesmas3 2:ddf9879f0e25 76 int Get_values_Xbee();
Freescale_cup 0:3ec7fc598e48 77 /******************************************************/
Freescale_cup 0:3ec7fc598e48 78
Freescale_cup 0:3ec7fc598e48 79 /****************CAMERA****************/
Freescale_cup 0:3ec7fc598e48 80 extern DigitalOut SI;
Freescale_cup 0:3ec7fc598e48 81 extern DigitalOut CLK;
Freescale_cup 0:3ec7fc598e48 82 extern AnalogIn AIN;
Freescale_cup 0:3ec7fc598e48 83 extern unsigned char cam_data[128];
Freescale_cup 0:3ec7fc598e48 84 extern InterruptIn Int_clk;
Freescale_cup 0:3ec7fc598e48 85 extern char numero_data;
Freescale_cup 0:3ec7fc598e48 86 extern char clk_active;
Freescale_cup 0:3ec7fc598e48 87
Freescale_cup 0:3ec7fc598e48 88 /***************SHIELD*****************/
Freescale_cup 0:3ec7fc598e48 89 extern char bosse;
Freescale_cup 0:3ec7fc598e48 90 extern int ajust_vitesse;
inesmas3 1:4a9196bcf97a 91 extern int ajust_vit_bosse;
Freescale_cup 0:3ec7fc598e48 92 extern int vitesse_virage;
Freescale_cup 0:3ec7fc598e48 93 extern DigitalOut BP1;
Freescale_cup 0:3ec7fc598e48 94 extern DigitalOut BP2;
Freescale_cup 0:3ec7fc598e48 95 extern DigitalOut led1;
Freescale_cup 0:3ec7fc598e48 96 extern DigitalOut led2;
Freescale_cup 0:3ec7fc598e48 97 extern DigitalOut led3;
Freescale_cup 0:3ec7fc598e48 98 extern DigitalOut led4;
inesmas3 2:ddf9879f0e25 99 extern DigitalOut led5;
inesmas3 2:ddf9879f0e25 100 extern DigitalOut led6;
inesmas3 2:ddf9879f0e25 101 extern DigitalOut led7;
inesmas3 2:ddf9879f0e25 102 extern DigitalIn S1;
inesmas3 2:ddf9879f0e25 103 extern DigitalIn S2;
Freescale_cup 0:3ec7fc598e48 104 extern DigitalIn S3;
Freescale_cup 0:3ec7fc598e48 105 extern DigitalIn S4;
Freescale_cup 0:3ec7fc598e48 106 extern AnalogIn pot1;
Freescale_cup 0:3ec7fc598e48 107 extern AnalogIn pot2;
Freescale_cup 0:3ec7fc598e48 108
Freescale_cup 0:3ec7fc598e48 109 /************TRAITEMENT_IMG************/
Freescale_cup 0:3ec7fc598e48 110 extern Ticker t_clk;
Freescale_cup 0:3ec7fc598e48 111 extern Ticker t_finInte;
Freescale_cup 0:3ec7fc598e48 112 extern int tempsInte;
Freescale_cup 0:3ec7fc598e48 113 extern int baricentre;
Freescale_cup 0:3ec7fc598e48 114 extern char arrivee;
Freescale_cup 0:3ec7fc598e48 115 extern int somme_derivee;
Freescale_cup 0:3ec7fc598e48 116 extern int seuil_der;
Freescale_cup 0:3ec7fc598e48 117 extern float last_three[3];
Freescale_cup 0:3ec7fc598e48 118 extern int bary_tab[3];
Freescale_cup 0:3ec7fc598e48 119 extern int bary_tab_bis[3];
Freescale_cup 0:3ec7fc598e48 120 extern int integral;
Freescale_cup 0:3ec7fc598e48 121 extern int new_bari;
Freescale_cup 0:3ec7fc598e48 122 extern int ralentire;
Freescale_cup 0:3ec7fc598e48 123 extern MMA8451Q acc;
Freescale_cup 0:3ec7fc598e48 124 extern char last_five[5];
Freescale_cup 0:3ec7fc598e48 125
Freescale_cup 0:3ec7fc598e48 126 /*************AUTRES_VAR***************/
Freescale_cup 0:3ec7fc598e48 127 extern Ticker t_cyc;
Freescale_cup 0:3ec7fc598e48 128 extern Serial pc;
inesmas3 2:ddf9879f0e25 129 extern Serial dataXB;
Freescale_cup 0:3ec7fc598e48 130 extern Timer t_debut;
Freescale_cup 0:3ec7fc598e48 131 extern Timer t_ligne;
Freescale_cup 0:3ec7fc598e48 132 extern Timer timer;
Freescale_cup 0:3ec7fc598e48 133 extern int begin;
Freescale_cup 0:3ec7fc598e48 134 extern int VIT;
Freescale_cup 0:3ec7fc598e48 135 extern int KP;
inesmas3 2:ddf9879f0e25 136 extern int KD;
inesmas3 2:ddf9879f0e25 137 extern int KI;
Freescale_cup 0:3ec7fc598e48 138 extern int ligne_droite;
Freescale_cup 0:3ec7fc598e48 139
inesmas3 2:ddf9879f0e25 140 /**xbee*/
inesmas3 2:ddf9879f0e25 141 extern xbee xbee1; //Initalise xbee_lib varName(rx,tx,reset)
inesmas3 2:ddf9879f0e25 142 extern DigitalOut rst1;
Freescale_cup 0:3ec7fc598e48 143
inesmas3 1:4a9196bcf97a 144
Freescale_cup 0:3ec7fc598e48 145
Freescale_cup 0:3ec7fc598e48 146
Freescale_cup 0:3ec7fc598e48 147
Freescale_cup 0:3ec7fc598e48 148
Freescale_cup 0:3ec7fc598e48 149
Freescale_cup 0:3ec7fc598e48 150
Freescale_cup 0:3ec7fc598e48 151
Freescale_cup 0:3ec7fc598e48 152
Freescale_cup 0:3ec7fc598e48 153
Freescale_cup 0:3ec7fc598e48 154 #endif /* !MLIB_H*/