Master CAN module for Hankzor balancers

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

Master CAN module for Hankzor balancers

Post by arber333 »

I have a set of 5 Hankzor active balancers that are not quite BMS, but they gather data, balance and output data on CAN bus.
I need to program a master unit for them to listen to. Hardware is Arduino DUE with CAN bus transciever.
CAN protocol for modules is found here:
Balancer-CAN-Communication Protocol (1).pdf
(348.43 KiB) Downloaded 281 times
Units work at 250kbps
Each unit needs to have its own ID which is set by the DIP switches on the side of the module.
CAN bus is dormant until master requests data from particular module. When that is accomplished that module dumps several lines of data on the CAN bus. ID is still the same for every line, but data is classified by the first byte of the line.
For example 01 in byte1 is reserved for cell temperature values and 04 is actual cell values...
Master querry:
ID 01 DATA FF
Slave response:
ID 01 DATA 01 00 11 24 F9 0F 68 18
ID 01 DATA 02 10 03 02 00 2C 04 5A
ID 01 DATA 03 00 05 03 E8 01 18
ID 01 DATA 04 00 0F 64 0F 61 0F 61
ID 01 DATA 04 03 0F 60 0F 60 0F 67
ID 01 DATA 04 06 0F 61 0F 61 0F 62
ID 01 DATA 04 09 0F 73 0F 6B 0F 61
ID 01 DATA 04 0C 0F 69 0F 73 0F 71
ID 01 DATA 04 0F 0F 6B 0F 8C 0F 64
ID 01 DATA 04 12 0F 65 0F 62 0F 65
ID 01 DATA 04 15 0F 65 0F 6F 0F 60

I know Byte1 04 means it is cell values and Byte2 shows which cell row it is. Next are actual cell voltages in 2 byte values.
I have a pretty good idea on how to collect peripheral info such as cell temp and average voltage from other messages.
What i dont know is how to collect cell values and put them into some array or other structure for later processing.
I dont have enough of programming knowledge to collect cell values from those CAN telegrams with the same ID.
Does anyone has any idea on how to go about that?

Thanks!
tom91
Posts: 1271
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 97 times
Been thanked: 201 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

Just do some if statements.

so

Code: Select all

if(inMsg.buf[0] == 0x04)
{
CellV[inMsg.buf[1]] = inMsg.buf[1]*256+inMsg.buf[3];
CellV[inMsg.buf[1]+1] = inMsg.buf[1]*256+inMsg.buf[3];
CellV[inMsg.buf[1]+2] = inMsg.buf[1]*256+inMsg.buf[3];
}
this should then populate the array

Edit - the first byte 1 position is 0 and then increments already by 3 so its real easy to index
Founder Volt Influx https://www.voltinflux.com/
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Wow! Is it really that simple? Thanks.
Would i need to create 5 different buffers for each of the IDs or can i use the same buffer to continue from the previous ID?

I am thinking of using flags for conditionals to set the order of cell count from HV- to HV+.
User avatar
midway
Posts: 78
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by midway »

Do you have a table of correspondence between the position of dip switches and device identifiers
Can't find information
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

midway wrote: Wed Feb 16, 2022 9:29 am Do you have a table of correspondence between the position of dip switches and device identifiers
Can't find information
Well i was in the same predicament as i couldnt setup DIPs as i imagined they would.
Then i connected bluetooth. Basicaly i was setting switches and observing numbers in the bluetooth app for every module individually.
I dont have a table made yet, but i need to open my car and test every setting to make a table... any day now 😎

EDIT: I will have to reset those IDs anyway because they are not in sync with battery orientation as they are now. I set front modules to 1H, 2H ,3H ... ust because i can get access to front modules and experiment with CAN easier than from the back.
User avatar
midway
Posts: 78
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by midway »

Thanks, I'll try today
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

midway wrote: Wed Feb 16, 2022 2:05 pm Thanks, I'll try today
First you need to connect one balancer so it responds to bluetooth. Then pull down the first of the DIPs. This will give you a state of 01H. Now CAN module will be able to respond.
Next CAN module is SLAVE, it will not do anything on its own. You need to command it from master.
CAN should be 250kbps, normal ID.
For demanding report i send ID 01 and data field of a single byte value of FF.

So: ID 01 data FF

Response is immediate with several lines of the same ID where data is stored.
Sort it out against protocol i put in the first post here...

Then there are also commands to start/stop balancing etc...
My plan is to simply use report to trigger conditional so balancing starts only abov 3.9V per cell.
User avatar
midway
Posts: 78
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by midway »

1645376378856.jpg
CAN bus controller is installed on the board
1645434672774.jpg
I was unable to connect to the active balancer. It feels like the Chinese sent it not with a can bus, but with RS485
Vendor ID: JK-DZ08-B1A24S
Hardware Ver: 8.X-M
Software Ver : 8.04
Version 4.3.1

I send request like this :

msg.id = 0x01;
msg.len = 8;
msg.buf[0] = 0xFF;
Can1.write(msg);
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: Master CAN module for Hankzor balancers

Post by m.art.y »

Arber, I have read in the other thread that you are very happy with those balancers. Could you explain how do they work and how is your progress on this master board? I imagine they are like individual balancers which are not linked between themselves? Are they balancing constantly or can you set a target voltage at which to balance? What other features do they have? So you are saying it is possible to monitor the cell data over bluetooth? Because when I put my battery modules in a battery box they will be totally unaccessible to measure cell voltages manually.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Hi

As far asvi know those are balancers made according to a belgian patent. Chin ripoff i persume. They work on supercap isolation principle. One way energy upwards and then back to cell level. Difference from usual cap modules is that balancer is able to add upper charge to any cell within its range of 24s.
I like them because they can easily keep my aging cells to within 30mv. And if each section gets lower i can just connec my 60v charger and trust balancers will bring them back together.
They add bluetooth link and you can choose serial or CAN interface.
Normally they are off and you can turn balancing on via interface. They balance through 3.2 to 4.2 range.
I see CAN command to turn balancing on/off so i will implement this in my master to balance only from 3.9v upwards or if dV will be more than 100mV.
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: Master CAN module for Hankzor balancers

Post by m.art.y »

arber333 wrote: Mon May 23, 2022 3:39 pm I like them because they can easily keep my aging cells to within 30mv. And if each section gets lower i can just connec my 60v charger and trust balancers will bring them back together.
You see that's what I'm worried about, if a section gets lower I will not be able to connect extra charger to only that section. The battery will be under the car totally unaccessible. Any other ways to prevent/sort sections getting lower than others?
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

m.art.y wrote: Mon May 23, 2022 5:46 pm
You see that's what I'm worried about, if a section gets lower I will not be able to connect extra charger to only that section. The battery will be under the car totally unaccessible. Any other ways to prevent/sort sections getting lower than others?
Good point. Then you could cross connect balancers. For example you connect the last two wires of the first balancer and the first two of the secind balancer so they will share charge. This should balance cells as a pack. But that would count cross connected cells as more cells than in reality, n+1 for every module. Still you would solve the balancing problem that way.
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: Master CAN module for Hankzor balancers

Post by m.art.y »

arber333 wrote: Mon May 23, 2022 6:27 pm Good point. Then you could cross connect balancers. For example you connect the last two wires of the first balancer and the first two of the secind balancer so they will share charge. This should balance cells as a pack. But that would count cross connected cells as more cells than in reality, n+1 for every module. Still you would solve the balancing problem that way.
Have you tested this setup and are sure it would work that way? 😊
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Yes, i tested it in my pug. But cells there are newer LG cells and it is more important to keep an eye on complete setup cell by cell. I reverted back to 24s modules so i can observe cells by their position better.
I could substract cell position from the array, but it would still leave me with two separate banks of cells. 16S and 24S configuration makes more sense and is more efficient modulewise...
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: Master CAN module for Hankzor balancers

Post by m.art.y »

Arber, could you please post a link or add some pictures? I found them but there are so many different sellers and options, some seem to be inductive balancers.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

m.art.y wrote: Tue May 24, 2022 4:19 am Arber, could you please post a link or add some pictures? I found them but there are so many different sellers and options, some seem to be inductive balancers.
I already posted here
https://openinverter.org/forum/viewtopi ... 626#p33626

Dont forget to select the one with BT/CAN option.
Also next post are the photos of my installation. If you need i can send you design for the interface PCBs. That way you can cross connect your cell modules and still are able to remove BMS.

EDIT: Design for the 4x 16S connecting boards in design spark
Attachments
16S adapter new.zip
(45.97 KiB) Downloaded 105 times
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

[quote=midway post_id=37041 time=1645374046 user_id=1337

I send request like this :

msg.id = 0x01;
msg.len = 8;
msg.buf[0] = 0xFF;
Can1.write(msg);
[/quote]

I revewed your post and i noticed a quirk!
In your CAN command you declare msg length as 8 bytes. CAN protocol demands single byte command msg value FF.

You would need to declare:
msg.id = 0x01;
msg.len = 1;
msg.buf[0] = 0xFF;
Can1.write(msg);

Try this and you should see several lines of return data.
If it works i will have a master finished soon that will be able to interpret that data.
User avatar
midway
Posts: 78
Joined: Mon Feb 15, 2021 3:52 pm
Location: Ural
Has thanked: 5 times
Been thanked: 8 times

Re: Master CAN module for Hankzor balancers

Post by midway »

arber333 wrote: Tue Jul 19, 2022 2:34 pm [quote=midway post_id=37041 time=1645374046 user_id=1337

I send request like this :

msg.id = 0x01;
msg.len = 8;
msg.buf[0] = 0xFF;
Can1.write(msg);
I revewed your post and i noticed a quirk!
In your CAN command you declare msg length as 8 bytes. CAN protocol demands single byte command msg value FF.

You would need to declare:
msg.id = 0x01;
msg.len = 1;
msg.buf[0] = 0xFF;
Can1.write(msg);

Try this and you should see several lines of return data.
If it works i will have a master finished soon that will be able to interpret that data.
[/quote]
Thank you. I figured out, the problem was in the speed of the CAN bus
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

I managed to develop a VCU that i can use with those JK balancers with CAN bus.
I will post further development here as it is more appropriate for ESP32 based development.

My BMS plan includes those active JKBMS modules and its 250kbaud CAN output to make a complete system. Zero user involvment into BMS while battery is working properly and very simple UI via WIfI or BT to identify individual cells gone astray. Or just to observe situation.
- There would be one output on this VCU dedicated to HMI BMS warning - a buzzer.
- Also since there is a single CAN and it needs to run at 250kbaud it can only control those JK balancers. I cant use 250kbaud signal to command 500kbaud charger... So i intend to use another output, active low to keep the charging process alive in the other VCU which would actually control the charger and other systems like AC or heater.
- I really like Outlander way of single CAN telegram that works as a heartbeat. Remove that and all processes cease. So in my instance i intend to use a simple pulldown pin to command 0x285 CAN telegram to stop transmitting. That will stop chargers as well as running gear, but keep contactors alive.
Or i can do it the FAILSAFE way; to command the heartbeat by that active BMS signal. If you remove the signal everything fails safe.

This version of VCU actually could also be used to run Leaf or Outlander inverter. It has the analog pins and correct inputs and outputs as well. So practicaly to run the car, L2 charger, BMS and chademo one would need like 3 or 4 of theese VCUs. Overkill? Time will tell.

What i am working on now is BMS code which is somewhat different in that i use revolving ID telegrams. Whenever i need to send a querry to N+1
modules i spit out a function with several cases which revolve from 0 to N. This means a quick succession of BMS requests with immediate reports.
I managed to get my JK BMS modules to report to VCU request. I also see i can directly command balancing switch.
I now need to setup cell arrays and find some way of reporting cell difference.
I will use its error reports as well. I will need to test it though...
I am now trying to get the revolving function part to work attached to an interrupt so i can have it automated.

I also see an averaging report for voltage per module and will use it to condition cell balancing from the SOV side.
For that i intend to use various flags. CAN reports will condition them to be raised or lowered.

Software development to date:
1. Hardware side is working and no serious hindrance from I/Os
2. Digital I/O interface programmed in and confirmed working.
3. Process watchdog programmed operating within 3s and confirmed working
4. CAN bus library programmed in. Transmission protocol confirmed working at 500kbaud as well as 250kbaud
5. Function revolving works as intended. Transmission timing to 500ms.
6. BMS CAN report received and balancing return command works

What to implement yet:
1. BMS request telegrams attaching to interrupt routine for fully automated requests.
2. Report readbacks:
- average cell voltage per module
- highest and lowest cell positions per module
- max cell difference withing module
- temperature readback
- Error state

3. Setup voltage arrays for storing individual cell voltage reports
4. Preprogram error states to buzzer protocol
5. Preprogram BMS outputs and actions
Attachments
IMG-20221027-WA0001.jpeg
IMG-20221027-WA0003.jpeg
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Well it was partial success :).
I managed to get the revolving function attached to an interrupt and made BMS spit out its reports. This is now working, check!
Within reports i can read values and my conditionals pull them in.i can see the reports.

I have also made several conditions for switching the balancing function ON or OFF. I use flags conditioned by the reports.
I see commands work well. Balancers would turn on at the CAN traffic request however they would also turn off according to another request.
I havent sorted out conditionals apparently and balancing keeps turning ON or OFF.
Since the reports are being sent at 500ms maybe my conditionals are also reporting the empty values between the cycles?
Annoying!
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

I may need to outsource some ideas anyone?
I accept all ideas.

I have succesfully requested cell values from moduled which are reporting at about 500ms. I can lower this time quite easily but 100ms in uC terms is still an eternity.
Seems uC is reading can values during the cycles when there is no reports.

1. How to tell it to only read reports when there is something to report?

2. I want to balance only upwards of 3.9V per cell. I wanted to trigger this via a flagg. But it keeps changing. Any idea?
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

OK, managed to assemble a good alarm buzzer function.
Idea is to signal alarm state by short and long beeps
example:
Cell overvoltage alarm 3 short, 1 long
Cell undervoltage alarm 5 short 1 long
Cel overtemperature alarm 6 short 1 long
and variations...

I will build a table of alarms that i consider vital so we will know immediately what BMS is telling us.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Damn! I just had my first sincere error from Hankzor balancers. And i didnt even notice it untill i went testing my new code.
I wondered why i couldnt get the balancers to change from balancing to nonbalancing. Then i edited my code so that i provided clear input for balancing change by input pins. As i included an error detection to this new function i just couldnt get the modules to start balancing. I could order them to stop balancing though. Hm... i went on inspecting the modules by BT.
I saw an error at the 2nd module it couldnt detect all cells AW!!!

I changed inputs from one module to the other and every time that particular module would declare error while others were working good.
There seems to be no change to the cells connected. It also could not be used to balance anything. It seems error is limited to sensing.
I will have to replace that module, but i still can use it to test error codes at least...
Erroneous module is about a year old...
Attachments
Screenshot_20221120-231713.jpg
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Master CAN module for Hankzor balancers

Post by arber333 »

Well now...
Inside the circuit there are small 0603 resistors of 0.01R value. They are somewhere at 500mW rating and seem too small for 1A declared balancing.
I used those balancers actively for about a year. There must have been wear on those resistors which were balancing at 1A all the time.

As bluetooth screen showed gaps between cells i disconnected the module.
When i measured cells for error i couldnt find any. All were sitting at 3.80V.
I inspected the electronics board for obvious errors. I found several R01 resistors burned.
I went on and contacted Hankzor BMS rep on Aliexpress. They were really forthcomming and helpfull with instructions even though i had a feeling of language barrier.

In the end they advised replacing all R01 resistors with new ones.
As i didnt have them in stock yet i went and soldered some thin silver wire in their place, just to try if rest of circuit was ok.
I got good contact with BT and CAN! Looks like BMS module is alive.

Today however i found two other cells missing on neighbouring modules. Seems like illness is transferable. I ordered several R01 resistors and shut off balancing. When i repair them i will probably set balancing value to 200mA to keep resistors alive.

EDIT: To clarify, BMS was not faulty. Rather from the long term use of balancing at 1A the cell fuses burned up. They are fairly easy to replace even with hand soldering. I think i will see more failed fuses in future and i intend to replace them fully. Another preventive measure would be to limit balancing to two scenarios:
1. When any cell would be higher than 3.90V
2. When the biggest voltage differential allowed would happen. Value would be set pragmatically.
tom91
Posts: 1271
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 97 times
Been thanked: 201 times

Re: Master CAN module for Hankzor balancers

Post by tom91 »

I just got my self a JK-BMS module a JK-DZ08-B1A24S.

How has your experience been with the longevity of these units? Do they start to drift after a while?

I will have a look at the code you wrote and see if I can add support for the modules on my EVS-BMS Code and a SimpBMS version. Plus ofcourse flag any bugs I find.
Attachments
Screenshot_20230120_174558.jpg
20230120_171151.jpg
Founder Volt Influx https://www.voltinflux.com/
Post Reply