Mini Cheetah Actuator Branch Superseded by: https://github.com/bgkatz/motorcontrol

Dependencies:   mbed-dev-f303 FastPWM3

Superseded by: https://github.com/bgkatz/motorcontrol

Revision:
52:8e74c22ed89f
Parent:
51:6cd89bd6fcaa
--- a/main.cpp	Wed Jul 17 03:40:12 2019 +0000
+++ b/main.cpp	Sun Jul 21 21:42:49 2019 +0000
@@ -52,7 +52,7 @@
 //DigitalOut drv_en_gate(PA_11);
 DRV832x drv(&drv_spi, &drv_cs);
 
-PositionSensorAM5147 spi(16384, 0.0, NPP);  
+PositionSensorAM5147 spi(16384, 0.0, 0.0);  
 
 volatile int count = 0;
 volatile int state = REST_MODE;
@@ -221,6 +221,7 @@
                     controller.kd = 0;
                     controller.t_ff = 0;
                     } 
+                
 
                 torque_control(&controller);
                 commutate(&controller, &observer, &gpio, controller.theta_elec);           // Run current loop
@@ -413,8 +414,10 @@
     if(isnan(CAN_ID) || CAN_ID==-1){CAN_ID = 1;}
     if(isnan(CAN_MASTER) || CAN_MASTER==-1){CAN_MASTER = 0;}
     if(isnan(CAN_TIMEOUT) || CAN_TIMEOUT==-1){CAN_TIMEOUT = 0;}
+    if(isnan(NPP) || NPP==-1){NPP = 1;}
     spi.SetElecOffset(E_OFFSET);                                                // Set position sensor offset
     spi.SetMechOffset(M_OFFSET);
+    spi.SetNPP(NPP);
     int lut[128] = {0};
     memcpy(&lut, &ENCODER_LUT, sizeof(lut));
     spi.WriteLUT(lut);                                                          // Set potision sensor nonlinearity lookup table
@@ -430,6 +433,7 @@
     printf(" Position Sensor Electrical Offset:   %.4f\n\r", E_OFFSET);
     printf(" Output Zero Position:  %.4f\n\r", M_OFFSET);
     printf(" CAN ID:  %d\n\r", CAN_ID);
+    printf(" Pole-Pairs:  %d\n\r", NPP);
     
 
 
@@ -448,8 +452,10 @@
 
     int counter = 0;
     while(1) {
+        
         drv.print_faults();
-       wait(.1);
+        //if(drv.get_fault()>0){drv.write_DCR(0x0, 0x0, 0x0, PWM_MODE_3X, 0x0, 0x0, 0x0, 0x0, 0x1);}
+        wait(.1);
        //printf("%.4f\n\r", controller.v_bus);
        /*
         if(state == MOTOR_MODE)