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.
Diff: motors.cpp
- Revision:
- 10:0714feaaaee1
- Parent:
- 6:ea6b30c4bb01
- Child:
- 16:ae65ce77b1f9
--- a/motors.cpp Thu Jul 30 19:43:16 2020 +0000
+++ b/motors.cpp Fri Sep 11 10:56:08 2020 +0000
@@ -7,44 +7,75 @@
motGauche_fwd();
//motDroite_fwd();
motDroite_bck();
- drvGauche.moveLinSpeed(0.05);
- drvDroite.moveLinSpeed(0.05);
- mode = 0b111; // M0, M1 et M2 sont à 1
+ 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()
{
- drvGauche.setEnable(START);
- //drvDroite.setEnable(START);
+ motG_en();
+ motD_en();
}
void mot_dis()
{
+ motG_dis();
+ motD_dis();
+}
+
+void motG_en()
+{
+ drvGauche.setEnable(START);
+}
+
+void motD_en()
+{
+ drvDroite.setEnable(START);
+}
+
+void motG_dis()
+{
drvGauche.setEnable(STOP);
- //drvDroite.setEnable(STOP);
+}
+
+void motD_dis()
+{
+ drvDroite.setEnable(STOP);
}
// FORWARD
void motGauche_fwd()
{
drvGauche.setDir(FORWARD);
+ //drvGauche.setDir(BACKWARD);
}
void motDroite_fwd()
{
drvDroite.setDir(BACKWARD);
+ //drvDroite.setDir(FORWARD);
}
// BACKWARD
void motGauche_bck()
{
drvGauche.setDir(BACKWARD);
+ //drvGauche.setDir(FORWARD);
}
void motDroite_bck()
{
drvDroite.setDir(FORWARD);
+ //drvDroite.setDir(BACKWARD);
}
@@ -52,6 +83,7 @@
//
void test_drv()
{
+ /*
mot_en();
motGauche_fwd();
motDroite_fwd();
@@ -62,6 +94,49 @@
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);
}
-void testAngle(int cmdAngle){}
+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) {}