Only positive numbers to setpoint with modbus

I have a problem with setting the setpoint with modbus. The system only accepts positive numbers for the setpoint (register nr. 2700),any negative number is ignored. I want to set also negative numbers to feed-in power to the grid, but it does not accept this. I have a (rebooted) Cerbo-S with firmware v. 3.55 and 3x MultiPlus II 5000/70
(3-phase system), with firmware v. 556. It was v.506 but I recently updated. It worked fine with the previous version. I think it is modbus because I can set negetive values with VRM but not with modbus (from Home Assistant)
Anyone with the same problem?

Regards, Bert

Hi Bert,

I use nodered to send the setpoint value from homeassistant to the Cerbo, and use this code:

let setpoint = msg.setpoint;

// If the value is negative, convert it to two's complement
if (setpoint < 0) {
    setpoint = 0xFFFF + setpoint + 1;  // Two's complement conversion
}

// Send the value to the Modbus register
msg.payload = {
    'value': [setpoint],  // The value, either positive or converted to two's complement
    'fc': 16,             // Function code for writing to holding registers (FC16)
    'unitid': 100,        // Slave ID for the Modbus device
    'address': 2700,      // Register address to write the value to
    'quantity': 1         // The number of registers to write
};

return msg;

Have you tried setting it with the two’s complement format?

Thank you for your response.

This my yaml-code:
actions:

  • data:
    address: 2700
    unit: 100
    value: “{{ states(‘input_number.setpoint’)}}”
    hub: Victron
    action: modbus.write_register
    mode: single

The input_number ‘setpoint’ is a slider I can slide between -7000 and + 7000. Victron Setpoint should be able to contain values between -32768 and 32767 according to the modbus register list , 0-7000 works fine, below 0 is ignored. It did work fine with version 506 of the firmware of the MultiPlus, since recent upgrade to 556 not anymore. I do not know how to convert the value to two’s complent as you suggest.
Regards,
Bert

It’s on his first lines of code…

// If the value is negative, convert it to two's complement
if (setpoint < 0) {
    setpoint = 0xFFFF + setpoint + 1;  // Two's complement conversion
}

Wasn’t that changed to register 2716/2717 in Venus 3.50?

Edit:

I tried both positive and negative values. The Setpoint did not change

Hi Bert,
Does the setpoint also not change when you enter a different positive value?
Try this YAML code and let me know if it works. If it doesn’t work, please describe in detail what you tried and what exactly doesn’t work.

actions:
  - data:
      address: 2700
      unit: 100
      value: >
        {% set val = states('input_number.setpoint') | int %}
        {% if val < 0 %}
          {{ (65536 + val) }}
        {% else %}
          {{ val }}
        {% endif %}
      hub: Victron
      action: modbus.write_register
      mode: single

I just discovered it does not work in VRM either. Negative values for grid setpoint are visible in VRM, but they are ignored in the MultiPlus, no energy feed-in.

@ Djossaa: When I enter positive value in Home Assistant it is visible in VRM and the MultiPlus reacts, only negative values from HA is ignored in VRM.
I will try your Yaml code and let you know.

@Djossaa: I tried your yaml-code in my HA, it did not work.


I have set -500 in HA, VRM shows 0 (previous value in HA). If I set a positive value in HA it is visible in VRM.
Problem 1: negative values for setpoint in HA are not visible in VRM with modbus-register 2700.
Problem 2: If I set a value for the grid setpoint (ESS setting) in VRM (positive or negative) it is ignored in MultiPlus, so a value other than 0 is not possible to set

So if you set a negative value through the remote console on the Cerbo, does nothing happen?
Then it has something to do with your feed-in settings, not with Modbus or Home Assistant.
Could you share those?

Yes. I have now set 2000 W (charge battery from grid with 2000 W) to grid setpoint in VRM, nothing happens, no charging. Charging from excess AC solar is allright.

So I was wrong. Not only negative numbers are ignored, but ALL numbers from VRM are ignored in MultiPlus II. Negative numbers set in HA throug Modbus register 2700 to MultiPlus II are also not visible in VRM (ESS grid setpoint settings stays 0). So there are 2 issues with the setpoint, since updating the firmware in MultiPlus II from v. 506 to 556.

Okay, thanks for the extra info. Then I think it’s a good idea to check via VEConfigure if the ESS assistant is correctly configured.

To my knowledge they are allright, the same as with v. 506 anyway.