Skip to content

Commit

Permalink
V0.14fixes (#379)
Browse files Browse the repository at this point in the history
* JKBMS temp fixes

fix #354
fix #378

* Add check for CVL min

* new version
  • Loading branch information
Louisvdw authored Dec 29, 2022
1 parent dd27c05 commit 3685d15
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion buildfiles.lst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
rc.local
conf/serial-starter.d
etc/dbus-serialbattery/service/run
etc/dbus-serialbattery/service/log/run
Expand Down
10 changes: 6 additions & 4 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ def manage_charge_voltage_linear(self):
self.voltage = currentBatteryVoltage # for testing

if foundHighCellVoltage:
self.control_voltage = currentBatteryVoltage - penaltySum
# Keep penalty above min battery voltage
self.control_voltage = max(currentBatteryVoltage - penaltySum, MIN_CELL_VOLTAGE * self.cell_count)
else:
self.control_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.control_voltage = FLOAT_CELL_VOLTAGE * self.cell_count

def manage_charge_voltage_step(self):
voltageSum = 0
Expand All @@ -149,7 +150,8 @@ def manage_charge_voltage_step(self):
self.allow_max_voltage = False

if self.allow_max_voltage:
self.control_voltage = MAX_CELL_VOLTAGE * self.cell_count
# Keep penalty above min battery voltage
self.control_voltage = max(MAX_CELL_VOLTAGE * self.cell_count, MIN_CELL_VOLTAGE * self.cell_count)
else:
self.control_voltage = FLOAT_CELL_VOLTAGE * self.cell_count

Expand Down Expand Up @@ -431,7 +433,7 @@ def log_cell_data(self):

def log_settings(self):

logger.info(f'Battery connected to dbus from {self.port}')
logger.info(f'Battery {self.type} connected to dbus from {self.port}')
logger.info(f'=== Settings ===')
cell_counter = len(self.cells)
logger.info(f'> Connection voltage {self.voltage}V | current {self.current}A | SOC {self.soc}%')
Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/jkbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def read_status_data(self):
temp1 = unpack_from('>H', self.get_data(status_data, b'\x81', offset, 2))[0]
offset = cellbyte_count + 9
temp2 = unpack_from('>H', self.get_data(status_data, b'\x82', offset, 2))[0]
self.to_temp(1, temp1 if temp1 <= 100 else -(temp1 - 100))
self.to_temp(2, temp1 if temp2 <= 100 else -(temp2 - 100))
self.to_temp(1, temp1 if temp1 < 99 else (100 - temp1))
self.to_temp(2, temp2 if temp2 < 99 else (100 - temp2))

offset = cellbyte_count + 12
voltage = unpack_from('>H', self.get_data(status_data, b'\x83', offset, 2))[0]
Expand Down
6 changes: 3 additions & 3 deletions etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# Constants - Need to dynamically get them in future
DRIVER_VERSION = 0.14
DRIVER_SUBVERSION = '2'
DRIVER_SUBVERSION = '.3'
zero_char = chr(48)
degree_sign = u'\N{DEGREE SIGN}'

Expand Down Expand Up @@ -75,8 +75,8 @@
# if the cell voltage reaches 3.55V, then reduce current battery-voltage by 0.01V
# if the cell voltage goes over 3.6V, then the maximum penalty will not be exceeded
# there will be a sum of all penalties for each cell, which exceeds the limits
PENALTY_AT_CELL_VOLTAGE = [3.55, 3.6]
PENALTY_BATTERY_VOLTAGE = [0.01, 2.0] # this voltage will be subtracted
PENALTY_AT_CELL_VOLTAGE = [3.45, 3.55, 3.6]
PENALTY_BATTERY_VOLTAGE = [0.01, 1.0, 2.0] # this voltage will be subtracted


######### SOC limitation #########
Expand Down

0 comments on commit 3685d15

Please sign in to comment.