Changes

no edit summary
Line 9: Line 9:  
[[File:ModbusTCPMasterSlaveLanIP.png]]
 
[[File:ModbusTCPMasterSlaveLanIP.png]]
   −
Now we need to enable Modbus service for this slave device as we will open specific port for letting through TCP communications. This is done in '''Services->Modbus''' page:
+
Now we need to enable Modbus service for this slave device as we will open specific port for letting through TCP communications (it is also possible to 'Allow remote access' if we wish to access this router from external WAN using it's public IP). This is done in '''Services->Modbus''' page:
    
[[File:ModbusTCPMasterSlaveEnableTCP.png]]
 
[[File:ModbusTCPMasterSlaveEnableTCP.png]]
Line 15: Line 15:  
==Adding new slave device==
 
==Adding new slave device==
    +
On '''master device''' (in this example master device has 192.168.1.1 internal IP address) open '''Services->Modbus->Modbus TCP Master'''.
 
To add a new slave, enter a custom name, slave's ID, IP address and port and click the "Add" button:
 
To add a new slave, enter a custom name, slave's ID, IP address and port and click the "Add" button:
    +
[[File:AddNewSlave.png]]
   −
==Testing ==
+
'''Note''': Slave's ID, IP and Port should be exactly the same as configured in the slave's device '''Services->Modbus''' page
 +
 
 +
 
 +
After clicking the 'Add' button you will be redirected to advanced slave's configuration page:
 +
 
 +
[[File:AdvancedSlaveConfig.png]]
 +
 
 +
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>yes | no; default: <b>no</b></td>
 +
        <td>Turns communication with the slave device on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Name</td>
 +
        <td>string; default: <b>none</b></td>
 +
        <td>Slave device's name, used for easier management purposes.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Slave ID</td>
 +
        <td>integer [0..255]; default: <b>none</b></td>
 +
        <td>Slave ID. Each slave in a network is assigned a unique identifier ranging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID. When set to 0, the slave will respond to requests addressed to any ID.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>IP address</td>
 +
        <td>ip; default: <b>none</b></td>
 +
        <td>Slave device's IP address.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Port</td>
 +
        <td>integer [0..65535]; default: <b>none</b></td>
 +
        <td>Slave device's Modbus TCP port.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Period</td>
 +
        <td>integer [1..6400]; default: <b>none</b></td>
 +
        <td>Interval at which requests are sent to the slave device.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Timeout</td>
 +
        <td>integer [1..30]; default: <b>none</b></td>
 +
        <td>Maximum response wait time.</td>
 +
    </tr>
 +
</table>
 +
 
 +
 
 +
Enable this slave's configuration by clicking on the checkbox and enter the timeout in seconds. Click '''Save'''.
 +
 
 +
Now the slave device is added to the Modbus TCP Master section but we need to test if it is working.
 +
 
 +
==Testing==
 +
 
 +
[[File:AddedSlaveDevice.png]]
 +
 
 +
For testing if the functionality is working we can configure a request. A Modbus request is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
 +
 
 +
We click ''''Edit'''' button in the slave device's configuration.
 +
 
 +
[[File:NewRequest.png]]
 +
 
 +
By clicking the ''''Add'''' button in the Requests configuration section we will be able to configure a new request. Let's say that in our case we are interested in the '''System Uptime''' parameter which is located in the first 2 registers of our device (more about the parameters and their registers we can get or set using Modbus service: '''[[RUT955 Modbus]]'''). Here is how our request should look like for this purpose:
 +
 
 +
[[File:SystemUptimeRequestSlave.png]]
 +
 
 +
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Name</td>
 +
        <td>string; default: <b>Unnamed Parameter</b></td>
 +
        <td>Request name. Used for easier management purposes.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Data type</td>
 +
        <td>8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float, Byte order 1,2,3,4 | 32bit float, Byte order 4,3,2,1 | 32bit float, Byte order 2,1,4,3 | 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
 +
        <td>How read data will be stored.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Function</td>
 +
        <td>1 | 2 | 3 | 4 | 5 | 6 | 15 | 16; default: <b>3</b></td>
 +
        <td>A function code specifies the type of register being addressed by a Modbus request. The codes represent these functions:<br>
 +
            <ul>
 +
                <li><b>1</b> - read Coil Status</li>
 +
                <li><b>2</b> - read Input Status</li>
 +
                <li><b>3</b> - read Holding Registers</li>
 +
                <li><b>4</b> - read Input Registers</li>
 +
                <li><b>5</b> - force Single Coil</li>
 +
                <li><b>6</b> - preset Single Register</li>
 +
                <li><b>15</b> - force Multiple Coils</li>
 +
                <li><b>16</b> - force Multiple Registers</li>
 +
            </ul>
 +
        </td>
 +
    </tr>
 +
    <tr>
 +
        <td>First Register</td>
 +
        <td>integer [0..65535]; default: <b>1</b></td>
 +
        <td>First Modbus register from which data will be read.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Number of Registers</td>
 +
        <td>integer [1..2000]; default: <b>none</b></td>
 +
        <td>Number of Modbus registers that will be read during the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>yes | no; default: <b>no</b></td>
 +
        <td>Turns the request on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Test</td>
 +
        <td>- (interactive button)</td>
 +
        <td>Generates a Modbus request according to given parameters in order to test the request configuration. You must first save the configuration before you can use the Test button.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Delete</td>
 +
        <td>- (interactive button)</td>
 +
        <td>Deletes the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Add</td>
 +
        <td>- (interactive button)</td>
 +
        <td>Adds a new request configuration.</td>
 +
    </tr>
 +
</table>
 +
 
 +
'''Note''': During the time this article is written, we need to 'Save' the configuration first before clicking the 'Test' button. This will redirect you to the Modbus TCP Master page and you will need to click 'Edit' button again to try and test the functionality of this request.
 +
 
 +
 
 +
Now by clicking the 'Test' button we can get the System Uptime value from the first 2 registers:
 +
 
 +
[[File:SystemUptimeTime.png]]
 +
 
 +
We can see that the slave device returns the registers master device has asked for. More about how to understand the information we are getting from registers: '''[[Monitoring via Modbus]]'''
0

edits

Navigation menu