use Generic 4 controller for 4L6X base
This commit is contained in:
parent
b6ccc6d5d2
commit
b30db6d771
|
@ -5,146 +5,32 @@
|
|||
#if EFI_TCU
|
||||
Gm4l6xTransmissionController gm4l6xTransmissionController;
|
||||
static SimplePwm tccPwm("TCC Control");
|
||||
static SimplePwm pcPwm("Pressure Control");
|
||||
static SimplePwm shift32Pwm("3-2 Shift Control");
|
||||
|
||||
void Gm4l6xTransmissionController::init() {
|
||||
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
||||
enginePins.tcuSolenoids[i].initPin("Transmission Solenoid", engineConfiguration->tcu_solenoid[i], engineConfiguration->tcu_solenoid_mode[i]);
|
||||
}
|
||||
enginePins.tcuTccOnoffSolenoid.initPin("TCC On/Off Solenoid", engineConfiguration->tcu_tcc_onoff_solenoid, engineConfiguration->tcu_tcc_onoff_solenoid_mode);
|
||||
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
||||
startSimplePwm(&tccPwm,
|
||||
"TCC",
|
||||
&engine->executor,
|
||||
&enginePins.tcuTccPwmSolenoid,
|
||||
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
||||
0);
|
||||
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, engineConfiguration->tcu_pc_solenoid_pin_mode);
|
||||
startSimplePwm(&pcPwm,
|
||||
"Line Pressure",
|
||||
&engine->executor,
|
||||
&enginePins.tcuPcSolenoid,
|
||||
engineConfiguration->tcu_pc_solenoid_freq,
|
||||
0);
|
||||
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
||||
startSimplePwm(&shift32Pwm,
|
||||
"3-2 Solenoid",
|
||||
&engine->executor,
|
||||
&enginePins.tcu32Solenoid,
|
||||
engineConfiguration->tcu_32_solenoid_freq,
|
||||
0);
|
||||
Generic4TransmissionController::init();
|
||||
|
||||
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
||||
startSimplePwm(&tccPwm,
|
||||
"TCC",
|
||||
&engine->executor,
|
||||
&enginePins.tcuTccPwmSolenoid,
|
||||
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
||||
0);
|
||||
|
||||
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
||||
startSimplePwm(&shift32Pwm,
|
||||
"3-2 Solenoid",
|
||||
&engine->executor,
|
||||
&enginePins.tcu32Solenoid,
|
||||
engineConfiguration->tcu_32_solenoid_freq,
|
||||
0);
|
||||
}
|
||||
|
||||
void Gm4l6xTransmissionController::update(gear_e gear) {
|
||||
setCurrentGear(gear);
|
||||
setTccState();
|
||||
setPcState(gear);
|
||||
Generic4TransmissionController::update(gear);
|
||||
|
||||
set32State(gear);
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
if (engineConfiguration->debugMode == DBG_TCU) {
|
||||
engine->outputChannels.debugIntField1 = config->tcuSolenoidTable[static_cast<int>(gear) + 1][0];
|
||||
engine->outputChannels.debugIntField2 = config->tcuSolenoidTable[static_cast<int>(gear) + 1][1];
|
||||
engine->outputChannels.debugIntField3 = config->tcuSolenoidTable[static_cast<int>(gear) + 1][2];
|
||||
engine->outputChannels.debugIntField4 = config->tcuSolenoidTable[static_cast<int>(gear) + 1][3];
|
||||
engine->outputChannels.debugIntField5 = config->tcuSolenoidTable[static_cast<int>(gear) + 1][4];
|
||||
}
|
||||
#endif
|
||||
|
||||
TransmissionControllerBase::update(gear);
|
||||
|
||||
float time = isShiftCompleted();
|
||||
if (time != 0) {
|
||||
lastShiftTime = time;
|
||||
isShifting = false;
|
||||
}
|
||||
}
|
||||
|
||||
gear_e Gm4l6xTransmissionController::setCurrentGear(gear_e gear) {
|
||||
if (gear == getCurrentGear()) {
|
||||
return getCurrentGear();
|
||||
}
|
||||
currentGear = gear;
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(0);
|
||||
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
||||
#if ! EFI_UNIT_TEST
|
||||
enginePins.tcuSolenoids[i].setValue(config->tcuSolenoidTable[static_cast<int>(gear) + 1][i]);
|
||||
#endif
|
||||
}
|
||||
measureShiftTime(gear);
|
||||
return getCurrentGear();
|
||||
}
|
||||
|
||||
void Gm4l6xTransmissionController::setTccState() {
|
||||
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
|
||||
auto vss = Sensor::get(SensorType::VehicleSpeed);
|
||||
if (!tps.Valid || !vss.Valid) {
|
||||
return;
|
||||
}
|
||||
if (getCurrentGear() == GEAR_4) {
|
||||
int lockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccLockSpeed);
|
||||
int unlockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccUnlockSpeed);
|
||||
if (vss.Value > lockSpeed) {
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(1);
|
||||
} else if (vss.Value < unlockSpeed) {
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(1);
|
||||
}
|
||||
} else {
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Gm4l6xTransmissionController::setPcState(gear_e gear) {
|
||||
uint8_t (*pcts)[sizeof(config->tcu_pcAirmassBins)/sizeof(config->tcu_pcAirmassBins[0])];
|
||||
if (gear != getCurrentGear()) {
|
||||
shiftingFrom = getCurrentGear();
|
||||
isShifting = true;
|
||||
}
|
||||
|
||||
switch (getCurrentGear()) {
|
||||
case REVERSE:
|
||||
pcts = &config->tcu_pcValsR;
|
||||
break;
|
||||
case NEUTRAL:
|
||||
pcts = &config->tcu_pcValsN;
|
||||
break;
|
||||
case GEAR_1:
|
||||
if (isShifting && shiftingFrom == GEAR_2) {
|
||||
pcts = &config->tcu_pcVals21;
|
||||
} else {
|
||||
pcts = &config->tcu_pcVals1;
|
||||
}
|
||||
break;
|
||||
case GEAR_2:
|
||||
if (isShifting && shiftingFrom == GEAR_1) {
|
||||
pcts = &config->tcu_pcVals12;
|
||||
} else if (isShifting && shiftingFrom == GEAR_3) {
|
||||
pcts = &config->tcu_pcVals32;
|
||||
} else {
|
||||
pcts = &config->tcu_pcVals2;
|
||||
}
|
||||
break;
|
||||
case GEAR_3:
|
||||
if (isShifting && shiftingFrom == GEAR_2) {
|
||||
pcts = &config->tcu_pcVals23;
|
||||
} else if (isShifting && shiftingFrom == GEAR_4) {
|
||||
pcts = &config->tcu_pcVals43;
|
||||
} else {
|
||||
pcts = &config->tcu_pcVals3;
|
||||
}
|
||||
break;
|
||||
case GEAR_4:
|
||||
pcts = &config->tcu_pcVals4;
|
||||
break;
|
||||
default:
|
||||
// TODO: how did we get here?
|
||||
pcPwm.setSimplePwmDutyCycle(0);
|
||||
return;
|
||||
}
|
||||
|
||||
float duty = 0.01f * interpolate2d(engine->fuelComputer.sdAirMassInOneCylinder, config->tcu_pcAirmassBins, *pcts);
|
||||
pcPwm.setSimplePwmDutyCycle(duty);
|
||||
}
|
||||
|
||||
void Gm4l6xTransmissionController::set32State(gear_e gear) {
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
// file tc_4l6x.h
|
||||
|
||||
#include "tcu.h"
|
||||
#include "tc_4.h"
|
||||
|
||||
#if EFI_TCU
|
||||
class Gm4l6xTransmissionController: public TransmissionControllerBase {
|
||||
class Gm4l6xTransmissionController: public Generic4TransmissionController {
|
||||
public:
|
||||
void update(gear_e);
|
||||
void init();
|
||||
|
@ -13,9 +14,6 @@ public:
|
|||
return TransmissionControllerMode::Gm4l6x;
|
||||
}
|
||||
private:
|
||||
gear_e setCurrentGear(gear_e gear);
|
||||
void setTccState();
|
||||
void setPcState(gear_e gear);
|
||||
void set32State(gear_e gear);
|
||||
bool isShifting = false;
|
||||
gear_e shiftingFrom;
|
||||
|
|
Loading…
Reference in New Issue