Ensure idle load is updating when cranking. Fixes #178

This commit is contained in:
Josh Stewart 2019-02-04 14:32:05 +11:00
parent 24981dc01f
commit 631867dec2
2 changed files with 20 additions and 12 deletions

View File

@ -3181,7 +3181,7 @@ cmdtestspk450dc = "E\x03\x0C"
softlimitOn = bits, U08, 31, [3:3]
boostCutSpark = bits, U08, 31, [4:4]
error = bits, U08, 31, [5:5]
idle = bits, U08, 31, [6:6]
idleControlOn = bits, U08, 31, [6:6]
sync = bits, U08, 31, [7:7]
rpmDOT = scalar, S16, 32, "rpm/s", 1.000, 0.000
flex = scalar, U08, 34, "%", 1.000, 0.000

View File

@ -196,21 +196,23 @@ void idleControl()
{
//Currently cranking. Use the cranking table
currentStatus.idleDuty = table2D_getValue(&iacCrankDutyTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
if( currentStatus.idleDuty == 0 ) { disableIdle(); break; }
idle_pwm_target_value = percentage(currentStatus.idleDuty, idle_pwm_max_count);
idleOn = true;
}
else
{
//Standard running
currentStatus.idleDuty = table2D_getValue(&iacPWMTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
if( currentStatus.idleDuty == 0 ) { disableIdle(); break; }
idle_pwm_target_value = percentage(currentStatus.idleDuty, idle_pwm_max_count);
currentStatus.idleLoad = currentStatus.idleDuty >> 1; //Idle Load is divided by 2 in order to send to TS
idleOn = true;
}
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
if( currentStatus.idleDuty == 0 )
{
disableIdle();
break;
}
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
idle_pwm_target_value = percentage(currentStatus.idleDuty, idle_pwm_max_count);
currentStatus.idleLoad = currentStatus.idleDuty >> 1; //Idle Load is divided by 2 in order to send to TS
idleOn = true;
break;
@ -221,10 +223,14 @@ void idleControl()
idlePID.Compute();
idle_pwm_target_value = idle_pid_target_value;
if( idle_pwm_target_value == 0 ) { disableIdle(); }
if( idle_pwm_target_value == 0 )
{
disableIdle();
break;
}
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
currentStatus.idleLoad = ((unsigned long)(idle_pwm_target_value * 100UL) / idle_pwm_max_count) >> 1;
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
//idle_pwm_target_value = 104;
idleCounter++;
break;
@ -392,6 +398,8 @@ static inline void disableIdle()
idleStepper.targetIdleStep = idleStepper.curIdleStep; //Don't try to move anymore
}
}
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag off
currentStatus.idleLoad = 0;
}
//Any common functions associated with starting the Idle