Write SMA Modbus Register

Hi, after a successful Modbus query (read) I wanted to venture into the next chapter, to write Modbus.. but I need some help:

Modbus register 40016 defines Power value of inverter in W to provide (set-point):
positive discharge, negative charge
40016 Power Value for Charge (-) or Discharge (+)

Activate has to be send before sending ‘Power Value for Charge (-) or Discharge (+)’
40151 "Activate Power Setpoint 802 active/ 803 inactive

With register 41187 could be select the mapping of power measurement to Devcie or Metering
(3053: MsSrcMtr -> use Meter data; 3547: MsSrcDev -> use inverter data).
And which meaning the ‘Power Value for Charge (-) or Discharge (+)’ has!!

this is from SMA



this is from a guy who uses Siemes SPS.

and this is my first step:

[{"id":"95b6b7ed.d22d38","type":"modbus-write","z":"9f6752b0.b55988","name":"40151","showStatusActivities":true,"showErrors":true,"unitid":"3","dataType":"HoldingRegister","adr":"40151","quantity":"1","server":"b6c6500c.41cc1","emptyMsgOnFail":false,"keepMsgProperties":false,"x":790,"y":4320,"wires":[[],[]]},{"id":"d3f2c1e.3905f4","type":"ui_dropdown","z":"9f6752b0.b55988","name":"SBS manuelle Steuerung","label":"SBS manuell","tooltip":"","place":"Select option","group":"cafe7086.9845e8","order":13,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"aktiv","value":802,"type":"num"},{"label":"aus","value":803,"type":"num"}],"payload":"","topic":"topic","topicType":"msg","x":270,"y":4320,"wires":[["d8369c1c.1bf58"]]},{"id":"86b1def.36c442","type":"debug","z":"9f6752b0.b55988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":4380,"wires":[]},{"id":"d8369c1c.1bf58","type":"buffer-maker","z":"9f6752b0.b55988","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint32be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":510,"y":4320,"wires":[["86b1def.36c442","95b6b7ed.d22d38"]]},{"id":"b6c6500c.41cc1","type":"modbus-client","name":"SBS2.5","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.168.55","tcpPort":"502","tcpType":"TPC-RTU-BUFFERED","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":3,"commandDelay":200,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"cafe7086.9845e8","type":"ui_group","name":"manuelle Steuerung","tab":"69ee5cda.ec1a2c","order":3,"disp":true,"width":"6","collapse":false},{"id":"69ee5cda.ec1a2c","type":"ui_tab","name":"Speicher","icon":"fa-battery-half","order":4,"disabled":false,"hidden":false}]

which is unsuccessful :roll_eyes:
(I just wanted to switch the inverter in manuell mode)

grafik
this comes out of the buffer maker to write modbus

here some information from SMA:
SMA-Modbus-general-TI-en-10.pdf (286.3 KB)

I think I circled the problem:

green: output of a modbus read uint32-be

I think I have to write such an array to two registers, but I don´t know how to create an array, and write array 0 to register 40151 and array 1 to register 40152.

Maybe @Steve-Mcl has an idea.

so what is it you need to achieve (in words).

e.g...

  • Set register 40151 to UINT32 value 803
  • then set 40016 to UINT32 a value entered in dashboard

PS for UINT32 values, you will probably need to send 2 16bit values to 2 registers starting at the address specified in the docs.
e.g. for setting a value of 803 to register 40151 you will probably need to use modbus function FC:16 and quantity of 2 then send 2 UINT16 values in an array. To achieve that, you can use buffer-maker and buffer-parser together like this...

[{"id":"eb22adaf.f8d3b","type":"buffer-parser","z":"4b3f21a3.ba434","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"data","offset":0,"length":2,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1140,"y":1540,"wires":[["f9e12d3.4d4c4d"]]},{"id":"25af7742.696c78","type":"buffer-maker","z":"4b3f21a3.ba434","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint32be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":950,"y":1540,"wires":[["eb22adaf.f8d3b"]]},{"id":"f9e12d3.4d4c4d","type":"debug","z":"4b3f21a3.ba434","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1330,"y":1540,"wires":[]},{"id":"3514a83f.169cb8","type":"inject","z":"4b3f21a3.ba434","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"803","payloadType":"num","x":790,"y":1540,"wires":[["25af7742.696c78"]]},{"id":"53955222.0657cc","type":"inject","z":"4b3f21a3.ba434","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"9999999","payloadType":"num","x":780,"y":1580,"wires":[["25af7742.696c78"]]},{"id":"6edb51fe.0b9d1","type":"inject","z":"4b3f21a3.ba434","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4294967295","payloadType":"num","x":770,"y":1620,"wires":[["25af7742.696c78"]]}]
1 Like

yeah it works:

[{"id":"95b6b7ed.d22d38","type":"modbus-write","z":"9f6752b0.b55988","name":"40149","showStatusActivities":true,"showErrors":true,"unitid":"3","dataType":"MHoldingRegisters","adr":"40149","quantity":"2","server":"b6c6500c.41cc1","emptyMsgOnFail":false,"keepMsgProperties":false,"x":970,"y":4400,"wires":[[],[]]},{"id":"d3f2c1e.3905f4","type":"ui_dropdown","z":"9f6752b0.b55988","name":"SBS manuelle Steuerung","label":"manuelle Steuerung","tooltip":"","place":"Select option","group":"cafe7086.9845e8","order":13,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"aktiv","value":802,"type":"num"},{"label":"aus","value":803,"type":"num"}],"payload":"","topic":"topic","topicType":"msg","x":210,"y":4500,"wires":[["7bbfa576.6245fc"]]},{"id":"eb22adaf.f8d3b","type":"buffer-parser","z":"9f6752b0.b55988","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"data","offset":0,"length":2,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":710,"y":4400,"wires":[["f9e12d3.4d4c4d","95b6b7ed.d22d38"]]},{"id":"25af7742.696c78","type":"buffer-maker","z":"9f6752b0.b55988","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"int32be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":520,"y":4400,"wires":[["eb22adaf.f8d3b"]]},{"id":"f9e12d3.4d4c4d","type":"debug","z":"9f6752b0.b55988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":4460,"wires":[]},{"id":"3514a83f.169cb8","type":"inject","z":"9f6752b0.b55988","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"400","payloadType":"num","x":360,"y":4400,"wires":[["25af7742.696c78"]]},{"id":"98173ae5.5c8d68","type":"modbus-write","z":"9f6752b0.b55988","name":"40151","showStatusActivities":true,"showErrors":true,"unitid":"3","dataType":"MHoldingRegisters","adr":"40151","quantity":"2","server":"b6c6500c.41cc1","emptyMsgOnFail":false,"keepMsgProperties":false,"x":970,"y":4600,"wires":[[],[]]},{"id":"975bdcc1.ee8b68","type":"buffer-parser","z":"9f6752b0.b55988","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"data","offset":0,"length":2,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":710,"y":4600,"wires":[["856b9961.52575","98173ae5.5c8d68"]]},{"id":"7bbfa576.6245fc","type":"buffer-maker","z":"9f6752b0.b55988","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint32be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":520,"y":4600,"wires":[["975bdcc1.ee8b68"]]},{"id":"856b9961.52575","type":"debug","z":"9f6752b0.b55988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":4660,"wires":[]},{"id":"51df5a94.a9cb94","type":"inject","z":"9f6752b0.b55988","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"803","payloadType":"num","x":350,"y":4600,"wires":[["7bbfa576.6245fc"]]},{"id":"7cf8dcb7.d2c40c","type":"inject","z":"9f6752b0.b55988","name":"aktiv","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"802","payloadType":"num","x":350,"y":4660,"wires":[["7bbfa576.6245fc"]]},{"id":"dc0b5ef5.915538","type":"ui_text_input","z":"9f6752b0.b55988","name":"Leistung","label":"Leistung","tooltip":"(- Laden / + Entladen)","group":"cafe7086.9845e8","order":1,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"topic","topicType":"msg","x":300,"y":4320,"wires":[["25af7742.696c78"]]},{"id":"b6c6500c.41cc1","type":"modbus-client","name":"SBS2.5","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.168.55","tcpPort":"502","tcpType":"TPC-RTU-BUFFERED","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":3,"commandDelay":200,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"cafe7086.9845e8","type":"ui_group","name":"manuelle Steuerung","tab":"69ee5cda.ec1a2c","order":3,"disp":true,"width":"6","collapse":false},{"id":"69ee5cda.ec1a2c","type":"ui_tab","name":"Speicher","icon":"fa-battery-half","order":4,"disabled":false,"hidden":false}]

but after a few seconds, the inverter falls back to automatic mode, do I have to write it periodically ?

Do you have an idea how to implement ?

No, sorry, I dont know anything about your particular invertor.

Do you know how to write the values I set in the dashboard periodically (every 5s) into modbus ?

Why would you want to?

Cant you just write the 803 value before sending the updated value?

If you must though, store the dashboard value in context (flow.something or global something) then use an inject node to grab the context value and write it to modbus.

because it has to be by the inverter every 15s (somebody told me).

can you please explain what I have to do:

If you must though, store the dashboard value in context (flow.something or global something) then use an inject node to grab the context value and write it to modbus.

so I only get the timestamp into the field :weary:

You didnt store the dashboard value in context.

e.g...

It doesn´t work, can you please give me the flow ? never worked with flow.xxx

I dont have a flow for you. I just knocked that up for the screenshot.

It is not difficult.

DASHBOARD INPUT → CHANGE NODE (set flow.xxxx to msg.payload)
image

INJECT (set msg.payload to flow.xxxx) → buffer → buffer → modbus
image

You can check in the context viewer to see if the value is present...
image

1 Like

thank you, I reversed the flow with msg :grimacing:

I need a little help again :nerd_face:

I have now built all the write registers, but now I have to have them written one after the other, all at once overwhelmed the Modbus server.
Similar to how you built it for me with the reading registers (see red marking) - but I don't know how.

edit, i think i got it:

just with set

1 Like

one last question @Steve-Mcl :wink:

is this correct ?
the parser always uint16be ? i´m not sure

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.