Skip to content
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

Support for Daly CAN Bus #169

Merged
merged 8 commits into from
Sep 17, 2023

Conversation

SamuelBrucksch
Copy link
Contributor

@SamuelBrucksch SamuelBrucksch commented Aug 1, 2022

This is still highly experimental.

Install python-can on Venus OS:
As pip3 is not available this needs to be done manually, you can check the download link here: https://pypi.org/project/python-can/#files

wget https://files.pythonhosted.org/packages/1f/f7/a643cba269d59e108fe4c1854a8e71d5cdadadd4de1b9c8862b190171122/python-can-4.0.0.tar.gz
tar xf python-can-4.0.0.tar.gz
cd python-can-4.0.0
python3 setup.py develop

In dbus-serialbattery.py comment all battery types, and uncomment DalyCAN, so it is the only BMS that is tried to connect to.

In Venus OS settings via Remote Console go to Settings->Services->VE.Canport->CAN-bus profile and click disabled. Then on console via SSH enter ip link set can0 up type can bitrate 250000 check that a profile with 250k is selected.

As we do not need a serial port, this can be executed from command line directly, without searching for a serial device.

cd /data/etc/dbus-serialbattery
python3 dbus-serialbattery

If everything works well and cables were made correctly, you should see data on remote console.

To test that everything works you can also use Venus OS CLI tools:

candump can0

This will list all the communication on can0

cansend can0 18950140#

This will request the battery cell voltages. Response will look like this:

  candump can0
  cansend can0 18950140# [execute this on a second terminal]
  can0  18950140   [0] 
  can0  18954001   [8]  01 0D 7D 0D 7E 0D 7E 58
  can0  18954001   [8]  02 0D 7E 0D 7F 0D 7E 58
  can0  18954001   [8]  03 0D 7E 0D 7F 0D 7E 58
  can0  18954001   [8]  04 0D 7E 0D 7E 0D 7E 58
  can0  18954001   [8]  05 0D 7E 0D 7F 0D 7F 58
  can0  18954001   [8]  06 0D 7F 0D 7F 0D 7F 58

@SamuelBrucksch
Copy link
Contributor Author

@Louisvdw this sounds a bit complex but a few things can be made easier, like that you do not need to manually setup can0, if i add the right filters to the can bus library. However can does not need a serial, so we need to add a detection mechanism somewhere.

That detection mechanism could for example execute the cansend and candump command line tool and if we get data, we know we have a connected can interface. Is that something we could easily add to the detection mechanism? Because in that case we could also do the auto detection and add a small code snipped, to switch between CAN and serial based on the detection.

@Louisvdw
Copy link
Owner

Louisvdw commented Aug 2, 2022

Hi Samuel
Yes that has always been the issue as the CANbus is not running through the serial starter mechanism that the driver normally use. There are a few other batteries that I am working on that also work a bit different. I'll play around with a few options on how to detect the CAN as well.

@SamuelBrucksch
Copy link
Contributor Author

I just added the can filters, so no need to manually set up can anymore as it is set to 250k by default, we can still mention to check if it is really set to 250k.

@danygi79
Copy link

danygi79 commented Aug 5, 2022

Is it possible to configure the CAN bus at 500K? On multiplus II GX it is not possible to select the speed at 250k and therefore it does not work.

@SamuelBrucksch
Copy link
Contributor Author

SamuelBrucksch commented Aug 6, 2022

Daly has 250k. If the MP2 GX has VE.Can it can be configured to 250k. Only BMS Can is 500k.

@geromd
Copy link

geromd commented Aug 11, 2022

Is it possible to configure the CAN bus at 500K? On multiplus II GX it is not possible to select the speed at 250k and therefore it does not work.

You need to update the Multiplus II GX Firmware. Than you have the Menue to set the 250k for CAN
CAN

I will wait till Louis has implemented the CAN-Connection to the next stable release.

@LukasBenner
Copy link

How did you connect the MP2 GX to the Daly BMS? Simply an adapter from daly bms port to rj45 of MP2 GX?

@SamuelBrucksch
Copy link
Contributor Author

Daly has CAN bus so i just connected pins L and H from Daly to can port from Cerbo.

@stanhausc
Copy link

Hi, no need to change utils.py file?

I'm trying to implement can communication with a BMS Fox. Fox BMS.

image

@Mipamlius
Copy link

Hello Maybe a stupid question but does can bus work with venus os 2.9 on raspberry pi ?

@SamuelBrucksch
Copy link
Contributor Author

SamuelBrucksch commented Feb 23, 2023

Just tried venus os 2.93 on a Cerbo and it works. Not sure about the Raspi.

@Newti04
Copy link

Newti04 commented Mar 28, 2023

Hello Samuel,
I will use it on a raspberry py 3b+ with a can-hat from waveshare.
I installed the python-can-4.0 package and it is possible to use the commands:
candump can0 and cansend can0 18950140# (in extra terminal)
It shows the Voltages from the battery-cells. (My can-hat uses can8 and can9 instead of can0)
Now I want to install dbus-seriallbattery, but I cannot find the right branch witch supports the can-connection. And the code in this pullrequest does not work with the actual released code 0.14.3
Please can you show me, where I can get it.
BR
Claus

@SamuelBrucksch
Copy link
Contributor Author

I'm still on the code of this branch, as it works fine for me. There is no newer version of this.

@Newti04
Copy link

Newti04 commented Mar 29, 2023

Hello Samuel,
i tried this branch [36f297a]: https://github.com/SamuelBrucksch/dbus-serialbattery/tree/samuel/add-daly-can-support
I copied dbus-serialbattery-samuel-add-daly-can-support/etc/dbus-serialbattery to /data/etc/dbus-serialbattery
Then i edit /data/etc/dbus-serialbattery/dbus-serialbattery.py

from dbushelper import DbusHelper            
from utils import DRIVER_VERSION, DRIVER_SUBVERSION, logger
import logging                                             
# from lltjbd import LltJbd                                
# from daly import Daly                                    
# from ant import Ant                                      
# from jkbms import Jkbms                                  
# from sinowealth import Sinowealth                        
# from renogy import Renogy        
# from revov import Revov          
from daly_can import DalyCAN       
# from mnb import MNB
...
    def get_battery_type(_port):                                    
        # all the different batteries the driver support and need to test for
        battery_types = [                                                                                 
            # LltJbd(port=_port, baud=9600),                        
            # Ant(port=_port, baud=19200),                                   
            # Daly(port=_port, baud=9600, address=b"\x40"),                                               
            # Daly(port=_port, baud=9600, address=b"\x80"),         
            # Jkbms(port=_port, baud=115200),                                
            # Sinowealth(port=_port, baud=9600),                                                          
            # Renogy(port=_port, baud=9600),                        
            # Revov (port=_port, baud=9600),                                 
            DalyCAN(port=_port, baud=9600),                                                               
            # MNB(port=_port, baud=9600),                           
        ] 

and I changed can0 to can 8 in /data/etc/dbus-serialbattery/daly_can.py

...
               {"can_id":self.response_cell_balance, "can_mask": 0xFFFFFFF},
               {"can_id":self.response_alarm, "can_mask": 0xFFFFFFF}]
        self.bus = can.Bus(interface='socketcan',
              channel='can8',       
              receive_own_messages=False,
              can_filters=can_filters)
...

because my can-device is named can8

cansend can8 18950140#

shows in an extra terminal candump can8

....
can8  307   [8]  12 34 56 78 56 49 43 00
  can8  305   [8]  00 00 00 00 00 00 00 00
  can8  307   [8]  12 34 56 78 56 49 43 00
  can8  18950140   [0] 
  can8  18954001   [8]  01 0D 1B 0D 1D 0D 1D 00
  can8  18954001   [8]  01 0D 1B 0D 1D 0D 1D C0
  can8  18954001   [8]  01 0D 19 0D 1B 0D 1C 88
  can8  18954001   [8]  02 0D 1E 0D 1F 0D 1E 00
  can8  18954001   [8]  02 0D 1D 0D 1D 0D 1D C0
  can8  18954001   [8]  02 0D 1D 0D 1D 0D 1D 88
  can8  18954001   [8]  03 0D 1F 0D 1E 0D 1F 00
  can8  18954001   [8]  03 0D 1D 0D 1D 0D 1E C0
  can8  18954001   [8]  03 0D 1D 0D 1D 0D 1B 88
  can8  18954001   [8]  04 0D 1E 0D 1D 0D 1E 00
  can8  18954001   [8]  04 0D 1D 0D 1E 0D 1D C0
  can8  18954001   [8]  04 0D 1A 0D 1B 0D 1B 88
  can8  18954001   [8]  05 0D 1E 0D 1E 0D 1E 00
  can8  18954001   [8]  05 0D 19 0D 1D 0D 1D 88
  can8  18954001   [8]  06 0D 1B 0D 1E 0D 1E 00
  can8  18954001   [8]  05 0D 1D 0D 1D 0D 1D C0
  can8  18954001   [8]  06 0D 18 0D 1D 0D 1D 88
  can8  18954001   [8]  06 0D 1B 0D 1D 0D 1D C0
  can8       305   [8]  00 00 00 00 00 00 00 00
  can8       307   [8]  12 34 56 78 56 49 43 00
  can8       305   [8]  00 00 00 00 00 00 00 00
....

It shows the cell-numbers 3 times, because I have 3 DalyBMS 16S connected to the can-bus.

When I start dbus-serialbattery with::

python3 /data/etc/dbus-serialbattery/dbus-serialbattery.py can8

I get this output:

INFO:SerialBattery:Starting dbus-serialbattery
INFO:SerialBattery:dbus-serialbattery v0.12b2
INFO:SerialBattery:Testing DalyCAN
INFO:SerialBattery:DalyBMS 16 cells
INFO:SerialBattery:Connection established to DalyCAN
INFO:SerialBattery:Battery connected to dbus from can8
INFO:SerialBattery:=== Settings ===
INFO:SerialBattery:> Connection voltage NoneV | current NoneA | SOC None%
INFO:SerialBattery:> Cell count 16 | cells populated 0
INFO:SerialBattery:> CCL Charge NoneA | DCL Discharge NoneA
INFO:SerialBattery:> MIN_CELL_VOLTAGE 2.9V | MAX_CELL_VOLTAGE 3.45V
INFO:SerialBattery:DeviceInstance = 2
INFO:SerialBattery:com.victronenergy.battery.can8
WARNING:SerialBattery:read_soc_data - triesValid 2
WARNING:SerialBattery:read_soc_data - triesValid 1
Traceback (most recent call last):
  File "/data/etc/dbus-serialbattery/dbushelper.py", line 176, in publish_battery
    self.publish_dbus()
  File "/data/etc/dbus-serialbattery/dbushelper.py", line 186, in publish_dbus
    self._dbusservice['/Soc'] = round(self.battery.soc, 2)
TypeError: type NoneType doesn't define __round__ method

Cell count 16 is correct, the other things are None

Do you have any hints for me?
BR
Claus

@Newti04
Copy link

Newti04 commented Mar 29, 2023

Hello Samuel,
I found the problem, I disconnect 2 DalyBMS, so with one DalyBMS connected it works :-)
So I have to check, what to do, to use 3 BMS at one can-bus.
Thanks for your help.
Claus

@stanhausc
Copy link

stanhausc commented Mar 29, 2023

Hello Samuel, i tried this branch [36f297a]: https://github.com/SamuelBrucksch/dbus-serialbattery/tree/samuel/add-daly-can-support I copied dbus-serialbattery-samuel-add-daly-can-support/etc/dbus-serialbattery to /data/etc/dbus-serialbattery Then i edit /data/etc/dbus-serialbattery/dbus-serialbattery.py from dbushelper import DbusHelper from utils import DRIVER_VERSION, DRIVER_SUBVERSION, logger import logging

# from lltjbd import LltJbd
# from daly import Daly
# from ant import Ant
# from jkbms import Jkbms
# from sinowealth import Sinowealth
# from renogy import Renogy
# from revov import Revov
from daly_can import DalyCAN

# from mnb import MNB
... def get_battery_type(_port): # all the different batteries the driver support and need to test for battery_types = [ # LltJbd(port=_port, baud=9600), # Ant(port=_port, baud=19200), # Daly(port=_port, baud=9600, address=b"\x40"), # Daly(port=_port, baud=9600, address=b"\x80"), # Jkbms(port=_port, baud=115200), # Sinowealth(port=_port, baud=9600), # Renogy(port=_port, baud=9600), # Revov (port=_port, baud=9600), DalyCAN(port=_port, baud=9600), # MNB(port=_port, baud=9600), ] and I changed can0 to can 8 in /data/etc/dbus-serialbattery/daly_can.py ... {"can_id":self.response_cell_balance, "can_mask": 0xFFFFFFF}, {"can_id":self.response_alarm, "can_mask": 0xFFFFFFF}] self.bus = can.Bus(interface='socketcan', channel='can8', receive_own_messages=False, can_filters=can_filters) ... because my can-device is named can8 cansend can8 18950140# shows in an extra terminal candump can8 .... can8 307 [8] 12 34 56 78 56 49 43 00 can8 305 [8] 00 00 00 00 00 00 00 00 can8 307 [8] 12 34 56 78 56 49 43 00 can8 18950140 [0] can8 18954001 [8] 01 0D 1B 0D 1D 0D 1D 00 can8 18954001 [8] 01 0D 1B 0D 1D 0D 1D C0 can8 18954001 [8] 01 0D 19 0D 1B 0D 1C 88 can8 18954001 [8] 02 0D 1E 0D 1F 0D 1E 00 can8 18954001 [8] 02 0D 1D 0D 1D 0D 1D C0 can8 18954001 [8] 02 0D 1D 0D 1D 0D 1D 88 can8 18954001 [8] 03 0D 1F 0D 1E 0D 1F 00 can8 18954001 [8] 03 0D 1D 0D 1D 0D 1E C0 can8 18954001 [8] 03 0D 1D 0D 1D 0D 1B 88 can8 18954001 [8] 04 0D 1E 0D 1D 0D 1E 00 can8 18954001 [8] 04 0D 1D 0D 1E 0D 1D C0 can8 18954001 [8] 04 0D 1A 0D 1B 0D 1B 88 can8 18954001 [8] 05 0D 1E 0D 1E 0D 1E 00 can8 18954001 [8] 05 0D 19 0D 1D 0D 1D 88 can8 18954001 [8] 06 0D 1B 0D 1E 0D 1E 00 can8 18954001 [8] 05 0D 1D 0D 1D 0D 1D C0 can8 18954001 [8] 06 0D 18 0D 1D 0D 1D 88 can8 18954001 [8] 06 0D 1B 0D 1D 0D 1D C0 can8 305 [8] 00 00 00 00 00 00 00 00 can8 307 [8] 12 34 56 78 56 49 43 00 can8 305 [8] 00 00 00 00 00 00 00 00 ...

It shows the cell-numbers 3 times, because I have 3 DalyBMS 16S connected to the can-bus.

When I start dbus-serialbattery with:: python3 /data/etc/dbus-serialbattery/dbus-serialbattery.py can8 I get this output:

INFO:SerialBattery:Starting dbus-serialbattery INFO:SerialBattery:dbus-serialbattery v0.12b2 INFO:SerialBattery:Testing DalyCAN INFO:SerialBattery:DalyBMS 16 cells INFO:SerialBattery:Connection established to DalyCAN INFO:SerialBattery:Battery connected to dbus from can8 INFO:SerialBattery:=== Settings === INFO:SerialBattery:> Connection voltage NoneV | current NoneA | SOC None% INFO:SerialBattery:> Cell count 16 | cells populated 0 INFO:SerialBattery:> CCL Charge NoneA | DCL Discharge NoneA INFO:SerialBattery:> MIN_CELL_VOLTAGE 2.9V | MAX_CELL_VOLTAGE 3.45V INFO:SerialBattery:DeviceInstance = 2 INFO:SerialBattery:com.victronenergy.battery.can8 WARNING:SerialBattery:read_soc_data - triesValid 2 WARNING:SerialBattery:read_soc_data - triesValid 1 Traceback (most recent call last): File "/data/etc/dbus-serialbattery/dbushelper.py", line 176, in publish_battery self.publish_dbus() File "/data/etc/dbus-serialbattery/dbushelper.py", line 186, in publish_dbus self._dbusservice['/Soc'] = round(self.battery.soc, 2) TypeError: type NoneType doesn't define **round** method

Cell count 16 is correct, the other things are None

Do you have any hints for me? BR Claus

The error is in the frame you are receiving from the SOC, you receive 'NoneType', I believe it is not returning anything. Have a look at what you're getting, or you can try adding 'self.soc = 50' to your code, and see if it works, and then fix that error.

@SamuelBrucksch
Copy link
Contributor Author

SamuelBrucksch commented Mar 29, 2023

If you have multiple Daly you try to connect to, you probably need one instance of this for each BMS (with its own physical connection). Else every BMS needs a separate ID. But querying multiple BMS with different IDs is also not supported. So if they share one CAN Bus you definitely need multiple IDs for multiple devices. Check if you can set an ID in the Daly BMS app.

@Newti04
Copy link

Newti04 commented Mar 29, 2023

Hello Samuel,
yes, I have set different IDs for each BMS with the PC-Software.
You wrote -> But querying multiple BMS with different IDs is also not supported.
You mean it is not supported by this Software-Release, but it could be possible with rewriting/changing it, if the BMSs have different IDs on one can-bus.
Ok, my can-hat has 2 can-bus connections and I could use the second can9 for the second BMS, but the intention was to use one connection for all 3 BMS.
I see, if I start it with different args, it gets different DeviceInstance numbers, so it is possible to use it with different ports.

Do you know, how to check, how the BMS marks the data with his BMS-ID? ore how to filter the data from each BMS?
BR
Claus

@SamuelBrucksch
Copy link
Contributor Author

You can check with candump and cansend. One part of the identifier should be the ID, maybe the 01 part, don't remember. Just try to replace the ID part with the new ID, also for filtering the responses and it should work.

@Newti04
Copy link

Newti04 commented Mar 29, 2023

In the script daly_can.py there is
# command bytes [Priority=18][Command=94][BMS ID=01][Uplink ID=40]
command_base = 0x18940140
command_soc = 0x18900140
so I tried cansend
cansend 18950140#
cansend 18950240#
cansend 18950340#
cansend 18950440#
cansend 18950540#
... and so on, but only with result on: cansend 18950140#

I have to check tomorrow with the PC, if the IDs on the BMSs are correct set.

@Newti04
Copy link

Newti04 commented Mar 30, 2023

Hello Samuel,
now I had a look on the settings from the 3 BMS with BMSMonitor-V2.1.9 on the TAB "Engineering model" in the section "BMS address manager", all have different BoardNo: (1-3) and the same SlaveNo: 1. The SlaveNo cannot be changed.
If I connect only one BMS and try to read data with candump, I get always the same result, with each BMS 1-3 and they give only feedback on cansend can8 18950140#
So, I think the BMS do not change the can-ID when the BoardNo in BMS address manager is changed.
The firmware on my BMSs is 11_221015_AL1T, perhaps other firmware will do the trick.

@transistorgit
Copy link
Contributor

Hi guys,

What's the Status here? Any new insights about multiple bms on one port?

I initially wanted this also. My findings were:

  • You have to order a daly bms with can support explicitely
  • You have to also mention that you want to use them in parallel
  • And you also have to buy the WNT Connection boards

On the wnt, you choose the address by dip switch.

I got it running partly, but some read values were garbage. So I ditched it and use normal serial connection. But I'm still interested if there is a working solution.

@SirDingDong
Copy link

Hi, i am a bit lost, is there a step by step how to set up can connection? Serial is working, but also want to try can =)

@mr-manuel mr-manuel changed the base branch from master to dev September 17, 2023 09:03
@mr-manuel mr-manuel marked this pull request as ready for review September 17, 2023 09:22
@mr-manuel mr-manuel changed the title WIP: Support for Daly CAN Bus Support for Daly CAN Bus Sep 17, 2023
@mr-manuel
Copy link
Collaborator

I will merge this PR and make some changes to work with the latest version. Since the Bluetooth driver is also not needing the serial adapter I make some changes to the install script so you can specify the can port number in the config.ini.

@mr-manuel mr-manuel merged commit b1880f5 into Louisvdw:dev Sep 17, 2023
@mr-manuel
Copy link
Collaborator

Is there a simple way for a user to display all CAN devices like can0, can8 and so on in case it's not the default one?

@mr-manuel
Copy link
Collaborator

Please try the latest nightly from the dev branch. To enable CAN add CAN_PORT = can0 to the config.ini.

@SamuelBrucksch SamuelBrucksch deleted the samuel/add-daly-can-support branch October 28, 2023 08:16
@SamuelBrucksch
Copy link
Contributor Author

SamuelBrucksch commented Oct 28, 2023

Hi @mr-manuel , sorry for the late reply, i just tried it and set the CAN_PORT to can0, however it does not seem to have any effect. this is the log:

root@einstein:/data/etc/dbus-serialbattery# python3 dbus-serialbattery.py 
INFO:SerialBattery:
INFO:SerialBattery:Starting dbus-serialbattery
INFO:SerialBattery:dbus-serialbattery v1.0.20231010dev2
INFO:SerialBattery:No Port needed
INFO:SerialBattery:-- Testing BMS: 1 of 3 rounds
INFO:SerialBattery:-- Testing BMS: 2 of 3 rounds
INFO:SerialBattery:-- Testing BMS: 3 of 3 rounds
ERROR:SerialBattery:ERROR >>> No battery connection at /dev/ttyUSB9
root@einstein:/data/etc/dbus-serialbattery# 

Also if i enforce can0 in code, it also doesn't work:

root@einstein:/data/etc/dbus-serialbattery# python3 dbus-serialbattery.py 
INFO:SerialBattery:
INFO:SerialBattery:Starting dbus-serialbattery
INFO:SerialBattery:dbus-serialbattery v1.0.20231010dev2
INFO:SerialBattery:-- Testing BMS: 1 of 3 rounds
INFO:SerialBattery:-- Testing BMS: 2 of 3 rounds
INFO:SerialBattery:-- Testing BMS: 3 of 3 rounds
ERROR:SerialBattery:ERROR >>> No battery connection at can0
root@einstein:/data/etc/dbus-serialbattery# 

@mr-manuel
Copy link
Collaborator

Did you troubleshoot the CAN connection with can tools in the first post?

@SamuelBrucksch
Copy link
Contributor Author

No, i just stopped my working daly can implementation, renamed it to *_old, installed the nightly from develop at the old location and setup everything and reinstalled locally, restarted and then i didnt see anything. so i tried to start it manually by setting can0 and daly programmatically, and it didn't work. As i have a working version, i didn't spend much time on debugging. So not sure, what exactly was wrong here. After i switched back to my old version, everything worked again, so it's probably nothing related to the hardware/can setup.

@mr-manuel
Copy link
Collaborator

Since I could not test the integrations it will be nice, if you can debug it.

Louisvdw pushed a commit that referenced this pull request Nov 25, 2023
* Update reinstall-local.sh: Fixed charge current parameter

Update reinstall-local.sh: Corrected charge current parameter for  initial config.ini

* Exclude devices from driver startup
This prevents blocking the serial port

* implement callback function for update

* fix comments to reflect new logic

* update changelog

* set soc=100% when charge mode changes to float, apply exponential smoothing on current readout

* remove scan for devices

the scan for devices and check if the BMS to test is present doesn't add value
if the device is not within range (or the MAC is wrong), then the subsequent start_scraping call will either fail or fail to produce usable data

* JKBMS_BLE driver fixes

* added Bluetooth signal strenght, increased debug

* Optimized reinstallation procedure
- Changed: Optimized restart sequence for the bluetooth installation
- Changed: Run serial part first and then bluetooth part. This allows the serial driver to get operative faster
- Removed: $DRIVERNAME variable for clearer paths
- Removed: Bluetooth system driver restart, since the devices get disconnected by the service before starting the dbus-serialbatterydriver

* Improved Jkbms_Ble error handling

* optimized disable procedure

* small fixes

* save custom name and make it restart persistant
#100

* changed unique identifier from string to function
function can be overridden by BMS battery class

* fix typo

* fix Sinowealth not loading
#702

* fix unique identifier function

* enable BMS over config, if disabled by default
Now you can also add more then one BMS for BMS_TYPE

* show battery port in log

* ANT BMS fixes
Fixed that other devices are recognized as ANT BMS

* Sinowealth BMS fixes
Fixed that other devices are recognized as Sinowealth BMS

* improved publish_battery error handling
switched from error count to seconds

* Improve Battery Voltage Handling in Linear Absorption Mode

* Refactor change time() to int(time()) for consistency in max_voltage_start_time and tDiff calculation
* Refactor battery voltage calculations for efficiency and clarity
* Remove penalty_buffer
* Reset max_voltage_start_time wenn we going to bulk(dynamic) mode

* updated changelog

* fix reply processing

* Reduce the big inrush current, if the CVL jumps
from Bulk/Absorbtion to Float
fix #659

* Check returned data lenght for Seplos BMS

Be stricter about the return data we accept, might fix the problem of grid meters accidently being recognized as a Seplos

* Validate current, voltage, capacity and SoC for all BMS
This prevents that a device, which is no BMS, is detected as BMS

* removed double check

* bump version

* fix validation if None

* updated changelog

* proposal to #659 formatted :)

* bugfix proposal to #659

* refactor setting float charge_mode

* fix type error, removed bluetooth cronjob

* updated changelog

* fix rs485 write communication errors by inserting sleeps, add debug print for charge mode and fix crash on write soc failures

* fix write problem on set_soc. also changed the switch charge/discharge function, just in case

* debug msg

* Bluetooth optimizations

* Fixes by @peterohman
#505 (comment)

* fix #712

* fix meaningless time to go values

* fix meaningless time to go values

* Duration of transition to float depends on number of cells

* Float transition - Voltage drop per second

* Update hlpdatabms4s.py

* Validate setting of FLOAT_CELL_VOLTAGE and avoid misconfiguration

* consider utils.LINEAR_RECALCULATION_EVERY to refresh CVL

* cleanup

* consider utils.LINEAR_RECALCULATION_EVERY to refresh CVL

* small refactor, introduced set_cvl_linear function to set CVL only once every LINEAR_RECALCULATION_EVERY seconds

* fix typo

* updated changelog

* remove debug msg

* remove debug msg

* undo debug change

* Daly BMS make auto reset soc configurable

* added debug and error information for CVL

* fix proposal for #733 (#735)

* Added: Tollerance to enter float voltage once the timer is triggered

* Add bulk voltage
Load to bulk voltage every x days to reset the SoC to 100% for some BMS

* JKBMS disable high voltage warning on bulk
reenable after bulk was completed

* fixed error

* disable high voltage warning for all BMS
when charging to bulk voltage

* fix error and change default value
measurementToleranceVariation from 0.025 to 0.5 else in OffGrid mode max voltage is always kept

* Added temperature names to dbus/mqtt

* Use current avg of last 300 cycles for TTG & TTS

* Calculate only positive Time-to-SoC points

* added current average of last 5 minutes

* make CCL and DCL more clear

* fix small error

* bugfix: LLTJBD BMS SOC different in Xiaoxiang app and dbus-serialbattery

* black formatting

* JDB BMS - Control FETs for charge, discharge and disable / enable balancer (#761)

* feature: Allow to control charge / discharge FET
* feature: Allow to enable / disable balancer

* bugfix: Cycle Capacity is in 10 mAh

Fixes SoC with factor 100 * 100% percentage

* JBD BMS show balancer state in GUI page IO (#763)

* Bump version

* Fix typos

* Smaller fixes
- fixes #792 (comment)

* Removed comments from utils.py
This should make more clear that there are no values to change

* Updated changelog

* possible fix for LLT/JBS connection problems
#769
#777

* bugfix: LLT/JBD BMS general packet data size check

* improved reinstall and disable script

* LLT/JBD BMS - Improved error handling and automatical driver restart
in case of error. Should fix:
- #730
- #769
- #777

* Fixed Building wheel for dbus-fast won't finish on weak systems
Fixes #785

* Support for Daly CAN Bus (#169)

* support for Daly CAN Bus
* fix constructor args
* revert port, needs fix
* add can filters
* comment logger

Some changes are still needed to work with the latest version. They will follow in a next PR.

---------

Co-authored-by: Samuel Brucksch <samuel@iternio.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>

* JKBMS BLE - Introduction of automatic SOC reset (HW Version 11) (#736)

* Introduction of automatic SOC reset for JK BMS (HW Version 11)
* Fixed value mapping
* Rework of the code to make it simpler to use without additional configuration.
Moved execution of SOC reset. It's now executed while changing from "Float" to "Float Transition".
* Implementation of suggested changes
Persist initial BMS OVP and OVPR settings
Make use of max_cell_voltage to calculate trigger value for OVP alert

* Added: Daly CAN and JKBMS CAN

* added CAN bms to installation script
optimized CAN drivers

* smaller fixes

* Trigger JK BLE SOC reset when using Step Mode

* Moved trigger_soc_reset()

* fixes LLT/JBD SOC > 100%
#769

* changed VOLTAGE_DROP behaviour

* Fix JKBMS not starting if BMS manuf. date is empty

* corrected bulk, absorption and soc reset terms

* fix typo

* add JKBMS_BLE debugging data

* fix small error

* added logging to config

* add sleep before starting driver
prevents lot of timeouts after reinstalling the driver, since the restart is now much faster than before

* changed post install info

* fix error

* Daly BMS fixed embedded null byte
#837

* added info for SoC reset to default config file

* fix for #716
#716

* fix for #716 and JKBMS model recognition
#716

* optimized logging

* fix JKBMS recognition

* added debugging

* fixes #716
#716

---------

Co-authored-by: Holger Schultheiß <hoschult@web.de>
Co-authored-by: Stefan Seidel <lkml@stefanseidel.info>
Co-authored-by: Bernd Stahlbock <6627385+transistorgit@users.noreply.github.com>
Co-authored-by: seidler2547 <github@stefanseidel.info>
Co-authored-by: ogurevich <50322596+ogurevich@users.noreply.github.com>
Co-authored-by: wollew <wollew@users.noreply.github.com>
Co-authored-by: Oleg Gurevich <oleg@gurevich.de>
Co-authored-by: peterohman <psub@fieber.se>
Co-authored-by: Strawder, Paul <paul@coach-ai.com>
Co-authored-by: Paul Strawder <paulidstein@gmail.com>
Co-authored-by: Samuel Brucksch <SamuelBrucksch@users.noreply.github.com>
Co-authored-by: Samuel Brucksch <samuel@iternio.com>
Co-authored-by: ArendsM <136503378+ArendsM@users.noreply.github.com>
Co-authored-by: Meik Arends <github@arends.info>
Louisvdw pushed a commit that referenced this pull request Feb 28, 2024
* fix Sinowealth not loading
#702

* fix unique identifier function

* enable BMS over config, if disabled by default
Now you can also add more then one BMS for BMS_TYPE

* show battery port in log

* ANT BMS fixes
Fixed that other devices are recognized as ANT BMS

* Sinowealth BMS fixes
Fixed that other devices are recognized as Sinowealth BMS

* improved publish_battery error handling
switched from error count to seconds

* Improve Battery Voltage Handling in Linear Absorption Mode

* Refactor change time() to int(time()) for consistency in max_voltage_start_time and tDiff calculation
* Refactor battery voltage calculations for efficiency and clarity
* Remove penalty_buffer
* Reset max_voltage_start_time wenn we going to bulk(dynamic) mode

* updated changelog

* fix reply processing

* Reduce the big inrush current, if the CVL jumps
from Bulk/Absorbtion to Float
fix #659

* Check returned data lenght for Seplos BMS

Be stricter about the return data we accept, might fix the problem of grid meters accidently being recognized as a Seplos

* Validate current, voltage, capacity and SoC for all BMS
This prevents that a device, which is no BMS, is detected as BMS

* removed double check

* bump version

* fix validation if None

* updated changelog

* proposal to #659 formatted :)

* bugfix proposal to #659

* refactor setting float charge_mode

* fix type error, removed bluetooth cronjob

* updated changelog

* fix rs485 write communication errors by inserting sleeps, add debug print for charge mode and fix crash on write soc failures

* fix write problem on set_soc. also changed the switch charge/discharge function, just in case

* debug msg

* Bluetooth optimizations

* Fixes by @peterohman
#505 (comment)

* fix #712

* fix meaningless time to go values

* fix meaningless time to go values

* Duration of transition to float depends on number of cells

* Float transition - Voltage drop per second

* Update hlpdatabms4s.py

* Validate setting of FLOAT_CELL_VOLTAGE and avoid misconfiguration

* consider utils.LINEAR_RECALCULATION_EVERY to refresh CVL

* cleanup

* consider utils.LINEAR_RECALCULATION_EVERY to refresh CVL

* small refactor, introduced set_cvl_linear function to set CVL only once every LINEAR_RECALCULATION_EVERY seconds

* fix typo

* updated changelog

* remove debug msg

* remove debug msg

* undo debug change

* Daly BMS make auto reset soc configurable

* added debug and error information for CVL

* fix proposal for #733 (#735)

* Added: Tollerance to enter float voltage once the timer is triggered

* Add bulk voltage
Load to bulk voltage every x days to reset the SoC to 100% for some BMS

* JKBMS disable high voltage warning on bulk
reenable after bulk was completed

* fixed error

* disable high voltage warning for all BMS
when charging to bulk voltage

* fix error and change default value
measurementToleranceVariation from 0.025 to 0.5 else in OffGrid mode max voltage is always kept

* Added temperature names to dbus/mqtt

* Use current avg of last 300 cycles for TTG & TTS

* Calculate only positive Time-to-SoC points

* added current average of last 5 minutes

* make CCL and DCL more clear

* fix small error

* bugfix: LLTJBD BMS SOC different in Xiaoxiang app and dbus-serialbattery

* black formatting

* JDB BMS - Control FETs for charge, discharge and disable / enable balancer (#761)

* feature: Allow to control charge / discharge FET
* feature: Allow to enable / disable balancer

* bugfix: Cycle Capacity is in 10 mAh

Fixes SoC with factor 100 * 100% percentage

* JBD BMS show balancer state in GUI page IO (#763)

* Bump version

* Fix typos

* Smaller fixes
- fixes #792 (comment)

* Removed comments from utils.py
This should make more clear that there are no values to change

* Updated changelog

* possible fix for LLT/JBS connection problems
#769
#777

* bugfix: LLT/JBD BMS general packet data size check

* improved reinstall and disable script

* LLT/JBD BMS - Improved error handling and automatical driver restart
in case of error. Should fix:
- #730
- #769
- #777

* Fixed Building wheel for dbus-fast won't finish on weak systems
Fixes #785

* Support for Daly CAN Bus (#169)

* support for Daly CAN Bus
* fix constructor args
* revert port, needs fix
* add can filters
* comment logger

Some changes are still needed to work with the latest version. They will follow in a next PR.

---------

Co-authored-by: Samuel Brucksch <samuel@iternio.com>
Co-authored-by: Manuel <mr-manuel@outlook.it>

* JKBMS BLE - Introduction of automatic SOC reset (HW Version 11) (#736)

* Introduction of automatic SOC reset for JK BMS (HW Version 11)
* Fixed value mapping
* Rework of the code to make it simpler to use without additional configuration.
Moved execution of SOC reset. It's now executed while changing from "Float" to "Float Transition".
* Implementation of suggested changes
Persist initial BMS OVP and OVPR settings
Make use of max_cell_voltage to calculate trigger value for OVP alert

* Added: Daly CAN and JKBMS CAN

* added CAN bms to installation script
optimized CAN drivers

* smaller fixes

* Trigger JK BLE SOC reset when using Step Mode

* Moved trigger_soc_reset()

* fixes LLT/JBD SOC > 100%
#769

* changed VOLTAGE_DROP behaviour

* Fix JKBMS not starting if BMS manuf. date is empty

* corrected bulk, absorption and soc reset terms

* fix typo

* add JKBMS_BLE debugging data

* fix small error

* Some changes for lost bluetooth connection / hci_uart stack restart

* added logging to config

* add sleep before starting driver
prevents lot of timeouts after reinstalling the driver, since the restart is now much faster than before

* changed post install info

* fix error

* Daly BMS fixed embedded null byte
#837

* added info for SoC reset to default config file

* fix for #716
#716

* fix for #716 and JKBMS model recognition
#716

* optimized logging

* fix JKBMS recognition

* added debugging

* fixes #716
#716

* Bind device instance to unique_identifier
#718

* added data types to battery class
disabled unused variables

* save current charge state
#840

* correct file permissions

* updated changelog

* added periodic saveChargeDetails

* fix some small errors

* fix issue with ruuvi tags
When there are hundreds of unused ruuvi tags in the settings list that where added because thei where nearby the driver does not start correctly. These stale entries are disabled on the driver startup.
The issue was already filed to Victron developers

* CVL with i-controller instead of penaltysum

* cvl_controller: switch to choose PenaltySum or ICOntroller + documentation

* docu enhancement

* Add setting and install logic for usb bluetooth module

* round temperatures

* changed battery disconnect behaviour

* Fixes #891
#891

* updated changelog

* Add bluetooth device note to config.default.ini

* Fix typo in bluetooth note in config.default.ini

* fixed error in new cvl_controller

* fixed float division by zero and code optimization

* Restart MAX_VOLTAGE_TIME_SEC if cell diff > CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_TIME_RESTART

* Calculation of the SOC based on coloumb-counting (#868)

* Calculation of the SOC in the driver based on coloumb-counting

* soc_calc: add current correction before integration

* soc_calc: correction map for current

* Soc_calc: CorrectionMap, switch to turn on/off correction, selectable initial value

* soc_calc: Bugfix

* soc_calc: Bugfix

* store soc in dbus for restart

* store soc in dbus for restart (formatted)

* store soc in dbus for restart (bugfix)

* save soc_calc only after change > 1.0

* store soc in dbus for restart (bugfix)

* logger does not work this way. do not know why

* writing and reading to dbus works

* Removed options: SOC_CALC_CURRENT_CORRECTION, SOC_CALC_RESET_VALUE_ON_RESTART, SOC_CALC_INIT_VALUE
sort soc_calc alphabetically

* fixed comments

* Updated changelog, small fixes

* Changed: PUBLISH_CONFIG_VALUES from 0/1 to True/False

* Changed: Code optimizations
- Changed some variables to be more clear
- Added comments for easier code understanding

* Calculated SOC: Added two decimals, added BMS SOC for MQTT & Node-RED

* Updated changelog, small fixes

* Changed: PUBLISH_CONFIG_VALUES from 0/1 to True/False

* Changed: Code optimizations
- Changed some variables to be more clear
- Added comments for easier code understanding

* Calculated SOC: Added two decimals, added BMS SOC for MQTT & Node-RED

* Fix #898
#898

* Changed: Fix issue loading settings from dbus

* Added nightly install option
makes it easier for users to pretest fixes

* Changed: more detailed error output when an exception happens

* Possible fix for #912
#912

* Fixes #919
#919

* Changed: Exit script with error, if port excluded
else the serialstarter stops at the dbus-serialbattery

* Fixed some smaller errors

* Updated pre-release workflow

* Fix JK BMS connection restart when bluetooth fails.

This fix installs a new thread to monitor the state of the original
scraping thread.
If scraping thread dies, it verifies that it did not because the
scraping was intentionally stopped by calling stop_scrapping.
When restarting the scrapper, it first calls the bluetooth
reset lambda function that was passed in the class contructor, such that
bluetooth is ready to make a proper connection.

* Fixes #916
#916

* Added Venus OS version to logfile

* Fix #840
#840

* Small code formatting fixes

* Optimized reinstall script. Restart GUI only on changes.

* Display debugging data in GUI when DEBUG enabled

* Install script now shows repositories and version numbers

* Update daly_can.py

Fixing #950 for DalyBMS

* Update jkbms_can.py

Fixing #950 for Jk BMS

* Fix black lint check

* Fixes #970
#970

* Fixed some errors in restoring values from dbus settings

* Moved sleep on start for all BMS

* Update config description

* Reworked a part of the default config

* fix typo in stopping services when reinstalling

* Fix Time-to-SoC and Time-to-Go calculation

* Add changelog info

* Round sum and diff voltage

* Temperature limitation variables where changed

* SoC limitation variables where changed

* Added error messages

* Remove unneeded code

* Reset SoC to 0% if empty

* Add GUIv2 for dbus-serialbattery

* Check free space before installing

* Added new GUIv2 version

* Removed Python 2 compatibility

* Changelog update

* Code cleanup
- Removed: get_temperatures()
- Removed: update_last_seen()

* Bluetooth code optimizations

* Fixed some JKBMS BLE not starting
#819

* Check if packages are already installed before install

* Fixed some SOC calculation errors

* Fixed None SOC on driver start

* Do not show and allow button change when callback is missing for:
- ForceChargingOff
- ForceDischargingOff
- TurnBalancingOff

* Check if a device instance is already used by creating a PID file

* Log and execute SOC reset to 100% or 0% only once

* Update GitHub workflow and issue templates

* Fixed LLT/JBD BMS with only on temperature sensor #791
#971

* Fix warning on reinstall

* Fix missing IO control for JBDBMS #992
#992

* Prepare for removing dev branch

---------

Co-authored-by: ogurevich <50322596+ogurevich@users.noreply.github.com>
Co-authored-by: Bernd Stahlbock <6627385+transistorgit@users.noreply.github.com>
Co-authored-by: wollew <wollew@users.noreply.github.com>
Co-authored-by: Oleg Gurevich <oleg@gurevich.de>
Co-authored-by: peterohman <psub@fieber.se>
Co-authored-by: Strawder, Paul <paul@coach-ai.com>
Co-authored-by: Paul Strawder <paulidstein@gmail.com>
Co-authored-by: Samuel Brucksch <SamuelBrucksch@users.noreply.github.com>
Co-authored-by: Samuel Brucksch <samuel@iternio.com>
Co-authored-by: ArendsM <136503378+ArendsM@users.noreply.github.com>
Co-authored-by: Meik Arends <github@arends.info>
Co-authored-by: Marvo2011 <Marvin.Edeler@gmail.com>
Co-authored-by: cflenker <christian.flenker@gmx.de>
Co-authored-by: cflenker <125555670+cflenker@users.noreply.github.com>
Co-authored-by: Cupertino Miranda <cupertinomiranda@gmail.com>
Co-authored-by: Martin Polehla <p0l0us@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.