Master CAN module for Hankzor balancers

Topics concerning OEM and open source BMSes
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

It seems i did the modules injustice. Its sensory part is very precise IF you calibrate it beforehand. It seems to look to AD differences between cells and takes complete scale with respect to that. Whrn you use a good multimeter ti measure module voltage you insert that in the application and it will then follow that value.

But regarding longevitl i would say it ran for over a year with balancers allways on. Then mosfets failed and consecutively resistor fuses. Now mosfets failed on 24S wired models not 16S. Those are still running strong.
This leads me to believe it shouldnt be used as 24S. Maybe rather 20S. Transistor gap is too small for 90V and mosfets are 100V rated. We need more margin...
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

Ah okay, quite a shame to have to run it under capacity. It does say its rated at 100V which of course literally will be the max voltage of a package and not the design itself.

Did you publish your decoding and control publicly?
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

Sorry answered my own question.

A bit bulky code, will look into making a bit more "dynamic" as in not fixed and fully configurable.

https://github.com/arber333/ESP32-VCU/b ... 32BMSa.ino
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

tom91 wrote: Fri Jan 20, 2023 6:30 pm Sorry answered my own question.

A bit bulky code, will look into making a bit more "dynamic" as in not fixed and fully configurable.

https://github.com/arber333/ESP32-VCU/b ... 32BMSa.ino
Yes i am no coder... i changed it multiple times. I want to use flags as i need the code selectively turn on.

For my first objective i tried to turn balancers on and off as i drive or charge.
For second objective i want to get all cell values and store them in an array. There i can compare them and choose the highest and lowest cell and its position.
For third objective i will take temp values and make some alarms from all data.
For rest of steps i would like to put filtered data to Wifi or Bluetooth.

Would you need one sample board for testing?
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

I will first get it working on my SimpBMS Teensy 3.2 probably starting with VW code base.

Then I will look at working out how to best share this with others, dont want to go rewriting your whole code as I do not know the "I/O functions".
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

tom91 wrote: Fri Jan 20, 2023 8:42 pm I will first get it working on my SimpBMS Teensy 3.2 probably starting with VW code base.

Then I will look at working out how to best share this with others, dont want to go rewriting your whole code as I do not know the "I/O functions".
Ah ok BMS is just sensing ENABLE and PP signals and possibly 12V level on AD rest are outputs for interfacing with the car.

When you test your code and it works please report back on how it works as i may copy your hard work.
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

First draft created. https://github.com/Tom-evnut/SimpBMS-JK

It reads the info and can command balancing.


Balancing is done here, they need to be set once so using a simple integer to do this.

Code: Select all

      if (balancecells == 1)
      {
        if (SetBal == 2 || SetBal == 0)
        {
          bms.balanceCells(1, 0); //1 is debug
          SetBal = 1;
        }
      }
      else
      {
        if (SetBal == 1 || SetBal == 0)
        {
          bms.balanceCells(0, 0); //1 is debug
          SetBal = 2;
        }
      }
BMS section handles the sending of the can message, it first checks which modules are known to exist.

Code: Select all

void BMSModuleManager::balanceCells(bool balance, int debug)
{
  for (int y = 1; y < MAX_MODULE_ADDR; y++)
  {
    if (modules[y].isExisting() == 1)
    {
      OUTmsg.id  = y;
      OUTmsg.len = 2;
      OUTmsg.ext = 0;

      OUTmsg.buf[0] = 0xF6;
      OUTmsg.buf[1] = balance;
      Can0.write(OUTmsg);

      delay(1);
    }
  }
}
Requesting info, currently is just a shotgun approach not cyclic like you probally want to implement it.
The variable settings.NumModules is a setting to assign amount of modules that should be requested.

Code: Select all

void sendcommand()
{
  for (int I = 1; I < (settings.NumModules + 1); I++)
  {
    msg.id  = I;
    msg.len = 1;
    msg.buf[0] = 0xFF;
    Can0.write(msg);
    delay(1);
  }
}
The decoding happens as follows. It merely looks for a message in the right range and passes it on.

Code: Select all

 if (inMsg.id < 0x00F)//Can Messages from modules
  {
    if (candebug == 1)
    {
      bms.decodecan(inMsg, 1); //Can Messages from modules
    }
    else
    {
      bms.decodecan(inMsg, 0); //Can Messages from modules
    }
  }
Again a simple pass along to the right section using the message id as the module id.

Code: Select all

void BMSModuleManager::decodecan(CAN_message_t &msg, int debug)
{
  int CMU, Id = 0;

  CMU = msg.id;

  if (debug == 1)
  {
    Serial.println();
    Serial.print(CMU);
    Serial.print(" | ");
  }

  modules[CMU].setExists(true);
  modules[CMU].setReset(true);
  modules[CMU].decodecan(msg);

}
Here is how I decode the message, it puts all the variables into the right places to allow it to function in the SimpBMS code frame work.

Code: Select all

void BMSModule::decodecan(CAN_message_t &msg)
{
  uint8_t Id = 0;

  Id = msg.buf[0];

  switch (Id)
  {
    case 1:
      temperatures[0] = msg.buf[2] + msg.buf[1] * 256;
      break;

    case 2:
      balstat = msg.buf[3];
      break;

    case 4:
      cellVolt[msg.buf[1]] = (msg.buf[3] + msg.buf[2] * 256) * 0.001;
      cellVolt[msg.buf[1] + 1] = (msg.buf[5] + msg.buf[4] * 256) * 0.001;
      cellVolt[msg.buf[1] + 2] = (msg.buf[7] + msg.buf[6] * 256) * 0.001;
      break;

    default:
      break;
  }
}
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

I think in the past i promised the DIP switch address table:
image.png
image.png (8.65 KiB) Viewed 3566 times
Riwi
Posts: 43
Joined: Wed Jun 12, 2019 5:50 pm
Has thanked: 1 time
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by Riwi »

tom91 wrote: Sat Jan 21, 2023 2:14 pm First draft created. https://github.com/Tom-evnut/SimpBMS-JK

It reads the info and can command balancing.


Balancing is done here, they need to be set once so using a simple integer to do this.

Code: Select all

      if (balancecells == 1)
      {
        if (SetBal == 2 || SetBal == 0)
        {
          bms.balanceCells(1, 0); //1 is debug
          SetBal = 1;
        }
      }
      else
      {
        if (SetBal == 1 || SetBal == 0)
        {
          bms.balanceCells(0, 0); //1 is debug
          SetBal = 2;
        }
      }
BMS section handles the sending of the can message, it first checks which modules are known to exist.

Code: Select all

void BMSModuleManager::balanceCells(bool balance, int debug)
{
  for (int y = 1; y < MAX_MODULE_ADDR; y++)
  {
    if (modules[y].isExisting() == 1)
    {
      OUTmsg.id  = y;
      OUTmsg.len = 2;
      OUTmsg.ext = 0;

      OUTmsg.buf[0] = 0xF6;
      OUTmsg.buf[1] = balance;
      Can0.write(OUTmsg);

      delay(1);
    }
  }
}
Requesting info, currently is just a shotgun approach not cyclic like you probally want to implement it.
The variable settings.NumModules is a setting to assign amount of modules that should be requested.

Code: Select all

void sendcommand()
{
  for (int I = 1; I < (settings.NumModules + 1); I++)
  {
    msg.id  = I;
    msg.len = 1;
    msg.buf[0] = 0xFF;
    Can0.write(msg);
    delay(1);
  }
}
The decoding happens as follows. It merely looks for a message in the right range and passes it on.

Code: Select all

 if (inMsg.id < 0x00F)//Can Messages from modules
  {
    if (candebug == 1)
    {
      bms.decodecan(inMsg, 1); //Can Messages from modules
    }
    else
    {
      bms.decodecan(inMsg, 0); //Can Messages from modules
    }
  }
Again a simple pass along to the right section using the message id as the module id.

Code: Select all

void BMSModuleManager::decodecan(CAN_message_t &msg, int debug)
{
  int CMU, Id = 0;

  CMU = msg.id;

  if (debug == 1)
  {
    Serial.println();
    Serial.print(CMU);
    Serial.print(" | ");
  }

  modules[CMU].setExists(true);
  modules[CMU].setReset(true);
  modules[CMU].decodecan(msg);

}
Here is how I decode the message, it puts all the variables into the right places to allow it to function in the SimpBMS code frame work.

Code: Select all

void BMSModule::decodecan(CAN_message_t &msg)
{
  uint8_t Id = 0;

  Id = msg.buf[0];

  switch (Id)
  {
    case 1:
      temperatures[0] = msg.buf[2] + msg.buf[1] * 256;
      break;

    case 2:
      balstat = msg.buf[3];
      break;

    case 4:
      cellVolt[msg.buf[1]] = (msg.buf[3] + msg.buf[2] * 256) * 0.001;
      cellVolt[msg.buf[1] + 1] = (msg.buf[5] + msg.buf[4] * 256) * 0.001;
      cellVolt[msg.buf[1] + 2] = (msg.buf[7] + msg.buf[6] * 256) * 0.001;
      break;

    default:
      break;
  }
}
Hi Tom!

What’s the status on the Jkbms/balancer integration to simpbms? Do you have it up and running?

Thanks

Rikard
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

Riwi wrote: Sat Apr 15, 2023 8:10 pm Hi Tom!

What’s the status on the Jkbms/balancer integration to simpbms? Do you have it up and running?

Thanks

Rikard
It literally is in the github link.
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
Riwi
Posts: 43
Joined: Wed Jun 12, 2019 5:50 pm
Has thanked: 1 time
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by Riwi »

tom91 wrote: Sat Apr 15, 2023 8:53 pm It literally is in the github link.
Ok, so loading the evsbms with SimpJK.ino.TEENSY32.hex would do it?

When using more than 24s I guess that the jk-balancers needs to be connected like this in order for all cells to be balanced evenly?
Image
tom91
Posts: 1307
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 103 times
Been thanked: 216 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

Riwi wrote: Mon Apr 17, 2023 6:29 am Ok, so loading the evsbms with SimpJK.ino.TEENSY32.hex would do it?
NO that is for the SimpBMS as it says and the previous posts mention. If you need it to work on EVS-BMS hardware that can be looked at too, do you have an EVS-BMS?
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
Riwi
Posts: 43
Joined: Wed Jun 12, 2019 5:50 pm
Has thanked: 1 time
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by Riwi »

tom91 wrote: Mon Apr 17, 2023 8:38 am NO that is for the SimpBMS as it says and the previous posts mention. If you need it to work on EVS-BMS hardware that can be looked at too, do you have an EVS-BMS?
Ok, I haven’t decided on the bms to use yet, still looking though options.

Thanks
Post Reply