Logic Machine Forum
Modbus profile with SunSpec Data Types - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Modbus profile with SunSpec Data Types (/showthread.php?tid=1473)



Modbus profile with SunSpec Data Types - winamp - 03.07.2018

Hi all,

I need to create a Modbus profile for a PV inverter with Sunspec Data Types. They are documented at https://www.sma.de/fileadmin/content/landingpages/pl/FAQ/SunSpec_Modbus-TI-en-15.pdf on page 13-14. The most registers have the dt int or uint and can be easily integrated into the Modbus profile. But I also need some registers with data types that are not in the LM Modbus profile description like acc32, bitfield16, enum16 or string. I already read that the string format is not supported in profile, so my question is, if the other three data types can be integrated?

For example there is a register called "Battery Type" with dt enum16. Then there are defined types for values from 0 to 10 like 0: Unknown, 1: Lithium-Ion, ...
Can I set the register in the Modbus profile as dt uint16 and write these types under value_custom? Same question applies to the dt bitfield16, because there are also costum values.

I can't do a RTU read test right now so I'm thankful for any help.

Best Regards


RE: Modbus profile with SunSpec Data Types - AEK - 06.07.2018

(03.07.2018, 12:30)winam Wrote: For example there is a register called "Battery Type" with dt enum16. Then there are defined types for values from 0 to 10 like 0: Unknown, 1: Lithium-Ion, ...
Can I set the register in the Modbus profile as dt uint16 and write these types under value_custom? 

Hi, I think that it is the best way
try to do like this

Code:
{
     "name": "Mode",
     "bus_datatype": "uint8",
     "datatype": "int16",
     "type": "register",
     "address": 3,
     "writable": 1,
     "Value_custom": {
       "0": "Auto",
       "1": "Heat",
       "2": "Fan",
       "3": "Cool",
       "4": "Dry"
     }
   },




(03.07.2018, 12:30)winamp Wrote:  Same question applies to the dt bitfield16, because there are also costum values.
here you need valuebitmask

for bitfield16 exaple:
Code:
{
     "name": "bitfield16 bit 0",
     "bus_datatype": "bool",
     "type": "register",
     "datatype": "uint16",
     "address": 50002,
      "value_bitmask": "1",
     "value_custom": {
       "0": "no err",
       "1": "err"
     }
   },
    {
     "name": "bitfield16 bit 1",
     "bus_datatype": "bool",
     "type": "register",
     "datatype": "uint16",
     "address": 50002,
      "value_bitmask": "2",
     "value_custom": {
       "0": "no err",
       "1": "err"
     }
   },
    {
     "name": "bitfield16 bit 2",
      "bus_datatype": "bool",
      "type": "register",
     "datatype": "uint16",
      "address": 50002,
      "value_bitmask": "4",
     "value_custom": {
     "0": "no err",
     "1": "err"
     }
   },


value bitmask = 2^N
N - bit number (from 0 to 15)

for bitfield32 example:

Code:
{
     "name": "bitfield32 bit 0",
     "bus_datatype": "bool",
     "type": "register",
     "datatype": "uint16",
     "read_swap": "b",
     "address": 50002,
      "value_bitmask": "1",
     "value_custom": {
       "0": "no err",
       "1": "err"
     }
   },
    {
     "name": "bitfield32 bit 1",
     "bus_datatype": "bool",
     "type": "register",
     "datatype": "uint16",
     "read_swap": "b",
     "address": 50002,
      "value_bitmask": "2",
     "value_custom": {
       "0": "no err",
       "1": "err"
     }
   },

there is new feald - "read_swap"

Code:
read_swap

 Boolean/String
Swap byte/word order during conversion (endianness). Default value is word (2-byte) swap.
Possible string values: 
Code:
n

 (no swap), 
Code:
w

 (word swap), 
Code:
b

 (byte swap), 
Code:
bw

 (byte and word swap)
Example:
no swap: 0xABCD
word swap: 0xCDAB
byte swap: 0xBADC
byte and word swap: 0xDCBA