asser1

Dependencies:   mbed asser1

Revision:
2:5764f89a27f6
Parent:
0:6ca63d45f0ee
Child:
3:1dba6eca01ad
diff -r 0690cf83f060 -r 5764f89a27f6 hardware.cpp
--- a/hardware.cpp	Wed Dec 12 20:03:07 2018 +0000
+++ b/hardware.cpp	Wed Apr 17 18:55:22 2019 +0000
@@ -13,27 +13,27 @@
 L6470_init_t init[L6470DAISYCHAINSIZE] = {
     /* First Motor. */
     {
-        9.0,                           /* Motor supply voltage in V. */
-        400,                           /* Min number of steps per revolution for the motor. */
-        1.7,                           /* Max motor phase voltage in A. */
-        3.06,                          /* Max motor phase voltage in V. */
-        300.0,                         /* Motor initial speed [step/s]. */
+        10,                           /* Motor supply voltage in V. */
+        200,                           /* Min number of steps per revolution for the motor. */
+        4,                           /* Max motor phase voltage in A. */
+        7.06,                          /* Max motor phase voltage in V. */
+        300,                         /* Motor initial speed [step/s]. */
         500.0,                         /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
         1500.0,                        /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
         992.0,                         /* Motor maximum speed [step/s]. */
         0.0,                           /* Motor minimum speed [step/s]. */
         602.7,                         /* Motor full-step speed threshold [step/s]. */
-        3.06,                          /* Holding kval [V]. */
-        3.06,                          /* Constant speed kval [V]. */
-        3.06,                          /* Acceleration starting kval [V]. */
-        3.06,                          /* Deceleration starting kval [V]. */
+        4.5,                          /* Holding kval [V]. */
+        4.5,                          /* Constant speed kval [V]. */
+        4.5,                          /* Acceleration starting kval [V]. */
+        4.5,                          /* Deceleration starting kval [V]. */
         61.52,                         /* Intersect speed for bemf compensation curve slope changing [step/s]. */
         392.1569e-6,                   /* Start slope [s/step]. */
         643.1372e-6,                   /* Acceleration final slope [s/step]. */
         643.1372e-6,                   /* Deceleration final slope [s/step]. */
         0,                             /* Thermal compensation factor (range [0, 15]). */
-        3.06 * 1000 * 1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
-        3.06 * 1000 * 1.00,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
+        4.5*1000*1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
+        32,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
         StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
         0xFF,                          /* Alarm conditions enable. */
         0x2E88                         /* Ic configuration. */
@@ -41,27 +41,27 @@
 
     /* Second Motor. */
     {
-        9.0,                           /* Motor supply voltage in V. */
-        400,                           /* Min number of steps per revolution for the motor. */
-        1.7,                           /* Max motor phase voltage in A. */
-        3.06,                          /* Max motor phase voltage in V. */
-        300.0,                         /* Motor initial speed [step/s]. */
+        10,                           /* Motor supply voltage in V. */
+        200,                           /* Min number of steps per revolution for the motor. */
+        4,                           /* Max motor phase voltage in A. */
+        7.06,                          /* Max motor phase voltage in V. */
+        300,                         /* Motor initial speed [step/s]. */
         500.0,                         /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
-        1500.0,                         /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
+        1500.0,                        /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
         992.0,                         /* Motor maximum speed [step/s]. */
         0.0,                           /* Motor minimum speed [step/s]. */
         602.7,                         /* Motor full-step speed threshold [step/s]. */
-        3.06,                          /* Holding kval [V]. */
-        3.06,                          /* Constant speed kval [V]. */
-        3.06,                          /* Acceleration starting kval [V]. */
-        3.06,                          /* Deceleration starting kval [V]. */
+        4.5,                          /* Holding kval [V]. */
+        4.5,                          /* Constant speed kval [V]. */
+        4.5,                          /* Acceleration starting kval [V]. */
+        4.5,                          /* Deceleration starting kval [V]. */
         61.52,                         /* Intersect speed for bemf compensation curve slope changing [step/s]. */
         392.1569e-6,                   /* Start slope [s/step]. */
         643.1372e-6,                   /* Acceleration final slope [s/step]. */
         643.1372e-6,                   /* Deceleration final slope [s/step]. */
         0,                             /* Thermal compensation factor (range [0, 15]). */
-        3.06 * 1000 * 1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
-        3.06 * 1000 * 1.00,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
+        4.5*1000*1.10,            /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
+        32,            /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
         StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
         0xFF,                          /* Alarm conditions enable. */
         0x2E88                         /* Ic configuration. */
@@ -76,10 +76,16 @@
 
 
 //Connections codeuses
-InterruptIn ENCAL(D6);
-InterruptIn ENCAJ(D5);
-InterruptIn ENCBL(D8);
-InterruptIn ENCBJ(D7);
+//Nucleo 401re
+InterruptIn ENCAL(D9);
+InterruptIn ENCAJ(D8);
+InterruptIn ENCBL(D6);
+InterruptIn ENCBJ(D5);
+/*//Nucelo 746zg
+InterruptIn ENCAL(D8);
+InterruptIn ENCAJ(D7);
+InterruptIn ENCBL(D4);
+InterruptIn ENCBJ(D0);*/
 
 volatile long encoderValueA = 0; //nombre de tics sur l'encodeur A
 volatile long encoderValueB = 0; //nombre de tics sur l'encodeur B
@@ -150,6 +156,47 @@
     x_nucleo_ihm02a1->perform_prepared_actions();
 }
 
+void set_step_moteur_D(int steps)
+{
+    if (!moteurs_arret) {
+        if (1) {
+            motors[0]->prepare_move(StepperMotor::BWD, steps); //BWD = backward , FWD = forward , la vitesse doit etre positive
+        /*} else if (PWM <-PWM_MAX) {
+            motors[0]->prepare_run(StepperMotor::FWD, PWM_MAX);
+        } else if (PWM > 0) {
+            motors[0]->prepare_run(StepperMotor::BWD, PWM);
+        } else if (PWM < 0) {
+            motors[0]->prepare_run(StepperMotor::FWD, -PWM);
+        } else if (PWM == 0) {
+            motors[0]->prepare_run(StepperMotor::BWD, 0);
+        */}
+    /*} else {
+        motors[0]->prepare_hard_hiz(); //mode haute impédence pour pouvoir déplacer le robot à la main*/
+    }
+    x_nucleo_ihm02a1->perform_prepared_actions();
+}
+/*
+void set_step_moteur_G(int PWM)
+{
+
+    if (!moteurs_arret) {
+        if (PWM > PWM_MAX) {
+            motors[1]->prepare_run(StepperMotor::FWD, PWM_MAX);
+        } else if (PWM <-PWM_MAX) {
+            motors[1]->prepare_run(StepperMotor::BWD, PWM_MAX);
+        } else if (PWM > 0) {
+            motors[1]->prepare_run(StepperMotor::FWD, PWM);
+        } else if (PWM < 0) {
+            motors[1]->prepare_run(StepperMotor::BWD, -PWM);
+        } else if (PWM == 0) {
+            motors[1]->prepare_run(StepperMotor::BWD, 0);
+        }
+    } else {
+        motors[1]->prepare_hard_hiz(); //mode haute impédence pour pouvoir déplacer le robot à la main
+    }
+    x_nucleo_ihm02a1->perform_prepared_actions();
+}*/
+
 long int get_nbr_tick_D()
 {
     return encoderValueA;