Index: branch/lepogam/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/lepogam/Emb_App/SessionM32C_E8a_system.ini	(revision 295)
+++ branch/lepogam/Emb_App/SessionM32C_E8a_system.ini	(revision 296)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0034
+RESET=ff0038
Index: branch/lepogam/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/lepogam/Emb_App/SessionM32C_E8a_system.hsf	(revision 295)
+++ branch/lepogam/Emb_App/SessionM32C_E8a_system.hsf	(revision 296)
@@ -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" "0000000000FF3297" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF3383" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A42" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000846" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000004" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A5A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000085E" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
@@ -172,8 +172,8 @@
 "{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" "0000000000000512" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A42" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "00000000001200FE" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A5A" 
 "{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,7 +207,15 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "alpha, 2, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "1" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "couleur, 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" "consigne_vitesse, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Global," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "npiste, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "vitesse_min, 2, 0, P, Col, Dec, 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}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -277,7 +285,7 @@
 0 
 [WINDOW_POSITION_STATE_DATA_VD1]
 "Help" "TOOLBAR 0" 59419 2 4 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
-"{WK_00000001_CmdLine}" "WINDOW" 59422 0 1 "0.08" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
+"{WK_00000001_CmdLine}" "WINDOW" 59422 0 1 "0.07" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
 "{WK_00000001_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "0.0" 
 "{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.11" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
 "{WK_00000001_MEMORY}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.23" 365 2 -1 350 200 2065 0 "42202|42203|42204|42233|<<separator>>|42206|42205|42230|42229|42207|<<separator>>|42208|42209|42210|49076|42228|42227|<<separator>>|42231|42232|42234|42235|<<separator>>|42211|<<separator>>|32796|32797" "0.0" 
@@ -358,5 +366,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 90544424 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 101587000 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/lepogam/Emb_App/programme_principal_etud.c
===================================================================
--- branch/lepogam/Emb_App/programme_principal_etud.c	(revision 295)
+++ branch/lepogam/Emb_App/programme_principal_etud.c	(revision 296)
@@ -126,7 +126,9 @@
 unsigned int couleur=0; // vert -> ligne droie
 unsigned int npiste=0;
 unsigned int distance_ref=700;
+unsigned int distance_ref_init=700;
 unsigned int consigne=450;
+unsigned int consigne_init=450;
 unsigned int consigne_vitesse=34;
 unsigned int vitesse_min=24;
 unsigned int valeur_t=0;
@@ -156,31 +158,31 @@
 		switch(npiste){
 			
         	case(256) : //verte
-            consigne_vitesse =60;
-            vitesse_min =35;
-       		distance_ref = 880;
+            consigne_vitesse =60; //60
+            vitesse_min =35; //35
+       		distance_ref_init = 820; // décalée à gauche 820
 			go=1;
             break;
 			
             case(512) : //bleue
-            consigne_vitesse =40;
-            vitesse_min =22;
-            distance_ref = 700;
+            consigne_vitesse =50; //48 ok 21'19, max 50
+            vitesse_min =30;//26 ok 21,19, max 30
+            distance_ref_init = 700; // centrée 700
 			go=1;
             break;
 			
             case(768) : //rouge
-            consigne_vitesse =34;
-            vitesse_min =24;
-            distance_ref = 700;
+            consigne_vitesse =46; //40 ok 26,19
+            vitesse_min =20; // 20 ok 26'19
+            distance_ref_init = 700;
 			go=1;
             break;
 
                 
             case(1024) : //noir
-            consigne_vitesse =25;
-            vitesse_min =25;
-            distance_ref = 700;
+            consigne_vitesse =22;
+            vitesse_min =22;
+            distance_ref_init = 700;
 			go=1;
             break;
             }
@@ -216,7 +218,7 @@
 	}
 
 void asserv1(){ //asservissement tourelle
-	if(alpha!=consigne) valeur_t=k1*(consigne-alpha);
+	if(alpha!=consigne) valeur_t=k1*(consigne-alpha);	
 	}
 
 void asserv_roue(){
@@ -238,7 +240,8 @@
 	
 		comm.data.id='D'; 
 		comm.data.rtr=0; 
-		comm.data.val=valeur_r;
+		if(valeur_r>-100) comm.data.val=valeur_r;
+		else comm.data.val=-100;
 		snd_dtq (CanTx,comm.msg);
 		dly_tsk(10);
 		}
@@ -245,8 +248,13 @@
 
 	}
 void asserv2(){ //asservissement roue
-	if(couleur==0x1c80) ; // bloc rouge grand valeur 2 avant saut
+	if(couleur==0x1c80 || couleur==0x18c8 ) ; // avant saut: bloc rouge grand valeur 2 et pré-barille: petit bloc cyan 32 , bloc les roues
+	else if(couleur==0x18d0){
+		distance_ref=400;
+		if(distance!=distance_ref) valeur_r=-k2*(distance_ref-distance);
+		}
 	else {
+		distance_ref=distance_ref_init;
 		if(distance!=distance_ref) valeur_r=-k2*(distance_ref-distance);
 		}
 	}
@@ -275,8 +283,11 @@
 	}
 void asserv3(){ //asservisement vitesse
 	if(couleur==0x1580 || couleur==0x1581 ) vitesse=consigne_vitesse; // vert=ligne droite
-	else if(couleur==0x1c80) vitesse=45; // vitesse saut
-	else if(couleur==0x1c88) vitesse=14; //vitesse après saut,  bloc rouge grand valeur 32 après saut
+	else if(couleur==0x1c80) vitesse=45; // vitesse saut: bloc rouge grand valeur 2
+	else if(couleur==0x1c88) vitesse=vitesse_min; //vitesse après saut:  bloc rouge grand valeur 32 
+	else if(couleur==0x1a90 || couleur==0x1890) vitesse=consigne_vitesse-8; //mise en place rail: grand bloc jaune 64 et piste courbe: petit bloc bleu(cyan) 64
+	else if(couleur==0x1a88) vitesse=consigne_vitesse+4; //rail apres mise en place: gand bloc jaune 32 
+	else if(couleur==0x18d0 || couleur==0x18c8) vitesse=vitesse_min; //barille: petit bloc cyan 64 et pré-barille: petit bloc cyan 32
 	else{
 		vitesse=vitesse_min; //virage
 		}
