Edge 1.0.0

Modbus: Write

The Modbus: Write Node allows you to write to multiple registers from your Modbus. This node is only available in Edge Workflows.

Modbus Write Node

Node Properties

There are two main parts of the configuration for this node.

Modbus Write Node Configuration

Address Configuration

Address Configuration contains three fields:

  • Host (Required): A string template for the IP address at which the register(s) resides.
  • Port (Required): A string template or integer for the HTTP port.
  • Unit ID (Required): A string template or integer for the Unit ID at the specified host and port. Defaults to 0.
  • Timeout Template: A string template or integer for the numbers of seconds to wait before a timeout occurs while waiting for write results. Defaults to 30 seconds.

Write Instructions

Write Instructions can be given in two ways, either is required.

  • Array of Template Strings: For each write instruction, fill out the following input configuration fields; all of which can utilize templates. You must define at least one instruction.

    • Address (Required): A string template or integer for the address at which to write. This should resolve to an integer between 0 and 65535 inclusive.
    • Register Type (Required):
    • Holding Register: (default) Present single register (FC=06)
    • Coils: Present single coil (FC=05)
    • Holding Registers: Present multiple registers (FC=16)
    • Value (Required): A string template or integer or path, depending on the register type, to specify the value to write to the address. If the register type is Holding Register then this should resolve to an integer between 0 and 65535 inclusive otherwise if the type os Coils the value should be a single bit. If the register type is Holding Registers then this value expects a path to an array on your payload of integer values to write to the registers.
  • Payload Path: (edge version 1.9.0 and above) Give a payload path that will resolve to an array of write instructions to be run on this node. The following are the object properties that each object in the array should contain for successful attempts:

    • type (Required): one of the following types: holding-register, holding-registers, or coil.
    • address (Required): An integer or array of integers for the address at which to write. This integer(s) must be between 0 and 65534 inclusive.
    • value (Required): An integer value to write to the specified address.

    The following is an example of an array that you could pass in:

[
  {
    "type": "coil",
    "address": 3,
    "value": 0
  },
  {
    "type": "holding-register",
    "address": 1,
    "value": 3
  },
  {
    "type": "holding-registers",
    "address": 5,
    "value": [ 1, 2, 3, 4, 5 ]
  }
]

Destination Path

Modbus Write Node Result

The Destination Path (a payload path) is optional, but if you want to confirm that the write was successful, the path should be set. If set, the result of write instruction will be at a key in the format of addr-${Number(address)}, successful writes will have a value of true, and failures will have a value of false.

If any errors occurred, there will be an errors key in the object at your path defining each error that occurred. The only time you will get a single error for multiple writes is if the connection could never be made to the Modbus itself.

Node Examples

For example, say we want to write to two addresses (one at 23, and the other at 80), and we set our Destination Path to destination.output. If all write instructions were successful, the output will look like the following:

"destination": {
  "output": {
    "addr-23": true,
    "addr-80": true
  }
}

Node Errors

If an error occurred the output will look like the following:

"destination": {
  "output": {
    "errors": [
      { "type": "MODBUS_WRITE_ERROR", "message": "Some error occurred at 23" },
      { "type": "MODBUS_WRITE_ERROR", "message": "Some error occurred at 80" },
    ],
    "addr-23": false,
    "addr-80": false
  }
}

If an error occurred for one write instruction, that does not mean all writes were unsuccessful. If one is successful and the other is not the output might look like the following:

"destination": {
  "output": {
    "errors": [
      { "type": "MODBUS_WRITE_ERROR", "message": "Some error occurred at 23" },
    ],
    "addr-23": false,
    "addr-80": true
  }
}