Analog to Modbus/TCP-IP Server

In this tutorial, YuDash LYNX will be used to read 8 channel analog inputs (4-20mA) and act as Modbus TCP-IP server

Ready-to-use json configuration files are available for ZENYX and LYNX in the end of the tutoral. They can simply be loaded into the device for quick start.

1) Connection Diagram

  1. Test setup of 4 channel 4-20mA analog generator is connected (red line) to analog inputs of LYNX. The value of 5, 10, 15 and 20 mA are being generated in the test setup. LYNX will read 8 analog channels. So, balance 4 channels will have zero values.

  2. The LAN cable is connected from ethernet port of LYNX to laptop. Modbus/TCP-IP server is configured on the ethernet LAN port.

  3. The Modbus Poll software is acting as modbus TCP-IP client on the laptop. It is reading LYNX Modbus/TCP-IP and receiving 8 analog values on given modbus registers.

Modbus Poll download link

2) General Settings in LYNXsettings

  • Loop Delay is set to 0. As we act as server, we want to read input data continuously without any delay.

  • Analog Inputs is enabled to read 4-20mA input.

  • The Cloud/Network set to to "Offline". In this usage, we are not sending data to any server.

  • Ethernet/LAN is enabled

Notes in general settings:

1) Modbus/RS485 is NOT enabled here (which makes YuDash as Modbus master). We will be enabling Modbus/RS485 server in the next step

2) The datascale feature of YuDash can be used to scale the analog input to required process values. This is not covered in this tutorial for simplicity.

3) Analog Input Settings in LYNX

  • Analog Input Settings: All 8 analog inputs are enabled. We read 0-20mA inputs.

  • The eight variables read are analog1 to analog8 respectively. These variables will be mapped to Modbus/ TCP-IP server register in next section.

4) Ethernet LAN Settings

  • Ethernet Settings are used to assign a static IP address to the LYNX

  • Static IP of 192.168.2.73 is assigned in this tutorial. This can be changed as per network topology.

  • This IP address will be used to read LYNX Modbus TCP-IP server in the Mobus poll.

5) Modbus Server Settings

  • Modbus Server Type: This is selected as TCP/IP. This pertains to TCP/IP (LAN port) acting as Modbus Server.

  • Modbus TCP-IP Server Settings:

    • Modbus TCP/IP port: The TCP/IP port used to run the server. It is set to 502 in the example.

    • The section of "Modbus RS485 Server Settings" is not applicable.

    • Only Server Id of 1 is applicable for Modbus TCP-IP.

  • Modbus Server Register Settings block

    • You need to click "Open Modbus Server Settings" to open the details.

    • Click on "Read Modbus Server Settings" to check existing mappings.

    • Click on "Update Modbus Server Settings" after any changes.

  • Modbus Server Register Settings

    • Input variables "analog1" is mapped to 40000 register as floating point output.

    • The "Var Type" is set to 2 (floating point data type). This is the only supported data type at present. So, 2 modbus registers are used for one variable.

    • The "Enable Modbus Register" checkbox enables the value. This entry is ignored/delete if the check box is not present.

    • In the tutorial, the eight analog inputs variables (analog1 to analog8) are mapped to registers 40000 40002 40004, upto 40014.

6) Tutorial Json configuration file

Above 5 steps complete the configuration in the LYNX. These settings are readily available in the following json file. We recommend loading below json file to run through the tutorial.

In case RTC and timeSync is enabled in the advance settings, loopDelay=0 will be ignored. In this case TimeSync Server Mode sould be enabled for fast response.

These settings are for specific advance use-cases and not required for the tutorial. We recommend loading ready-made json configuration files as starting point.

7) Modbus poll read

Reboot LYNX after completing all settings. The input analog values should be available on modbus-poll on the laptop. Following are typical settings to match the Modbus server

1) The Connection Setup is selected as Modbus TCP/IP and IP address of 192.168.2.73 is selected. Server port of 502 is selected.

2) The "Display" is selected as 32-bit Float with Little-endian byte swap

3) All 8 variables (16 registers) are visible in Modbus poll. First 4 registers have analog values from the test setup. Rest 4 analog inputs have zero values as they are not connected.

YuDash Modbus Server specifications

  1. The output registers are mapped in holding registers (starting from 40000).

  2. The data type is fixed floating type (Var Type = 2).

  3. The entries in the register map should be in increasing order only.

  4. Maximum of 16 variables (32 registers) can be mapped to modbus register map.

  5. The data scaling on input variables can be applied to receive process data on the modbus registers.

8) YuDash ZENYX as Analog to Modbus TCP/IP Server

Similar to above tutorial, YuDash LYNX can be configured as Modbus TCP/IP Server. Following is typical wire connection:

7.1) Ethernet LAN is enabled to use LAN port for Modbus TCP/IP server

7.2) Ethernet of YuDash ZENYX is configured as static IP

The IP address is assigned as static. Sample IP address of 192.168.2.73 is assigned. This IP address will be readby Modbus poll software.

7.3) Modbus Server Settings.

  • In Modbus Server Type Settings, "TCP/IP" is selected

  • The Modbus TCP/IP port of 502 is assigned. The IP address was assigned in 7.2 earlier.

  • The block of "Modbus RS485 Server Settings" is ignored.

  • Modbus Server ID remains 1 for Modbus TCP/IP.

  • Only server ID of 1 is supported in Modbus TCP/IP. The uniqueness is managed by port number.

8) Analog to Modbus TCP/IP Server Json file

Last updated