Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update shutdown delay #118

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/outlanderCharger.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ bool clearToStart=false , shutDownReq=false, pwmON=false;
static uint8_t chgStatus , evseDuty;
static float dcBusV , temp_1 , temp_2 , ACVolts , DCAmps , ACAmps;
static float LV_Volts , LV_Amps;
static uint16_t batteryVolts;

static void handle377(uint32_t data[2]);
static void handle389(uint32_t data[2]);
Expand Down
6 changes: 3 additions & 3 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define VER 2.20.TM
#define VER 2.20.TN


/* Entries must be ordered as follows:
Expand Down Expand Up @@ -75,7 +75,7 @@
PARAM_ENTRY(CAT_THROTTLE, throtdead, "%", 0, 50, 10, 76 ) \
PARAM_ENTRY(CAT_THROTTLE, RegenBrakeLight, "%", -100, 0, -15, 128 ) \
PARAM_ENTRY(CAT_THROTTLE, throtrpmfilt, "rpm/10ms", 0.1, 200, 15, 131 ) \
PARAM_ENTRY(CAT_LEXUS, Gear, LOWHIGH, 0, 2, 0, 27 ) \
PARAM_ENTRY(CAT_LEXUS, Gear, LOWHIGH, 0, 3, 0, 27 ) \
PARAM_ENTRY(CAT_LEXUS, OilPump, "%", 0, 100, 50, 28 ) \
PARAM_ENTRY(CAT_CRUISE, cruisestep, "rpm", 1, 1000, 200, 29 ) \
PARAM_ENTRY(CAT_CRUISE, cruiseramp, "rpm/100ms",1, 1000, 20, 30 ) \
Expand Down Expand Up @@ -271,7 +271,7 @@
#define CCS_STATUS "0=NotRdy, 1=ready, 2=SWoff, 3=interruption, 4=Prech, 5=insulmon, 6=estop, 7=malfunction, 15=invalid"
#define DIRS "-1=Reverse, 0=Neutral, 1=Drive, 2=Park"
#define ONOFF "0=Off, 1=On, 2=na"
#define LOWHIGH "0=LOW, 1=HIGH, 2=AUTO"
#define LOWHIGH "0=LOW, 1=HIGH, 2=AUTO, 3=HIGHFWDLOWREV"
#define OKERR "0=Error, 1=Ok, 2=na"
#define CANSPEEDS "0=125k, 1=250k, 2=500k, 3=800k, 4=1M"
#define CANIOS "1=Cruise, 2=Start, 4=Brake, 8=Fwd, 16=Rev, 32=Bms"
Expand Down
2 changes: 1 addition & 1 deletion libopencm3
Submodule libopencm3 updated 276 files
47 changes: 32 additions & 15 deletions src/GS450H.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static uint8_t mth_data[140];
static const uint8_t htm_data_setup[100]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,25,0,0,0,0,0,0,0,128,0,0,0,128,0,0,0,37,1};
static uint8_t htm_data[105]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0};
static const uint8_t htm_data_GS300H[105]= {0,14,0,2,0,0,0,0,0,0,0,0,0,23,0,97,0,0,0,0,0,0,0,248,254,8,1,0,0,0,0,0,0,22,0,0,0,0,0,23,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,23,0,75,22,47,250,137,14,0,0,23,0,0,0,0,201,0,218,0,16,0,0,0,29,0,0,0,0,0,0
};
};
static const uint8_t htm_data_Prius[100] = {0,30,0,2,0,0,0,55,0,128,254,0,0,40,0,97,0,0,0,0,0,0,136,249,120,6,143,255,50,255,48,255,49,0,0,0,48,255,43,0,1,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,40,0,75,33,68,246,51,8,0,0,40,0,0,0,201,0,222,0,16,0,0,0,211,40,0,0,62,15};

#if 0
Expand Down Expand Up @@ -138,9 +138,9 @@ void GS450HClass::SetTorque(float torquePercent)
{
mg1_torque = 0;
}
else if(MotorActive == 3)//MG1 only at high torque
else if(MotorActive == 3)//MG1 only at high torque
{
mg1_torque = 0;
mg1_torque = 0;
if(torquePercent > 50)//only have MG1 active above 50%
{
mg1_torque = utils::change(torquePercent,50,100,0,4375);
Expand Down Expand Up @@ -194,14 +194,14 @@ void GS450HClass::SetTorque(float torquePercent)
{
mg1_torque = 0;
}
else if(MotorActive == 3)//MG1 only at high torque
{
mg1_torque = 0;
if(torquePercent > 50)//only have MG1 active above 50%
{
mg1_torque = utils::change(torquePercent,50,100,0,4375);
}
}
else if(MotorActive == 3)//MG1 only at high torque
{
mg1_torque = 0;
if(torquePercent > 50)//only have MG1 active above 50%
{
mg1_torque = utils::change(torquePercent,50,100,0,4375);
}
}
}
else
{
Expand Down Expand Up @@ -238,7 +238,7 @@ void GS450HClass::GS450Hgear()//!!! should be ran every 10ms - ran before calcul
//Param::SetInt(Param::InvStat, GS450HClass::statusFB()); //update inverter status on web interface
gear=(Param::GetInt(Param::Gear));

if(gear == 2)//!!!Auto Shifting using code from AK - Always start in low gear when powered on
if(gear == 2)//!!!Auto Shifting always start in low gear when powered on
{
if(gearAct == 0 && mg2_speed > 7000) //Shift up when in low gear and mg2 is over 7000rpm
{
Expand Down Expand Up @@ -290,6 +290,23 @@ void GS450HClass::GS450Hgear()//!!! should be ran every 10ms - ran before calcul
DigIo::SL1_out.Set();
DigIo::SL2_out.Set();
}

if (gear == 3) //!!!High in FWD and Low in REV - Jamie Jones special
{
int dir = Param::GetInt(Param::dir);
if (dir == -1) //reverse go low
{
DigIo::SP_out.Clear();
DigIo::SL1_out.Set();
DigIo::SL2_out.Set();
}
else //go high
{
DigIo::SP_out.Clear();
DigIo::SL1_out.Clear();
DigIo::SL2_out.Clear();
}
}
}

void GS450HClass::GS450Houtput()//!!! should be ran every 10ms
Expand Down Expand Up @@ -414,7 +431,7 @@ void GS450HClass::Task1Ms()
if(VerifyMTHChecksum(100)==0 || dma_get_interrupt_flag(DMA1, DMA_CHANNEL6, DMA_TCIF)==0)
{
statusInv=0;
//set speeds to 0 to prevent dynamic throttle/regen issues
//set speeds to 0 to prevent dynamic throttle/regen issues
mg1_speed=0;
mg2_speed=0;
//disable cruise
Expand Down Expand Up @@ -529,7 +546,7 @@ void GS450HClass::Task1Ms()
{

statusInv=0;
//set speeds to 0 to prevent dynamic throttle/regen issues
//set speeds to 0 to prevent dynamic throttle/regen issues
mg1_speed=0;
mg2_speed=0;
//disable cruise
Expand Down Expand Up @@ -668,7 +685,7 @@ void GS450HClass::Task1Ms()

statusInv=0;
//inv_status=0; Stop reinit of inverter
//set speeds to 0 to prevent dynamic throttle/regen issues
//set speeds to 0 to prevent dynamic throttle/regen issues
mg1_speed=0;
mg2_speed=0;
//disable cruise
Expand Down
8 changes: 8 additions & 0 deletions src/outlanderCharger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ float outlanderCharger::ACAmps;
float outlanderCharger::DCAmps;
float outlanderCharger::LV_Volts;
float outlanderCharger::LV_Amps;
uint16_t outlanderCharger::batteryVolts;


bool outlanderCharger::ControlCharge(bool RunCh, bool ACReq)
Expand Down Expand Up @@ -230,8 +231,15 @@ void outlanderCharger::handle389(uint32_t data[2])
ACVolts = bytes[1]; //AC voltage measured at charger. Scale 1 to 1.
ACAmps = bytes[6] * 0.1; //Current in Amps from mains. scale 0.1.
DCAmps = bytes[2] * 0.1; //Current in Amps from charger to battery. scale 0.1.
batteryVolts = bytes[0] * 2;

Param::SetFloat(Param::AC_Volts, ACVolts);
Param::SetFloat(Param::AC_Amps, ACAmps);

if (Param::GetInt(Param::ShuntType) == 0 && Param::GetInt(Param::Inverter)!= 1)//Only populate if no shunt is used and not using Leaf inverter !!!look to clean up
{
Param::SetFloat(Param::udc, batteryVolts);
}
}

void outlanderCharger::handle38A(uint32_t data[2])
Expand Down
25 changes: 17 additions & 8 deletions src/stm32_vcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static void Ms10Task(void)

selectedInverter->SetTorque(torquePercent);

//Brake light based on regen being below the set threshold
//Brake light based on regen being below the set threshold !! this logic needs verifying
if(Param::GetInt(Param::reversemotor) == 0)
{
if((torquePercent * requestedDirection) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1
Expand All @@ -561,7 +561,7 @@ static void Ms10Task(void)
}
else //Motor torques flipped so need to flip again
{
if((torquePercent * requestedDirection * -1) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1, reversed again for MotRev
if((torquePercent * requestedDirection) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1, reversed again for MotRev
{
//enable Brake Light Ouput
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set();
Expand Down Expand Up @@ -604,13 +604,19 @@ static void Ms10Task(void)
initbyStart=false;
initbyCharge=false;
DigIo::inv_out.Clear();//inverter power off
DigIo::dcsw_out.Clear();
IOMatrix::GetPin(IOMatrix::NEGCONTACTOR)->Clear();//Negative contactors off if used
IOMatrix::GetPin(IOMatrix::COOLANTPUMP)->Clear();//Coolant pump off if used
DigIo::prec_out.Clear();
Param::SetInt(Param::dir, 0); // shift to park/neutral on shutdown regardless of shifter pos
selectedVehicle->DashOff();
StartSig=false;//reset for next time

if(rlyDly!=0) rlyDly--;//here we are going to pause to allow system shut down before opening HV contactors
if(rlyDly==0)
{
DigIo::dcsw_out.Clear();
IOMatrix::GetPin(IOMatrix::NEGCONTACTOR)->Clear();//Negative contactors off if used
DigIo::prec_out.Clear();
}

if(Param::GetInt(Param::pot) < Param::GetInt(Param::potmin))
{
if ((selectedVehicle->Start() && selectedVehicle->Ready()))
Expand Down Expand Up @@ -682,7 +688,11 @@ static void Ms10Task(void)

case MOD_CHARGE:
if(rlyDly!=0) rlyDly--;//here we are going to pause before energising precharge to prevent too many contactors pulling amps at the same time
if(rlyDly==0) DigIo::dcsw_out.Set();
if(rlyDly==0)
{
DigIo::dcsw_out.Set();
rlyDly=25;//Recharge sequence timer
}
ErrorMessage::UnpostAll();
if(!chargeMode) opmode = MOD_OFF;
Param::SetInt(Param::opmode, opmode);
Expand All @@ -694,14 +704,13 @@ static void Ms10Task(void)
{
DigIo::dcsw_out.Set();
DigIo::inv_out.Set();//inverter power on
rlyDly=25;//Recharge sequence timer
}
Param::SetInt(Param::opmode, MOD_RUN);
ErrorMessage::UnpostAll();
if(!selectedVehicle->Ready()) opmode = MOD_OFF;
Param::SetInt(Param::opmode, opmode);
break;


}

ControlCabHeater(opmode);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void GS450hOilPump(uint16_t pumpdc)
{
if(pumpdc>9)
{
pumpdc = utils::change(pumpdc, 10, 80, 425, 1875); //map oil pump pwm to timer
pumpdc = utils::change(pumpdc, 10, 80, 1875, 425); //map oil pump pwm to timer
pumpdc = pumpdc * 0.5;//Scalar increase 2x so duty is period is halved and so is DC.
}
else
Expand Down
Loading