Reading modbus RS-485 in settings Gateway Impulse C07W

1

.

Requirements

To edit settings you need the user right "GatewaySettings".

2

.

Understanding Settings

The settings are always processed in JSON format by the system before being sent to the gateway.

These JSON settings are divided into 2 parts:

SlaveDefinitions

In "slaveDefinitions" you determine what you will read out. Per "Slave" there are a number of settings:

  • address: this is the slave id of the modbus slave you want to read out.
  • type: to choose which register to read out, enter here "generic-rtu".
  • baud rate:the transmission rate expressed in bits per second. Set the same baud rate as on the modbus slave.
  • bus: this is where the RTU expansion card is plugged in. If it is on expansion 1 you choose 102. If it is on expansion 2 choose 101.
  • serialconfig: use this notation to set advanced serial communication parameters, such as the number of data bits, stop bits and parity bits, and which handshake protocol should be used.

    baudrate: the transmission rate expressed in bits per second.
    data bits: the number of bits used per character.

    For parity, stop bits and handshake use the following ENUM values:

    parity:
    • 0 (None): No parity check.
    • 1 (Odd): The total number of data bits is always an odd number.
    • 2 (Even): The total number of data bits is always an even number.
    • 3 (Mark): The parity bit is always 1.
    • 4 (Space): The parity bit is always 0.

stop bits:

    • 0 (One): One stop bit is used.
    • 1 (OnePointFive): One-and-a-half stop bits are used.
    • 2 (Two): Two stop bits are used.

handshake:

    • 0 (None): No handshake protocol is being applied.
    • 1 (RequestToSend/ClearToSend): RTS/CTS flow-control.
    • 2 (XOn/XOff): Software-based flow-control.

Example of a SlaveDefinitions block:

    "slaveDefinitions": [

        {

            "name": "modbus.rtu",

            "slaves": [

                {

                    "address": 3,

                    "type": "generic-rtu",

                    "busdefinitiontype": 100,

                    "baud rate": 9600,

                    "bus": "101"

                },

                {

                    "address": 4,

                    "type": "generic-rtu",

                    "busdefinitiontype": 100,

                    "bus": "101",

                    "serialconfig": {

                        "baud rate": 19200,

                        "parity": 0,

                        "stop bits": 2,

                        "handshake": 0,

                        "data bits": 8

                    }

                }

            ]

        }

    ]

SlaveSettings

For each slave you have defined in SlaveDefinitions, you can determine in SlaveSettings which registers you want to effectively read out.

First, you start in SlaveSettings by defining the name, always in the following format:

modbus.rtu.mb_uart{bus_id}.{slave_id}

- bus_id: the last digit of the bus that you noted in the SlaveDefinitions. For bus 101 it is 1 and for bus 102 it is 2.

- slave_id: the slave id you noted in SlaveDefinitions.

For example: modbus.rtu.mb_uart1.3 (Bus 101, so we use 1. Slave id = 3).

Furthermore, in MeasurementPaths you determine which modbus registers you want to read out.

You want to read bit X: "0000 0X00". In this case, you use "FirstBit": 2 and "LastBit": 2.

You want to read out bits XX: "XX00 0000". In this case you use "FirstBit": 6 and "LastBit": 7.

Choose Int16 (type 1 in the gateway settings) as the data type.

Example of a SlaveSettings block:

"slaveSettings": [

        {

            "name": "modbus.rtu.mb_uart1.3",

            "settings": {

                "measurementPaths": [

                    {

                        "measurementPath": "voltage.uv",

                        "functionCode": 4,

                        "startAddress": 0,

                        "dataType": 1,

                        "factor": 1,

                        "minValue":0,

                        "maxValue": 500

                    }

                ]

            }

        },

        {

            "name": "modbus.rtu.mb_uart1.4",

            "settings": {

                "measurementPaths": [

                    {

                        "measurementPath": "alarm_1,

                        "functionCode": 3,

                        "startAddress": 1,

                        "dataType": 1,

                        "factor": 1,

                        "minValue":0,

                        "maxValue": 1,

                        "firstBit": 7,

                        "lastBit": 7

                    }

                ]

            }

        }

    ]

3

.

Example of a complete settings definition:

{

    "slaveDefinitions": [

        {

            "name": "modbus.rtu",

            "slaves": [

                {

                    "address": 3,

                    "type": "generic-rtu",

                    "busdefinitiontype": 100,

                    "baudrate": 9600,

                    "bus": "101"

                },

                {

                    "address": 4,

                    "type": "generic-rtu",

                    "busdefinitiontype": 100,

                    "baudrate": 9600,

                    "bus": "101"

                }

            ]

        }

    ],

    "slaveSettings": [

        {

            "name": "modbus.rtu.mb_uart1.3",

            "settings": {

                "measurementPaths": [

                    {

                        "measurementPath": "voltage.uv",

                        "functionCode": 4,

                        "startAddress": 0,

                        "dataType": 1,

                        "factor": 1,

                        "minValue": 0,

                        "maxValue": 500

                    }

                ]

            }

        },

        {

            "name": "modbus.rtu.mb_uart1.4",

            "settings": {

                "measurementPaths": [

                   {

                        "measurementPath": "alarm_1,

                        "functionCode": 3,

                        "startAddress": 1,

                        "dataType": 1,

                        "factor": 1,

                        "minValue": 0,

                        "maxValue": 1,

                        "firstBit": 7,

                        "lastBit": 7

                    }

                ]

            }

        }

    ]

}

Advanced Add Tag

    Related Articles

Need Support?

Can’t find the answer you’re looking for? Don’t worry we’re here to help!

Ask For Help
Language Choice Disclaimer

These texts have been automatically translated using advanced AI translation tools. If you notice any inaccuracies or errors, please help us improve by sending a message to hello@calculus.group. Your feedback assists us in enhancing the quality of our multilingual documentation.