Dual Leaf batteries with ZV
Posted: Wed Jul 23, 2025 6:33 pm
I am going to use 2 Leaf batteries in my van project, a 24kWh and a 30kWh. Both batteries will be connected in parallel at the contactor box. Each battery will still have it's own service disconnect plug. What I would like to do is to have the 30kWh on CAN1 and the 24kWh on CAN2. So far my software engineer (my son, just finished his 2nd year of a computer science degree and on summer holidays
) has added a BMS menu item "LeafDualBMS" and copied the leafbms.cpp to leafdualbms.cpp. It's been compiled, loaded to the ZV and everything seems to work. The ZV can talk to the Leaf BMS, it charges on AC and we have motor/wheel spin. .https://github.com/mtmjnb/Stm32-vcu/tree/leafduelbms
What we need to do is set BattCur and power to the sum of both batteries.
The parameters BMS_ChargeLim, BMS_MaxInput and BMS_MaxOutput will be 75% of the sum of both batteries, unless there is a difference of more than 75% between the 2 batteries, in which case set the parameter to the lowest value of either battery. If any of the batteries reports a 0 limit then the parameter would be set to 0. Hopefully that makes sense.
So onto the next step. how would we go about getting the ZV to talk to 2 Leaf BMSs on CAN1 and CAN2?
My understanding is that these messages keep the Leaf BMS alive and would need to be sent on both CAN1 and CAN2. Are there any examples in the code that would show how this is done? Maybe it's as simple as duplicating the above code with (CanHardware* can) being changed to (CanHardware* 0) and (CanHardware* 1)?
Would the same idea work for the next section? This
becomes this
and this
with all the code that follows duplicated?
Thanks in advance for any ideas on how to implement this.
What we need to do is set BattCur and power to the sum of both batteries.
The parameters BMS_ChargeLim, BMS_MaxInput and BMS_MaxOutput will be 75% of the sum of both batteries, unless there is a difference of more than 75% between the 2 batteries, in which case set the parameter to the lowest value of either battery. If any of the batteries reports a 0 limit then the parameter would be set to 0. Hopefully that makes sense.
So onto the next step. how would we go about getting the ZV to talk to 2 Leaf BMSs on CAN1 and CAN2?
Code: Select all
void LeafDualBMS::SetCanInterface(CanHardware* can) {
can->RegisterUserMessage(0x1DB);//Leaf BMS message 10ms
can->RegisterUserMessage(0x1DC);//Leaf BMS message 10ms
can->RegisterUserMessage(0x55B);//Leaf BMS message 100ms
can->RegisterUserMessage(0x5BC);//Leaf BMS message 100ms (500ms on ZE0)
//can->RegisterUserMessage(0x5C0);//Leaf BMS message 500ms
//can->RegisterUserMessage(0x59E);//Leaf BMS message 500ms (Only on AZE0)
can->RegisterUserMessage(0x1C2);//Leaf BMS message 10ms (ZE1)
can->RegisterUserMessage(0x1ED);//Leaf BMS message 10ms (ZE1, only on 62kWh)
}
Would the same idea work for the next section? This
Code: Select all
void LeafDualBMS::DecodeCAN(int id, uint8_t * data) {Code: Select all
void LeafDualBMS::DecodeCAN(int 0, uint8_t * data) {Code: Select all
void LeafDualBMS::DecodeCAN(int 1, uint8_t * data) {Thanks in advance for any ideas on how to implement this.