modified 0511

Dependencies:   mbed-dev FastPWM3

Revision:
57:ae8105f28fbf
Parent:
56:542e99ed5565
Child:
58:636e46484432
--- a/main.cpp	Fri Jun 18 14:22:20 2021 +0000
+++ b/main.cpp	Fri Jun 18 15:13:31 2021 +0000
@@ -126,8 +126,8 @@
     printf(" %-4s %-31s %-5s %-6s %d\n\r", "t", "CAN Timeout (cycles)(0 = none)", "0", "100000", CAN_TIMEOUT);
     wait_us(10);
     
-    printf(" %-4s %-31s %-5s %-6s %.2f\n\r", "p", "MOTOR_KP", "0.0", "500.0", MOTOR_KP);
-    wait_us(10);
+    //printf(" %-4s %-31s %-5s %-6s %.2f\n\r", "p", "MOTOR_KP", "0.0", "500.0", MOTOR_KP);
+    //wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %.2f\n\r", "i", "MOTOR_KI", "0.0", "10.0", MOTOR_KI);
     wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %.2f\n\r", "d", "MOTOR_KD", "0.0", "5.0", MOTOR_KD);
@@ -325,9 +325,11 @@
                     case 't':
                         CAN_TIMEOUT = atoi(cmd_val);
                         break;
+                    /*
                     case 'p':
                         MOTOR_KP = fmaxf(fminf(atof(cmd_val), KP_MAX), KP_MIN);;
                         break;
+                    */
                     case 'i':
                         MOTOR_KI = fmaxf(fminf(atof(cmd_val), KI_MAX), KI_MIN);;
                         break;
@@ -434,7 +436,7 @@
     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(MOTOR_KP) || MOTOR_KP==-1){MOTOR_KP = 50;}
+    //if(isnan(MOTOR_KP) || MOTOR_KP==-1){MOTOR_KP = 50;}
     if(isnan(MOTOR_KI) || MOTOR_KI==-1){MOTOR_KI = 0;}
     if(isnan(MOTOR_KD) || MOTOR_KD==-1){MOTOR_KD = 1.25;}
     spi.SetElecOffset(E_OFFSET);                                                // Set position sensor offset
@@ -460,8 +462,8 @@
     controller.ki = MOTOR_KI;
     controller.kd = MOTOR_KD;
     printf("PID controller parameters \n\r");
-    printf("KP: %.3f, KI: %.3f, KD: %.3f \n\r", controller.kp, controller.ki, controller.kd);
-
+    //printf("KP: %.3f, KI: %.3f, KD: %.3f \n\r", controller.kp, controller.ki, controller.kd);
+    printf("KI: %.3f, KD: %.3f \n\r", controller.ki, controller.kd);
 
     //printf(" %d\n\r", drv.read_register(DCR));
     //wait_us(100);