From b65e7b49c6baa5101181d83a3ee2a4f7f22bf612 Mon Sep 17 00:00:00 2001 From: tomdebree Date: Wed, 1 May 2024 10:15:46 +0100 Subject: [PATCH] Reverse Motor Fix Outland Rear Clean up the serttings of reversemotor param, force zero for all except outlander rear. Correction for unsigned torque request number when using negatives. --- include/param_prj.h | 2 +- src/RearOutlanderinverter.cpp | 14 ++++++++------ src/stm32_vcu.cpp | 12 +++++++----- src/throttle.cpp | 1 - 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/param_prj.h b/include/param_prj.h index cf4c87f3..12f360ca 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.15.A +#define VER 2.17.A /* Entries must be ordered as follows: diff --git a/src/RearOutlanderinverter.cpp b/src/RearOutlanderinverter.cpp index 56710abe..e6cce3c6 100644 --- a/src/RearOutlanderinverter.cpp +++ b/src/RearOutlanderinverter.cpp @@ -58,17 +58,19 @@ void RearOutlanderInverter::DecodeCAN(int id, uint32_t data[2]) } } - - void RearOutlanderInverter::SetTorque(float torquePercent) { - final_torque_request = ((torquePercent * 2000) / 100.0f ); //!! Moved into parameter *-1 reverses torque direction - if(Param::GetInt(Param::reversemotor) == 1) + if(Param::GetInt(Param::reversemotor) == 0) + { + + final_torque_request = 10000 + (torquePercent * 20); //!! Moved into parameter *-1 reverses torque direction + } + else { - final_torque_request *= -1;//reverse torque request to flip motor rotation + final_torque_request = 10000 - (torquePercent * 20); } - final_torque_request += 10000; + Param::SetInt(Param::torque,final_torque_request);//post processed final torque value sent to inv to web interface } diff --git a/src/stm32_vcu.cpp b/src/stm32_vcu.cpp index badfc005..21876da1 100644 --- a/src/stm32_vcu.cpp +++ b/src/stm32_vcu.cpp @@ -532,8 +532,8 @@ static void Ms10Task(void) 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(); - DigIo::inv_out.Set();//inverter power on + DigIo::dcsw_out.Set(); + DigIo::inv_out.Set();//inverter power on } Param::SetInt(Param::opmode, MOD_RUN); ErrorMessage::UnpostAll(); @@ -631,8 +631,6 @@ static void UpdateVehicle() //This will call SetCanFilters() via the Clear Callback canInterface[0]->ClearUserMessages(); canInterface[1]->ClearUserMessages(); - - Param::SetFloat(Param::AC_Amps, Param::Vehicle); } static void UpdateCharger() @@ -878,7 +876,11 @@ void Param::Change(Param::PARAM_NUM paramNum) if(Param::GetInt(Param::reversemotor) != 0) { - if(Param::GetInt(Param::Inverter) != InvModes::Leaf_Gen1 ||Param::GetInt(Param::Inverter) != InvModes::RearOutlander) + if(Param::GetInt(Param::Inverter) == InvModes::RearOutlander) + { + + } + else { Param::SetInt(Param::reversemotor,0); } diff --git a/src/throttle.cpp b/src/throttle.cpp index 6c2ddf70..0a02dbb8 100644 --- a/src/throttle.cpp +++ b/src/throttle.cpp @@ -167,7 +167,6 @@ float Throttle::CalcThrottle(int potval, int potIdx, bool brkpedal) speed = SpeedFiltered; - Param::SetFloat(Param::AC_Volts, speed); /////////////////////// if(dir == 0)//neutral no torque command