Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TVDctrller2017_brdRev1_ver6 by
Diff: TVDCTRL.cpp
- Revision:
- 14:7cc98e159c6e
- Parent:
- 13:6dc51981f391
- Child:
- 15:3255cbe4ff34
--- a/TVDCTRL.cpp Tue Aug 09 06:10:35 2016 +0000 +++ b/TVDCTRL.cpp Tue Aug 09 07:52:17 2016 +0000 @@ -314,8 +314,9 @@ disTrq = 0; else { steering -= deadband; - disTrq = (int)((MAX_DISTRIBUTION_TORQUE / (M_PI - deadband)) * steering); + disTrq = (int)(MAX_DISTRIBUTION_TORQUE / (M_PI - deadband) * steering); } + //pc.printf("%d\r\n", disTrq); return disTrq; } @@ -338,6 +339,8 @@ 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 = 0; if(rpm < 3000) { //3000rpm未満は回転数による出力制限がないフラットな領域 outputVoltage = interpolateLinear(torque, MAX_MOTOR_TORQUE); @@ -440,8 +443,10 @@ torqueHigh = (int)(requestTorque*2.0); //片モーター下限値時,反対のモーターも出力クリップ } else torqueLow = requestTorque - distributionTrq; + + //printf("%d %d\r\n", torqueLow, torqueHigh); - if(getSteerDirection()) { + if(getSteerDirection()==1) { //steer left McpData.valA = calcTorqueToVoltage(torqueHigh, RIGHT_MOTOR); McpData.valB = calcTorqueToVoltage(torqueLow, LEFT_MOTOR); @@ -450,6 +455,8 @@ McpData.valA = calcTorqueToVoltage(torqueLow, RIGHT_MOTOR); McpData.valB = calcTorqueToVoltage(torqueHigh, LEFT_MOTOR); } + + pc.printf("%d %d\r\n", (int)McpData.valA, (int)McpData.valB); mcp.writeA(McpData.valA); //右モーター mcp.writeB(McpData.valB); //左モーター