Skip to content

Commit

Permalink
Set default charge/discharge current from utils in main battery class
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Jul 15, 2024
1 parent 98023a0 commit ed2f95d
Show file tree
Hide file tree
Showing 16 changed files with 10 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
* Changed: JKBMS BLE - Fixes wrong max battery voltage https://github.com/Louisvdw/dbus-serialbattery/issues/1094 by @mr-manuel
* Changed: JKBMS PB Model fixes by @KoljaWindeler
* Changed: Reworked, documented and cleaned up a lot of code by @mr-manuel
* Changed: Set default charge/discharge current from utils in main battery class by @mr-manuel
* Changed: The setting `HELTEC_MODBUS_ADDR` was replaced by `MODBUS_ADDRESSES` in the `config.default.ini` by @mr-manuel
* Changed: Updated `battery_template.py` and added tons of descriptions by @mr-manuel

Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def __init__(self, port: str, baud: int, address: str):
self.hardware_version: str = None
self.cell_count: int = None
# max battery charge/discharge current
self.max_battery_charge_current: float = None
self.max_battery_discharge_current: float = None
self.max_battery_charge_current: float = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current: float = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.has_settings: bool = False

# this values should only be initialized once,
Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def get_settings(self):
# After successful connection get_settings() will be called to set up the battery
# Set the current limits, populate cell count, etc
# Return True if success, False for failure
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.version = "ANT BMS V2.0"
logger.info(self.hardware_version)
return True
Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/daly.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def get_settings(self, ser):
self.read_capacity(ser)
self.read_production_date(ser)

self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
return True

def refresh_data(self):
Expand Down
3 changes: 1 addition & 2 deletions etc/dbus-serialbattery/bms/daly_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def test_connection(self):

def get_settings(self):
self.capacity = BATTERY_CAPACITY
self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT

return True

def refresh_data(self):
Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def get_settings(self):
# Return True if success, False for failure

# Uncomment if BMS does not supply capacity
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.cell_count = utils.LIPRO_CELL_COUNT
self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count
Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/eg4_lifepower.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def get_settings(self):
# After successful connection get_settings() will be called to set up the battery
# Set the current limits, populate cell count, etc
# Return True if success, False for failure
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
hardware_version = self.read_serial_data_eg4(self.command_hardware_version)
if hardware_version:
# I get some characters that I'm not able to figure out the encoding, probably chinese so I discard it
Expand Down
3 changes: 0 additions & 3 deletions etc/dbus-serialbattery/bms/eg4_ll.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ def get_settings(self):
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count
self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count

self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT

# self.balancer_voltage = int.from_bytes(config_results[25:27], "big")/1000
# self.balancer_current_delta = int.from_bytes(config_results[27:29], "big")/1000

Expand Down
3 changes: 0 additions & 3 deletions etc/dbus-serialbattery/bms/hlpdatabms4s.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from battery import Battery, Cell
from utils import logger
import utils
import serial
from time import sleep
import sys
Expand Down Expand Up @@ -79,8 +78,6 @@ def read_test_data(self):
if ix > 0:
self.hardware_version = s1[ix : len(s1) - 1]
self.version = self.hardware_version
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.poll_interval = 10000
self.control_discharge_current = 1000
self.control_charge_current = 1000
Expand Down
5 changes: 1 addition & 4 deletions etc/dbus-serialbattery/bms/jkbms_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from utils import (
is_bit_set,
logger,
MAX_BATTERY_CHARGE_CURRENT,
MAX_BATTERY_DISCHARGE_CURRENT,
MAX_CELL_VOLTAGE,
MIN_CELL_VOLTAGE,
JKBMS_CAN_CELL_COUNT,
Expand Down Expand Up @@ -92,8 +90,7 @@ def get_settings(self):
# Set the current limits, populate cell count, etc
# Return True if success, False for failure
self.cell_count = JKBMS_CAN_CELL_COUNT
self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT

self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count

Expand Down
3 changes: 0 additions & 3 deletions etc/dbus-serialbattery/bms/lltjbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ def get_settings(self):
if not self.read_gen_data():
return False

self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT

with self.eeprom(writable=False):
cycle_cap = self.read_serial_data_llt(readCmd(REG_CYCLE_CAP))

Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/mnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def __init__(self, port, baud, address=0):
self.poll_interval = None
self.type = self.BATTERYTYPE
self.inst_capacity = None
self.max_battery_charge_current = None
self.max_battery_discharge_current = None
self.V_C_min = None
self.V_C_max = None
self.max_battery_voltage = None
Expand Down
4 changes: 1 addition & 3 deletions etc/dbus-serialbattery/bms/renogy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ def get_settings(self):
# After successful connection get_settings() will be called to set up the battery
# Set the current limits, populate cell count, etc
# Return True if success, False for failure
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT

self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count

return True

def refresh_data(self):
Expand Down
2 changes: 0 additions & 2 deletions etc/dbus-serialbattery/bms/revov.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def get_settings(self):
# Set the current limits, populate cell count, etc
# Return True if success, False for failure

self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT
self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count
# Need to fix to use correct value will do later. hard coded for now
Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/bms/seplos.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def get_settings(self):
# Return True if success, False for failure

# BMS does not provide max charge-/discharge, so we have to use hardcoded/config values
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
# self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
# self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT

self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count
Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/bms/sinowealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_connection(self):

def get_settings(self):
# hardcoded parameters, to be requested from the BMS in the future
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
# self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
# self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT

if self.cell_count is None:
self.read_pack_config_data()
Expand Down

0 comments on commit ed2f95d

Please sign in to comment.