Android Modbus TCP Server
The Modbus Monitor Advanced app have many modes of operation known as a Master Mode (Client) and Slave (Server) Mode. Technically this mode can be split into new "Modbus Server Android App", but it was decided to add as an option to the main app for convenience and ease of use.
The Server mode of the app turns your Android device into the Modbus TCP Slave (server). Yes, the Server only talks Modbus TCP protocols. Other protocol and physical medium are not designed to work in the Server/Slave mode of operation. In other words, only Modbus Monitor point with "Modbus TCP" protocol selection will work and do the correct things during server mode. Other items in the list without the "Modbus TCP" protocol are ignored. The same Modbus Monitor points list is shared during both Master and Slave operation (saving data entry steps).
First setup the Modbus TCP with the correct server port. This is done in the Preference screen in the "Settings" menu. Most commonly, this will be setup as port number 502. However, the Port 502 can not be used for the server unless your Android device is rooted (Android Operating system blocks many ports below 1024). Many users don't prefer rooting the device; so only option available than is to use the port numbers allowed by your stock Android operating system. It is possible to use any port above 1024; assuming that are not occupied by any other application or operating system. The Port number "8888" was tested to be good on many phones when we done testing internally.
The setting of "0" is allowed by Modbus Monitor Advanced App. When the Port is set to 0, the app asks Android operating system to find the best port available for the Modbus Monitor Advanced. This may seem like good way to get the port without hassle. However, this may lead to more issues for the other devices on your local network. It is better to assign the port manually that you know won't conflict with existing ports that are used by "other" devices on your network (i.e. VOIP box). Little effort on selecting correct port for the server will save headaches in resolving port issues with other devices at site. For example, when we chose the port 5060, our VOIP service started having issue with ringing and not hearing audio. So, the point to this explanation is to do your research before selecting correct port for the Modbus TCP Server and use "0" with caution.
Second setup step is to Turn ON the Server feature so it can be started. This can simply done by turning on the "Modbus Server?" checkmark under Preference screen. Turning this feature on puts the familiar "server icon" on the icon bar. The Server Icon is the only way to turn the Server communication ON.
If there are no Monitoring points in your list, at least add one to get the server started. This can be done easily with (+) and configure similar to Modbus Master type. Ignore the IP Address and Port settings in the Monitor configuration dialog; leave them default. Only IP Address and Port in the Server Settings are used as discussed earlier. The image below shows the setting to server five (5) float values (5 floats * 2 words/floats = 10 counts). The Protocol must be set to Modbus TCP. The Modbus register start at address 0 with function code of 3 (PLC Register 40001). If you need help translating address, refer to Address page.
- Channel = TCP/IP
- Protocol = Modbus TCP
- Address = 0
- Count = 10
- Function = 3
- Write = Auto
- Data Type = Float
- Byte Swap = 3210 (Inverse)
After setup is complete, the server can be started with Start Server Communication icon. If the Server is able to get the port and no errors are encountered, the Server Icon color is changed to "Green" as shown in the image above. If it doesn't turn green, the Modbus Monitor Advanced is having trouble creating the socket on the programmed port. Once the remote Modbus Master is connected, the number in the parenthesis is updated to indicate how many sockets have been created so far. The Transmit and Receive frame content can not be updated in the server mode.
Now that Server is up and running, the (float) values can be updated by tapping the Monitor Point and selecting "Change" option. That bring the dialog box to update the value to register. Note that the registers are automatically updated with data type and byte swaps. The Write Page discusses more about the Write feature.
Continue to Modbus TCP Sensor Server