-
-
Notifications
You must be signed in to change notification settings - Fork 92
Feature: Add new battery provider JK BMS via CAN bus #2113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
The driver was cloned from the pylontech driver with some modifications for the hardware interface. The CAN Interface can be configured for 250 kBits CAN Speed by adding the statement "can_type": 2 to the pin description in the hardware config. "battery": { "rx": 13, "tx": 14, "can_type": 2 } sets the speed to 250 kBits. Any other value will set it to 500 kBits which was previously the default.
The number of cells for the battery pack can be configured. Then the voltage of the individual cells will is displayed in the overview. Implemented most JK BMS Can Identifiers. Cleaning up the code. Removed some leftover code from the originating pylontech driver.
…f the manufacturer. The values for _chargeVoltage und _chargeCurrentLimitation are in big endian format. The function ReadBigEndianUnsignedInt16 was implemented to read the data correctly.
… in the battery admin menu. The version 1 CAN Protocol supports a 10 mV accuracy in battery voltage. With version 2 of the CAN Protocol, the accuracy can be higher because the voltages of each individual cell is reported. The pack voltage can be calculated by summing up the voltages of each cell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations to your first pull request on this project! 🚀
You mentioned that this is a alpha version. What do you mean by that?
I don't feel confident merging a new battery provider that is marked as alpha version.
I added some comments and would ask to you do some cleanup please.
Please remove commented code and superfluous new lines.
@@ -0,0 +1,103 @@ | |||
name: OpenDTU-onBattery Test Build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this new workflow? based on the commit it looks like it was added by accident.
print yourself. | ||
|
||
### Ready-To-Use | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes to the README. By looking at the commits it looks like those changes got introduced by accident.
"vite": "^6.3.5", | ||
"vite-plugin-compression": "^0.5.1", | ||
"vite-plugin-css-injected-by-js": "^3.5.2", | ||
"vite-plugin-vue-devtools": "^7.7.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the purpose of the devtools?
As it is unrelated to the JK BMS CAN support i would suggest to create a new pull-request to include it, if needed.
"SerialInterfaceTypeTransceiver": "RS-485 Transceiver on MCU", | ||
"JbdBmsConfiguration": "JBD BMS Settings", | ||
"JkBmsPackConfiguration": "JK BMS pack configuration", | ||
"NumberOfCells": "Number of Cells in this battery pack", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can revert the changes in the french locales file as there will be a fallback to the english file if strings are not present. And because the strings are not translated they are simply duplicates.
|
||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
import vueDevTools from 'vite-plugin-vue-devtools' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment about the addition of the devtools.
public: | ||
void getLiveViewData(JsonVariant& root) const final; | ||
void mqttPublish() const final; | ||
// bool getImmediateChargingRequest() const { return _chargeImmediately; } ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supported? If not, please remove it
; then execute ls /dev/tty* again and check which device was added | ||
;monitor_port = COM4 | ||
;upload_port = COM4 | ||
monitor_port = /dev/ttyACM2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes in this file
batteryConfigList.provider == 4 || | ||
batteryConfigList.provider == 5) | ||
batteryConfigList.provider == 5 || | ||
batteryConfigList.provider == 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the JK BMS does not report a discharge current limit, at least you are not ever setting in your provider implementation, it should not be part of this list.
:postfix="'Cells'" | ||
wide | ||
/> | ||
<InputElement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this a dropdown please that shows supported versions only?
Otherwise people might put in arbitrary numbers and wonder why its not working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need to configure the protocol version?
According to your PR description versions are backward compatible and we will simply get more and better data?
The 2.1 version has more features like reading single cell voltage or more detailed temperature readouts.
Thank your for the revision of the pull request. I actually never contributed to any GitHub Project. So I wanted to see if it is going in the right direction. By alpha version I mean, that not all CAN Identifiers are correctly implemented now. I am stuck a little bit on the error reporting functions. I have generated two errors (undervoltage and overcurrent) but the Values I got were a little unexpected. So I have to revise this part of the code. Regarding the different protocol versions. You are right. I also thought about detecting this automatically. |
This pull-request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull-request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is a basic CAN Driver for JK BMS which don't support other CAN Protocols like the Pylontech or others.
It will be implemented according to the specifications found here.
http://www.jk-bms.com/en/Upload/2023-12-05/1559288117.pdf
The driver is still in alpha stadium. Not all identifiers are implemented now.
According to the Datasheet, JK has at least two protocol Versions, the 1.0 and the 2.1 which are backward compatible.
The 2.1 version has more features like reading single cell voltage or more detailed temperature readouts.
With this driver it would be possible to have more than one Battery because the CAN Message Identifier is related to the setting "Device Addr.:"
But this is not implemented now.