Projet

Général

Profil

« Précédent | Suivant » 

Révision 179

Ajouté par aueuphrasi il y a plus de 6 ans

Ajout depart au feux vert
Lecture potentiometre pour position tourelle et vitesse max
Lecture clavier
amelioration asservissement vitesse et roues

Voir les différences:

branch/euphrasie_auguste/Emb_App/SessionM32C_E8a_system.ini
[Target]
M32C E8a SYSTEM=Renesas Communications
[USER_DATA]
RESET=ff0028
RESET=ff0036
branch/euphrasie_auguste/Emb_App/programme_principal_etud.c
void periph_command(char addr, short valeur);
short periph_requete(char addr);
void initialisation(void);
void assser_tourelle(void);
void asser_roue_vitesse(void);
void decode_int(void);
short i;
short touche;
short clavier;
short consigne_T = 450;
float k_T = 2.0;
short commande_T;
short ang_T;
short distance_centre = 710;
float k_D = 0.8;
short distance_centre = 500;
float k_D = 1.10;
short commande_D;
short dist_mur_droit;
float dist_mur_droit;
float k_V = 0.05;
float k_V = 0.15;
short commande_V_max = 40;
short commande_V;
short commande_V;
unsigned short etat_feux;
void main()
{
ports_mcu();
lcd_init();
periph_init();
periph_nom("#AutoTest*");
can_init();
clavier_init(1);
capture_init();
sta_cyc(ID_acqui);
sta_tsk(ID_periph_rx);
periph_command('V', 25);
{
initialisation();
for(i=0;i<25;i++){
assser_tourelle();
dly_tsk(10);
}
while((periph_requete('M') >> 15) == 0 ); // attente feux vert
while(1)
{
assser_tourelle();
assser_tourelle();
asser_roue_vitesse();
dly_tsk(50);
dly_tsk(50);
}
}
void acqui()
{
LED_V=!LED_V;
void decode_int(void){
//short i = 0;
//while(touche != '#'){
vrcv_dtq(QdmTouche,&touche);
clavier = touche-48;
//i++;
//}
}
void asser_roue_vitesse(void){
dist_mur_droit = periph_requete('U');
if(dist_mur_droit > 2500){ dist_mur_droit = distance_centre;}
dist_mur_droit = periph_requete('U')*sin((3.1415f*(periph_requete('R')))/1800.0f);
if((dist_mur_droit > 1500) || (dist_mur_droit < -1500)){ dist_mur_droit = distance_centre;}
commande_D = k_D * (dist_mur_droit - distance_centre);
periph_command('D', commande_D);
if(commande_D < 0) commande_D = commande_D * (-1);
commande_V = commande_V_max - k_V * (dist_mur_droit - distance_centre);
commande_V = commande_V_max - (k_V * commande_D);
periph_command('V', commande_V);
}
......
void initialisation(void){
ports_mcu();
lcd_init();
periph_init();
periph_nom("#AutoTest*");
can_init();
clavier_init(1);
capture_init();
sta_cyc(ID_acqui);
sta_tsk(ID_periph_rx);
}
void acqui()
{
LED_V=!LED_V;
consigne_T = ad00;
commande_V_max = ad01/10;
}
void assser_tourelle(void){
ang_T = periph_requete('R');
commande_T = k_T * (consigne_T - ang_T);
......
UINT flag;
requete.data.id = addr;
requete.data.rtr = 1;
periph[ADDR(addr)].ev = 0x01;
periph[ADDR(addr)].ev = 0x01;//***
snd_dtq (CanTx,requete.msg);
wai_flg(ev_periph, 0x01, TWF_ANDW, &flag);
periph[ADDR(addr)].ev = 0x00;//***
pos = periph[ADDR(addr)].val;
return pos;
}

Formats disponibles : Unified diff