ArminJo / JK-BMSToPylontechCAN

Converts the JK-BMS RS485 data to Pylontech CAN data
GNU General Public License v3.0
64 stars 10 forks source link

Inverter read battery total capacity (norminal) wrong (50Ah) while serial log show different value (210Ah) #13

Closed paulsteigel closed 1 year ago

paulsteigel commented 1 year ago

Hi Armin, Today I tried a test with Arduino Uno R3 (ATMega328) at my parent's home and have the inverter connected successfully with the JK-BMS. However, Battery Capacity shown by Inverter was only 50Ah while the real value (read by Serial log was 210Ah - this is the correct number). Other values were correct such as: SOC, voltage...etc, only the total capacity of the battery was wrong! I doubt the CAN converter module (code) have a bit of problem on calculating. Can you please be so kind to help checking this with thanks. Yours very faithfully, Dang Dinh Ngoc ===============QUOTE SERIAL LOG======================== C:\Users\Admin\Desktop\JK-BMSToPylontechCAN-main\JK-BMSToPylontechCAN-main\JK-BMSToPylontechCAN\JK-BMSToPylontechCAN.ino Version 2.2.2 from Oct 19 2023 No I2C LCD connected at address 0x27 Serial to JK-BMS started with 115200 bit/s! CAN started with 500 kbit/s! Page switching button is at pin 2 At long press, CAN Info page is entered and additional debug data is printed as long as button is pressed 2000 ms between 2 BMS requests 2000 ms between 2 CAN transmissions LCD Backlight timeout is 5 min

Current Calibration[mA]=834 Sleep Wait Time[s]=10

Dedicated Charge Switch Active=0 Start Current Calibration State=0 Battery Actual Capacity[Ah]=210

Total Runtime Minutes=18848 -> 13D02H08M

Warning: CellOvervoltageProtectionMillivolt value 3500 mV > 3450 mV is not recommended for LiFePO4 chemistry. There is less than 1% extra capacity above 3.5V. Temperature: Power MosFet=31, Sensor 1=27, Sensor 2=27 SOC[%]=38 -> Remaining Capacity[Ah]=79 Battery Voltage[V]=52.46, Current[A]=-9.34, Power[W]=-489, Difference to full[V]=3.5 ===============END QUOTE===============================

ArminJo commented 1 year ago

At long press, CAN Info page is entered and additional debug data is printed as long as button is pressed

What is the output of the debug page???

paulsteigel commented 1 year ago

Hi Armin, Here is the entire Log. Please help with great thanks Ngoc

============================Quote - Log=================== START C:\Users\Admin\Desktop\JK-BMSToPylontechCAN\JK-BMSToPylontechCAN.ino Version 2.0 from Oct 22 2023 No I2C LCD connected at address 0x27 Serial to JK-BMS started with 115200 bit/s! CAN started with 500 kbit/s! If you connect debug pin 3 to ground, additional debug data is printed 2000 ms between 2 BMS requests 2000 ms between 2 CAN transmissions

Receive timeout at ReplyFrameBufferIndex=0 BMS INFO Protocol Version Number=1 Software Version Number=11.XW_S11.272__ Modify Parameter Password=123456a@

External Temperature Sensors=2

BATTERY INFO Manufacturer Date=2310 Manufacturer Id=Input Userda210Ah0804202 Device ID String=Input Us Device Address=1 Total Battery Capacity[Ah]=210, Low Capacity Alarm Percent=20 Charging Cycles=8 Total Charging Cycle Capacity=1731

Battery Cells=16, Cell Count=16

VOLTAGE PROTECTION INFO Battery Overvoltage Protection[mV]=56000, Undervoltage=48000 Cell Overvoltage Protection[mV]=3500, Recovery=3450, Delay[s]=5 Cell Undervoltage Protection[mV]=3000, Recovery=3050, Delay[s]=5 Cell Voltage Difference Protection[mV]=300 Discharging Overcurrent Protection[A]=80, Delay[s]=300 Charging Overcurrent Protection[A]=60, Delay[s]=30

TEMPERATURE PROTECTION INFO Power MosFet Temperature Protection=100, Recovery=80 Sensor1 Temperature Protection=100, Recovery=100 Sensor1 to Sensor2 Temperature Difference Protection=20 Charge Overtemperature Protection=70, Discharge=70 Charge Undertemperature Protection=-20, Recovery=-10 Discharge Undertemperature Protection=-20, Recovery=-10

MISC INFO Balance Starting Cell Voltage=[mV]2900 Balance Triggering Voltage Difference[mV]=10

Current Calibration[mA]=834 Sleep Wait Time[s]=10

Dedicated Charge Switch Active=0 Start Current Calibration State=0 Battery Actual Capacity[Ah]=210

Total Runtime Minutes=18981 -> 13D04H21M Total balancing time=1 -> 0D00H00M02S CELL INFO 16 Cells, Minimum=3268 mV, Maximum=3289mV, Delta=21 mV, Average=3283 mV 1=3278 mV, 2=3288 mV, 3=3279 mV, 4=3288 mV, 5=3288 mV, 6=3288 mV, 7=3288 mV, 8=3289 mV, 9=3275 mV, 10=3271 mV, 11=3268 mV, 12=3289 mV, 13=3283 mV, 14=3288 mV, 15=3289 mV, 16=3289 mV, Minimum percentages 1= 0 % | 0, 2= 0 % | 0, 3= 0 % | 0, 4= 0 % | 0, 5= 0 % | 0, 6= 0 % | 0, 7= 0 % | 0, 8= 0 % | 0, 9= 0 % | 0, 10= 0 % | 0, 11= 0 % | 1, 12= 0 % | 0, 13= 0 % | 0, 14= 0 % | 0, 15= 0 % | 0, 16= 0 % | 0, Maximum percentages 1= 0 % | 0, 2= 0 % | 0, 3= 0 % | 0, 4= 0 % | 0, 5= 0 % | 0, 6= 0 % | 0, 7= 0 % | 0, 8= 0 % | 1, 9= 0 % | 0, 10= 0 % | 0, 11= 0 % | 0, 12= 0 % | 1, 13= 0 % | 0, 14= 0 % | 0, 15= 0 % | 1, 16= 0 % | 1,

Warning: CellOvervoltageProtectionMillivolt value 3500 mV > 3450 mV is not recommended for LiFePO4 chemistry. There is less than 1% extra capacity above 3.5V. Temperature: Power MosFet=30, Sensor 1=27, Sensor 2=27 SOC[%]=28 -> Remaining Capacity[Ah]=58 Battery Voltage[V]=52.53, Current[A]=-0.40, Power[W]=-21 Battery Voltage difference to full[V]=3.5 Charging MosFet enabled, active | Discharging MosFet enabled, active | Balancing enabled, active Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x85, 0x14, 0xFC, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Battery Voltage[V]=52.53, Current[A]=-0.26, Power[W]=-13 Battery Voltage difference to full[V]=3.5 Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x85, 0x14, 0xFE, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x85, 0x14, 0xFE, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x85, 0x14, 0xFE, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Battery Voltage[V]=52.48, Current[A]=-9.87, Power[W]=-517 Battery Voltage difference to full[V]=3.5 Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x80, 0x14, 0x9E, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Battery Voltage[V]=52.45, Current[A]=-14.81, Power[W]=-776 Battery Voltage difference to full[V]=3.5 Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7D, 0x14, 0x6C, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Battery Voltage[V]=52.44, Current[A]=-14.67, Power[W]=-769 Battery Voltage difference to full[V]=3.6 Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7C, 0x14, 0x6E, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Battery Voltage[V]=52.44, Current[A]=-14.81, Power[W]=-776 Battery Voltage difference to full[V]=3.6 Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7C, 0x14, 0x6C, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7C, 0x14, 0x6C, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7B, 0x14, 0x6C, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E Send CAN CANId=0x351, FrameLength=8, Data=0x30, 0x2, 0x58, 0x2, 0x20, 0x3, 0xE0, 0x1 CANId=0x355, FrameLength=4, Data=0x1C, 0x0, 0x64, 0x0 CANId=0x356, FrameLength=6, Data=0x7A, 0x14, 0x6C, 0xFF, 0x2C, 0x1 CANId=0x35E, FrameLength=8, Data=0x50, 0x59, 0x4C, 0x4F, 0x4E, 0x20, 0x20, 0x20 CANId=0x35C, FrameLength=2, Data=0xC0, 0x0 CANId=0x305, FrameLength=8, Data=0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 CANId=0x359, FrameLength=7, Data=0x0, 0x0, 0x0, 0x0, 0x1, 0x50, 0x4E ============================end Quote - Log===================

ArminJo commented 1 year ago

It must look like https://github.com/ArminJo/JK-BMSToPylontechCAN/blob/9f9be264ac7ef9d2e3c29954dffca267e3409461/extras/JK-BMS.log#L70

paulsteigel commented 1 year ago

It must look like

https://github.com/ArminJo/JK-BMSToPylontechCAN/blob/9f9be264ac7ef9d2e3c29954dffca267e3409461/extras/JK-BMS.log#L70

Hi Armin, I updated the log file and discovered that CAN data frame does not include Total Capacity in Ah. That is why the Inverter does not reflect / and or calculate and just use its default value! (50Ah) or the inverter might not have data to calculate this amount then! Can you please be so kind to include with 0x35F into the CAN structure? image Ref: https://github.com/Uksa007/esphome-jk-bms-can/blob/main/docs/SMA%20CAN%20Protocol%20Mapping.pdf I also update the CAN log (previous comment) for your reference then! Ngoc

ArminJo commented 1 year ago

I must test it for backward compatibility...

paulsteigel commented 1 year ago

Many thanks Armin, It will be well appreciated by many users like my country then. Today, I tested 2 replication of the Arduino Uno R3 and nano (ATMega328P) and discovered strange behavior:

Case 1: Arduino Uno (ATMega328P)-Chip1 and it received data from JK-BMS well with response on details data of the BMS. I replace the with a new Uno R3 (same chip)-Chip2 , same firmware and the "Receive timeout at ReplyFrameBufferIndex=..." error happened. I plug back the Chip1 and no error happened! Case 2: I used Dupont wire to connect Arduino nano with JK-BMS and similar to case 1, replace a new nano, the error happened again. It seems that with Atmega 328 (DIP) version, all the tests were success with BMS response. Do you have any advice on this with thanks. The problem was far out of my knowledge and logic. Ngoc!

ArminJo commented 1 year ago

Hi Ngoc, what is the sensible content of the 6 non capacity bytes in frame 0x35F? I guessed some values.

What is the sensible content of SOCHighDefinition100PPM as 3. word of frame 0x355, documented in SMA CAN protocol. I did not include it so far.

There should be no difference between the 328 versions, except if this are counterfeit versions. My two China clone Nanos are working fine.

paulsteigel commented 1 year ago

Hi Ngoc, what is the sensible content of the 6 non capacity bytes in frame 0x35F? I guessed some values.

What is the sensible content of SOCHighDefinition100PPM as 3. word of frame 0x355, documented in SMA CAN protocol. I did not include it so far.

There should be no difference between the 328 versions, except if this are counterfeit versions. My two China clone Nanos are working fine.

Hi Armin, Regarding this table, I assume only the 4th and 5th are meaningful for the capacity in Ah to be sent to the inverter. image

I am now checking a bit more with other type of batteries to see whether these can be meaningful and worth incorporating into the PylontechCAN. At the moments, the SOC is enough for the inverter to control charging/discharging.

image What I am wondering is how the inverter can have this data for some other type of the batteries (SVE5000WM), it can read the Capacity in Ah and also apply a nice charging curve for the battery (see second image). So it means that the Inverter can request more data than we have included in the CAN message and probably have its internal charging computation so far. Best, Ngoc