Update modbus readme

This commit is contained in:
Daniel Nelson 2020-04-21 11:27:35 -07:00
parent c7797cc3c4
commit d1f109b316
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
2 changed files with 144 additions and 141 deletions

View File

@ -1,91 +1,97 @@
# Telegraf Input Plugin: Modbus # Modbus Input Plugin
The Modbus plugin collects Discrete Inputs, Coils, Input Registers and Holding Registers via Modbus TCP or Modbus RTU/ASCII The Modbus plugin collects Discrete Inputs, Coils, Input Registers and Holding
Registers via Modbus TCP or Modbus RTU/ASCII.
### Configuration: ### Configuration
```toml ```toml
## Connection Configuration [[inputs.modbus]]
## ## Connection Configuration
## The module supports connections to PLCs via MODBUS/TCP or ##
## via serial line communication in binary (RTU) or readable (ASCII) encoding ## The module supports connections to PLCs via MODBUS/TCP or
## ## via serial line communication in binary (RTU) or readable (ASCII) encoding
## Device name ##
name = "Device" ## Device name
name = "Device"
## Slave ID - addresses a MODBUS device on the bus ## Slave ID - addresses a MODBUS device on the bus
## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved] ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
slave_id = 1 slave_id = 1
## Timeout for each request ## Timeout for each request
timeout = "1s" timeout = "1s"
## Maximum number of retries and the time to wait between retries ## Maximum number of retries and the time to wait between retries
## when a slave-device is busy. ## when a slave-device is busy.
## NOTE: Please make sure that the overall retry time (#retries * wait time) # busy_retries = 0
## is always smaller than the query interval as otherwise you will get # busy_retries_wait = "100ms"
## an "did not complete within its interval" warning.
#busy_retries = 0
#busy_retries_wait = "100ms"
# TCP - connect via Modbus/TCP # TCP - connect via Modbus/TCP
controller = "tcp://localhost:502" controller = "tcp://localhost:502"
# Serial (RS485; RS232) ## Serial (RS485; RS232)
#controller = "file:///dev/ttyUSB0" # controller = "file:///dev/ttyUSB0"
#baud_rate = 9600 # baud_rate = 9600
#data_bits = 8 # data_bits = 8
#parity = "N" # parity = "N"
#stop_bits = 1 # stop_bits = 1
#transmission_mode = "RTU" # transmission_mode = "RTU"
## Measurements ## Measurements
## ##
## Digital Variables, Discrete Inputs and Coils ## Digital Variables, Discrete Inputs and Coils
## name - the variable name ## name - the variable name
## address - variable address ## address - variable address
discrete_inputs = [ discrete_inputs = [
{ name = "Start", address = [0]}, { name = "Start", address = [0]},
{ name = "Stop", address = [1]}, { name = "Stop", address = [1]},
{ name = "Reset", address = [2]}, { name = "Reset", address = [2]},
{ name = "EmergencyStop", address = [3]}, { name = "EmergencyStop", address = [3]},
] ]
coils = [ coils = [
{ name = "Motor1-Run", address = [0]}, { name = "Motor1-Run", address = [0]},
{ name = "Motor1-Jog", address = [1]}, { name = "Motor1-Jog", address = [1]},
{ name = "Motor1-Stop", address = [2]}, { name = "Motor1-Stop", address = [2]},
] ]
## Analog Variables, Input Registers and Holding Registers ## Analog Variables, Input Registers and Holding Registers
## measurement - the (optional) measurement name, defaults to "modbus" ## measurement - the (optional) measurement name, defaults to "modbus"
## name - the variable name ## name - the variable name
## byte_order - the ordering of bytes ## byte_order - the ordering of bytes
## |---AB, ABCD - Big Endian ## |---AB, ABCD - Big Endian
## |---BA, DCBA - Little Endian ## |---BA, DCBA - Little Endian
## |---BADC - Mid-Big Endian ## |---BADC - Mid-Big Endian
## |---CDAB - Mid-Little Endian ## |---CDAB - Mid-Little Endian
## data_type - INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT32, FLOAT32-IEEE (the IEEE 754 binary representation) ## data_type - INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT32, FLOAT32-IEEE (the IEEE 754 binary representation)
## scale - the final numeric variable representation ## scale - the final numeric variable representation
## address - variable address ## address - variable address
holding_registers = [ holding_registers = [
{ name = "PowerFactor", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [8]}, { name = "PowerFactor", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [8]},
{ name = "Voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [0]}, { name = "Voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [0]},
{ name = "Energy", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [5,6]}, { name = "Energy", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [5,6]},
{ name = "Current", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [1,2]}, { name = "Current", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [1,2]},
{ name = "Frequency", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [7]}, { name = "Frequency", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [7]},
{ name = "Power", byte_order = "ABCD", data_type = "FLOAT32", scale=0.1, address = [3,4]}, { name = "Power", byte_order = "ABCD", data_type = "FLOAT32", scale=0.1, address = [3,4]},
] ]
input_registers = [ input_registers = [
{ name = "TankLevel", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]}, { name = "TankLevel", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]},
{ name = "TankPH", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]}, { name = "TankPH", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]},
{ name = "Pump1-Speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]}, { name = "Pump1-Speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]},
] ]
``` ```
### Example Output:
### Metrics
Metric are custom and configured using the `discrete_inputs`, `coils`,
`holding_register` and `input_registers` options.
### Example Output
``` ```
$ ./telegraf -config telegraf.conf -input-filter modbus -test $ ./telegraf -config telegraf.conf -input-filter modbus -test

View File

@ -72,86 +72,83 @@ const (
const description = `Retrieve data from MODBUS slave devices` const description = `Retrieve data from MODBUS slave devices`
const sampleConfig = ` const sampleConfig = `
## Connection Configuration ## Connection Configuration
## ##
## The plugin supports connections to PLCs via MODBUS/TCP or ## The plugin supports connections to PLCs via MODBUS/TCP or
## via serial line communication in binary (RTU) or readable (ASCII) encoding ## via serial line communication in binary (RTU) or readable (ASCII) encoding
## ##
## Device name ## Device name
name = "Device" name = "Device"
## Slave ID - addresses a MODBUS device on the bus ## Slave ID - addresses a MODBUS device on the bus
## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved] ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
slave_id = 1 slave_id = 1
## Timeout for each request ## Timeout for each request
timeout = "1s" timeout = "1s"
## Maximum number of retries and the time to wait between retries ## Maximum number of retries and the time to wait between retries
## when a slave-device is busy. ## when a slave-device is busy.
## NOTE: Please make sure that the overall retry time (#retries * wait time) # busy_retries = 0
## is always smaller than the query interval as otherwise you will get # busy_retries_wait = "100ms"
## an "did not complete within its interval" warning.
#busy_retries = 0
#busy_retries_wait = "100ms"
# TCP - connect via Modbus/TCP # TCP - connect via Modbus/TCP
controller = "tcp://localhost:502" controller = "tcp://localhost:502"
# Serial (RS485; RS232) ## Serial (RS485; RS232)
#controller = "file:///dev/ttyUSB0" # controller = "file:///dev/ttyUSB0"
#baud_rate = 9600 # baud_rate = 9600
#data_bits = 8 # data_bits = 8
#parity = "N" # parity = "N"
#stop_bits = 1 # stop_bits = 1
#transmission_mode = "RTU" # transmission_mode = "RTU"
## Measurements ## Measurements
## ##
## Digital Variables, Discrete Inputs and Coils ## Digital Variables, Discrete Inputs and Coils
## measurement - the (optional) measurement name, defaults to "modbus" ## measurement - the (optional) measurement name, defaults to "modbus"
## name - the variable name ## name - the variable name
## address - variable address ## address - variable address
discrete_inputs = [ discrete_inputs = [
{ name = "start", address = [0]}, { name = "start", address = [0]},
{ name = "stop", address = [1]}, { name = "stop", address = [1]},
{ name = "reset", address = [2]}, { name = "reset", address = [2]},
{ name = "emergency_stop", address = [3]}, { name = "emergency_stop", address = [3]},
] ]
coils = [ coils = [
{ name = "motor1_run", address = [0]}, { name = "motor1_run", address = [0]},
{ name = "motor1_jog", address = [1]}, { name = "motor1_jog", address = [1]},
{ name = "motor1_stop", address = [2]}, { name = "motor1_stop", address = [2]},
] ]
## Analog Variables, Input Registers and Holding Registers ## Analog Variables, Input Registers and Holding Registers
## measurement - the (optional) measurement name, defaults to "modbus" ## measurement - the (optional) measurement name, defaults to "modbus"
## name - the variable name ## name - the variable name
## byte_order - the ordering of bytes ## byte_order - the ordering of bytes
## |---AB, ABCD - Big Endian ## |---AB, ABCD - Big Endian
## |---BA, DCBA - Little Endian ## |---BA, DCBA - Little Endian
## |---BADC - Mid-Big Endian ## |---BADC - Mid-Big Endian
## |---CDAB - Mid-Little Endian ## |---CDAB - Mid-Little Endian
## data_type - INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT32, FLOAT32-IEEE (the IEEE 754 binary representation) ## data_type - INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT32, FLOAT32-IEEE (the IEEE 754 binary representation)
## scale - the final numeric variable representation ## scale - the final numeric variable representation
## address - variable address ## address - variable address
holding_registers = [ holding_registers = [
{ name = "power_factor", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [8]}, { name = "power_factor", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [8]},
{ name = "voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [0]}, { name = "voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [0]},
{ name = "energy", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [5,6]}, { name = "energy", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [5,6]},
{ name = "current", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [1,2]}, { name = "current", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [1,2]},
{ name = "frequency", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [7]}, { name = "frequency", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [7]},
{ name = "power", byte_order = "ABCD", data_type = "FLOAT32", scale=0.1, address = [3,4]}, { name = "power", byte_order = "ABCD", data_type = "FLOAT32", scale=0.1, address = [3,4]},
] ]
input_registers = [ input_registers = [
{ name = "tank_level", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]}, { name = "tank_level", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]},
{ name = "tank_ph", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]}, { name = "tank_ph", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]},
{ name = "pump1_speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]}, { name = "pump1_speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]},
] ]
` `
// SampleConfig returns a basic configuration for the plugin // SampleConfig returns a basic configuration for the plugin