asservissement robot 2, C++, doc fournie
Dependencies: mbed QEI L298 Asservissement
Revision 2:41e56a06c580, committed 2019-03-20
- Comitter:
- hamaint
- Date:
- Wed Mar 20 00:28:46 2019 +0000
- Parent:
- 1:11cbd2bf65d7
- Commit message:
- version shlag mais c++ en mode bg;
Changed in this revision
diff -r 11cbd2bf65d7 -r 41e56a06c580 Asservissement.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Asservissement.lib Wed Mar 20 00:28:46 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Polybot-Grenoble/code/Asservissement/#3827dab9a2eb
diff -r 11cbd2bf65d7 -r 41e56a06c580 L298.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/L298.lib Wed Mar 20 00:28:46 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Polybot-Grenoble/code/L298/#e6ed3d459a99
diff -r 11cbd2bf65d7 -r 41e56a06c580 Moteur.cpp --- a/Moteur.cpp Tue Mar 19 19:24:04 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -#include "Moteur.h" - - -#define PERIODE_PWM_MOTEUR 0.001 - -PwmOut mypwm_a(D6); -PwmOut mypwm_b(D11); - -DigitalOut in1(D7); -DigitalOut in2(D8); -DigitalOut in3(D9); -DigitalOut in4(D10); - - - -void moteur_init() -{ - mypwm_a.period(PERIODE_PWM_MOTEUR); - mypwm_b.period(PERIODE_PWM_MOTEUR); - mypwm_a.pulsewidth(0); - mypwm_b.pulsewidth(0); -} - -void moteur_a(float percent) -{ - - if (percent>=0) { - in1 = 1; - in2 = 0; - } else { - in1 = 0; - in2 = 1; - percent = -1 * percent; - } - mypwm_a.pulsewidth((float)percent*(float)PERIODE_PWM_MOTEUR); -} - -void moteur_b(float percent) -{ - - if (percent>=0) { - in4 = 1; - in3 = 0; - } else { - in4 = 0; - in3 = 1; - percent = -1 * percent; - } - - mypwm_b.pulsewidth((float)percent*(float)PERIODE_PWM_MOTEUR); -}
diff -r 11cbd2bf65d7 -r 41e56a06c580 Moteur.h --- a/Moteur.h Tue Mar 19 19:24:04 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -#ifndef MOTEUR_H -#define MOTEUR_H - -#include "mbed.h" - -void moteur_init(); -void moteur_a(float percent); -void moteur_b(float percent); - -#endif \ No newline at end of file
diff -r 11cbd2bf65d7 -r 41e56a06c580 main.cpp --- a/main.cpp Tue Mar 19 19:24:04 2019 +0000 +++ b/main.cpp Wed Mar 20 00:28:46 2019 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" #include "QEI.h" -#include "Moteur.h" +#include "L298.h" #include "math.h" Serial pc(SERIAL_TX,SERIAL_RX); @@ -40,6 +40,8 @@ float PID(float erreur,float type); int main() { + + L298 pontH(); float distance = 0; float orientation_deg = 90; @@ -64,9 +66,7 @@ float orientation_dist = orientation_deg * (float)DISTANCE_ENTRE_ROUES * 3.14 / 360; - printf("%f\n\r",orientation_dist); - - moteur_init(); + //moteur_init(); while(1) { @@ -102,8 +102,8 @@ n_commande_b = -LIMITE_VITESSE; - moteur_a(n_commande_a); - moteur_b(n_commande_b); + //moteur_a(n_commande_a); + //moteur_b(n_commande_b); wait(FREQ_CORRECTION); }
diff -r 11cbd2bf65d7 -r 41e56a06c580 mbed.bld --- a/mbed.bld Tue Mar 19 19:24:04 2019 +0000 +++ b/mbed.bld Wed Mar 20 00:28:46 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file