Here is my the function for selecting gears:
Code: Select all
void setGear()
{
if (RequestedGear ^ CurrentGear) //gear shift requested
{
TorqueRestoreOK = false; //put torque restore on hold
TorquePercent = 0; //reduce torque
if (GearShiftInit = 0)
{
GearShiftInit = millis();
}
if(RequestedGear) //upshift into "High Gear"
{
//TODO: confirm torque reduction reading from MTH data
//if (since_last_packet > 1000) //wait for next 2 packages to be send to Inverter (1 every 1000us)
if (millis() - GearShiftInit > 10)//wait 10ms
{
digitalWrite(TransSL1,LOW);
digitalWrite(TransSL2,LOW);
}
//if(!digitalRead(TransPB1) || //when pressure is present on Brake 2
// abs(mg2_speed) < 100) //or low RPM
if (millis() - GearShiftInit > 20)//wait 10ms
{
CurrentGear = RequestedGear; //update current
TorqueRestoreOK = true; //allow to restore torque
GearShiftInit = 0;
}
}
else //downshift into "Low Gear"
{
if (millis() - GearShiftInit > 10)
{
digitalWrite(TransSL1,HIGH);
digitalWrite(TransSL2,HIGH);
}
//if(!digitalRead(TransPB2) || //when pressure is present on Brake 2
// abs(mg2_speed) < 100) //or low RPM
if (millis() - GearShiftInit > 20)//wait 10ms
{
CurrentGear = RequestedGear; //update current
TorqueRestoreOK = true; //allow to restore torque
GearShiftInit = 0;
}
}
}
}
It worked fine at stand still and also while driving gently at modest speeds but was not smooth enough.
It needs refining for sure so use it as a guideline only, some comments may be useful.
One thing that is missing here I did not have time to test is control of the "SP" solenoid which I believe allows to modulate pressure. Perhaps it is a key to smooth shifting.
As I mentioned this comes from my highly customized software based on Damien's v7 which came way before "User friendly" version became available.
I do not have ability at the moment to integrate it with current codebase therefore I cannot push this code into repository.
Bryson if you cant tweak it to work with latest version of the code then go ahead and integrate it.
BTW, I am feeling better but it will take many more weeks before I can actually do something productive. I will get there though, thanks!