Analog to Modbus/TCP-IP Server
Last updated
Last updated
In this tutorial, YuDash LYNX will be used to read 8 channel analog inputs (4-20mA) and act as Modbus TCP-IP server
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.
The LAN cable is connected from ethernet port of LYNX to laptop. Modbus/TCP-IP server is configured on the ethernet LAN port.
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.
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
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.
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.
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.
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.
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.
The output registers are mapped in holding registers (starting from 40000).
The data type is fixed floating type (Var Type = 2).
The entries in the register map should be in increasing order only.
Maximum of 16 variables (32 registers) can be mapped to modbus register map.
The data scaling on input variables can be applied to receive process data on the modbus registers.
Similar to above tutorial, YuDash LYNX can be configured as Modbus TCP/IP Server. Following is typical wire connection:
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.
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.
Modbus Poll