Modified Motor Driver Firmware to include Flash + Thermal

Dependencies:   FastPWM3 mbed-dev-STM-lean

Files at this revision

API Documentation at this revision

Comitter:
elijahsj
Date:
Fri Jan 29 20:39:36 2021 +0000
Parent:
65:bfdf1e10428d
Child:
67:96a4052a1705
Commit message:
update U12 parameters;

Changed in this revision

CAN/CAN_com.cpp Show annotated file Show diff for this revision Revisions of this file
Config/current_controller_config.h Show annotated file Show diff for this revision Revisions of this file
Config/motor_config_R60.h Show annotated file Show diff for this revision Revisions of this file
Config/motor_config_U10.h Show annotated file Show diff for this revision Revisions of this file
Config/motor_config_U12.h Show annotated file Show diff for this revision Revisions of this file
FOC/foc.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CAN/CAN_com.cpp	Thu Nov 26 04:31:14 2020 +0000
+++ b/CAN/CAN_com.cpp	Fri Jan 29 20:39:36 2021 +0000
@@ -9,8 +9,8 @@
  #define KP_MAX 500.0f
  #define KD_MIN 0.0f
  #define KD_MAX 5.0f
- #define T_MIN -18.0f
- #define T_MAX 18.0f
+ #define T_MIN -72.0f
+ #define T_MAX 72.0f
  
 
 /// CAN Reply Packet Structure ///
--- a/Config/current_controller_config.h	Thu Nov 26 04:31:14 2020 +0000
+++ b/Config/current_controller_config.h	Fri Jan 29 20:39:36 2021 +0000
@@ -2,13 +2,13 @@
 #define CURRENT_CONTROLLER_CONFIG_H
 
 // Current controller///
-#define K_D .05f                    // Loop gain,  Volts/Amp
-#define K_Q .05f                    // Loop gain,  Volts/Amp
+#define K_D .01f                    // Loop gain,  Volts/Amp
+#define K_Q .01f                    // Loop gain,  Volts/Amp
 #define K_SCALE 0.0001f             // K_loop/Loop BW (Hz) 0.0042
-#define KI_D 0.0455f                // PI zero, in radians per sample
-#define KI_Q 0.0455f                // PI zero, in radians per sample
-#define V_BUS 24.0f                 // Volts
-#define OVERMODULATION 1.15f        // 1.0 = no overmodulation
+#define KI_D 0.002f                // PI zero, in radians per sample
+#define KI_Q 0.002f                // PI zero, in radians per sample
+#define V_BUS 30.0f                 // Volts
+#define OVERMODULATION 1.0f        // 1.0 = no overmodulation
 
 #define D_INT_LIM V_BUS/(K_D*KI_D)  // Amps*samples
 #define Q_INT_LIM V_BUS/(K_Q*KI_Q)  // Amps*samples
--- a/Config/motor_config_R60.h	Thu Nov 26 04:31:14 2020 +0000
+++ b/Config/motor_config_R60.h	Fri Jan 29 20:39:36 2021 +0000
@@ -5,19 +5,19 @@
 
 //TODO: fill in all of these parameters
 
-#define R_PHASE 0.5f              //Ohms
-#define L_D 0.000084f //needs update             //Henries
-#define L_Q 0.000104f //needs update             //Henries
-#define NPP 14                    //Number of pole pairs  
+//#define R_PHASE 0.5f              //Ohms
+//#define L_D 0.000084f //needs update             //Henries
+//#define L_Q 0.000104f //needs update             //Henries
+//#define NPP 14                    //Number of pole pairs  
 
-#define KT 0.083f                 //N-m per peak phase amp, = WB*NPP*3/2
-#define GR 2.0f                   //Gear ratio
-#define KT_OUT 0.166f             //KT*GR
-#define WB 0.0040f // from KT     //Flux linkage, Webers.  
+//#define KT 0.083f                 //N-m per peak phase amp, = WB*NPP*3/2
+//#define GR 2.0f                   //Gear ratio
+//#define KT_OUT 0.166f             //KT*GR
+//#define WB 0.0040f // from KT     //Flux linkage, Webers.  
 
-#define R_TH 1.25f  //needs update            //Kelvin per watt
-#define INV_M_TH 0.02825f //needs update      //Kelvin per joule
-#define T_AMBIENT 25.0f           // ambient temperature during temp calibration
+//#define R_TH 1.25f  //needs update            //Kelvin per watt
+//#define INV_M_TH 0.02825f //needs update      //Kelvin per joule
+//#define T_AMBIENT 25.0f           // ambient temperature during temp calibration
 
 // R60 motor is KV115...use to calculate Kt
 // actuator has 24 stator slots, 28 pole magnets
--- a/Config/motor_config_U10.h	Thu Nov 26 04:31:14 2020 +0000
+++ b/Config/motor_config_U10.h	Fri Jan 29 20:39:36 2021 +0000
@@ -3,14 +3,14 @@
 
 // CONFIGURATION PARAMETERS OF U10 MOTORS
 
-#define R_PHASE 0.158f            //Ohms
+#define R_PHASE 0.433f            //Ohms
 #define L_D 0.0002f               //Henries
-#define L_Q 0.000256f             //Henries
+#define L_Q 0.0002f             //Henries, set both inductances equal for now
 #define NPP 21                    //Number of pole pairs   
 
-#define KT 0.191f                 //N-m per peak phase amp, = WB*NPP*3/2   
+#define KT 0.15f                 //N-m per peak phase amp, = WB*NPP*3/2   
 #define GR 6.0f                   //Gear ratio
-#define KT_OUT 1.146f             //KT*GR
+#define KT_OUT 0.9f             //KT*GR
 #define WB 0.00606f // from KT    //Flux linkage, Webers.
   
 #define R_TH 1.25f  //needs update            //Kelvin per watt
--- a/Config/motor_config_U12.h	Thu Nov 26 04:31:14 2020 +0000
+++ b/Config/motor_config_U12.h	Fri Jan 29 20:39:36 2021 +0000
@@ -1,17 +1,18 @@
 #ifndef MOTOR_CONFIG_U12_H
 #define MOTOR_CONFIG_U12_H
 
+
 // CONFIGURATION PARAMETERS FOR U12 MOTORS
 
-#define R_PHASE 0.433f            //Ohms
+#define R_PHASE 0.158f            //Ohms
 #define L_D 0.000084f             //Henries
-#define L_Q 0.000104f             //Henries
+#define L_Q 0.000084f             //Henries
 #define NPP 21                    //Number of pole pairs  
 
-#define KT 0.239f                 //N-m per peak phase amp, = WB*NPP*3/2
+#define KT 0.1916f                 //N-m per peak phase amp, = WB*NPP*3/2
 #define GR 6.0f                   //Gear ratio
-#define KT_OUT 1.434f             //KT*GR
-#define WB 0.0076f // from KT     //Flux linkage, Webers.  
+#define KT_OUT 1.15f             //KT*GR
+#define WB 0.00608f // from KT     //Flux linkage, Webers.  
 
 #define R_TH 1.25f  //needs update            //Kelvin per watt
 #define INV_M_TH 0.02825f //needs update      //Kelvin per joule
--- a/FOC/foc.h	Thu Nov 26 04:31:14 2020 +0000
+++ b/FOC/foc.h	Fri Jan 29 20:39:36 2021 +0000
@@ -7,7 +7,7 @@
 #include "hw_config.h"
 #include "math.h"
 #include "../math_ops.h"
-#include "motor_config_U10.h"
+#include "motor_config_U12.h"
 #include "current_controller_config.h"
 #include "FastMath.h"
 #include "user_config.h"
--- a/main.cpp	Thu Nov 26 04:31:14 2020 +0000
+++ b/main.cpp	Fri Jan 29 20:39:36 2021 +0000
@@ -26,7 +26,7 @@
 #include "math_ops.h" 
 #include "current_controller_config.h"
 #include "hw_config.h"
-#include "motor_config_U10.h" // need to choose between two files here, one for U10 and one for U12
+#include "motor_config_U12.h" // need to choose between two files here, one for U10 and one for U12
 #include "stm32f4xx_flash.h"
 #include "FlashWriter.h"
 #include "user_config.h"
@@ -124,7 +124,7 @@
     wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %-5i\n\r", "m", "CAN Master ID", "0", "127", CAN_MASTER);
     wait_us(10);
-    printf(" %-4s %-31s %-5s %-6s %.1f\n\r", "l", "Current Limit (A)", "0.0", "40.0", I_MAX);
+    printf(" %-4s %-31s %-5s %-6s %.1f\n\r", "l", "Current Limit (A)", "0.0", "65.0", I_MAX);
     wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %.1f\n\r", "f", "FW Current Limit (A)", "0.0", "33.0", I_FW_MAX);
     wait_us(10);
@@ -380,7 +380,7 @@
                         CAN_MASTER = atoi(cmd_val);
                         break;
                     case 'l':
-                        I_MAX = fmaxf(fminf(atof(cmd_val), 40.0f), 0.0f);
+                        I_MAX = fmaxf(fminf(atof(cmd_val), 65.0f), 0.0f);
                         break;
                     case 'f':
                         I_FW_MAX = fmaxf(fminf(atof(cmd_val), 33.0f), 0.0f);