Outlander VCU - Rear inverter, Charger and BMS

Mitsubishi hybrid drive unit hacking
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

I measured acceleration at 15s from 0 to 100km/h....
I made some effort to play with map3 and changed some values at the first section up to 2500rpm from 7 to 15! This notably increased responsiveness from takeoff. At second try i got 14.4s to 100km/h. I am sure i could do even better....
Attachments
Screenshot_20240210-143555_Dragger.jpg
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by aot93 »

Did you also change or comment out the over torque check in the code?

I ask as a value of 15 in the map would be 150% of 200nm so 300nm
Would be interesting to see how much the inverter thinks it's putting out.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

aot93 wrote: Sun Feb 11, 2024 12:11 pm Did you also change or comment out the over torque check in the code?
No i kept it in as i thought final sanity check might help :).
I just prepared a new map for test

Code: Select all

 const int pedal_map_three[21][22] = {
    // Sport
    // map 3..
    /*250*/ {0, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*500*/ {-10, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*625*/ {-20, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*750*/ {-30, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*1000*/ {-50, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*1250*/ {-70, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*1500*/ {-90, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*2000*/ {-110, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*2500*/ {-130, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*3000*/ {-150, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*3500*/ {-150, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*4000*/ {-150, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*4500*/ {-150, 0, 18, 20, 20, 20, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18},
    /*5000*/ {-160, 0, 15, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 15, 15, 15, 15, 16, 18, 18},
    /*5500*/ {-180, 0, 15, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 15, 15, 15, 15, 16, 18, 18},
    /*6000*/ {-200, 0, 15, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 15, 15, 15, 15, 16, 18, 18},
    /*6500*/ {-200, 0, 15, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 18, 18},
    /*7000*/ {-225, 0, 15, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 18, 18},
    /*7500*/ {-250, 0, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 18, 18},
    /*8000*/ {-300, 0, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 18, 18},
    /*10000*/ {-300, 0, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 18, 18},
};
I may try to remove the limits or simply increase it to 250Nm or similar, just to see what will happen.
Mazda V6 engine used to have 230Nm of max torque at 5300RPM...

EDIT: Whoa! Torque at start was huge with value 25! I could easily shave tires... But very soon torqueRequest = 0; reduction kicked in.
So for another attempt i reduced values to 20 and changed torque reduction to torqueRequest = 2000; So as to stop adding to torque but keep the torque already requested.

Code: Select all

if (torqueRequest > (2000))
    {
      torqueRequest = 2000; // max value is reached
      Serial.println("--!OVER TOURQUE!--");
    }
    if (torqueRequest < (-2000))
    {
      torqueRequest = -2000; // min value is reached
      Serial.println("--!UNDER TOURQUE!--");
    }
EDIT2: Yep! As i thought. With all those changes motor will just about spin tires on the spot. Acceleration is much more healthy and torqueRequest will stop at 2000 mark. Max amps will reach 220A and never exceed that limit. Even regen is behaving softly at 25A. All this in pedal map3 without any increments. I must say i really like map3 logic.

There is a dark side though, When in map1 there is a rubbery feeling of throttle effect. Also suddenly throttle would go from 100% to 0 and create a sudden jolt. I abhore map1 and its incremented torque. Seems unnatural.

EDIT3: To remedy this i remodeled map1 and still i get unnatural acceleration/decelleration with increments. But now when in overtorque torqueRequest goes to final value at least it wont jolt the car anymore...
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by aot93 »

Ok so I think we can say your application does not need any ramping to control wheelspin.
I would suggested removing it and simplifying the code, your fork is quite far from mine now so It's hard to debug any issues you are having

I would be interested to see if you can actually command (and get) more than 200nm from the inverter
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

aot93 wrote: Tue Feb 13, 2024 2:17 pm Ok so I think we can say your application does not need any ramping to control wheelspin.
I would suggested removing it and simplifying the code, your fork is quite far from mine now so It's hard to debug any issues you are having

I would be interested to see if you can actually command (and get) more than 200nm from the inverter
Yes thank yxou for your help. I suspect i can already get up to 230Nm. I assume this empyrically as i corrected my code in part of max torque limiter where i set 2300 as the limit. And result was 240A current when accelerating where before it was only 210A.
I will confirm this further by openning up the limit to 280Nm and see if there is any change in amp draw.

EDIT: I tried to remove incrementing from map1 and it worked the same asa for map3. In addition i inhibited all regen when in map1. This should be used when in rainy or icy conditions due to possible wheel lock.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

Now finally everything works as it should with VCU. I got good acceleration, good regen response, Nice reverse drive and everything connected to Outlander components is operating aas it should.

Acceleration at 13s now. I managed 11s with large torque swings, but it was not comfortable. I setup all around comfortable ride.

There are some weird things i noticed though... after some 2 days of non use i would start the car and immediately i would get weird shakes from throttle in both directions. Myap 3 as well as map1! After i would reset the VCU power everything would go back to normal. I guess i would have to create some sort of VCU reset when itis inactive... lets think...

In the mean time i noticed i get absolutely nothing from CAN1 or CAN3. CAN1 is my BMS at 250kbaud and it is totally silent...
@aot93 or @midway can you verify you get CAN traffic out of your VCU?
tnx
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

arber333 wrote: Wed Feb 14, 2024 6:10 pm Now finally everything works as it should with VCU. I got good acceleration, good regen response, Nice reverse drive and everything connected to Outlander components is operating aas it should.

Acceleration at 13s now. I managed 11s with large torque swings, but it was not comfortable. I setup all around comfortable ride.

There are some weird things i noticed though... after some 2 days of non use i would start the car and immediately i would get weird shakes from throttle in both directions. Myap 3 as well as map1! After i would reset the VCU power everything would go back to normal. I guess i would have to create some sort of VCU reset when itis inactive... lets think...

In the mean time i noticed i get absolutely nothing from CAN1 or CAN3. CAN1 is my BMS at 250kbaud and it is totally silent...
@aot93 or @midway can you verify you get CAN traffic out of your VCU?
tnx
All three can bus work fine for me. One balancer did not respond well to requests, I replaced it.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

midway wrote: Thu Feb 15, 2024 6:11 am All three can bus work fine for me. One balancer did not respond well to requests, I replaced it.
Tnx i will look into why i cant get any traffic on the lines...

On the other hand i see very little torque in reverse. Today i tested this driving in a small hill. It was embarrasing :(. How to up this a little?
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

arber333 wrote: Thu Feb 15, 2024 3:35 pm Tnx i will look into why i cant get any traffic on the lines...

On the other hand i see very little torque in reverse. Today i tested this driving in a small hill. It was embarrasing :(. How to up this a little?
I also have little torque in reverse. Probably here

Code: Select all

 BMS_keyOn = 1;             // enable the inverter
    digitalWrite(OUT12, HIGH); // Turn on the reversing lights

    if (throttlePosition > 5)
    {
      torqueRequest = throttlePosition * -6; // lets make the pedal less responsive
      inverterFunction = 0x03;
      if (motorRPM < -2000)
      {
        torqueRequest = 0;
      }
    }

    if (brake_pedal == 0)
    {
      torqueRequest = 0; // 0 Torque if the brake is presed
    }
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by aot93 »

Yes that's the torque and speed limit in reverse.

Change the -6 for more torque
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

aot93 wrote: Fri Feb 16, 2024 2:25 pm Change the -6 for more torque
So do i go less than -6? Ok like if the higher number makes more torque? ...

Hm... should i increase this condition for throttle position too?

Code: Select all

   if (throttlePosition > 6)    {
      torqueRequest = throttlePosition * 6; // lets make the pedal less responsive *6
      inverterFunction = 0x03;
      if (motorRPM < -2000)
      {
        torqueRequest = 0;
      }   }
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by aot93 »

Yes it should be a lower number, I'm not sure where you are doing the flip for reverse now, in OEM orientation -20 should map to -200nm at 100% pedal.

Throttle position is just to add a little extra dead zone to the pedal to catch accidental blips, you could set this to 1. Personally i would keep to low values max 5.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

I got it now thanks! Reverse is now good even in uphill.

Next i tackled the missing CAN traffic on CAN1 that i setup for JK BMS comms. I found out there was really bad 3V3 connection and i resoldered this link. Now i get good traffic. Because i didnt want to connect BMS requests to shady timers i opened another HW timer and setup its triggering

Code: Select all

IntervalTimer BMSread; // declare fixed timer
....
 BMSread.begin(BMS_Stat, 500000); //in setup call out function BMS_Stat
....
This now works very well at about 1/2s.

But no matter what i do i dont get complete voltage array and value out of BMS telegrams...
My BMS read function is like this...
@midway can you comment if i got everything correct? It seems i cant compile part of your code for BMS CAN msg filter

Code: Select all

void canRX_001(const CAN_message_t &msg); // i declare function for BMS Status 
...
  //Can1.setMBFilter(MB1, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07); // i get an error from compiler when i try this
  Can1.setMBFilterRange(MB1, 0x01,0x07); // this compiles well, but i dont see any result
...
void canRX_001(const CAN_message_t &msg) // actual function to sense voltages
{

if (msg.buf[0] == 1)
  {
   BMS_avgvolt=max(BMS_avgvolt,((msg.buf[5] / 1000.0) * 256) + (msg.buf[6] / 1000.0)); 
     BMS_avgtmp = max(BMS_avgtmp,(msg.buf[2] + msg.buf[1]) + 8);
  }

  if (msg.buf[0] == 4)
  {
  if (msg.buf[1] < 19)

  {
    if (msg.id == 0x01)
  {
      //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1]] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 1] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 2] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }
  if (msg.id == 0x02)
  {
      //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 13] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 14] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 15] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }
  if (msg.id == 0x03)
  {
      //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 25] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 26] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 27] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }
  if (msg.id == 0x04)
  {
         //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 37] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 38] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 39] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }

      if (msg.id == 0x05)
  {
         //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 49] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 50] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 52] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }

   if (msg.id == 0x06)
  {
         //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 61] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 62] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 63] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }   

  if (msg.id == 0x07)
  {
         //BMS_avgtmp4=0;
    //BMS_packvoltage4 = 0;
    BMS_Volt[msg.buf[1] + 73] = (((msg.buf[2] / 1000.0) * 256) + (msg.buf[3] / 1000.0));
    BMS_Volt[msg.buf[1] + 74] = (((msg.buf[4] / 1000.0) * 256) + (msg.buf[5] / 1000.0));
    BMS_Volt[msg.buf[1] + 75] = (((msg.buf[6] / 1000.0) * 256) + (msg.buf[7] / 1000.0));
  }
    
  }
   }

 // Serial.println(msg.id);
if (msg.buf[0] == 0x01)
  {
   // BMS_avgtmp1=0;
   // BMS_packvoltage1 = 0;
     }

 // BMS_SOC = ((msg.buf[1] * 256) + msg.buf[0]);
  //BMS_avgtmp = (((msg.buf[5] / 10.0) * 256) + (msg.buf[4] / 10.0));
  //BMS_Status = 3;

  if (BMS_Status == 5)
  {
    if (VCUstatusChangeCounter > VCUstatusChangeThreshold)

      VCUstatusChangeCounter = 0;
    VCUstatus = 7;
  }
  else
  {
    VCUstatusChangeCounter++;
  }
}
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

Are certain BMSs not included in the array, or is data from one BMS partially missing?
I only use data from cells that are not repeated in the array.
I have an 84 cell battery, 4 pieces of BMS.
21cell+3cells
21cell+3cells
21cell+3cell
21cell.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

midway wrote: Sun Feb 18, 2024 4:48 pm Are certain BMSs not included in the array, or is data from one BMS partially missing?
I have 84S cells as well. But i use 7 BMS modules. Each BMS module is connected to 12S battery module as this was the easiest. When i connect to CAN lines i can see the FF request going out and i see all 7 modules reporting on the line. Everything is good on the lines but VCU does not read the telegrams and fill in the array. I dont know if i put anything bad in the code...

My updated working code is here...
https://github.com/arber333/Mini-E-VCU
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

arber333 wrote: Sun Feb 18, 2024 6:11 pm I have 84S cells as well. But i use 7 BMS modules. Each BMS module is connected to 12S battery module as this was the easiest. When i connect to CAN lines i can see the FF request going out and i see all 7 modules reporting on the line. Everything is good on the lines but VCU does not read the telegrams and fill in the array. I dont know if i put anything bad in the code...

My updated working code is here...
https://github.com/arber333/Mini-E-VCU
You need to check the response message from BMS

Code: Select all

void canRX_001(const CAN_message_t &msg)
{
Serial.println(msg.id);
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

midway wrote: Mon Feb 19, 2024 7:28 am You need to check the response message from BMS

Code: Select all

void canRX_001(const CAN_message_t &msg)
{
Serial.println(msg.id);
Hm... i still have to verify this. In the meantime i noticed my speedo function is misbehaving. The needle is oscillating a lot. I use Tone function for this as it can quickly vary frequency for the output. Now this Tone function is quite interrupt intensive process and it seems something is interfering with interrupts.
After longer observation i found speedo works good up to 40km/h and then starts to throw the needle...
I may have to make a separete BMS module to relese interrupts because BMS function is the only new addition after successful drive.
User avatar
rstevens81
Posts: 353
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 23 times
Been thanked: 92 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by rstevens81 »

Am I understanding this thread correct you are able to command 280Nm from the stock inverter? I assume that means that you are exceeding the stock 60kw power output? Or is it just hitting 60kw at lower rpm? (I assume current is recorded from the shunt?)
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

rstevens81 wrote: Mon Feb 19, 2024 8:55 pm Am I understanding this thread correct you are able to command 280Nm from the stock inverter? I assume that means that you are exceeding the stock 60kw power output? Or is it just hitting 60kw at lower rpm? (I assume current is recorded from the shunt?)
Not yet. I reset it back to 230Nm. I managed to get about 75kW, tha tis 240A from 320Vdc. I setup 280Nm limit to see if i can pull more amps from the motor.

Right now i am battling some strange interrupt problems. I am trying to get my speedo working and i only get waving hand. The dial will move to the value but will immediately drop for 10km/h. It is disconcerting but it will show progressive values. I suspect my 1uF capacitor that i use inline is too weak. Any suggestions?

Another problem i detected is outlander heater will not work all of a sudden. I traced the problem to 0x285 msg which is not effective even though heater reports it being present (byte 0). If i in turn connect directly to heater CANbus and command 0x285 telegram from my computer everything suddenly works. :?
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

The tone function has another parameter: pulse duration.
tone(pin, frequency, duration)
And also in your code, line 2026 "tone(OUT9, 3000); " what is it for?
You need to enable hardware PWM. The code already contains the library #include "Teensy_PWM.h"

Code: Select all

  frequency = 10000.0f;

  PWM_Instance = new Teensy_PWM(pinToUse, frequency, 50.0f);
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

Request BMS

Code: Select all

void BMS_Stat()
{
 if (timer1000_3.check() == 1)
{
  BMS_avgtmp = 0;
BMS_packvoltage = 0.00;  
memset(BMS_Volt, 0, sizeof(BMS_Volt)); 
   


for (int I = 1; I < 5; I++)
  {
    msg.id  = I;
    msg.len = 1;
    msg.buf[0] = 0xFF;
    Can1.write(msg);
  //  Serial.println(msg.id);
  }
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

midway wrote: Tue Feb 20, 2024 5:52 am The tone function has another parameter: pulse duration.
tone(pin, frequency, duration)
And also in your code, line 2026 "tone(OUT9, 3000); " what is it for?
You need to enable hardware PWM. The code already contains the library #include "Teensy_PWM.h"

Code: Select all

  frequency = 10000.0f;

  PWM_Instance = new Teensy_PWM(pinToUse, frequency, 50.0f);
Well that tone function i used only for testing the performance of another dial output. I removed it in my code.

Hm... i was under the impression i cant simply change frequency with Teensy_PWM in real time.
Does 50.0f mean 50% duty there?
I need frequency from 10Hz to about 250Hz to run my speedo dial. That dial is not PWM controled, rather it responds to spark plug distributor like signal and counts when signal crosses under the GND. This means i use small 1uF foil cap inline with signal to dip pulse below GND. Worked well for Peugeot RPM indicator and engine running signal as well.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

OK now i changed from tone to PWM code and it works...sort of :?.

I still get needle to jump by 10km/h. This lets me to belive the problem is not in the code but rather in the CAN bus rutine or chip.
It seems like inverter report does not arrive to VCU in time and so speedo is not updated fast enough.
In the same way i noticed my heater does not work even though it does receive 0x285 telegram and it confirms with 0x398 byte0 value 01.
If i remove 0x285 telegram byte0 i nthe report goes to 00.
Now if i connect directly to the heater by my PC CAN reader i can command 0x188 and heater will respond to command and give 4kW power.
But 0x285 has to be updated in 10ms interval or else heater does not work.
This leads me to believe there is something wrong either in the 10ms 0x285 routine or in the chip itself.
User avatar
midway
Posts: 79
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by midway »

arber333 wrote: Wed Feb 21, 2024 4:07 pm OK now i changed from tone to PWM code and it works...sort of :?.

I still get needle to jump by 10km/h. This lets me to belive the problem is not in the code but rather in the CAN bus rutine or chip.
It seems like inverter report does not arrive to VCU in time and so speedo is not updated fast enough.
In the same way i noticed my heater does not work even though it does receive 0x285 telegram and it confirms with 0x398 byte0 value 01.
If i remove 0x285 telegram byte0 i nthe report goes to 00.
Now if i connect directly to the heater by my PC CAN reader i can command 0x188 and heater will respond to command and give 4kW power.
But 0x285 has to be updated in 10ms interval or else heater does not work.
This leads me to believe there is something wrong either in the 10ms 0x285 routine or in the chip itself.
Call the speedo() function after receiving a response from the inverter.

Code: Select all

void canRX_289(const CAN_message_t &msg)
{
  motorTorque = ((((msg.buf[0] * 256) + msg.buf[1]) - 10000) / 10); // Motor Torque -200 / + 200nm
  motorRPM = (msg.buf[2] * 256 + msg.buf[3] - 20000);               // 289_RrRPM,Rear RPM,220289,C*256+D-20000,-10000,10000,RPM,
  motorRPM = motorRPM * -1;  //Changing direction of RPM reading
  motorHVbatteryVolts = (msg.buf[4] * 256 + msg.buf[5]);            // Inverter HV
  Speedo();
}
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Outlander VCU - Rear inverter, Charger and BMS

Post by arber333 »

midway wrote: Thu Feb 22, 2024 6:57 am Call the speedo() function after receiving a response from the inverter.
Ah!!! Nice idea. Will test this today thanks.
Post Reply