Kia Niro BMS

bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

Success! i can see the voltages on some cells but then it seems to crash soon after.
There is a cell reading zero in the middle so i assume that as this is also sometimes used as a 72 cell bms in other models the one they didnt use was the middle cell?
good to see some data starting to come through :-)
Attached log

Edit: got the crashing under control, was a just a hardware issue with the int pin, seems to read consistently and updates. :D
Attachments
error.txt
(3.97 KiB) Downloaded 269 times
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

I think the cells are connected in the same manner as the PHEV-bms, i.e. pos 1-4 and 6-9 and not pos 1-8 for each chip.
That means you need to roll back some of the early changes.
usus
Posts: 34
Joined: Sun Jul 10, 2022 7:45 pm
Has thanked: 2 times
Been thanked: 4 times

Re: Kia Niro BMS

Post by usus »

Hey guys,

I am having a storage pack with Peugeot modules that also use MAX 17841
viewtopic.php?p=62076#p62076

Are you using Arduino Nano or ESP 32 for controller?
I have an Arduino working but I have problem moving to ESP32. My problem with Arduino is that the RAM memory is full and I don’t have space for development.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

usus wrote: Mon Oct 30, 2023 8:17 am Hey guys,

I am having a storage pack with Peugeot modules that also use MAX 17841
viewtopic.php?p=62076#p62076

Are you using Arduino Nano or ESP 32 for controller?
I have an Arduino working but I have problem moving to ESP32. My problem with Arduino is that the RAM memory is full and I don’t have space for development.
I'm using Arduino or more specifik Atmega328P on an home made board but should work on most arduinos.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

I editied this part back to original as this seems to be the part that reads the data into the memory?
void readData()
{
for(int i=0; i<4; i++)
{
readAllSlaves((0x20 + i), true); // Read CELL 1-4 of all slaves
}
for(int i=0; i<4; i++)
{
readAllSlaves((0x25 + i), true); // Read CELL 5-8 of all slaves"

It had no effect, the zero was still in the middle, i tried changing the numbers in the "Stores measured cell voltage data in cellVoltage array" and set cell voltage register to 0x29 but got back to the errobyte 1 condition.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

Try this:
BMS2_7_3_EDITED_3.ino
(47.39 KiB) Downloaded 271 times
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

Nearly, something odd happening with the last cell like its been cut short, is the one on the far right die temperature?
0 0 0 21
1: 3682 3684 3685 3685 3685 3683 3684 7 20
2: 3684 3684 3685 3684 3683 3685 3683 16 21
3: 3685 3684 3685 3685 3684 3684 3684 3 21
4: 3684 3685 3685 3685 3685 3685 3683 2 21
5: 3684 3684 3684 3684 3684 3684 3683 32 20
6: 3684 3684 3684 3684 3684 3685 3684 1 21
7: 3684 3684 3684 3684 3684 3683 3684 8 21
8: 3685 3684 3685 3685 3684 3685 3684 3 21
0 0 0 0 0 0 0 0
206.3 -22.4 22.9 F 1
3 3685 32 2
0 0 0 21
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

Yes, the die temp is on the far right.
Don't know at the moment what is going on with the 8th cell. Will have to wait until tomorrow to look into it further.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

No worries, I really appreciate the help I would be stuck without it.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

I can't find anything obviuos at the moment so I have turned on the print out of all received data from readAllSlaves. Please run this and post the print outs. Will be a lot of data...
BMS2_7_3_EDITED_3.ino
(47.38 KiB) Downloaded 253 times
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

No problem here it is:
Attachments
error.txt
(5.01 KiB) Downloaded 270 times
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

Try this for a better print out.
BMS2_7_3_EDITED_3_1.ino
(47.39 KiB) Downloaded 260 times
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

Here you go, cheers.
Attachments
error.txt
(3.61 KiB) Downloaded 220 times
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

This is a bit strange and I suspect some hardware issue.
Have you checked the cell connections (wiring) for cell no 8 for all modules (max17823)?
Please also verify with a multimeter that the cell voltages are infact close to 3,68V / cell, for those no 8 cells?
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

I tested the BMS using Torque and an ELM Bluetooth adaptor before i began and it showed all cells and they were all 3.6 range,

I just checked the individual cells on the input connector with a meter and they all seem fine end each module is outputting 58v on the bus bar.

If it was a fault in the CMU would that not be one whole horizontal row not the end cut of each one?
Could it be that the top cell is being read by something higher than 9? it does have 12 channels on each chip

The only thing i don't have per your schematic is the SHDN pin connected to the atmega and is just pulled high.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

bexander wrote: Tue Oct 31, 2023 3:19 pm This is a bit strange and I suspect some hardware issue.
Have you checked the cell connections (wiring) for cell no 8 for all modules (max17823)?
Please also verify with a multimeter that the cell voltages are infact close to 3,68V / cell, for those no 8 cells?
I just realised what you said, It has 8X max17845 chips onboard.

I will also see what pins connect to each battery on the chip then we will know if its 1-4 5-9 etc.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

I checked which cells connected to which pins on the chip, C0 is ground then all the way to C8 in sequence just like the 17845 datasheet.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

Try with this:
BMS2_7_3_EDITED_3_2.ino
(47.56 KiB) Downloaded 308 times
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

That was the same as before so i went looking to find where the measurement was failing, after pouring over the datasheet I set mesureeen to 0x11FF and i got this:
1: 3682 3683 3684 3684 3684 3684 3682 3684 20
2: 3684 3683 3685 3684 3683 3682 3685 3683 20
3: 3684 3684 3684 3684 3684 3683 3684 3684 21
4: 3683 3685 3684 3684 3684 3684 3685 3682 21
5: 3683 3683 3683 3683 3683 3684 3684 3683 20
6: 3684 3684 3684 3684 3684 3684 3684 3683 21
7: 3684 3684 3683 3683 3682 3684 3683 3684 21
8: 3684 3683 3684 3684 3684 3684 3685 3683 21
If you could go over the code and check what i have done to see if i haven't just messed things up and it was just
writeAllSlaves(0x12, 0x11fF, true); // Set MEASUREEN, Enable cell voltages 1-4, 6-9 and AUX1 that was stopping us reading the last cell.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

bigmotherwhale wrote: Thu Nov 02, 2023 2:36 pm That was the same as before so i went looking to find where the measurement was failing, after pouring over the datasheet I set mesureeen to 0x11FF and i got this:
1: 3682 3683 3684 3684 3684 3684 3682 3684 20
2: 3684 3683 3685 3684 3683 3682 3685 3683 20
3: 3684 3684 3684 3684 3684 3683 3684 3684 21
4: 3683 3685 3684 3684 3684 3684 3685 3682 21
5: 3683 3683 3683 3683 3683 3684 3684 3683 20
6: 3684 3684 3684 3684 3684 3684 3684 3683 21
7: 3684 3684 3683 3683 3682 3684 3683 3684 21
8: 3684 3683 3684 3684 3684 3684 3685 3683 21
If you could go over the code and check what i have done to see if i haven't just messed things up and it was just
writeAllSlaves(0x12, 0x11fF, true); // Set MEASUREEN, Enable cell voltages 1-4, 6-9 and AUX1 that was stopping us reading the last cell.
Yes, that is also what I discovered and changed in the last SW I posted but with all chanels enabled.

I would suggest:
writeAllSlaves(0x12, 0x00FF, true); // Set MEASUREEN, Enable cell voltages 1-8
and
writeAllSlaves(0x1E, 0x0008, true); // Set TOPCELL, Top cell for measurement is 8

Turning of aux1 (you stated previously you don't have any external temperature sensors, correct?)
Also turning of cell9 as it is not used, to avoid it to falsely trigger fault bits, as per maxim recommendations.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

"writeAllSlaves(0x1E, 0x0008, true); // Set TOPCELL, Top cell for measurement is 8"
Yes i also changed this already to get it working.
I dont have any temp sensors, will have a look at disabling them. how do i change the bits D12 and D13 in the mesureen value? I dont understand how to do this.
How would i turn off cell 9? wont the topcell number do this?
Thanks for getting this up and running, most appreciated. :)
Can i also ask are you using contactors with built in economizers? as it seems that there is no PWM for the output of the contactor, im not entirely sure whether my contactors need this or not TBH.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 67 times
Been thanked: 96 times

Re: Kia Niro BMS

Post by bexander »

Looking at register 0x12 (MEASUREEN). If you want to set just bit D12, that corresponds to 0x1000 or translated to binary 0b 0001 0000 0000 0000. Every digit in hex coresponds to 4 bits in binary. D0 is the first digit, right most digit. D15 is the left most digit.
If you want to set cell 1-8 enabled and then also enabled D12 and D13, in binary 0b 0011 0000 1111 1111, in hex 0x30FF. Using the "calculator" (in windows or linux) in programming mode let's you visualize this in a good way and also translate from binary to hex or decimal for that matter.

I suggested 0x00FF, or 0b 0000 0000 1111 1111, to enabled cell 1-8 with everyting else (temp sensors) disabled.

Correct, my contactors don't need economizing so only on or off.
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

Thankyou for the clear explanation and help getting this up and running.
I hopefully should be able to handle the coding for the additional contactor and economizer control myself.
There are some thermistors in the pack in a couple of places handled directly by the micro on the BMS, im not sure how im going to implement monitoring them yet. The inverter im trying to hack already has a voltage monitor via CAN and there is an isolated 0-5v refence on the board so I have some options there.
User avatar
manny
Posts: 65
Joined: Sun Jan 23, 2022 4:15 pm
Location: Netherlands
Has thanked: 13 times
Been thanked: 51 times

Re: Kia Niro BMS

Post by manny »

First of all great work on this code!
Very happy I can reuse the bms slave modules

I have a complete e208 pack. So i needed to change the code.
The e208 pack consists of 18 modules with 6 cells each.
Got the original code and the latest code posted. I used notepad++ to make a diff. To be able to find all the changes made.
To make the code less hard coded I adding a couple of variables
  • numberOfModules
  • numberOfCellsPerModule
  • Message_length
Got it working with my modules (3 at the moment).
Not sure that i got all the hard coded bits.
The split in cell layout in the original code is hard to code for, so I removed it

Also made a board to fit in a waterproof housing
20231105_123553.jpg
The DC DC converter and attiny are missing but on their way.
Attachments
BMS2_7_4.ino
(50.27 KiB) Downloaded 246 times
bigmotherwhale
Posts: 111
Joined: Tue Sep 22, 2020 6:48 pm
Has thanked: 15 times
Been thanked: 22 times

Re: Kia Niro BMS

Post by bigmotherwhale »

tidy setup, do you have contactor control on that board? I think this will need to be changed to reflect the number of modules and whether they are series / parallel

if((batteryVoltage > 300) && (compareVoltage > batteryVoltage) && (millis() - lastMillisContactor > 500))

I also found a thread on here where someone had done a similar thing to this code, it might be worth having a look, search for "MAX_Teensy_1.2"

Im interfacing with an all in one BMS with the CMUs onboard, using as much existing hardware as possible.

I realised my current sensor is only a single sensor not with high and low, and also I need an additional contactor and economizer control as well as a canbus signal from the inverter to determine voltage, so im trying to work out what I need to change in the code.
Attachments
DSC05382.JPG
Post Reply