Urgent help required for ESS mode 3 and ModbusTCP

Installation:
Victron MultiPlus-II GX Inverter/Charger (firmware: 3.67).
Fogstar-16kWh battery - CANbus connected to Victron.
4kW and 2kW Growatt PV inverters.
External Shelly Energy Monitors.
Current Shunt to be added for improved SOC.

The Victron/Fogstar installation seems ok with the Victron keeping the battery fully charged. Currently the switch is ON (-)

I have a lot of NodeRed gauges configured which are monitoring the system.

The Grid Code is set to UK for 98 & 99.

I want to use ESS Mode 3 to control the system…

This is the problem:

I have set the ESS mode using Unit_ID 100 and register 2902. That seems to work ok.

The document I am using for the ESS is: ess_mode_2_mode_3.pdf

I can read Modbus-TCP registers 37, 38, 39, 40 and 41 ok.

As registers 38 & 39 have a value of 0 in them I do not need to change them as they are “enabled”.

All I need to do is store a setpoint value of between -32768 and 32767 (INT) to tell the inverter how much power I either want to generate to the grid (L1) or take from the grid to charge the battery.

The simplicity of this is what attracted me to this Victron inverter in the first place. A ‘dumb’ bidirectional inverter/charger is what I want.

Now, if I try to update Register 37 (setpoint) I get a ModBus write error. In fact writing registers 38 and 39 also fail with a write error.

I have used my own Python code and the PowerHud Modbus Tester with the same result.

To see what the error actually is, I logged in as root and CD’d to root@nanopi:/var/log/dbus-modbustcp. The file “current” has the actual Modbus errors in it.

These are a couple of the error messages:

root@nanopi:/var/log/dbus-modbustcp# ERROR “Error processing function code 6, unit id 228, start address 37, quantity 0, src ::ffff:192.168.0.72: SetValue failed on /Hub4/L1/AcPowerSetpoint”

root@nanopi:/var/log/dbus-modbustcp# ERROR “Error processing function code 6, unit id 228, start address 37, quantity 0, src ::ffff:192.168.0.72: SetValue failed on /Hub4/L1/AcPowerSetpoint”

In both of these instances a value of -1000 was passed in the Modbus Write Register command but, strangely, the error message shows “quantity 0”.

Unfortunately the error message does not help me other than confirm a Modbus write fail.

The question is simple: What prevents the SetValue command from working?

My guess is there is a mode or flag that needs to be set somewhere. The ESS document does not have any specific warnings like “to use ESS mode 3 you must…” else I would have done that already.

So far, my Victron is sitting there with a fully charged battery and I cannot get it to generate anything.

Have you successfully run your system using ESS Mode 2 for a while before attempting Mode 3?

I have implemented a full Mode 3 setup and write to addresses 37 and 40 successfully to keep the power setpoint working.

I do not understand why you are getting that error. Try writing a small positive number instead of -1000 and see if it still does it. The “quantity 0” is definitely a clue. Perhaps the negative signed 16-bit data isn’t getting converted properly, as all writes are really unsigned raw bits. If so, just write 65536-1000 to the register instead.

Perhaps it means the length of the ModbusTCP packet is incorrect. Here is the protocol in bytes for function code 6:

    async def write_register_no_timeout(self, addr, value):
        # Writes the unsigned 16-bit value to the specified address.
        #
        # ModbusTCP Write Register: Function 0x06
        #   Command:  <tid_h> <tid_l> <pid_h> <pid_l> <length_h> <length_l> <unit_id>
        #             <func> <addr_h> <addr_l> <value_h> <value_l>
        #
        #   Response: <tid_h> <tid_l> <pid_h> <pid_l> <length_h> <length_l> <unit_id>
        #             <func> <addr_h> <addr_l> <value_h> <value_l>
        #
        # ModbusTCP Error Response
        #   <tid_h> <tid_l> <pid_h> <pid_l> <length_h> <length_l> <unit_id>
        #   <func|0x80> <exc_code>

Thanks for your reply.

No, I did not try ESS2. What advantage is there to trying it first?

I used a similar call to the one you outlined but take your point about the exact Modbus command length.

I will write a simple skeleton app to try and see exactly what is being transmitted.

The “quantity 0” is a clue for sure.

Personally, if I had access to the source of the Modbus server the Victron uses, I would be seeing where the SetValue message is emitted from and what specific conditions are being validated.

Thanks for you help.

I will update here once the solution is found.

David

You should understand how your system works with ESS Mode 2 before moving to Mode 3. There are critical things to understand like peak shaving, and how fast the system reacts to changes in loads. Also, you can watch the registers changing in dbus-spy to better understand what you will need to do in Mode 3.

I’m still not sure why you are getting that error, sorry.