zebra joint controller firmware (originally from MIT HKC motor controller by benkatz)

Dependencies:   mbed FastPWM3

Files at this revision

API Documentation at this revision

Comitter:
kageyuta
Date:
Fri Feb 05 10:49:02 2021 +0000
Parent:
54:59575833d16f
Commit message:
stable version

Changed in this revision

FOC/foc.cpp 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
mbed-dev.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/FOC/foc.cpp	Thu Aug 08 17:39:43 2019 +0000
+++ b/FOC/foc.cpp	Fri Feb 05 10:49:02 2021 +0000
@@ -147,6 +147,8 @@
            }
        controller->i_a = -controller->i_b - controller->i_c;       
        
+       //printf("%f %f %f\r\n",controller->i_a, controller->i_b, controller->i_c);
+       
        float s = FastSin(theta); 
        float c = FastCos(theta);                            
        dq0(controller->theta_elec, controller->i_a, controller->i_b, controller->i_c, &controller->i_d, &controller->i_q);    //dq0 transform on currents
@@ -155,7 +157,7 @@
         
         controller->i_q_filt = 0.95f*controller->i_q_filt + 0.05f*controller->i_q;
         controller->i_d_filt = 0.95f*controller->i_d_filt + 0.05f*controller->i_d;
-        
+        //printf("%f, %f, %f, %f, %f\r\n",controller->i_a, controller->i_b, controller->i_c, controller->i_d_filt, controller->i_q_filt);
         
         // Filter the current references to the desired closed-loop bandwidth
         controller->i_d_ref_filt = (1.0f-controller->alpha)*controller->i_d_ref_filt + controller->alpha*controller->i_d_ref;
@@ -224,5 +226,6 @@
     //float torque_ref = -.1*(controller->p_des - controller->theta_mech);
     controller->i_q_ref = torque_ref/KT_OUT;    
     controller->i_d_ref = 0.0f;
+    //printf("pos:%f  vel:%f  Kp:%f  Kd:%f  t_ff:%f\r\n",controller->p_des,controller->v_des,controller->kp,controller->kd,controller->t_ff);
     }
  
\ No newline at end of file
--- a/main.cpp	Thu Aug 08 17:39:43 2019 +0000
+++ b/main.cpp	Fri Feb 05 10:49:02 2021 +0000
@@ -10,7 +10,7 @@
 #define SETUP_MODE 4
 #define ENCODER_MODE 5
 
-#define VERSION_NUM "1.9"
+#define VERSION_NUM "HKC1.9/ZEBRA1.0"
 
 
 float __float_reg[64];                                                          // Floats stored in flash
@@ -26,7 +26,7 @@
 #include "current_controller_config.h"
 #include "hw_config.h"
 #include "motor_config.h"
-#include "stm32f4xx_flash.h"
+//#include "stm32f4xx_flash.h"
 #include "FlashWriter.h"
 #include "user_config.h"
 #include "PreferenceWriter.h"
@@ -52,7 +52,7 @@
 //DigitalOut drv_en_gate(PA_11);
 DRV832x drv(&drv_spi, &drv_cs);
 
-PositionSensorAM5147 spi(16384, 0.0, NPP);  
+PositionSensorAM5147 spi(8192, 0.0, NPP);  
 
 volatile int count = 0;
 volatile int state = REST_MODE;
@@ -200,7 +200,7 @@
             case MOTOR_MODE:                                                   // Run torque control
                 if(state_change){
                     enter_torque_mode();
-                    count = 0;
+                    //count = 0;
                     }
                 else{
                 /*
@@ -226,7 +226,7 @@
                 commutate(&controller, &observer, &gpio, controller.theta_elec);           // Run current loop
 
                 controller.timeout++;
-                count++; 
+                //count++; 
             
                 }     
                 break;
--- a/mbed-dev.lib	Thu Aug 08 17:39:43 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/benkatz/code/mbed-dev-f303/#36facd806e4a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 05 10:49:02 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file