Modbus 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 Modbus Master Mode is explained in the Modbus Master Page. The benefits of Modbus Server can be found in the FAQ page. The YouTube video also shows how to use this feature. 
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.


Be sure to set the Write mode to "Auto".  Here is summary of the Parameters updated. Other settings are left as defaults.  More details of parameters can be found on the Parameters 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.  


Sensor Server
One innovative feature of the Modbus Monitor Advanced is the "Sensor Server". This feature exposes all of your devices' sensors by linking them to Modbus Server.  This allows any Modbus TCP Master to access your phone's sensors without writing any custom android program.  It is also very easy to create this link.  Simply selecting the desired Sensor in the Modbus Monitoring point from the drop down list start the sensor data collection algorithm and links it to the Modbus Server. To help in understanding the technical aspects of the selected sensor, the Monitor Point (Register) Name is stuffed with internal sensor specifications. These types of information is usually derived from "Sensor Reading App".  Using the Modbus Monitor another such app is not needed because the features of that types of app is built in to Modbus Monitor Advanced. The raw data and sensor information is displayed and updated on the screen; just as any "Sensor Reading App" would do.  All you would require is familiarity with the information that is already provided by the Modbus Monitoring App.


When any sensor is selected from the drop down list, the Modbus Monitor Point name (Register Name) is changed by the App and stuffed with the detailed Sensor Data.  Examine the information provided by the app and you gain deep understanding about the sensor's spec.  The Name can be changed to what ever you want after the selection is made.  Note in the image above that the Name field starts with "Sensor number (#)" followed with "SensorName", "Sensor Power", "Sensor Resolution", "Sensor Maximum Range", "Sensor Vendor", and "Sensor Version".  The Raw Sensor data shown in the Green text in three float array [0] xxx.xx [1] xxx.xx [2] xxx.xx. Find the Manufacturer's sensor data sheet to understand the meaning of the values.  The developer's Android Sensor page lists many common sensor and it's meaning. 

When the Sensor is selected the Count field is automatically updated to 6 words (2 words / float * 3 floats).  During modification, ensure that minimum 6 words are selected along with start Address. In order for the Sensor Server to work correctly, following fields must be configured:







        • Sensor Selection
  • Address  = 0 or any unused address
  • Count  = 6
  • Protocol = Modbus TCP
  • Data Type = Float
  • Function = 3 or 4