question

ralfz avatar image
ralfz asked

Multiplus-II with Raspberry Pi and ESS Mode 3, python script for control loop

Situation

I have a Multiplus-II 48/5000/70 connected to a Raspberry Pi 3B+ running Venus OS with a MK3-USB. For test purposes, I have a 48V 70Ah LeadAcid AGM battery connected.

I am following the documentation ESS mode 2 and 3 - 3.3 Running software on the CCGX and using DBus paths.

The goal is to use my own script for doing the control loop, so I need Mode 3, where the MP2 inverter is fully under the scripts control.

I wrote a script in Python, based on the code from dummy_vebus.py. It claims the dbus service "com.victronenergy.vebus.ttyO1" as described in the docs. Here is the simple code in order to get me started:

  1. # Based on code from https://github.com/victronenergy/dbus_vebus_to_pvinverter/blob/master/test/dummy_vebus.py
  2. # This script is a simple test for controlling the MultiPlus-II via ESS Mode 3
  3. # publishing values on dbus for the MultiPlus-II to charge or discharge the battery
  4.  
  5. from dbus.mainloop.glib import DBusGMainLoop
  6. import gobject
  7. import dbus
  8. import dbus.service
  9. import platform
  10. import logging
  11. import sys
  12. import os
  13.  
  14. # our own packages
  15. sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../ext/velib_python'))
  16. from vedbus import VeDbusService
  17.  
  18. dbusservice = None
  19.  
  20. def update():
  21. dbusservice['/Hub4/L1/AcPowerSetpoint'] = -150 # discharge battery a little
  22. logging.info("/Hub4/L1/AcPowerSetpoint: -150W")
  23. gobject.timeout_add(500, update) # update every 500ms
  24.  
  25. # Init logging
  26. logging.basicConfig(level=(logging.INFO))
  27. logging.info(__file__ + " is starting up")
  28. logLevel = {0: 'NOTSET', 10: 'DEBUG', 20: 'INFO', 30: 'WARNING', 40: 'ERROR'}
  29. logging.info('Loglevel set to ' + logLevel[logging.getLogger().getEffectiveLevel()])
  30.  
  31. # Have a mainloop, so we can send/receive asynchronous calls to and from dbus
  32. DBusGMainLoop(set_as_default=True)
  33.  
  34. dbusservice = VeDbusService('com.victronenergy.vebus.ttyO1')
  35.  
  36. # Create the management objects, as specified in the ccgx dbus-api document
  37. dbusservice.add_path('/Management/ProcessName', __file__)
  38. dbusservice.add_path('/Management/ProcessVersion', 'Unkown version, and running on Python ' + platform.python_version())
  39. dbusservice.add_path('/Management/Connection', 'Mode3 battery regulator service')
  40.  
  41. # Create the mandatory objects
  42. dbusservice.add_path('/DeviceInstance', 0)
  43. dbusservice.add_path('/ProductId', 'NoID')
  44. dbusservice.add_path('/ProductName', 'Mode3 battery regulator')
  45. dbusservice.add_path('/FirmwareVersion', 0)
  46. dbusservice.add_path('/HardwareVersion', 0)
  47. dbusservice.add_path('/Connected', 1)
  48.  
  49. # Create all the objects that we want to export to the dbus
  50. dbusservice.add_path('/Hub4/L1/AcPowerSetpoint', -123) # discharge battery a little
  51. dbusservice.add_path('/Hub4/DisableCharge', 0)
  52. dbusservice.add_path('/Hub4/DisableFeedIn', 0)
  53. dbusservice.add_path('/Dc/V', 48.8)
  54. dbusservice.add_path('/Dc/Battery/Voltage', 48.9)
  55.  
  56. dbusservice.add_path('/Devices/0/Version', 'test')
  57.  
  58. gobject.timeout_add(100, update) # update in 100ms
  59.  
  60. print 'Connected to dbus, and switching over to gobject.MainLoop() (= event based)'
  61. mainloop = gobject.MainLoop()
  62. mainloop.run()
  63.  

Problem

I see no reaction of the MultiPlus-II on the signals being published on dbus. The inverter stays idle, the status is shown as "Passthru".

I do see all paths and values when I am using dbus-spy, so the script does what I told it to do.

Question

What am I missing here? There is probably only a little thing that I am doing wrong.

Does anyone have sample code that gets me going? Any help is welcome!

Multiplus-IIESSVenus OS
2 |3000

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

1 Answer
tschirch avatar image
tschirch answered ·

Hi, I have my Multiplus II and an MK3-USB since one week. Now I have it running with the same goal you have: My own control loop in mode 3.

But I don't use Venus OS. I think it's not possible to take it with the MK3-USB. I use the python program from Izak Burger: https://github.com/izak/ib.victron

If you want do the same, so I can help you!

Regards, Steffen.

3 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.

ralfz avatar image ralfz commented ·

I am using a Rasperry Pi 3B+, running Venus OS and it connects to my MultiPlus-II with the MK3-USB. Current status is described in my latest comment here.

You write "But I don't use Venus OS. I think it's not possible to take it with the MK3-USB.". Which problem do you see with this combination?

You write "I use the python program from ...". Can you describe your setup a bit?

0 Likes 0 ·
tschirch avatar image tschirch ralfz commented ·

I have a MultiPlus II, the MK3-USB-Interface and a RaspberryPi. I have the MultiPlus II in so called parallel-mode with my own control loop. I did some changes to the original python program from Izak Burger, because I want Python3. And I added the functionality to charge the battery or otherwise let the inverter working with a certain power.

With these functionality it is possible to make the power on the net side to zero. At the moment I checked only the functionality, because I have a very small battery and no power meter. As a GUI I have taken FHEM. There I can see Voltages, Currents etc. and I have a slider to put in the power. The range is at the moment from -200 to +200W. It works great. I'm satisfied with it.

BR, Steffen

0 Likes 0 ·
akabza avatar image akabza tschirch commented ·
Hello Steffen, I think I need your help with the same issue! Communicate via Python-Script TCP modubus with Multiplus II (w/o GX)!

How do you do that?

Thanks,

Alex


0 Likes 0 ·