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:

# Based on code from https://github.com/victronenergy/dbus_vebus_to_pvinverter/blob/master/test/dummy_vebus.py
# This script is a simple test for controlling the MultiPlus-II via ESS Mode 3
# publishing values on dbus for the MultiPlus-II to charge or discharge the battery

from dbus.mainloop.glib import DBusGMainLoop
import gobject
import dbus
import dbus.service
import platform
import logging
import sys
import os

# our own packages
sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../ext/velib_python'))
from vedbus import VeDbusService

dbusservice = None

def update():
  dbusservice['/Hub4/L1/AcPowerSetpoint'] = -150	# discharge battery a little
  logging.info("/Hub4/L1/AcPowerSetpoint: -150W")
  gobject.timeout_add(500, update)	# update every 500ms

# Init logging
logging.basicConfig(level=(logging.INFO))
logging.info(__file__ + " is starting up")
logLevel = {0: 'NOTSET', 10: 'DEBUG', 20: 'INFO', 30: 'WARNING', 40: 'ERROR'}
logging.info('Loglevel set to ' + logLevel[logging.getLogger().getEffectiveLevel()])

# Have a mainloop, so we can send/receive asynchronous calls to and from dbus
DBusGMainLoop(set_as_default=True)

dbusservice = VeDbusService('com.victronenergy.vebus.ttyO1')

# Create the management objects, as specified in the ccgx dbus-api document
dbusservice.add_path('/Management/ProcessName', __file__)
dbusservice.add_path('/Management/ProcessVersion', 'Unkown version, and running on Python ' + platform.python_version())
dbusservice.add_path('/Management/Connection', 'Mode3 battery regulator service')

# Create the mandatory objects
dbusservice.add_path('/DeviceInstance', 0)
dbusservice.add_path('/ProductId', 'NoID')
dbusservice.add_path('/ProductName', 'Mode3 battery regulator')
dbusservice.add_path('/FirmwareVersion', 0)
dbusservice.add_path('/HardwareVersion', 0)
dbusservice.add_path('/Connected', 1)

# Create all the objects that we want to export to the dbus
dbusservice.add_path('/Hub4/L1/AcPowerSetpoint', -123) # discharge battery a little
dbusservice.add_path('/Hub4/DisableCharge', 0)
dbusservice.add_path('/Hub4/DisableFeedIn', 0)
dbusservice.add_path('/Dc/V', 48.8)
dbusservice.add_path('/Dc/Battery/Voltage', 48.9)

dbusservice.add_path('/Devices/0/Version', 'test')

gobject.timeout_add(100, update)	# update in 100ms

print 'Connected to dbus, and switching over to gobject.MainLoop() (= event based)'
mainloop = gobject.MainLoop()
mainloop.run()

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.

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 ·

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 ·
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 ·