![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Test
Diff: motors.cpp
- Revision:
- 22:f891c2bce091
- Parent:
- 18:48246daf0c06
--- a/motors.cpp Sun Oct 25 22:36:51 2020 +0000 +++ b/motors.cpp Tue Oct 27 17:27:33 2020 +0000 @@ -1,60 +1,33 @@ -// Nom du fichier : motors.cpp +/* #include */ #include "pins.h" +/* Initialisation des drivers */ void drv_init() { mot_dis(); - motGauche_bck(); + motGauche_fwd(); motDroite_fwd(); - //motGauche_fwd(); - //motDroite_bck(); - //drvGauche.moveLinSpeed(0.01); - //drvDroite.moveLinSpeed(0.01); - //mode = 0b111; // M0, M1 et M2 sont à 1 - mode_M0 = 1; //mode_M1 = 1; //mode_M2 = 1; - - //mot_en(); -} - -// ENABLE/DISABLE // Les deux modules ont le même enable - -void mot_en() -{ - motG_en(); - motD_en(); } -void mot_dis() -{ - motG_dis(); - motD_dis(); -} - -void motG_en() +/* Activation des moteurs */ +void mot_en() // Activation des moteurs { drvGauche.setEnable(START); -} - -void motD_en() -{ drvDroite.setEnable(START); } -void motG_dis() +/* Désactivation des moteurs */ +void mot_dis() // Désactivation des moteurs { drvGauche.setEnable(STOP); -} - -void motD_dis() -{ drvDroite.setEnable(STOP); } -// FORWARD +/* Rotation moteur vers l'avant */ void motGauche_fwd() { drvGauche.setDir(FORWARD); @@ -67,7 +40,7 @@ //drvDroite.setDir(FORWARD); } -// BACKWARD +/* Rotation moteur vers l'arrière */ void motGauche_bck() { drvGauche.setDir(BACKWARD); @@ -80,6 +53,7 @@ //drvDroite.setDir(BACKWARD); } +/* Changement de vitesse des moteurs */ void vitesseMotG(double vitesse) { drvGauche.moveLinSpeed((double)vitesse); @@ -90,65 +64,8 @@ drvDroite.moveLinSpeed((double)vitesse); } - -// FONCTIONS TESTS -// +/* Fonction test des moteurs */ void test_drv() { - /* - mot_en(); - motGauche_fwd(); - motDroite_fwd(); - drvGauche.moveLinSpeed(0.250); // 0.035 - drvDroite.moveLinSpeed(0.250); // 0.035 - wait(2); - motGauche_bck(); - motDroite_bck(); - wait(2); - mot_dis(); - */ - - /* - mot_en(); - motGauche_fwd(); - motDroite_fwd(); - wait(2); - mot_dis(); - */ - - mot_en(); - mot_acc(); - wait(2); - mot_dec(); - mot_dis(); - - drvDroite.moveLinSpeed(0.050); + /* Rien */ } - -void mot_acc() -{ - double i = 0; - - while (i < vitesseSAT) { - bt.printf("mot_acc() => i = %lf\r\n",i); - drvDroite.moveLinSpeed(i); - drvGauche.moveLinSpeed(i); - i+=0.005; - wait_ms(10); - } -} - -void mot_dec() -{ - double i = vitesseSAT; - - while (i > 0) { - bt.printf("mot_dec() => i = %lf\r\n",i); - drvDroite.moveLinSpeed(i); - drvGauche.moveLinSpeed(i); - i-=0.005; - wait_ms(10); - } -} - -void testAngle(int cmdAngle) {}