2014 sift / Mbed 2 deprecated TVDctrller2017_brdRev1_PandA

Dependencies:   mbed

Fork of TVDctrller2017_brdRev1_ver6 by 2014 sift

Revision:
15:3255cbe4ff34
Parent:
14:7cc98e159c6e
Child:
16:7afd623ef48a
diff -r 7cc98e159c6e -r 3255cbe4ff34 TVDCTRL.cpp
--- a/TVDCTRL.cpp	Tue Aug 09 07:52:17 2016 +0000
+++ b/TVDCTRL.cpp	Tue Aug 09 13:17:43 2016 +0000
@@ -338,9 +338,9 @@
     if(torque <= LINEAR_REGION_TORQUE) {         //要求トルク<=2.5Nmの時
         outputVoltage = (int)((double)(LINEAR_REGION_VOLTAGE-DACOUTPUT_MIN)/LINEAR_REGION_TORQUE * torque);
     } else {
-        rpm = (int)(1.0/getPulseTime(rl)*1000000.0 * 60.0);  //pulseTime:[us]
+        //rpm = (int)(1.0/getPulseTime(rl)*1000000.0 * 60.0);  //pulseTime:[us]
         
-        //rpm = 0;
+        rpm = 0;
 
         if(rpm < 3000) {        //3000rpm未満は回転数による出力制限がないフラットな領域
             outputVoltage = interpolateLinear(torque, MAX_MOTOR_TORQUE);
@@ -362,7 +362,10 @@
 
     outputVoltage += DACOUTPUT_MIN;   //最低入力電圧でかさ上げ
 
-    preOutputVol = (int)(outputVoltage*0.01 + preOutputVol*0.99);
+    //preOutputVol = (int)(outputVoltage*0.1 + preOutputVol*0.9);
+    preOutputVol = outputVoltage;
+    
+    //printf("%d\r\n", (int)(0xFFF*((double)preOutputVol/0xFFFF)));
 
     return (unsigned int)(0xFFF*((double)preOutputVol/0xFFFF));  //DACの分解能に適応(16bit->12bit)
 }
@@ -429,6 +432,8 @@
 
     distributionTrq = distributeTorque(getSteerAngle());  //トルク分配量計算
     distributionTrq /= 2.0;
+    
+    //printf("%d\r\n", distributionTrq);
 
     //デバッグ中
     //distributionTrq = 0;
@@ -456,7 +461,7 @@
         McpData.valB = calcTorqueToVoltage(torqueHigh, LEFT_MOTOR);
     }
     
-    pc.printf("%d %d\r\n", (int)McpData.valA, (int)McpData.valB);
+    pc.printf("%u %u\r\n", McpData.valA, McpData.valB);
 
     mcp.writeA(McpData.valA);   //右モーター
     mcp.writeB(McpData.valB);   //左モーター