Add some comments
This commit is contained in:
parent
649e7cf149
commit
e33cd6009d
|
@ -43,6 +43,8 @@ void GenericGearController::update() {
|
|||
// Loop through inputs
|
||||
for (size_t p = 0; p < efi::size(engineConfiguration->tcu_rangeInput); 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])) {
|
||||
float pinState = Sensor::getOrZero(getAnalogSensorType(p));
|
||||
if (isNearest(pinState, p, rangeStates)) {
|
||||
|
@ -96,6 +98,8 @@ void GenericGearController::update() {
|
|||
setDesiredGear(NEUTRAL);
|
||||
break;
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
@ -115,6 +119,8 @@ void GenericGearController::update() {
|
|||
}
|
||||
break;
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
@ -134,6 +140,8 @@ void GenericGearController::update() {
|
|||
}
|
||||
break;
|
||||
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();
|
||||
return;
|
||||
default:
|
||||
|
|
|
@ -29,7 +29,7 @@ void GearControllerBase::update() {
|
|||
if (transmissionController == NULL) {
|
||||
initTransmissionController();
|
||||
} else if (transmissionController->getMode() != engineConfiguration->transmissionControllerMode) {
|
||||
// TODO de-init here
|
||||
// TODO de-init here to allow change without power cycling
|
||||
initTransmissionController();
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,10 @@ void initGearController() {
|
|||
}
|
||||
|
||||
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) {
|
||||
case 1 :
|
||||
return config->tcu_rangePlus;
|
||||
|
|
|
@ -27,6 +27,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
|||
measureShiftTime(gear);
|
||||
}
|
||||
|
||||
// set torque converter and pressure control state
|
||||
setTccState(gear);
|
||||
setPcState(gear);
|
||||
|
||||
|
@ -35,6 +36,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
|||
SimpleTransmissionController::update(gear);
|
||||
|
||||
float time = isShiftCompleted();
|
||||
// 0 means shift is not completed
|
||||
if (time != 0) {
|
||||
lastShiftTime = time;
|
||||
isShifting = false;
|
||||
|
@ -42,6 +44,7 @@ void Generic4TransmissionController::update(gear_e gear) {
|
|||
}
|
||||
|
||||
void Generic4TransmissionController::setTccState(gear_e gear) {
|
||||
// disable if shifting
|
||||
if (isShifting) {
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(0);
|
||||
return;
|
||||
|
@ -52,10 +55,12 @@ void Generic4TransmissionController::setTccState(gear_e gear) {
|
|||
if (!tps.Valid || !vss.Valid) {
|
||||
return;
|
||||
}
|
||||
// only enable TC in gear 4
|
||||
if (gear == 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) {
|
||||
// torqueConverterDuty is only used for a gauge
|
||||
torqueConverterDuty = 100;
|
||||
enginePins.tcuTccOnoffSolenoid.setValue(1);
|
||||
} else if (vss.Value < unlockSpeed) {
|
||||
|
|
|
@ -39,7 +39,7 @@ void Gm4l6xTransmissionController::set32State(gear_e gear) {
|
|||
if (!vss.Valid) {
|
||||
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);
|
||||
shift32Pwm.setSimplePwmDutyCycle(pct*0.01);
|
||||
} else {
|
||||
|
|
|
@ -38,6 +38,7 @@ void TransmissionControllerBase::postState() {
|
|||
#endif
|
||||
}
|
||||
|
||||
// call to mark the start of the shift
|
||||
void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
||||
m_shiftTime = true;
|
||||
m_shiftTimer.reset();
|
||||
|
@ -47,13 +48,17 @@ void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
|||
float TransmissionControllerBase::isShiftCompleted() {
|
||||
auto detected = Sensor::get(SensorType::DetectedGear);
|
||||
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) {
|
||||
m_shiftTime = false;
|
||||
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)) {
|
||||
m_shiftTime = false;
|
||||
// convert ms to seconds for gauge
|
||||
return config->tcu_shiftTime * 0.001;
|
||||
} else {
|
||||
// a return value of 0 means the shift is not completed yet
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue