question

Mike Dorsett avatar image
Mike Dorsett asked

SPI BMS running under Venus

@Louis van der Walt, @Jeroen, @mvader (Victron Energy)

Thanks very much for your help (in getting various python modules loaded) and the code developed by Louis, I've now got the SPI connected BMS running and under test:

spibms.jpg

Currently running v2.71

device1.png

details2.png

Please can any one tell me the dbus address for the boxes circled in red (1-3)?

alarms1.png

Also what variable type replaces the "unknown" on the Alarms page?

Once I get the code tidied up I'll make it available through Github. The BMS is 8 channels, and has relays for load and charge disconnect, and also for Gen Run (2 wire).

Venus OSRaspberry Pi
spibms.jpg (555.9 KiB)
device1.png (23.0 KiB)
details2.png (34.6 KiB)
alarms1.png (25.1 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

5 Answers
Louis van der Walt avatar image
Louis van der Walt answered ·

Great work @Mike Dorsett

How did you get the SPI interface to work and picked up?
Also can I suggest that if you look at doing a pull request against my code repo so that we could look at merging your changes back and have it all in one place. Any fixes will then apply to you interface as well.

Regarding your questions:

1) The modules online/ofline are set up in my code base. Look for

/System/NrOfModulesOnline
/System/NrOfModulesOffline

2) Similar also for blocking

/System/NrOfModulesBlockingCharge
/System/NrOfModulesBlockingDischarge

3) and also capacity (the latest version has a fix in where both are now populated)

/Capacity
/InstalledCapacity


4) For the alarms, as with any value, if you keep/set them to None like my driver initilise them at they will be hidden on the screen, or --- if it is part of a disply group. If you do want to set them they must be 0 (no alarm), 1 (warning), 2 alarm.



2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mike Dorsett avatar image
Mike Dorsett answered ·

Hi Louis,

Thanks for the information. That should sort a lot out. Getting the SPI interface working was the big issue - first requirement was to get pip installed and working. I think that there may have been a bug in the opkg repository, but Jeroen helped a great deal with this. I think that the key package to install was build essentials group - then pip. Once pip is installed on the os, spidev and gpiozero can be installed. SPIDEV needs to be version 3.5 as 3.2 and 3.4 have a small bug in the code. my program has 2 key elements that interface with yours, primarily an overlay for the battery class file, and a library module that does the work. However, returned values are handled diferently so I've made some modifications to dbus-serialbattery.py too. I'll keep an eye on compatibility issues whilst tidying things up. Once I've done this, I'll zip the code and send you a copy. Perhaps you can put this in your repo as a branch? I will be making the hardware available too.

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mike Dorsett avatar image Mike Dorsett commented ·
with regard to getting the spi picked up, this is currently a 'fix' that makes the os think it's on /dev/tty/USB9.
0 Likes 0 ·
Louis van der Walt avatar image Louis van der Walt commented ·
That sounds good. We should be able to merge what you have done back. The setup would a bit more than the normal BMS to make work, but it is doable.
0 Likes 0 ·
Mike Dorsett avatar image
Mike Dorsett answered ·

Hi Louis, Thanks it worked fine:


screenshot-from-2021-07-09-08-33-38.png

Note I've also added the V,A & W..

screenshot-from-2021-07-09-08-34-10.png

screenshot-from-2021-07-09-08-34-10.png



4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mikhail-petukhov avatar image mikhail-petukhov commented ·

Hi Mike, could you please give a little example how to add text value V, A and W to the dbus?

0 Likes 0 ·
Mike Dorsett avatar image Mike Dorsett mikhail-petukhov commented ·
@Mikhail Petukhov This was done by converting the value to the d-bus service into a string. Whilst this worked fine on the above displays, it had the unfortunate side effect of trashing the "page" display on the animation pages, and causing further problems with VRM portal. This really needs to be tackled elsewhere - and I havent had the time or inclination to dive into the VE code that produces these display / menu pages. Likewise, I haven't managed t get the temperature id's to work. Mike.
0 Likes 0 ·
mikhail-petukhov avatar image mikhail-petukhov Mike Dorsett commented ·

Hi Mike, thanks for response, dbus record has two items - value and text. This is example for Multiplus inverter -

dbus -y com.victronenergy.vebus.ttyO5 /Ac/ActiveIn/L1/F GetValue
value = 0.0

dbus -y com.victronenergy.vebus.ttyO5 /Ac/ActiveIn/L1/F GetText
value = '0.0Hz'

Probably text part used for menu items, value - for some post processing and vrm.

And I did not find a way how to create and update Value and Text separately for my own non Victron inverter driver. In my case Value and Text both created by python script but with digits only.

0 Likes 0 ·
Mike Dorsett avatar image Mike Dorsett mikhail-petukhov commented ·
The python used was:

str(value)+"V"

etc.

the value was one of the battery parameters.


0 Likes 0 ·
stanhausc avatar image
stanhausc answered ·

Hi @Mike Dorsett and @Louis van der Walt.

Thanks for the excellent work, I made some changes to my BMS, I installed the GPIOZERO and SPIDEV modules, but now the COLOSYS module is missing, and I couldn't install it, any ideas?

1658939289200.png


1658939289200.png (243.5 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mike Dorsett avatar image
Mike Dorsett answered ·

I think you missed the R..

https://docs.python.org/3/library/colorsys.html

I haven't had time to work an this code recently,but if the coloursys module is not in the opkg repository, then you should be able to download and install from source....otherwise, you could just import the functions you need from GPIOZERO, and leave the colour space conversions out.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.