diff --git a/include/outlanderCharger.h b/include/outlanderCharger.h index 182c6de6..63d81500 100644 --- a/include/outlanderCharger.h +++ b/include/outlanderCharger.h @@ -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]); diff --git a/include/param_prj.h b/include/param_prj.h index ba5e403e..97e198ec 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#define VER 2.20.TM +#define VER 2.20.TN /* Entries must be ordered as follows: @@ -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 ) \ @@ -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" diff --git a/src/GS450H.cpp b/src/GS450H.cpp index 76269631..a4a4924b 100644 --- a/src/GS450H.cpp +++ b/src/GS450H.cpp @@ -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 @@ -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); @@ -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 { @@ -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 { @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/outlanderCharger.cpp b/src/outlanderCharger.cpp index 0526dd5b..0fbaf3ff 100644 --- a/src/outlanderCharger.cpp +++ b/src/outlanderCharger.cpp @@ -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) @@ -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]) diff --git a/src/stm32_vcu.cpp b/src/stm32_vcu.cpp index a209a9c2..7e733a5d 100644 --- a/src/stm32_vcu.cpp +++ b/src/stm32_vcu.cpp @@ -506,7 +506,7 @@ static void Ms10Task(void) selectedChargeInt->Task10Ms(); - if (Param::GetInt(Param::opmode) == MOD_RUN) + if (Param::GetInt(Param::opmode) == MOD_RUN) //!!!THROTTLE CODE HERE// { torquePercent = utils::ProcessThrottle(ABS(previousSpeed)); //run the throttle reading and checks and then generate Potnom @@ -546,15 +546,30 @@ static void Ms10Task(void) selectedInverter->SetTorque(torquePercent); - //Brake light based on regen being below the set threshold - if(torquePercent < Param::GetFloat(Param::RegenBrakeLight)) + //Brake light based on regen being below the set threshold !! this logic needs verifying + if(Param::GetInt(Param::reversemotor) == 0) { - //enable Brake Light Ouput - IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set(); + if((torquePercent * requestedDirection) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1 + { + //enable Brake Light Ouput + IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set(); + } + else + { + IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear(); + } } - else + else //Motor torques flipped so need to flip again { - IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear(); + 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(); + } + else + { + IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear(); + } } //speed = ABS(selectedInverter->GetMotorSpeed());//set motor rpm on interface NO ABS allowed on speed as we need to know direction @@ -589,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())) @@ -667,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); @@ -679,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); diff --git a/src/utils.cpp b/src/utils.cpp index 9338571f..22bad4f0 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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