Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed freescal_cup_k22f
Revision 6:a4e49784b533, committed 2015-01-13
- Comitter:
- RobinN7
- Date:
- Tue Jan 13 17:03:09 2015 +0000
- Parent:
- 5:4d1a524433ca
- Child:
- 12:3384196374ca
- Commit message:
- ca marche pas trop mal
Changed in this revision
--- a/Header/Gestion_Moteur.h Tue Jan 13 16:35:04 2015 +0000 +++ b/Header/Gestion_Moteur.h Tue Jan 13 17:03:09 2015 +0000 @@ -10,4 +10,7 @@ void init_led(void); -void test_qei(void); \ No newline at end of file +void test_qei(void); + +extern int consigne_moteur_1; +extern int consigne_moteur_2; \ No newline at end of file
--- a/source/Gestion_Moteur.cpp Tue Jan 13 16:35:04 2015 +0000 +++ b/source/Gestion_Moteur.cpp Tue Jan 13 17:03:09 2015 +0000 @@ -25,11 +25,13 @@ // Variables d'asserv moteur gauche // Mesure brute QEI 1, Mesure brute QEI 1 précédente, Écart mesuré, Écart de consigne -int mesure1=0,mesure_precedente1=0,mesure_moteur_1,consigne_moteur_1=6; +int mesure1=0,mesure_precedente1=0,mesure_moteur_1; +extern int consigne_moteur_1=0; // Coeff proportionnel, Intégral, Valeur intégrale, valeur sortie de l'asserv, consigne PWM envoyée au moteur gauche float Kp_moteur_1=2,Ki_moteur_1=2,I_x_moteur_1=0,sortie_asserv1,consigne_PWM1; // Variables d'asserv moteur droit -int mesure2=0,mesure_precedente2=0,mesure_moteur_2,consigne_moteur_2=6; +int mesure2=0,mesure_precedente2=0,mesure_moteur_2; +extern int consigne_moteur_2=0; // Coeff proportionnel, Intégral, Valeur intégrale, valeur sortie de l'asserv, consigne PWM envoyée au moteur droit float Kp_moteur_2=2,Ki_moteur_2=2,I_x_moteur_2=0,sortie_asserv2,consigne_PWM2;
--- a/source/main.cpp Tue Jan 13 16:35:04 2015 +0000
+++ b/source/main.cpp Tue Jan 13 17:03:09 2015 +0000
@@ -47,10 +47,19 @@
{
max_detect=j;
}
+ }
+ // Réduction de la vitesse moteur si l'angle du servo augmente
+ if (max_detect>64)
+ {
+ consigne_moteur_1=6-(max_detect-64)/20.;
+ consigne_moteur_2=6-(max_detect-64)/15.;
}
-
- //servo = float(min_detect-indexMin)/float(indexMax-indexMin);
- servo = 1.6*(double(max_detect)/128.-0.5)+0.5;
+ else
+ {
+ consigne_moteur_1=6-(64-max_detect)/15.;
+ consigne_moteur_2=6-(64-max_detect)/20.;
+ }
+ servo = 1.4*(double(max_detect)/128.-0.5)+0.5;
}
}