CQ_KIT_Ver1_5

Dependencies:   mbed RateLimiter BLDCmotorDriverCQ_KIT_Ver1_5

Revision:
13:038b62c7ac17
Parent:
12:33614e1dc638
diff -r 33614e1dc638 -r 038b62c7ac17 main.cpp
--- a/main.cpp	Thu Oct 20 14:44:40 2016 +0000
+++ b/main.cpp	Thu Aug 25 12:35:39 2022 +0000
@@ -39,13 +39,23 @@
 
 void checkTemperature()
 {
-    if (temperature > 0.55f){
-        printf("Overheating... Turning off now\n\r");
+float t = temperature;
+//    if (temperature > 0.55f){
+    if (temperature < 0.38f){
+        printf("Overheating... Turning off now,temp %1.2f \n\r",t);
         M.setDutyCycle(0);
         M.coast(); 
     }
 }
 
+// Pin to check current on the X-NUCLEO-IHM07M1 board
+AnalogIn current_u(P_CURR1),current_v(P_CURR2),current_w(P_CURR3);
+
+void checkCurrent()
+{
+
+}
+
 int main() {
     printf("Press 'w' to speed up, 's' to speed down\n\r");
     
@@ -55,20 +65,35 @@
     
     Ticker ticker;
     ticker.attach(checkTemperature, 1); // Periodic overheating check
+//    ticker.attach_us(checkCurrent,1000000); // current control interbal 10ms
+//    ticker.attach(checkCurrent,1); // current control interbal 10ms
     
     while(true) { 
 
-        char c = getchar();
-        if((c == 'w') && (dc < 0.9f)) {
-            dc += 0.1f;
-            M.setDutyCycle(dc);
-        }
-        if((c == 's') && (dc > -0.9f)) {
-            dc -= 0.1f;
-            M.setDutyCycle(dc);
-        }
+//        char c = getchar();
+//        if((c == 'w') && (dc < 0.9f)) {
+//            dc += 0.1f;
+//            M.setDutyCycle(dc);
+//        }
+//        if((c == 's') && (dc > -0.9f)) {
+//            dc -= 0.1f;
+//            M.setDutyCycle(dc);
+//        }
+        AnalogIn SPEED(P_SPEED);
+        float S;
+        S = SPEED + 0.001f;
+        if(S >0.999f) S = 0.999;
+        dc = S;
+        M.setDutyCycle(dc);
+        
+        float im[3];
+        im[0] = current_u;
+        im[1] = current_v;
+        im[2] = current_w;
 
-        printf("Duty Cycle: %1.2f, Sector: %d\n\r",dc, M.getSector());
+        printf("iu,iv,iw= %1.3f,%1.3f,%1.3f \n\r",im[0],im[1],im[2]);
+
+//        printf("Duty Cycle: %1.2f, Sector: %d, SPEED: %1.2f \n\r",dc, M.getSector(),S);
 
     }   
 }