Revision 404

View differences:

branch/guochao/Emb_App.tws
9 9
[OPEN_WORKSPACE_FILES]
10 10
"E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 
11 11
"E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 
12
"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 
12 13
"E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 
13 14
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 
15
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 
14 16
"E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 
15 17
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\conf_noyau.cfg" 
16 18
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\crt0mr.a30" 
......
31 33
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 0 
32 34
"E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 125 125 1430 351 0 11 
33 35
"E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 100 100 1430 351 0 10 
36
"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 0 0 1430 351 0 14 
34 37
"E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 100 100 1430 351 0 6 
35 38
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 125 125 1430 351 0 7 
39
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 150 150 1430 351 0 13 
36 40
"E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 25 25 1430 351 0 3 
37 41
[LOADED_PROJECTS]
38 42
"EmbM32C87App" 
branch/guochao/Emb_App/SessionM32C_E8a_system.ini
25 25
[Target]
26 26
M32C E8a SYSTEM=Renesas Communications
27 27
[USER_DATA]
28
RESET=ff013a
28
RESET=ff0146
branch/guochao/Emb_App/SessionM32C_E8a_system.hsf
149 149
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
150 150
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
151 151
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF06A4" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF06A0" 
153 153
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E94" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000BCC" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000014FA" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000C20" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004004" 
158 158
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
159 159
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
160 160
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
......
173 173
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
174 174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000008" 
175 175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000EC8" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "000000000000151C" 
177 177
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
178 178
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
179 179
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
......
205 205
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth2" "120" 
206 206
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth3" "200" 
207 207
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
208
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "sauter, 1, 0, P, Col, Hex, MA" 
208
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "secouerFini, 1, 0, P, Col, Hex, MA" 
209 209
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
210
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "coleur, 2, 0, P, Col, Hex, MA" 
210
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "boueTerreFini, 1, 0, P, Col, Hex, MA" 
211 211
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "num, 2, 0, P, Col, Hex, MA" 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "secouer, 1, 0, P, Col, Hex, MA" 
213 213
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
214
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "capteur, 1, 0, P, Col, Hex, MA" 
215
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Global," 
216
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "position, 1, 0, P, Col, Hex, MA" 
217
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
218
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "statue, 1, 0, P, Col, Hex, MA" 
214
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "dansAir, 1, 0, P, Col, Hex, MA" 
215
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
216
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "montrePont, 1, 0, P, Col, Hex, MA" 
217
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Global," 
218
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "position, 1, 0, P, Col, Hex, MA" 
219 219
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Global," 
220
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "erreur, 1, 0, P, Col, Hex, MA" 
221
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Global," 
222
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "msg, 1, 0, C0002, Col, Hex, MN" 
223
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "sauter, 10, 0, P, Col, Hex, N" 
220
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "obstacle, 1, 0, P, Col, Hex, MA" 
221
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
222
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "event, 1, 0, P, Col, Hex, N" 
223
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007_SCOPE" "Current Scope," 
224
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "pisteInfo, 10, 0, P, Col, Hex, N" 
224 225
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008_SCOPE" "Current Scope," 
225 226
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "7" 
226 227
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
......
326 327
[WINDOW_Z_ORDER]
327 328
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\programme_principal_etud.c" 
328 329
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\crt0mr.a30" 
330
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.h" 
329 331
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\conf_noyau.cfg" 
332
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.c" 
330 333
"E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 
334
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mr308.inc" 
335
"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 
336
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 
331 337
"E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 
332
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.h" 
333
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mr308.inc" 
334 338
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mrtable.a30" 
335 339
"E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 
336 340
"E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 
337
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.c" 
338 341
"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\kernel_id.h" 
339 342
"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 
340 343
[TARGET_NAME]
......
383 386
[FLASH_DETAILS]
384 387
"" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
385 388
[BREAKPOINTS]
386
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100066200 1 "{00000000-0000-0000-C000-000000000046}" "" 
389
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 102419808 1 "{00000000-0000-0000-C000-000000000046}" "" 
387 390
[END]
branch/guochao/Emb_App/programme_principal_etud.c
121 121
//				correspondant au nom du v?hicule si le nom se termine par '*'
122 122
#include "pid.h"
123 123

  
124
CanFrame comm;
125
CanFrame requete;
126
CanFrame reponse;
124
CanFrame comm;//*
125
CanFrame requete;//*
126
CanFrame reponse;//**
127 127

  
128 128
int g_angle450=450;
129 129
int position = 0;
130 130
int erreur = 0;
131 131

  
132
char coleur;
133
char num;
134
short capteur;
135
int valider=1;
136
int sauter;
137
float count;
138
int secouerFini;
139
int boueTerreFini=0;
140

  
141
int lastErreur;
142

  
143
int pistNoire;
144
int vitesseSauter;
145
int vitesseBase=0;
146

  
132 147
void corrigerAngle()
133 148
{
149
	CanFrame requete;
150
	CanFrame comm;
134 151
	int angle;
135 152
	int erreur;
136 153
	
154
	requete.data.id  = 'R';//*
155
	comm.data.id = 'T';
137 156
	requete.data.rtr = 1;
138 157
	comm.data.rtr = 0;
139 158
	while(1)
140 159
	{
141 160
		// lecture
142
		requete.data.id  = 'R';
143
		requete.data.rtr = 1;
161
		
144 162
		snd_dtq(CanTx, requete.msg);
145 163
		dly_tsk(5);
146 164
		angle = periph[ADDR('R')].val;//reponse.data.val;
147 165
	
148 166
			// corriger
149 167
		erreur = g_angle450 - angle;//** (ok)
150
		comm.data.id = 'T';
151 168
		comm.data.val = erreur;
152 169
		snd_dtq(CanTx, comm.msg);
153 170
		dly_tsk(20);	
......
193 210
	lcd_str(str);	
194 211
}
195 212

  
196
int getStatue(int erreur)
213
int getStatue(int erreur)//*
197 214
{
198 215
	if( abs(erreur) > 30 ) //abs
199 216
		return 1;
......
201 218
		return 0;
202 219
}
203 220

  
204
char coleur;
205
char num;
206
short capteur;
207
int valider;
208
int siSauter(void)
221

  
222
void siSauter()//*
209 223
{//** Tache ...
210
CanFrame requete;
224
	CanFrame requete;
211 225

  
226
	requete.data.rtr = 1;
212 227
	requete.data.id  = 'C';
213
	requete.data.rtr = 1;
214
	snd_dtq(CanTx, requete.msg);
215
	dly_tsk(5);	
216
	capteur = periph[ADDR('C')].val;
217
	coleur = capteur >> 8;
218
	num    = capteur & 0xff;
219 228

  
220
	if( 15 == num && coleur == 'r' && valider)
221
		return 1;
222
	else
223
		return 0;	
229
	while(1)
230
	{
231
		snd_dtq(CanTx, requete.msg);
232
		dly_tsk(5);	
233
		capteur = periph[ADDR('C')].val;
234
		coleur = capteur >> 8;
235
		num    = capteur & 0xff;
236

  
237
		if( 3 == num && coleur == 'V')
238
			sauter = 1;
239
		else if( 3 == num && coleur == 'B' )
240
			sauter = 0;	
241
			
242
		if( 4 == num && 'V' == coleur )
243
			secouerFini = 1;
244
		else
245
			secouerFini = 0;
246
			
247
		if( 1 == num && 'J' == coleur )
248
			vitesseBase = 1;
249
		else if( 2 == num && 'V' == coleur )
250
			vitesseBase = 2;
251
		else if( 2 == num && 'R' == coleur )
252
			vitesseBase = 0;
253
			
254
		dly_tsk(5);
255
	}
224 256
}
225 257

  
226
int sauter = 0;
227
int statue;
228
void main()
258
void siSecouerFini()
229 259
{
230
	float count = 0;
231
	int lastErreur = 0;
232
	valider = 1;
233
	
260
	CanFrame requete;
261

  
262
	
263
	while(1)
264
	{	
265
		dly_tsk(20);
266
	}
267
}
268

  
269
int secouer=0;
270
int dansAir=0;
271
int montrePont=0;
272
int obstacle=0;
273
int lastErreurVrai;
274
void control()
275
{
276
	int finiSauter=0;
277
	int montrePont=0;
278
	int positionABS=0;
279
	int erreurStatic=0;
280
	
281
	dly_tsk(2000);
282
	
283
	while(1)
284
    {
285
		positionABS = abs(position);
286
		erreur = IncPIDCalc(positionABS);		
287
		
288
		if( abs(erreur - lastErreur) > 300 && abs(erreur) > 500 )			// pour eviter le trou
289
		{
290
			if( !pistNoire )
291
				erreur = 0;
292
			else
293
				erreur = lastErreur; 	
294
		}
295
	
296
		if( 2 == vitesseBase )
297
		{
298
			if( (abs(erreur) > 2) && (positionABS < 695) )			// montrer le pont.
299
				erreur = 0;
300
		}
301
	
302
		if( sauter )
303
		{
304
			if( !secouer )
305
				setVitesse(vitesseSauter);
306

  
307
			if( (abs(erreur) > 3) && (positionABS < 680) )			// montrer le pont.
308
			{
309
				erreur = 0;
310
				montrePont = 1;
311
			}
312

  
313
			if( montrePont && (positionABS > 1000) )			// flying...
314
			{
315
				dansAir = 1;
316
				montrePont = 0;
317
			}
318

  
319
			if( dansAir && (positionABS < 700) )
320
			{
321
				setVitesse(0);				 // toucher le sol
322
				dansAir = 0;
323
				secouer = 1;					// commencer secouer
324
			}
325
		}
326
		else
327
		{
328
			if( secouer && !secouerFini && !boueTerreFini )       				// viens de toucher le sol, bcp de secouer!!
329
			{
330
				setVitesse(20);
331
			}
332
			else
333
			{
334
				if( pistNoire && !boueTerreFini && secouer )				// entre la boueTerre
335
				{
336
					setVitesse(11);
337
				}
338
				else
339
				{
340
					if( 1 == vitesseBase )
341
					{
342
						IncPIDInit(POSITION_STANDAR_45, 0, 0, 0);
343
						setVitesse(13);
344
					}
345
					else
346
						setVitesse(41);
347
						secouer = 0;
348
						dansAir = 0;
349
						sauter = 0;
350
						erreurStatic = 0;
351
				}
352
			}
353
		}
354
		
355
		controleRoue(erreur);
356
		lastErreur = erreur;
357
		
358
		dly_tsk(20);
359
    }
360
}
361

  
362
void main()
363
{	
234 364
	ports_mcu();
235 365
    lcd_init();
236 366
	periph_init();
......
238 368

  
239 369
    can_init();
240 370
    clavier_init(1);
241
	capture_init();
242
	IncPIDInit(POSITION_STANDAR_45, 0);
371
	capture_init();
372
	
373
	IncPIDInit(POSITION_STANDAR_45+200, -0.7, 0);
243 374

  
244 375
	sta_cyc(ID_acqui);
245 376
//	sta_cyc(ID_itouche);
246 377
	sta_tsk(ID_clavier);
247 378
	sta_tsk(ID_periph_rx);
379
	
248 380
	sta_tsk(ID_corrigerAngle);
249 381
	sta_tsk(ID_mesurerDistance);
382
	sta_tsk(ID_siSauter);
383
	sta_tsk(ID_control);
384
	sta_tsk(ID_secouerFini);
250 385
	
251

  
252
    while(1)
253
    {//*** Tache 
254
		erreur = IncPIDCalc(position);
255
		if( erreur > 200 || erreur < -200 )			// evider le tronc
256
			erreur = lastErreur;
257
		
258
	//	statue = getStatue(erreur);
259
		
260
		sauter = siSauter();
261
	
262
		if( (1 == sauter) && (count < 150) )
263
		{
264
			setVitesse(45);
265
			erreur = lastErreur;
266
			count++;
267
		}
268
		else if( count*1.5 > 0 )
269
		{
270
			count -= 0.5;
271
			valider = 0;
272
			setVitesse(0);
273
			erreur = lastErreur;
274
		}
275
		else
276
		{
277
			setVitesse(30);
278
			count = 0;
279
			valider = 1;
280
		}
281
		controleRoue(erreur);
282
		lastErreur = erreur;
283
    }
386
	pistNoire = 1;
387
	if( pistNoire )
388
	{
389
		vitesseSauter = 42;
390
	}
391
	else
392
	{
393
		vitesseSauter = 45;
394
	}
395
	
396
    while(1)
397
	{
398
		dly_tsk(50);
399
	}
284 400
}
285 401
/*
286 402
void itouche()
branch/guochao/Emb_App/conf_noyau.cfg
20 20

  
21 21
// max definition
22 22
maxdefine{
23
	max_task	= 6;
23
	max_task	= 8;
24 24
	max_flag	= 3;
25 25
	max_dtq	= 2;
26 26
	max_cyh	= 2;
......
39 39
	name	= ID_main;
40 40
	stack_size	= 512;
41 41
	stack_section	= stack;
42
	priority	= 1;
42
	priority	= 4;
43 43
	initial_start	= ON;
44 44
	exinf	= 0x0;
45 45
};
......
73 73
};
74 74

  
75 75
task[]{
76
	entry_address	= siSecouerFini();
77
	name	= ID_secouerFini;
78
	stack_size	= 256;
79
	stack_section	= stack;
80
	priority	= 5;
81
	initial_start	= OFF;
82
	exinf	= 0x0;
83
};
84

  
85
task[]{
76 86
	entry_address	= corrigerAngle();
77 87
	name	= ID_corrigerAngle;
78 88
	stack_size	= 256;
......
87 97
	name	= ID_mesurerDistance;
88 98
	stack_size	= 256;
89 99
	stack_section	= stack;
90
	priority	= 2;
100
	priority	= 3;
91 101
	initial_start	= OFF;
92 102
	exinf	= 0x0;
93 103
};
94 104

  
105
task[]{
106
	entry_address	= siSauter();
107
	name	= ID_siSauter;
108
	stack_size	= 256;
109
	stack_section	= stack;
110
	priority	= 1;
111
	initial_start	= OFF;
112
	exinf	= 0x0;
113
};
114

  
115
task[]{
116
	entry_address	= control();
117
	name	= ID_control;
118
	stack_size	= 256;
119
	stack_section	= stack;
120
	priority	= 3;
121
	initial_start	= OFF;
122
	exinf	= 0x0;
123
};
124

  
95 125
flag[]{
96 126
	name	= ev_bus_fin_tr;
97 127
	initial_pattern	= 0x0000;

Also available in: Unified diff