This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus profile with SunSpec Data Types
#2
(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
Reply


Messages In This Thread
RE: Modbus profile with SunSpec Data Types - by AEK - 06.07.2018, 10:53

Forum Jump: