Modbus RS485
Modbus/RS485 is a popular serial protocol to read various sensors. YuDash LYNX is being used to read a variety of instruments, sensors and PLCs for various applications. LYNX provides easy to configure approach for reading field Modbus instruments. Following are the key information points required for a successful read of instrument through Modbus:
Baudrate
Data Bits, Parity and Stop Bit
Slave ID of instrument
Modbus register information to read:
Modbus register numbers and types)
Modbus register data types (Size: integer/float/real. Byte swapping information: LSB/MSB etc.)
Modbus register address.
Modbus Register Mapping in YuDash LYNX.
Following four inputs have to be provided for processing of each Modbus register in YuDash LYNX:
1) Variable Name: YuDash LYNX reads a given Modbus register and stores it in a variable. This is the user defined string, which will be sent to IoT platform/server along with the process values. For sending to YuDash cloud, the variable names should be all small letters without any blank spaces. Sample variable name: volt1 temperature_celcius amp_01 amp_02 machine_status_flag
2) Register Number: The register types/function codes of Modbus are defined by register numbers. User has to specify complete #Register No. in Modbus register section. Following is the available range of registers:
1
COIL STATUS
0-9990
2
INPUT STATUS
10000-19999
4
INPUT REGISTERS
30000-39999
3
HOLDING REGISTERS
40000-49999
Important Note: LYNX uses base-0 register addressing (starting with 40000). OEM instrument manual uses both base-0 or base-1 registers, so that they have to checked accordingly. The MODSCAN uses base 1 register addressing (starting with 40001). So, after MODSCAN registers are identified, you have to enter register as one less than the MODSCAN register.
3) Type: The data type of Modbus registers are specified in data Type code in MODUS register settings. Following are the register type codes:
1
SIGNED INTEGER
1
2 or 20
Floating Point (LSB first)
2
CDAB
21
Floating Point (MSB first)
2
ABCD
22
32bit Integer (LSB first)
2
CDAB
23
32bit Integer (MSB first)
2
ABCD
24
32bit Unsigned Integer (LSB first)
2
CDAB
25
32bit Unsigned Integer (MSB first)
2
ABCD
11
Bit pattern Extraction
1
LYNX also supports byte swapping for 32 bit registers. For these special case, we have to use 3 digit Type (by adding a suffix 1 to original type). It will enable byte swapping with same data type as corresponding 2 digit code: 201, 221, 241: DCBA 211, 231, 251: BADC
Note: Support of code 24, 25 and 3 digit types is available in firmware V3.6 onwards.
YuDash IoT devices also support various 64 bit data types as IEEE-754 Floating-Point numbers and also 64 bit signed integer. For 64 bit data types, 4 modbus registers are read. We are not using terminology of LSB and MSB as there are various nomenclatures. We effectively support all swapping at 16bit register . We are calling them P, Q, R, S (for each 16 bit modbus register). This is similar to ABCD were bytes. Note: 64 bit data type is available in firmware V3.6 onwards.
Following are possible combinations:
4 or 40
RSPQ
401
SRQP
Float 64
41
PQRS
411
QPSR
Float 64
42
RSPQ
421
SRQP
Int 64
43
PQRS
431
QPSR
Int 64
By default, all values from YuDash IoT devices are converted to 32 bit floating point numbers. So, while we can read larger 64 bit values, there may be data precision loss or possibly overflow while processing large number 32 bit integer or 64 bit data types. Use of factor (see below) may be useful to handle cases of data overflow.
4) Factor: LYNX provides option to post process register value after reading of inputs. The register value is divided by the value provided in Factor. By default, Factor of 1 used . Typically, Factor of 10 or 100 may be used in cases when Modbus registers are integer representations in multiple. For example, if the voltage of 234.6 is represented as integer of 2346 in Modbus register, factor of 10 can be used. With this factor, LYNX will read 2346 integer value, divide by 10 and send 234.6 on the cloud platform. This helps in receiving values on cloud which map to values seen on display. In many cases, 100X value is used in integer form.
In most of industrial applications, MODSCAN (or similar) software is used to validate the Modbus settings. In case of any troubleshooting, we strongly suggest to validate the communication through MODSCAN. Our tutorial explains the mapping in reference of MODSCAN to LYNX settings.
Modbus/RS485 interfacing example
To explain Modbus/RS485 mapping in LYNX, we will interface it with a single phase energy meter to read its voltage and frequency.
Selec make EM2M is used to interface with MODSCAN software followed by YuDash LYNX.
Energy Meter MODUBUS settings checked in MODSCAN software.
Voltage and Frequency values test-read in MODSCAN software and co-related with datasheet values.
Corresponding settings updated in YuDash LYNX Modbus/RS485 section.
Following video explains the steps for updating Modbus/RS485 settings in LYNX:
Last updated