Kia Niro BMS

User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

bexander wrote: Tue Sep 20, 2022 9:40 am I contacted Maxim Integrated and they sent me a datasheet:
MAX17845.pdf
It's marked confidential so becarefull... 8-)
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

EV_Builder wrote: Tue Sep 20, 2022 9:56 am It's marked confidential so becarefull... 8-)
Interesting, I recived it directly from them without any prerequisites so should be ok.
royhen99
Posts: 234
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 20 times
Been thanked: 115 times

Re: Kia Niro BMS

Post by royhen99 »

In my limited experience Analog Devices use NDAs to preserve confidentiality. As they did not require one then it should be ok to release data sheet.
The MAX14823, MAX14843, and MAX14845 all look essentially the same. The only diffence I could find between the 23 an 43 was the aquistion time for die temperature measurement, and between the 43 and 45 is the cell voltage error +/-3.5mV vs +/-10mV ( +/-3.6mV typ).
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

I did reexamine the Niro slave boards and they do indeed use the MAX17845, just as @EV_Builder found on the Kona boards. Seem like Kia Niro and Hyundai Kona share the same BMS boards.

EDIT:
I have one board on my workbench and I will try to find the pinout and also see if I can communicate with the MAX17845.
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

Ok , i have the "double" models but I picked up a 20S and a 19S pack. So will test when time allows.

Don't see any problems as of yet.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

Did some reverse tracing and measurement today.
Looking at the connector as shown in below picture.
IMG_2068_scale.jpg
The pinout as I could trace it.
IMG_1922_scale.jpg
Very similar to the Kia Niro PHEV modules that is described in the start of this thread.

Also, when viewing from the bottom side, the chip closest to the connector is the lower voltage chip. Everything seem to be mounted so the boards should be possible to use up to 12S on each chip, 24S in total per pcb.

Each chip can handle 2 temp sensors per piece but usually only one temp sensor is connector and the used postion in the connector varies.
There is a kind of loop going on with pin column 3 and 4. I never figured out how to use this for the PHEV modules but looks very similar for the e-Niro as well.

Regarding cell connections, where it says "tom" in my notes, it's swedish for blank/empty. The most left blank pin (under left 10+) should be 11+ and the right 10+ is the 12+ or highest cell pin used (if only 9S is used it would need to connect to 9+). Hence 10+ in this case as only 10S is used.

Have done a setup, only needs code tweaking, to test communication with the chips. Will report back when tested.
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

Wow! That's quick! Top job, txs for sharing.

EDIT: When i can i check the connections with the real 10S and 9S packs (20S and 19S). At the moment a bit of between house moving etc.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

I've checked on a 20S module from the e-Niro pack. The 19S module has one less cable.

I'm able to communicate with the slave module and read out the cell voltages, die temperature as well as external temperature sensor, all while using the same hardware as mentioned in the start of this thread so I call this a big win!

@EV_Builder: Thank you for pointing out that the Kona slaves use this chip. The board I looked at first was hard to read the chip marking on and I did not find that marking and I then assumed it was a Kia/Hyundai specific chip.
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

I will join that party soon I hope...
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
ferencvarga46
Posts: 1
Joined: Thu Sep 29, 2022 8:13 pm

Re: Kia Niro BMS

Post by ferencvarga46 »

Hi!
If it help, I could make more reverse about the Kona board!
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

EV_Builder wrote: Mon Sep 26, 2022 4:09 pm I will join that party soon I hope...
Got it working guys! :D :D

Will show some GUI pictures later.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

Cant we better make an lookup table? For the temps?
That formula is costly...

like:

https://www.sebulli.com/ntc/index.php?l ... 10&tmax=60
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

EV_Builder wrote: Wed Oct 19, 2022 10:27 pm Cant we better make an lookup table? For the temps?
That formula is costly...

like:

https://www.sebulli.com/ntc/index.php?l ... 10&tmax=60
I'm assuming you are talking about this function in the code:

Code: Select all

/***************************************************************************
* Stores measured temperature sensor voltage data in cellTemperature array *
***************************************************************************/
void storeCellTemperature(uint8_t readRegisterData[29]) 
{	
	int8_t cellTemperature[12];
	
	for(int i=0; i<12; i++)
	{
		if((i == 0) || (i == 7) || (i == 8) || (i == 11)) // No temp sensor connected
    		{
      			cellTemperature[i] = 0;
		}
		else
		{		
			uint16_t beta = 3800;
			uint16_t measTemperature = ((readRegisterData[25-i*2] << 8) + readRegisterData[24-i*2]);
			measTemperature = (measTemperature >> 4);
      			int8_t temperature = beta / (log((float)measTemperature / (4095 - measTemperature)) + beta / 298.15) - 273;
			cellTemperature[i] = temperature;
		}
	}
	
	cellBlockTemp[0] = cellTemperature[1];
	cellBlockTemp[1] = cellTemperature[2];
	cellBlockTemp[2] = cellTemperature[3];
	cellBlockTemp[3] = cellTemperature[5];
	cellBlockTemp[4] = cellTemperature[6];
	cellBlockTemp[5] = cellTemperature[9];
	cellBlockTemp[6] = cellTemperature[10];
	cellBlockTemp[7] = cellTemperature[4]; // Battery box internal temperature
}
Or more specifically this line:

Code: Select all

int8_t temperature = beta / (log((float)measTemperature / (4095 - measTemperature)) + beta / 298.15) - 273;
I don't know the NTC resistance nor the pull-up/pull-down resistance but to create a table one can simply reverse the formula in the code, see attached spreadsheet.
Reverse_temp_calculation.ods
(14.68 KiB) Downloaded 136 times
Now, one would need som kind of lookup code to get the temperature from the ADC. Any ideas?
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

bexander wrote: Thu Oct 20, 2022 6:43 am Now, one would need som kind of lookup code to get the temperature from the ADC. Any ideas?
Yes indeed correct assumptions :D

Wow you did that quick!

Yeah i made a lookup table class with C# GUI tool to generate the table / code.
It's on the forum.

You can fill in a table with Temp and a column with the ADC value.

It will linear interpolate between the 2 cells. I Changed your sheet (easy) to 3 degrees jump (to save some RAM).
(i don't think the error would be big in each step of 3 degrees agree?)

I see it as a simple but solid way to add dynamic behavior.

Do have to add that its not rock solid code yet... :evil:
For example first column should go from min to max (order).
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

You could check how larger the error is by comparing to the value from the formula in the code, in a simple spreadsheet.

None of the BMS temperatures need any high resolution so it would be possible to just create a simple array and only choose by dividing ADC value with 64 (>> 6) and then use the result to select position in the temperature array.
Pseudocode:

Code: Select all

int8_t temperatureArray[52] = {80, 76, 72, 69, 65, 62, 59 ... -18, -20}
int8_t ADCLookUpValue = (ADC >> 6) - 7;
if(ADCLookUpValue < 0) {
	return 0;
}
else if(ADCLookUpValue > 51) {
    	return 51;
}
else
        return ADCLookUpValue;
}
int8_t temperature = temperatureArray[ADCLookUpValue];
Updated spreadsheet
Reverse_temp_calculation.ods
(25.26 KiB) Downloaded 157 times
Only a matter of what precision that is desired...
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

EV_Builder wrote: Thu Oct 20, 2022 7:16 am Yeah i made a lookup table class with C# GUI tool to generate the table / code.
It's on the forum.

You can fill in a table with Temp and a column with the ADC value.

It will linear interpolate between the 2 cells. I Changed your sheet (easy) to 3 degrees jump (to save some RAM).
(i don't think the error would be big in each step of 3 degrees agree?)

I see it as a simple but solid way to add dynamic behavior.

Do have to add that its not rock solid code yet... :evil:
For example first column should go from min to max (order).
Please post your code or a link to it in this thread. Helps everyone to find it.
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

This is for me very interesting.
I replaced the formula calculation with a simple array and the program should be quicker but it also uses LESS memory!?

The original code:

Code: Select all

uint16_t beta = 3800;
uint16_t measTemperature = ((readRegisterData[25-i*2] << 8) + readRegisterData[24-i*2]);
measTemperature = (measTemperature >> 4);
int8_t temperature = beta / (log((float)measTemperature / (4095 - measTemperature)) + beta / 298.15) - 273;
cellTemperature[i] = temperature;
When compiling in Arduino IDE:
Sketch uses 14966 bytes (48%) of program storage space. Maximum is 30720 bytes.
Global variables use 1407 bytes (68%) of dynamic memory, leaving 641 bytes for local variables. Maximum is 2048 bytes.

New code:

Code: Select all

const int8_t tempMap[52] = {80,76,72,69,65,62,59,57,54,52,49,47,45,43,42,40,38,36,35,33,32,30,29,27,26,
24,23,21,20,18,17,16,14,13,11,10,8,7,5,4,2,0,-1,-3,-5,-7,-9,-11,-13,-16,-18,-20};

uint16_t dataADC = ((readRegisterData[25-i*2] << 8) + readRegisterData[24-i*2]);
dataADC = (dataADC >> 10); // >> 4 for 12bit value & >> 6 for correct array index size
if(dataADC < 7) {
	dataADC = 7;
}
if(dataADC > 58) {
	dataADC = 58;
}      
cellTemperature[i] = tempMap[dataADC-7];
When compiling in Arduino IDE:
Sketch uses 14568 bytes (47%) of program storage space. Maximum is 30720 bytes.
Global variables use 1459 bytes (71%) of dynamic memory, leaving 589 bytes for local variables. Maximum is 2048 bytes.

Why is the new code using almost 400byte less program memory?

EDIT: I think it is possible to use PROGMEM to store the array in program memory if dynamic memory limit is reached.

EDIT2: Updated spreadsheet.
Reverse_temp_calculation.ods
(37.72 KiB) Downloaded 131 times
User avatar
EV_Builder
Posts: 1200
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 17 times
Been thanked: 35 times
Contact:

Re: Kia Niro BMS

Post by EV_Builder »

Programs run from RAM too. So the log function isn't loaded anymore. And It might be quite a big function.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

EV_Builder wrote: Fri Oct 21, 2022 12:55 pm Programs run from RAM too. So the log function isn't loaded anymore. And It might be quite a big function.
Aha, that makes sens.
Thank you for pointing out this inefficiency and helping me to improve!
inkubate1981
Posts: 5
Joined: Sun Nov 13, 2022 12:37 pm
Been thanked: 1 time

Re: Kia Niro BMS

Post by inkubate1981 »

Hi there,
Firstly many thanks for the information and code posted here. This has allowed me to progress a long way already towards using the MAX17841b IC.

I am working on a communication interface so I can get the BMS data from a bank of 6 Land Rover Samsung SDA modules which use this interface. I have generally used the circuit diagram published here with some changes to suit my application. The main change in the BMS interface is that I recovered the isolation transformers from the original BMS controller rather than buying new - these are 2 x Sumida CEP99 devices. I have tried to communicate with a single battery module for the time being but the chain initialisation is failing. As such I am now checking the hardware first and notice what may be the problem. The Rx back from the battery on the MAX17841 side of the isolation is AC. I doubt this is correct so ask if anyone can please assist and let me know if this is the problem? My circuit is below and I have marked the scope test points as TP A and TP B. They are both ref to GND. Many thanks.
Image Image Image
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

inkubate1981 wrote: Sun Nov 13, 2022 12:59 pm Hi there,
Firstly many thanks for the information and code posted here. This has allowed me to progress a long way already towards using the MAX17841b IC.

I am working on a communication interface so I can get the BMS data from a bank of 6 Land Rover Samsung SDA modules which use this interface. I have generally used the circuit diagram published here with some changes to suit my application. The main change in the BMS interface is that I recovered the isolation transformers from the original BMS controller rather than buying new - these are 2 x Sumida CEP99 devices. I have tried to communicate with a single battery module for the time being but the chain initialisation is failing. As such I am now checking the hardware first and notice what may be the problem. The Rx back from the battery on the MAX17841 side of the isolation is AC. I doubt this is correct so ask if anyone can please assist and let me know if this is the problem? My circuit is below and I have marked the scope test points as TP A and TP B. They are both ref to GND. Many thanks.
What step of the initialisation is failing? Have you made the correct adjustments to the SW to use only one slave? Is the slave wired correctly?
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

I have created adapter boards for the E-niro bms slave modules, see link below for more information.
viewtopic.php?p=48735#p48735
inkubate1981
Posts: 5
Joined: Sun Nov 13, 2022 12:37 pm
Been thanked: 1 time

Re: Kia Niro BMS

Post by inkubate1981 »

bexander wrote: Thu Nov 17, 2022 4:03 pm What step of the initialisation is failing? Have you made the correct adjustments to the SW to use only one slave? Is the slave wired correctly?
Thanks for getting back to me. The chain initialisation failed, however I scoped the signal at the Rx of the IC and it was a distorted triangle wave. I'm going to reduce the 1.5k resistors as maybe the RC combination with my different xfmrs is slowing the rise / fall. I checked the Maxim schematic for their dev board and they use 470R so I'll change these first and see if I can get the waveform clean. The plots pictured on my previous post are on the xfmr side of the resistors.

I'll post when I've tested and hopefully will work. Luckily the pin out is marked on the battery module bms PCB. I cross referenced to the original cables so expect this is ok. I'll share once I got a working system.

I've made quite a few adjustments to work for 1 X test board and then the 6 modules in my pack. Your code has made this much more possible for me and I understand most of it now so I think if the hardware works I can debug from there.
User avatar
bexander
Posts: 857
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 66 times
Been thanked: 95 times

Re: Kia Niro BMS

Post by bexander »

inkubate1981 wrote: Thu Nov 17, 2022 11:09 pm Thanks for getting back to me. The chain initialisation failed, however I scoped the signal at the Rx of the IC and it was a distorted triangle wave. I'm going to reduce the 1.5k resistors as maybe the RC combination with my different xfmrs is slowing the rise / fall. I checked the Maxim schematic for their dev board and they use 470R so I'll change these first and see if I can get the waveform clean. The plots pictured on my previous post are on the xfmr side of the resistors.

I'll post when I've tested and hopefully will work. Luckily the pin out is marked on the battery module bms PCB. I cross referenced to the original cables so expect this is ok. I'll share once I got a working system.

I've made quite a few adjustments to work for 1 X test board and then the 6 modules in my pack. Your code has made this much more possible for me and I understand most of it now so I think if the hardware works I can debug from there.
To summarize, the signal at TP A and TP B looks resonable and the signal received back at the max17841 looks terrible, correct?
How does the signal look at the low side receiving end of the first slave? At the high side output of the first slave? Might be a good idea to check the signal trought the whole chain, if possible, to narrow it down before starting to change components.
Post Reply