Projet

Général

Profil

« Précédent | Suivant » 

Révision 198

Ajouté par anfichot1 il y a plus de 6 ans

asservissement tourelle, distance_telemetre fini

Voir les différences:

branch/fichot/Emb_App/SessionM32C_E8a_system.ini
[Target]
M32C E8a SYSTEM=Renesas Communications
[USER_DATA]
RESET=ff0020
RESET=ff0016
branch/fichot/Emb_App/programme_principal_etud.c
//'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 '*'
int consigne =450;
int val_simu=0;
int k=5;
int vitesse=80;
int valeur = 0;
CanFrame vit_roue;
int k=2;
int vitesse = 50;
void demarrer()
CanFrame vit_roue; //canal de commande de la vitesse
/*void demarrer()
{
vit_roue.data.id='V';
vit_roue.data.rtr=0;
vit_roue.data.val=vitesse;
snd_dtq (CanTx,vit_roue.msg);
}
}*/
void asserv()
void rot_tourelle()
{
CanFrame comm;
CanFrame req;
CanFrame reponse;
while(1){
req.data.id='R';
req.data.rtr=1;
snd_dtq (CanTx,req.msg);
val_simu=periph[ADDR('R')].val;
comm.data.id='T';
comm.data.rtr=0;
comm.data.val=valeur;
snd_dtq (CanTx,comm.msg);
if( val_simu != consigne)
comm.data.id = 'T';
comm.data.rtr = 0;
comm.data.val = 120;
snd_dtq(CanTx, comm.msg);
}
short pos_tourelle(){
CanFrame req, reponse;
short angle;
req.data.id = 'R';
req.data.rtr = 1;
snd_dtq(CanTx, req.msg);
rcv_dtq(CanRx, &reponse.msg);
angle = reponse.data.val;
return angle;
}
void asserv(VP_INT stacd){
CanFrame comm;
while(1){
comm.data.id = 'T';
comm.data.rtr = 0;
comm.data.val = k*(450 - position_tourelle());
snd_dtq(CanTx, comm.msg);
}
}
short distance_telemetre(void){
CanFrame requete, reponse;
short distance;
requete.data.id = 'U';
requete.data.rtr = 1;
snd_dtq(CanTx, requete.msg);
rcv_dtq(CanRx, &reponse.msg);
if(reponse.data.id != 'U' )
{
valeur=k*(consigne - val_simu);
rcv_dtq(CanRx, &reponse.msg);
}
}
distance = reponse.data.val;
return distance;
}
void angle_roue(short angle){
CanFrame comm;
comm.data.id = 'D';
comm.data.rtr = 0;
comm.data.val = 0;
snd_dtq(CanTx, comm.msg);
}
void main()
{
ports_mcu();
lcd_init();
periph_init();
periph_nom("#AutoTest*");
periph_nom("#fich*");
can_init();
clavier_init(1);
capture_init();
demarrer();
asserv();
while(1){
//demarrer();
rot_tourelle();
pos_tourelle();
asserv();
distance_telemetre();
while(1){
}
}

Formats disponibles : Unified diff