PSL_2021 / Moteur_FCfurious
Committer:
margaux_lht
Date:
Fri Mar 12 10:11:08 2021 +0000
Revision:
0:7bc294a0862d
Child:
1:a0502fd47e2a
Moteur FC Furious commande et loi d'entree sortie

Who changed what in which revision?

UserRevisionLine numberNew contents of line
margaux_lht 0:7bc294a0862d 1 #include "MX12.h"
margaux_lht 0:7bc294a0862d 2 //extern UnbufferedSerial pc_serie(USBTX,USBRX,115200);
margaux_lht 0:7bc294a0862d 3 void cmd_moteur(float Vtm_s, float Vnm_s, float Wcrd_s){
margaux_lht 0:7bc294a0862d 4 static MX12 servo(PC_4,PC_5,115200);
margaux_lht 0:7bc294a0862d 5 float coeff=578.7/1023;
margaux_lht 0:7bc294a0862d 6 float W1;
margaux_lht 0:7bc294a0862d 7 float W2;
margaux_lht 0:7bc294a0862d 8 float W3;
margaux_lht 0:7bc294a0862d 9 float Rc;
margaux_lht 0:7bc294a0862d 10 float R;
margaux_lht 0:7bc294a0862d 11 float Vtc;
margaux_lht 0:7bc294a0862d 12 float Vnc;
margaux_lht 0:7bc294a0862d 13 float Wcc;
margaux_lht 0:7bc294a0862d 14 float Vtm_smax;
margaux_lht 0:7bc294a0862d 15 float Vnm_smax;
margaux_lht 0:7bc294a0862d 16 float Wcrd_smax;
margaux_lht 0:7bc294a0862d 17 Rc=0.08; // rayon du chassis*10
margaux_lht 0:7bc294a0862d 18 R=0.019; // rayon de la roue*10
margaux_lht 0:7bc294a0862d 19 W1=0;
margaux_lht 0:7bc294a0862d 20 W2=0;
margaux_lht 0:7bc294a0862d 21 W3=0;
margaux_lht 0:7bc294a0862d 22 //Vtm_smax=0.8; //sert pour calculer valeurs -999->999
margaux_lht 0:7bc294a0862d 23 //Vnm_smax=0.9;
margaux_lht 0:7bc294a0862d 24 //Wcrd_smax=2.9;
margaux_lht 0:7bc294a0862d 25 //if (Vtm_s>Vtm_smax)
margaux_lht 0:7bc294a0862d 26 // {Vtm_s=Vtm_smax;}
margaux_lht 0:7bc294a0862d 27 //if (Vnm_s>Vnm_smax)
margaux_lht 0:7bc294a0862d 28 // {Vnm_s=Vnm_smax;}
margaux_lht 0:7bc294a0862d 29 //if (Wcrd_s>Wcrd_smax)
margaux_lht 0:7bc294a0862d 30 // {Wcrd_s=Wcrd_smax;}
margaux_lht 0:7bc294a0862d 31 //if (Wcrd_s<-Wcrd_smax)
margaux_lht 0:7bc294a0862d 32 // {Wcrd_s=-Wcrd_smax;}
margaux_lht 0:7bc294a0862d 33
margaux_lht 0:7bc294a0862d 34 W1=(Wcrd_s*Rc-0.5*Vnm_s+0.866*Vtm_s)*coeff; //loi de commande moteur 1
margaux_lht 0:7bc294a0862d 35 W2=(Wcrd_s*Rc-0.5*Vnm_s-0.866*Vtm_s)*coeff;
margaux_lht 0:7bc294a0862d 36 W3=(Wcrd_s*Rc+Vnm_s)*coeff;
margaux_lht 0:7bc294a0862d 37 printf("%d %d %dn\r",(int)(1000*W1),(int)(1000*W2),(int)(1000*W3));
margaux_lht 0:7bc294a0862d 38
margaux_lht 0:7bc294a0862d 39
margaux_lht 0:7bc294a0862d 40 servo.SetSpeed(1,W1); // impose la vitesse au moteur 1
margaux_lht 0:7bc294a0862d 41 servo.SetSpeed(2,W2);
margaux_lht 0:7bc294a0862d 42 servo.SetSpeed(3,W3);
margaux_lht 0:7bc294a0862d 43
margaux_lht 0:7bc294a0862d 44
margaux_lht 0:7bc294a0862d 45
margaux_lht 0:7bc294a0862d 46 }