Revision 155

View differences:

branch/najib_idzim/tp_info6/Emb_App/SessionM32C_E8a_system.BKS
279 279
"Help" "TOOLBAR 0" 59419 2 4 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
280 280
"{WK_00000001_CmdLine}" "WINDOW" 59422 0 0 "0.14" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
281 281
"{WK_00000001_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "0.0" 
282
"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.16" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
282
"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.68" 365 0 0 350 200 2065 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
283 283
"{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" 
284 284
"{WK_00000001_OUTPUT}" "WINDOW" 59422 0 1 "1.00" 365 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
285 285
"{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 3 "0.15" 365 0 0 350 200 18 0 "47300|47301|47302|47303|47304|47305|47314|47306|47307|47308|47311|47312|47313|42211|42509|42303" "0.0" 
branch/najib_idzim/tp_info6/Emb_App/programme_principal_etud.c
120 120
//'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
121 121
//				correspondant au nom du v?hicule si le nom se termine par '*'
122 122

  
123
void vitesseTourelle(int vitesse);
123
void vitesseTourelle(int vitesse); //vitesse en 10e de degre/sec
124
unsigned short lirePosTourelle(); // position en 10e de degre
125
void asserv_pos_tour();
124 126

  
125 127
void main()
126 128
{
127

  
129
	unsigned short posTourelle = 0;
128 130
	
129 131
	ports_mcu();
130 132
    lcd_init();
131 133
	periph_init();
132
	periph_nom("#AutoTest*");
134
	periph_nom("#Ferrari*");
133 135

  
134 136
    can_init();
135 137
    clavier_init(1);
......
139 141
//	sta_tsk(ID_periph_rx);
140 142

  
141 143

  
144
	
145
	
146
    while(1)
147
    {
148
		asserv_pos_tour();
142 149

  
143
	vitesseTourelle (400);
144
    while(1)
145
    {
146
		LED_J=1;
147
		dly_tsk(100);
148
		LED_J=0;
149
		dly_tsk(100);
150 150

  
151 151
    }
152 152
}
......
159 159
void vitesseTourelle(int vitesse)
160 160
{
161 161
	CanFrame comm;
162
	
162 163
	comm.data.id = 'T';
163 164
	comm.data.rtr = 0; //ecriture
164 165
	comm.data.val = vitesse;
166
	
165 167
	snd_dtq (CanTx,comm.msg);
166 168
}
169

  
170
unsigned short lirePosTourelle()
171
{
172
	CanFrame requete, reponse;
173
	
174
	requete.data.id = 'R';
175
	requete.data.rtr = 1; // Requete de lecture 
176
	snd_dtq(CanTx, requete.msg);
177
	
178
	rcv_dtq(CanRx, &reponse.msg);
179
	
180
	return reponse.data.val;
181
}
182

  
183
void asserv_pos_tour()
184
{
185
	unsigned short pos;
186
	pos = lirePosTourelle();
187
	
188
	
189
	
190
	if (pos < 425) 
191
	{
192
		vitesseTourelle (800);
193
	}
194
	else if (pos >= 425 && pos < 450 )
195
	{
196
		vitesseTourelle (50);
197
	}
198
	else if (pos = 450)
199
	{
200
		vitesseTourelle(0);
201
	}
202
	else if (pos > 450 && pos <= 475)
203
	{
204
		vitesseTourelle(-50);
205
	}
206
	else if (pos > 475)
207
	{
208
		vitesseTourelle(-800);
209
	} 
210
}

Also available in: Unified diff