Analog to Modbus/RS485 Server (Slave)
Last updated
Last updated
In this tutorial, YuDash ZENYX will be used to read 4 channel analog inputs (4-20mA) and act as Modbus/RS485 slave (server).
Test setup of 4 channel 4-20mA analog generator is connected (red line) to analog inputs of ZENYX. The value of 5, 10, 15 and 20 mA are being generated in the test setup.
The Modbus/RS485 is connected to RS485-USB converter (yellow and green) for modbus read on the laptop. ZENYX Modbus/RS85 is configured as modbus slave (server).
The Modbus Poll software is acting as modbus master in the laptop. It is reading ZENYX Modbus/RS485 and receiving 4 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.
Analog Input Settings: The four analog inputs are enabled. We read 0-20mA inputs.
The four variables are read as analog1, analog2, analog3 and analog4. These variables will be mapped to Modbus/RS485 server register in next section.
Modbus Server Type: This is selected as RS485. This pertains to RS485 acting as Modbus Server (Slave). In case of LYNX, this maps to first RS485 channel acting as server.
Modbus RS485 Server Settings:
Modbus Server Id: Enter the Slave ID as per choice. (selected as 1 at present)
BaudRate: Required baud rate. Selected as 9600.
Data Parity: Required data parity. Selected as 8N1.
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 four analog inputs variables (analog1, analog2, analog3 and analog4) are mapped to registers 40000 40002 40004 and 40006
Above 4 steps complete the configuration in the ZENYX. These settings are readily available in the following json file. We recommend loading below json file to run through the tutorial.
These settings pertain to using TimeSync mode within "Advane Feature Settings".
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 ZENYX 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 matched to 9600, 8N1
2) The Slave ID is 1 and function is 0x3 (Read Holding Registers)
3) The Display data type is "32 bit Float" with Little-endian byte swap
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 ZENYX 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