Index: branch/porte/Emb_App.tws
===================================================================
--- branch/porte/Emb_App.tws	(revision 229)
+++ branch/porte/Emb_App.tws	(revision 230)
@@ -7,17 +7,19 @@
 [GENERAL_DATA]
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
-"E:\tp_info6_2018_porte\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_porte\tp_info6\bsp\radiocommande.c" 
+"E:\tp_info6_2018_porte\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
-"E:\tp_info6_2018_porte\tp_info6\Emb_App\Debug\mr308.inc" 100 100 1430 351 0 2 
+"E:\tp_info6_2018_porte\tp_info6\Emb_App\Debug\mr308.inc" 0 0 1430 351 0 4 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\conf_noyau.cfg" 0 0 1426 347 0 0 
-"E:\tp_info6_2018_porte\tp_info6\Emb_App\crt0mr.a30" -8 -30 1596 539 1 3 
-"E:\tp_info6_2018_porte\tp_info6\Emb_App\programme_principal_etud.c" 50 50 1430 351 0 1 
-"E:\tp_info6_2018_porte\tp_info6\bsp\periph.c" 100 100 1430 351 0 4 
+"E:\tp_info6_2018_porte\tp_info6\Emb_App\crt0mr.a30" 125 125 1430 351 0 2 
+"E:\tp_info6_2018_porte\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 1 
+"E:\tp_info6_2018_porte\tp_info6\bsp\radiocommande.c" 25 25 1430 351 0 5 
+"E:\tp_info6_2018_porte\tp_info6\bsp\uart0.c" 150 150 1430 351 0 3 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/porte/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/porte/Emb_App/SessionM32C_E8a_system.ini	(revision 229)
+++ branch/porte/Emb_App/SessionM32C_E8a_system.ini	(revision 230)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0042
+RESET=ff0044
Index: branch/porte/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/porte/Emb_App/SessionM32C_E8a_system.hsf	(revision 229)
+++ branch/porte/Emb_App/SessionM32C_E8a_system.hsf	(revision 230)
@@ -141,8 +141,8 @@
 "{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000044" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "0000000000000000" 
@@ -149,11 +149,11 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF054A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF056F" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000B36" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000086E" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E60" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000886" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
@@ -171,9 +171,9 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000004" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000009" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000B6A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000003" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000E82" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
@@ -207,15 +207,15 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "Distance, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "Somme_ErreurRoues, 2, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "Bord_defaut, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "Delta_Erreur, 2, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "Info_capteur, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "ErreurRoues, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "Bord_defaut, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "3" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -317,11 +317,12 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_porte\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_2018_porte\tp_info6\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_porte\tp_info6\bsp\radiocommande.c" 
 "E:\tp_info6_2018_porte\tp_info6\Emb_App\Debug\mr308.inc" 
-"E:\tp_info6_2018_porte\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_porte\tp_info6\bsp\uart0.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -368,5 +369,5 @@
 [FLASH_DETAILS]
 "" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
 [BREAKPOINTS]
-"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 94889256 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 93847448 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/porte/Emb_App/programme_principal_etud.c
===================================================================
--- branch/porte/Emb_App/programme_principal_etud.c	(revision 229)
+++ branch/porte/Emb_App/programme_principal_etud.c	(revision 230)
@@ -120,19 +120,21 @@
 //'I'/73/Ox49 : Définition du nom du véhicule. Doit débuter par le caractère '#' et entraine le chargement de la configuration de piste
 //				correspondant au nom du véhicule si le nom se termine par '*'
 
-unsigned int Angle_T=0;//prend la valeur de l'angle au temps t-1
-unsigned int Consigne_T=500; //Consigne de l'angle de la tourelle
-unsigned int valeur=0; //valeur transmise corrigé
-unsigned int Somme_Erreur=0, Erreur=0, Delta_Erreur=0, Erreur_pre=0;
+/*-------------------------------------- Variables ----------------------------------------*/
+unsigned int Angle_T=0;										//prend la valeur de l'angle au temps t-1
+unsigned int Consigne_T=500; 								//Consigne de l'angle de la tourelle
+unsigned int valeur=0; 										//valeur transmise corrigé
+//Variables pour l'asserivssement des roues, de la vitesse et du telemetre
+unsigned int Somme_Erreur=0, Erreur=0, Delta_Erreur=0, Erreur_pre=0;			
 unsigned int ErreurRoues=0, ErreurRouesPre=0, Delta_ErreurRoues=0,Somme_ErreurRoues=0;
-int Kp=1.5,	Kpr=2;	//Paramètre des PID tourelle et roues
-int Ki=4,	Kir=30;
-int Kd=1.5,	Kdr=1;
+int Kpt=1,	Kpr=2;											//Paramètre des PID tourelle et roues
+int Kit=4,	Kir=40;
+int Kdt=1.5,	Kdr=1;
 int i;
-unsigned int Vitesse_final=35, Vitesse_commande=5, Distance;
-unsigned int Angle_R=0; //Angle des roues
+unsigned int Vitesse_final=40, Vitesse_virage=25, Distance;		
+unsigned int Angle_R=0, distance_bord=660; 															//Angle des roues
 unsigned int Info_capteur;
-unsigned int Bord_defaut=0, Distance_pre=660;
+unsigned int Bord_defaut=0, ecart=400;
 
 
 void Asserv_T(){	
@@ -167,7 +169,7 @@
 	Somme_Erreur+=Erreur;
 	
 	if(Angle_T!=Consigne_T)
-		valeur=Kp*Erreur+Kd*Delta_Erreur+(1/Ki)*Somme_Erreur;//correction de l'angle par handler cyclique de la tourelle
+		valeur=Kpt*Erreur+Kdt*Delta_Erreur+(1/Kit)*Somme_Erreur;//correction de l'angle par handler cyclique de la tourelle
 	}
 
 void Asserv_R(){
@@ -177,6 +179,7 @@
 	CanFrame demande;
 	CanFrame reponse;
 	
+	dly_tsk(1500);
 	while(1){
 		
 		comm.data.id='D'; //Commande de l'angle des roues
@@ -184,7 +187,7 @@
 		comm.data.val=Angle_R;
 		snd_dtq (CanTx,comm.msg);//Envoi de la commande
 				
-		dly_tsk(4);
+		dly_tsk(1);
 		}
 	}
 
@@ -191,11 +194,11 @@
 void Asserv_R_hc(){	
 	
 	ErreurRouesPre=ErreurRoues;
-	ErreurRoues=660-Distance;
+	ErreurRoues=distance_bord-Distance;
 	Delta_ErreurRoues=ErreurRoues-ErreurRouesPre;
 	Somme_ErreurRoues+=ErreurRoues;
 	
-	if(Distance != 660 && Bord_defaut == 0)
+	if(Distance != distance_bord && Bord_defaut == 0)
 		Angle_R=-1*(Kpr*ErreurRoues+Kdr*Delta_Erreur+(1/Kir)*Somme_ErreurRoues);//correction de l'angle par handler cyclique des roues
 	}
 
@@ -206,24 +209,30 @@
 	CanFrame comm;
 	CanFrame demande;
 	CanFrame reponse;
+	
+	dly_tsk(3000);
 	while(1){		
-		
-		dly_tsk(3000);
-		comm.data.id='V'; //Commande de l'angle des roues
+	
+		comm.data.id='V'; 						//Commande de la vitesse des roues motrices
 		comm.data.rtr=0;
 		
 		//Rampe de vitesse au démarrage
-		for(i=0;i++;Vitesse_final < Vitesse_commande){
+	/*	for(i=0;i++;Vitesse_final < Vitesse_commande){
 			comm.data.val=Vitesse_final-Vitesse_commande+i;
-			snd_dtq (CanTx,comm.msg);		//Envoi de la commande de vitesse
+			snd_dtq (CanTx,comm.msg);			//Envoi de la commande de vitesse
 			dly_tsk(100);
-		}
+		}*/
 		
-		//if(Info_capteur == ){
+		if(Info_capteur == 0x560 && Bord_defaut == 0){				// Commande de vitesse pour les lignes droites (dernier capteur detecte = vert).
 			comm.data.val=Vitesse_final;	
-			snd_dtq (CanTx,comm.msg);//Envoi de la commande de vitesse
+			snd_dtq (CanTx,comm.msg);			// Envoi de la commande de vitesse
+		}
+		else{									// Ralentissement en cas de virage (selon valeur capteur)
+			comm.data.val=Vitesse_virage;	
+			snd_dtq (CanTx,comm.msg);
+		}
 				
-		dly_tsk(200);
+		dly_tsk(10);
 		}
 	}
 
@@ -243,7 +252,7 @@
 		snd_dtq (CanTx,demande.msg); 			// Interrogation du peripherique sur les donnees du dernier capteur touché.
 		Info_capteur=periph[ADDR('C')].val>>4; 		// contient la valeur de retour du simulateur sur le dernier capteur touché.
 		
-		dly_tsk(200);
+		dly_tsk(100);
 	}
 	
 	
@@ -264,17 +273,12 @@
 		snd_dtq (CanTx,demande.msg); // Interrogation du peripherique sur la distance mesure par le telemetre.
 		Distance=periph[ADDR('U')].val; // contient la valeur de retour du simulateur sur la distance mesuré par le telemetre.
 		
-		if(Distance > 660+300){
+		if(Distance > distance_bord+ecart  || Distance < distance_bord-ecart){
 			Bord_defaut=1;
 		}
-		else if(Distance < 660-300){
-			Bord_defaut=1;
-		}
 		else{
 			Bord_defaut=0;
-		}
-		Distance_pre=Distance;
-		
+		}		
 		dly_tsk(10);
 	}
 	
