# Modbus TCP

Modbus TCP enables communication with devices with Modbus TCP Server protocol from the inSCADA platform.

![Figure 1 : Modbus TCP](/files/-LkmdMopcMDGYxybnjLH)

To communicate with a device with Modbus TCP Server protocol, we need know following definitions:

* IP Address,
* Slave Id/Station Number,
* Data blocks start and end addresses,
* Data type of variables within data blocks.

Now let's examine how the Modbus TCP protocol is configured in the inSCADA platform.

#### Step 1. Create a Connection.

To connect to a device, we must first create a connection.&#x20;

![Figure 2 : Connection](/files/-LkmfOFKHXxom4xrRgam)

As shown in Figure 2, the IP address of the device we want to connect to is: 0.0.0.0 Port: 3501. We create a connection based on this information.

#### Step 2. Create the device connected to the connection.

Now let's create a device to connect to.

![Figure 3 : Device](/files/-LkmgYEjvw0PPGZLjTzo)

As shown in Figure 3, we create a device connected to the connection we created in the previous step. We choose protocol as "Modbus TCP", station address: 1. We set the scanning time to 1000 ms.

#### Step 3. Create data blocks to be read/written from/to the device.

In this step, we will now define the data blocks that will be read from the device. Data blocks in MODBUS protocol can be maximum 255 bytes/127 Word/63 Double Word. MODBUS protocol has grouped data blocks into 4 different types. They are;&#x20;

* Holding Registers,
* Input Registers,
* Digital Inputs,
* Coils,

#### Holding Registers

Holding Registers refers to the writable and readable word memory region. For more information, please visit [modbus.org](/ins/en-1/communication-protocols/modbus/modbus-rtu-over-udp.md).

#### Input Registers

Input Registers refers only to the readable word memory region. For more information, please visit [modbus.org](/ins/en-1/communication-protocols/modbus/modbus-rtu-over-udp.md).

#### Digital Inputs

Digital Inputs sadece okunabilir bit bellek bölgesini ifade eder. For more information, please visit [modbus.org](/ins/en-1/communication-protocols/modbus/modbus-rtu-over-udp.md).

#### Coils

Coils refer to readable and writable bit memory region. For more information, please visit [modbus.org](/ins/en-1/communication-protocols/modbus/modbus-rtu-over-udp.md).

![Figure 4 : Frame](/files/-Lkn10Dwh7TiLcz6_lFG)

As shown in Figure 4, we create a data block of the Holding Register type connected to the device we created in the previous step. We define with the starting address as 1000 and 20 Words.

After completing the steps here, we can now communicate with the device. You need to have information about the configuration settings you edited here, the device you want to communicate with, and the data blocks you want to read/write from.

To begin the communication, you can go to the Control Panel and start the corresponding Connection. If there are no incompatibilities, your connection will appear as Connected  on the Control Panel.

#### Last Step. Create a variable and read/write data

After the communication is established, we can now create our variables, read and write data from the device. To do this, we need to create a variable from the Development-> Variables menu.

![Figure 5 : Variables](/files/-Lkn0N4g09gcqk2L1deP)

As shown in Figure 5, we create a variable that depends on our data block. Now we can go back to our Control Panel, update our connection. and see the variable value.&#x20;

![Figure 6 : Modbus TCP Test On Control Panel](/files/-Lkn2_ECpAxdciR7NIKG)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://inscada.gitbook.io/ins/en-1/communication-protocols/modbus/modbus-tcp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
