Frame Structure Of Modbus-Rtu Protocol; Used Functions Of Modbus-Rtu Protocol; 0X03/0X04 Function - Reading Of The 16-Bits Value Of Registers [4X/3X-References] - CEL-MAR ADA-4040PC8 User Manual

Table of Contents

Advertisement

ADA-4040PC8

8.2. FRAME STRUCTURE OF MODBUS-RTU PROTOCOL

Device address (1-byte) Function (1-byte) Dane (n-bytes) CRC-16Lo (1-byte) CRC-16Hi (1-byte)

8.3. USED FUNCTIONS OF MODBUS-RTU PROTOCOL

Code of the Function
03 (0x03)
04 (0x04)
06 (0x06)
8.3.1. 0x03/0x04 FUNCTION - READING OF THE 16-BITS VALUE OF REGISTERS [4X/3X-
REFERENCES]
Function 0x03 / 0x04 are used for readout the registers from ADA-4040PC8, in which are available measurement values and status
values of JCT controller.
The measurement values readout form MODBUS-RTU register is presented by a 16-bit register.
The registers with the measurement value are in the integer format of 16-bit sign (in C/C++ type short int).
The actual measurement value is obtained from the read register using the following algorithms, using the appropriate DW factor value
(see table below).
Algorithm 1. Readout register is saved to regular type variable (float) and then divide it by the DW factor.
/ / Fragment of code in C language (VS6.0) presenting above algorithm
short int siMeasureReg;
float fMeasureVal;
......
fMeasureVal = (float) siMeasureReg;
fMeasureVal = fMeasureVal / DW;
Algorithm 2. Readout register is saved to regular type variable 16-bit (short int) and then divide by the DW factor, received change of
the dividing it is a number of the hundredth parts of the measurement value.
/ / Fragment of code in C language (VS6.0) presenting above algorithm
short int siMeasureReg;
div_t div_MeasureVal;
......
div_MeasureVal = div ((int) siMeasureReg, DW);
printf ("Total value of the measurement = % d\n, the hundredth parts of the value of the measurement = % d\n", div_MeasureVal.quot,
div_MeasureVal.rem);
Query register 40124 / 30124 (Cp SV value)
Byte no.
Designation
00
Converter Address
01
Function Code
02
Address of the register Hi
03
Address of the register Lo 1 Byte 7C
04
Number of registers Hi
05
Number of registers Lo
06
CRC-Lo
07
CRC-Hi
Example. Query for a value from the register address 40124 / address 30124 (Cp SV value).
40-03-00-7C-00-01-CRCLo-CRCHi
40-04-00-7C-00-01-CRCLo-CRCHi
Reading of controller parameters from the HOLDING MODBUS-RTU registers
Readout of controller parameters from INPUT MODBUS-RTU registers
Setting of a single HOLDING MODBUS-RTU register
Size
Value [hex]
1 Byte 40 [01 to F7]
1 Byte 03 / 04
1 Byte 00
1 Byte 00
1 Byte 01
1 Byte - - -
1 Byte - - -
Description
13

Advertisement

Table of Contents
loading

Table of Contents