# 13.3 Modbus Slave WCC Lite can act as one (or several) of slave devices in a communication line. This can be used to transmit data to SCADA systems or other RTU devices. It can reply to a messages from Modbus Master with matching device and register addresses. #### Configuring datapoints To use Modbus Slave in WCC Lite, it has to be configured via an Excel configuration. This configuration contains two Excel sheets where parameters have to be filled in - Devices and Signals

If TCP/IP is used as a trasmission medium, only devices with IPs predefined in host column are allowed to connect. All other connections are rejected

##### Modbus Slave parameters for Devices tab
**Parameter** **Type** **Description** **Required **Default value** (when not specified) **Range**
Min Max
name stringUser-friendly name for a device Yes
description stringDescription of a device No
device\_alias stringAlphanumeric string to identify a device Yes
enablebooleanEnabling/disabling of a device No101
protocolstringProtocol to be used Yes Modbus serial Slave, Modbus TCP Slave
hoststringSpace separated host IP addresses of master deviceYes (for TCP).
portintegerTCP port to listen for incoming connections Yes (for TCP)
bind\_addressstringIP address of network adapter used to connect to slave device (Default: ”0.0.0.0”) No (for TCP)0.0.0.0
keep\_alive\_timeout integerMinimum time a connection can be idle without being closed in miliseconds No (for TCP)60
modestringChoosing between RTU (”rtu”), ASCII (”ascii”) and TCP(”tcp”) modes. ASCII is the same as RTU, but with ASCII symbols.NoTCP (for TCP) RTU (for Serial) rtu, ascii, tcp
devicestring Communication port (”PORT1”/”PORT2”) Yes (for serial) PORT1 PORT2
baudrateintegerCommunication speed, baud/s No (for serial) 9600 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
databitsintegerData bit count for communication No (for serial) 8 6 9
stopbitsintegerStop bit count for communication No for serial) 1 1 2
paritystring Communication parity option No (for serial) none none, even, odd
flowcontrolstring Communication device’s flow control option. No (for serial) none none
##### Modbus Slave parameters for Signals tab
**Parameter** **Type** **Description** **Required **Default value** (when not specified) **Range**
Min Max
signal\_name stringUser-friendly signal name Yes
device\_alias stringAlphanumeric string to identify a device Yes
signal\_alias stringUnique alphanumeric name of the signal to be Yes used Yes
enablebooleanEnabling/disabling an individual signal No101
number\_type stringType of a number (FLOAT, DOUBLE, DIGITAL, etc.). This defines the size that will be read. Yes
log integerSize of this signal’s log in the Event log. No0
slave\_idintegerAddress of a slave deviceYes
functionintegerFunction numberYes
register\_addressintegerRegister addressYes
Modbus Slave has an additional signal which can be configured to show communication status. It is used to indicate if the slave device has disconnected from the master or vice versa. To configure such a signal, one column should be filled with particular value. To create an additional signal, one should make a `tag_job_todo` column equal to `device_status` or communication\_status. Communication error status is set when a predefined count of messages (three by default, defined in `keep_alive_timeout` column) fail to be received or are considered invalid. #### Mapping values to registers Internally stored values aren’t organised in a register-like order, therefore mapping should be done by the user. This mapping includes setting an address of the device WCC Lite is simulating as well as function number, register number and how much 16-bit registers are used to store a value. These values should be set in `common_address`, `function`, `info_address` and `size` columns respectively in the Excel configuration. To find out how many register should be used for storing a values, how values can have their values swapped, a user should consult a section `number_type`.

If a Modbus master device requests a data from a register that is mapped but doesn’t yet have initial value, ILLEGAL DATA ADDRESS error code will be returned. The same error code is returned if a requested size of value is bigger that defined or if register is not configured at all.

#### Debugging a Modbus Slave application If configuration for Modbus Slave is set up, handler for protocol will start automatically. If configuration is missing or contains errors, protocol will not start. It is done intentionally to decrease unnecessary memory usage. Modbus Slave command line debugging options `modbus-slave` ``` -h [ –help ] Display help information -V [ –version ] Show version -d Set debugging level -c [ –config ] Config path -r [ –raw ] Show raw telegram data -f [ –frame ] Show frame data -s [ –serial ] Show serial port data –tcp Show tcp packets –ascii Show ASCII messages –rtu Show RTU messages -e [ –redis ] Show redis debug information -R [ –readyfile ] Ready notification file ```

If Modbus Slave does not work properly (e.g. no communication between devices, data is corrupted, etc.), a user can launch a debug session from command line interface and find out why link is not functioning properly.

To launch a debugging session, a user should stop `modbus-slave` process and run `modbus-slave` command with respective flags as shown above.