Add some comments
This commit is contained in:
parent
649e7cf149
commit
e33cd6009d
|
@ -43,6 +43,8 @@ void GenericGearController::update() {
|
||||||
// Loop through inputs
|
// Loop through inputs
|
||||||
for (size_t p = 0; p < efi::size(engineConfiguration->tcu_rangeInput); p++) {
|
for (size_t p = 0; p < efi::size(engineConfiguration->tcu_rangeInput); p++) {
|
||||||
float cellState = rangeStates[p];
|
float cellState = rangeStates[p];
|
||||||
|
// We allow the user to configure either a digital input or an analog input for each pin,
|
||||||
|
// so we need to check which is valid.
|
||||||
if (isAdcChannelValid(engineConfiguration->tcu_rangeAnalogInput[p])) {
|
if (isAdcChannelValid(engineConfiguration->tcu_rangeAnalogInput[p])) {
|
||||||
float pinState = Sensor::getOrZero(getAnalogSensorType(p));
|
float pinState = Sensor::getOrZero(getAnalogSensorType(p));
|
||||||
if (isNearest(pinState, p, rangeStates)) {
|
if (isNearest(pinState, p, rangeStates)) {
|
||||||
|
@ -96,6 +98,8 @@ void GenericGearController::update() {
|
||||||
setDesiredGear(NEUTRAL);
|
setDesiredGear(NEUTRAL);
|
||||||
break;
|
break;
|
||||||
case SelectedGear::ManualPlus :
|
case SelectedGear::ManualPlus :
|
||||||
|
// Only allow manual shift once per 500 ms,
|
||||||
|
// and if the selected range was Manual prior to this update
|
||||||
if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
|
if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +119,8 @@ void GenericGearController::update() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SelectedGear::ManualMinus :
|
case SelectedGear::ManualMinus :
|
||||||
|
// Only allow manual shift once per 500 ms,
|
||||||
|
// and if the selected range was Manual prior to this update
|
||||||
if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
|
if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +140,8 @@ void GenericGearController::update() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SelectedGear::Drive :
|
case SelectedGear::Drive :
|
||||||
|
// If the gear selector is in drive, let AutomaticGearController,
|
||||||
|
// which this class inherits from, decide what gear the transmission should be in.
|
||||||
AutomaticGearController::update();
|
AutomaticGearController::update();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -29,7 +29,7 @@ void GearControllerBase::update() {
|
||||||
if (transmissionController == NULL) {
|
if (transmissionController == NULL) {
|
||||||
initTransmissionController();
|
initTransmissionController();
|
||||||
} else if (transmissionController->getMode() != engineConfiguration->transmissionControllerMode) {
|
} else if (transmissionController->getMode() != engineConfiguration->transmissionControllerMode) {
|
||||||
// TODO de-init here
|
// TODO de-init here to allow change without power cycling
|
||||||
initTransmissionController();
|
initTransmissionController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,10 @@ void initGearController() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float* GearControllerBase::getRangeStateArray(int i) {
|
float* GearControllerBase::getRangeStateArray(int i) {
|
||||||
|
// I don't remember why I put manual +/- first.
|
||||||
|
// I think maybe I had some concern about them needing to override under-specified ranges?
|
||||||
|
// e.g. with it this way, you could put 2 in the cells for +/- pins in everything else.
|
||||||
|
// So this way might make it a little easier/foolproof to configure, but not necessary.
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 1 :
|
case 1 :
|
||||||
return config->tcu_rangePlus;
|
return config->tcu_rangePlus;
|
||||||
|
|
|
@ -27,6 +27,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
||||||
measureShiftTime(gear);
|
measureShiftTime(gear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set torque converter and pressure control state
|
||||||
setTccState(gear);
|
setTccState(gear);
|
||||||
setPcState(gear);
|
setPcState(gear);
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
||||||
SimpleTransmissionController::update(gear);
|
SimpleTransmissionController::update(gear);
|
||||||
|
|
||||||
float time = isShiftCompleted();
|
float time = isShiftCompleted();
|
||||||
|
// 0 means shift is not completed
|
||||||
if (time != 0) {
|
if (time != 0) {
|
||||||
lastShiftTime = time;
|
lastShiftTime = time;
|
||||||
isShifting = false;
|
isShifting = false;
|
||||||
|
@ -42,6 +44,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generic4TransmissionController::setTccState(gear_e gear) {
|
void Generic4TransmissionController::setTccState(gear_e gear) {
|
||||||
|
// disable if shifting
|
||||||
if (isShifting) {
|
if (isShifting) {
|
||||||
enginePins.tcuTccOnoffSolenoid.setValue(0);
|
enginePins.tcuTccOnoffSolenoid.setValue(0);
|
||||||
return;
|
return;
|
||||||
|
@ -52,10 +55,12 @@ void Generic4TransmissionController::setTccState(gear_e gear) {
|
||||||
if (!tps.Valid || !vss.Valid) {
|
if (!tps.Valid || !vss.Valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// only enable TC in gear 4
|
||||||
if (gear == GEAR_4) {
|
if (gear == GEAR_4) {
|
||||||
int lockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccLockSpeed);
|
int lockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccLockSpeed);
|
||||||
int unlockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccUnlockSpeed);
|
int unlockSpeed = interpolate2d(tps.Value, config->tcu_tccTpsBins, config->tcu_tccUnlockSpeed);
|
||||||
if (vss.Value > lockSpeed) {
|
if (vss.Value > lockSpeed) {
|
||||||
|
// torqueConverterDuty is only used for a gauge
|
||||||
torqueConverterDuty = 100;
|
torqueConverterDuty = 100;
|
||||||
enginePins.tcuTccOnoffSolenoid.setValue(1);
|
enginePins.tcuTccOnoffSolenoid.setValue(1);
|
||||||
} else if (vss.Value < unlockSpeed) {
|
} else if (vss.Value < unlockSpeed) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ void Gm4l6xTransmissionController::set32State(gear_e gear) {
|
||||||
if (!vss.Valid) {
|
if (!vss.Valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//huh?uint8_t (*pcts)[sizeof(config->tcu_32SpeedBins)/sizeof(config->tcu_32SpeedBins[0])];
|
|
||||||
int pct = interpolate2d(vss.Value, config->tcu_32SpeedBins, config->tcu_32Vals);
|
int pct = interpolate2d(vss.Value, config->tcu_32SpeedBins, config->tcu_32Vals);
|
||||||
shift32Pwm.setSimplePwmDutyCycle(pct*0.01);
|
shift32Pwm.setSimplePwmDutyCycle(pct*0.01);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,6 +38,7 @@ void TransmissionControllerBase::postState() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// call to mark the start of the shift
|
||||||
void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
||||||
m_shiftTime = true;
|
m_shiftTime = true;
|
||||||
m_shiftTimer.reset();
|
m_shiftTimer.reset();
|
||||||
|
@ -47,13 +48,17 @@ void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
||||||
float TransmissionControllerBase::isShiftCompleted() {
|
float TransmissionControllerBase::isShiftCompleted() {
|
||||||
auto detected = Sensor::get(SensorType::DetectedGear);
|
auto detected = Sensor::get(SensorType::DetectedGear);
|
||||||
auto iss = Sensor::get(SensorType::InputShaftSpeed);
|
auto iss = Sensor::get(SensorType::InputShaftSpeed);
|
||||||
|
// If gear detection is set up and the gear we are trying to shift into has been detected
|
||||||
if (detected.Valid && m_shiftTime && m_shiftTimeGear == detected.Value) {
|
if (detected.Valid && m_shiftTime && m_shiftTimeGear == detected.Value) {
|
||||||
m_shiftTime = false;
|
m_shiftTime = false;
|
||||||
return m_shiftTimer.getElapsedSeconds();
|
return m_shiftTimer.getElapsedSeconds();
|
||||||
|
// If ISS isn't configured, we want to use a fixed value.
|
||||||
} else if (!iss.Valid && m_shiftTime && m_shiftTimer.hasElapsedMs(config->tcu_shiftTime)) {
|
} else if (!iss.Valid && m_shiftTime && m_shiftTimer.hasElapsedMs(config->tcu_shiftTime)) {
|
||||||
m_shiftTime = false;
|
m_shiftTime = false;
|
||||||
|
// convert ms to seconds for gauge
|
||||||
return config->tcu_shiftTime * 0.001;
|
return config->tcu_shiftTime * 0.001;
|
||||||
} else {
|
} else {
|
||||||
|
// a return value of 0 means the shift is not completed yet
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue