Skip to content

input.modbus Read custom bit lenght in coil #8506

@mirkocomparetti-synesis

Description

@mirkocomparetti-synesis

Relevant telegraf.conf:

This is an example configuration for this case, with a possible proposed solution that will be more clear later.

  coils = [
    { name = "FOut", measurement="alarms", address = [0.0]},
    { name = "ASHigh", measurement="alarms", address = [0.8]},
    { name = "A1High", measurement="alarms", address = [0.9]},
    { name = "A2High", measurement="alarms", address = [0.10]},
    { name = "A3High", measurement="alarms", address = [0.11]},
    { name = "ANHigh", measurement="alarms", address = [0.12]},
    { name = "ASLow", measurement="alarms", address = [0.13]},
    { name = "A1Low", measurement="alarms", address = [0.14]},
    { name = "A2Low", measurement="alarms", address = [0.15]},
    { name = "A3Low", measurement="alarms", address = [0.16]},
    { name = "ANLow", measurement="alarms", address = [0.17]},
    { name = "U12High", measurement="alarms", address = [0.24]},
    { name = "U23High", measurement="alarms", address = [0.25]},
    { name = "U31High", measurement="alarms", address = [0.26]},
    { name = "U12Low", measurement="alarms", address = [0.27]},
    { name = "U23Low", measurement="alarms", address = [0.28]},
    { name = "U31Low", measurement="alarms", address = [0.29]},
    { name = "COM", measurement="alarms", address = [0.31]},
    { name = "USHigh", measurement="alarms", address = [0.32]},
    { name = "U1NHigh", measurement="alarms", address = [0.33]},
    { name = "U2NHigh", measurement="alarms", address = [0.34]},
    { name = "U3NHigh", measurement="alarms", address = [0.35]},
    { name = "USLow", measurement="alarms", address = [0.36]},
    { name = "U1NLow", measurement="alarms", address = [0.37]},
    { name = "U2NLow", measurement="alarms", address = [0.38]},
    { name = "U3NLow", measurement="alarms", address = [0.39]},
  ]

System info:

Telegraf 1.16.3, ubuntu 18.04.4 server

Steps to reproduce:

This is the example configuration

  coils = [
    { name = "FOut", measurement="alarms", address = [0]},
  ]

which retrieves the value

$ telegraf -config testcoil.conf -input-filter modbus -test
2020-12-03T15:47:28Z I! Starting Telegraf 1.16.3
> alarms,host=somehost,name=somedevice,type=coil FOut=0i 1607010449000000000

Expected behavior:

Possibility to read a configurable lenght of bits from a coil address and possibility to map them to single variables; something like the above example configuration. In additional info there is an explaination of why those need to be handled in that way, so that we get

> alarms,host=somehost,name=somedevice,type=coil FrequencyOut=false,ASHigh=false,A1Higg=false,A2High=false,A3High=false,ANHigh=false,ASLow=true,A1Low=true,A2Low=true,A3Low=true,ANlow=true,U12High=false,U23High=true,U31High=false,U12Low=false,U23Low=true,U31Low=false,COM=false,USHigh=false,U1NHigh=false,U2NHigh=false,U3NHigh=true,USLow=false,U1NLow=true,U2NLow=false,U3NLow=true 1607010449000000000

The relevant config above is an example of how this can be achieved using dot notation, but it is not the solution, just an idea.

Actual behavior:

The value 0i for FOut in example above is the first 8bits of the coil 0000, and all the other 32 bits are not retrieved (see additional info)

Additional info:

The device is an energy meter from Seneca; in chapter 7 of the following document you can see how the coils are defined: the first 40bits of address 0000 contain the information that we need to gather and store as separeted bools in the database, because the meaning of each bit is specific and has to be stored separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/modbusbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions