Simply Modbus logo
← Previous: TCP Client Manual

Modbus TCP Client ManualWriting to Registers and Coils

Installation, Configuration, and Operation Manual

versions 8.x.x

Table of Contents

Writing to Registers and Coils

Press WRITE to open the write window.

TCP Client Tool - Write Window Screenshot

Control color Controls (inputs) that can be changed by the user.
Indicator color Indicators (outputs) that cannot be directly changed.

To write to a slave device, the following settings are needed.

Mode

Mode is copied from the main READ window.

Modbus mode selector

mode: "Modbus TCP" or "Modbus RTU-over-TCP" protocol.     Modbus TCP

Building a Command

   Enter Slave ID, First Register and Number of Values to Write, the Values and their Data Type to build the command string.

SlaveID selector

SlaveID:  The 1st byte in the Command string.
The unit address of the Slave device to get data from. normal range: 1 to 247.     SlaveID

2byte ID selector

2byte ID:  Setting a Slave ID over 255 will automatically check this box and allow Slave IDs up to 65535.
    SlaveID

Remains on for all addresses until a Slave ID below 256 is entered and the box manually unchecked.

Function Code selector

Function code:  The 2nd byte in the Command string.
The Write Window supports these Function codes:
FC 06 is used to write to one Holding Register.
FC 16 is used to write to multiple Registers.
FC 05 is used to write to one Coil.
FC 15 is used to write to multiple Coils.     Function codes

First Register selector

First Register:  The 3rd and 4th bytes in the Command string.
The register (or coil) number at the start of the block to read.     Data tables

Offset selector

Offset:  This value is subtracted from the First Register to get the data address used in the Request.     Data tables

Number of Values to Write selector

Number of Values to Write:  The 5th and 6th bytes in the Command string.
The quantity of registers (or coils) to write to the slave.

Register Size selector

Register size:  The size of the registers.
    16 bit registers - standard modbus registers.
     1 bit coils - standard modbus coils.
    32 bit registers - most Enron modbus registers.     Data tables

Use defaults selector

Use defaults:  When checked, the program will automatically populate the circled settings to default values as the value in "First Register" changes. To use non-default settings, or to keep these controls from changing with First Register, uncheck "Use defaults".

Default values

First Register Function Code Offset Register Size
1-10000 01 1 1 bit coils
10001-20000 02 10001 1 bit coils
20001-30000 03 0 32 bit regs
30001-40000 04 30001 16 bit regs
40001+ 03 40001 16 bit regs

Data Type

Data Type selector

Select the data type for the data to be written.
Multiple data types will require multiple write messages.

Available Data Types to select class="image">

These are the available Datatypes that can be selected.     Data Types

Values to Write

Enter the values in the first column.

Values to Write selector

The size of the array is set with the #values to Write (above)
The scrollbar will appear when writing more than 5 values.

High Byte first and High Word first

High Byte first and High Word first check boxes

The bytes and words can be swapped by toggling these check boxes.     Byte/Word Order

Sending a Command

Fail in timeout time selector

Set "fail in" time large enough to keep the program from timing out before the full response is received. The default is 2 seconds.

SEND button

Press SEND to transmit the command to the TCP server (slave) device.

Progress bar - waiting for response

The response time and a progress bar are shown as the program waits for a response. It stops when the expected response bytes are received or the "fail in" time is reached.

Reading the Response

After pressing SEND, the response bytes received from the slave device are displayed in the response indicator.

Response Indicator

The expected CRC (in RTU-over-TCP mode) and expected response bytes show a red background when the response has different values.
The response for write commands is often an echo of the command.
This response indicates the command was acted on and there was no error.

Byte History Log

All bytes sent and received are added to the byte history log with date/time stamps.
The maximum size of the byte log is 50,000 bytes when the oldest 10,000 is removed to keep the program from slowing down.

Byte Log indicator and buttons

Save Byte Log button

Pressing Save Bytes will Display a 'Save As..' dialog box to allow the log contents to be saved to a text file.

Clear Byte Log button class="image">

Pressing Clear Bytes will empty the byte log contents.

Save and Restore Configurations

Save Configuration button

Press Save Configuration to display a 'Save As..' dialog box to save the current settings to a text file.

Restore Configuration button

Press Restore Configuration to display an 'Open File' dialog box to select a previously saved settings file.

Configuration File Format

The file is saved in tabbed-text format (tab separated values).
Sending it to, or opening it from, a spreadsheet program like Excel will use the tabs as column delimiters as shown here...

Configuration File contents

Text in red is shown as reference notes and not included in the file.
Columns A & B contain the setting descriptions and their values.
Column C contains the data type numbers 0 through 6.
Column E contains the values to write.

Context help

Contect Help indicator

Pressing Control-H will open the Context Help box which shows additional help information as you hover over the controls and indicators.

Contect Help pop-up

Troubleshooting

If you see no response after hitting send
  • Check slave device is powered on and connected to the network
  • Check the IP Address and Port in the Modbus Server (Slave device) to make sure it matches the settings in the TCP Client program (Master device)
  • Check IP Address and port number.
  • Check mode. TCP or RTU-over-TCP.
  • Check slave ID.
  • Check slave device tables to verify the addresses of registers or coils.
  • Check offset to verify the hexadecimal address in the request message.
  • Check "fail in" time is not too low causing the program to time out before the response is received.
← Previous: TCP Client Manual