yezhong yezhong / Motor_DRV8323RH_for_2019-

Dependencies:   mbed-dev-f303 FastPWM3

Files at this revision

API Documentation at this revision

Comitter:
benkatz
Date:
Mon Aug 28 22:01:59 2017 +0000
Parent:
29:0dbc822dd29a
Commit message:
Broken, will come back to this;

Changed in this revision

FOC/foc.cpp Show annotated file Show diff for this revision Revisions of this file
hw_setup.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
--- a/FOC/foc.cpp	Mon Jun 12 17:41:00 2017 +0000
+++ b/FOC/foc.cpp	Mon Aug 28 22:01:59 2017 +0000
@@ -106,8 +106,8 @@
        //v_q_ff = 0;
        
        limit_norm(&controller->d_int, &controller->q_int, V_BUS/(K_Q*KI_Q));        // Limit integrators to prevent windup
-       controller->v_d = K_SCALE*I_BW*i_d_error + K_SCALE*I_BW*controller->d_int;// + v_d_ff;  
-       controller->v_q = K_SCALE*I_BW*i_q_error + K_SCALE*I_BW*controller->q_int;// + v_q_ff; 
+       controller->v_d = K_SCALE*I_BW*i_d_error + KI_D*K_SCALE*I_BW*controller->d_int;// + v_d_ff;  
+       controller->v_q = K_SCALE*I_BW*i_q_error + KI_Q*K_SCALE*I_BW*controller->q_int;// + v_q_ff; 
        
        //controller->v_q = 4.0f;;
        //controller->v_d = 0.0f;
@@ -143,7 +143,7 @@
           controller->loop_count  = 0;
            
            //printf("%.2f  %.2f  %.2f\n\r", controller->i_a, controller->i_b, controller->i_c);
-           //printf("%f\n\r", controller->theta_elec);
+            printf("%f   %f   %f\n\r", controller->i_a, controller->i_b, controller->i_c);
            //pc.printf("%f    %f    %f\n\r", controller->i_a, controller->i_b, controller->i_c);
            //pc.printf("%f    %f\n\r", controller->i_d, controller->i_q);
            //pc.printf("%d    %d\n\r", controller->adc1_raw, controller->adc2_raw);
--- a/hw_setup.cpp	Mon Jun 12 17:41:00 2017 +0000
+++ b/hw_setup.cpp	Mon Aug 28 22:01:59 2017 +0000
@@ -63,7 +63,7 @@
 
 void Init_All_HW(GPIOStruct *gpio){
     Init_PWM(gpio);
-    Init_ADC();
-    //Init_DAC();
+    //Init_ADC();
+    Init_DAC();
     
     }
\ No newline at end of file
--- a/main.cpp	Mon Jun 12 17:41:00 2017 +0000
+++ b/main.cpp	Mon Aug 28 22:01:59 2017 +0000
@@ -271,10 +271,10 @@
                 //toggle.write(0);
                 controller.timeout += 1;
                 
-                if(count == 1){
+                if(count == 100){
                      //count = 0;
-                     wait(.001);
-                    //printf(" Started commutating\n\r");
+                     //wait(.001);
+                    //printf("%f\n\r", controller.i_q_ref);
                      }
                      }