Skip to main content

9. MODBUS Communication

9.1 RS-485 Wiring

ED3M model Servodrives provide the MODBUS communication function with RS-485 interface, which can be used to easily set parameters or to perform monitoring operations and so on.
The definitions of the Servodrive communication connector terminals (CN3 and CN4) are as follows

image.png

image.png

For example, a network consists of one PLC and three of Servodrives A, B and C, the connection of them is shown in following figure. 

image.png

 

9.2 Relevant Parameters for MODBUS

image.png

 

9.3 MODBUS Protocol

There are two modes for MODBUS communication: ASCII (American Standard Code for information interchange) mode and RTU (Remote Terminal Unit) mode.

9.3.1 Code Meaning
ASCII Mode
In Modbus ASCII, each data byte is split into the two bytes, representing the two ASCII characters in the Hexadecimal value. For example, the ASCII value ‘64’ is represented as 3634 in hex, in which, ASCII value ‘6’ is represented as 36(H), and ‘4’ is represented as 34(H).
The range of data bytes in Modbus ASCII represent only the 16 hexadecimal characters. Therefore, every data byte in Modbus ASCII must be one of these 16. 

image.png

 

RTU Mode
In Modbus RTU, each data byte (8-bit) consists of two 4-bit hexadecimal value. For example, the decimal data 100 can be represented as 64(H) in RTU mode.

 Data Structure: 10-bit character form (for 7-bit data)

image.png

 

 Data Structure: 11-bit character form (for 8-bit data)

image.png

 

9.3.2 Data Format
ASCII Mode

image.png

 

RTU Mode

image.png

 

Format Description
 STX (communication starting)
− ASCII mode: character ‘: ’
− RTU mode: A static period for transferring 4 bytes at least.
 ADR (communication address)
A valid communication address is the range from 1 to 254.
For example, communicate with the Servodrive which address is 32 (20 in hex):
− In ASCII mode: ADR=‘2’, ‘0’ → ‘2’=32H, ‘0’=30H
− In RTU mode: ADR=20H
 CMD (command code) and DATA
The format of the data depends on the command code. The common command code is shown as following:
Command code: 03 H, read N words, and N is not greater than 20.
For example, read 2 words starting from 0070 H from the servo drive which address is 01 H.

image.png

image.png

For another example, write 1 (0001 H) into 01H servo address 0070H. In which, the command code is 06H, and write 1 word into.

image.png

image.png

 

Error Detection Value Calculation
 LRC check in ASCII mode
ASCII mode uses LRC (Longitudinal Redundancy Check) error detection value. The exceeded parts (e.g. the total value is 128H of hex, then take 28H only) is taken off by the unit of 256 in the total value from ADR to the last information, then calculate and compensate, the final result is LRC error detection value.
For example: read 1 word from 01H servo address 0201H

image.png

Add from ADR data to the last data.
01 H +03 H +02 H +01 H +00 H +01 H =08 H
The compensate value is F8H when 2 is used to compensate 08H, so LRC is “F”, ”8”.
 CRC check in RTU mode
RTU mode uses CRC (Cyclical Redundancy Check) error detection value.
The process of CRC error detection value calculation is shown as follows:
Step 1: Load in a 16-bit register of FFFFH, named “CRC” register.
Step 2: Run XOR calculation between the first bit (bit 0) of instruction information and 16-bit CRC register’s low bit (LSB), and the result is saved to CRC register.
Step 3: Check the lowest bit (LSB) of CRC register, if it is 0, CRC register moves one bit to right; if it is 1, CRC register moves one bit to right, then run XOR calculation with A001H;
Step 4: Go to Step 5 till the third step has been executed for 8 times, otherwise return to Step 3.
Step 5: Repeat the steps from Step 2 to Step 4 for the next bit of instruction information, the comment of CRC register is the CRC error detection value while all the bits have been executed by the same way.

Example
After calculating out the CRC error detection value, the CRC low bit should be filled first in instruction information, and then fill the high bit of CRC. Please refer to the following example: Read 2 words from the 0101H address of 01H servo. The final CRC register content calculated from ADR to the last bit of data is 3794H, and then the instruction information is shown as follows. Please be sure that 94H is transmitted before 37H.

image.png

 ASCII mode
Communication is ended with (0DH) - [carriage return] and (0AH) - [new line].
 RTU mode
When the time exceeds the sleep interval by at least 4 bytes transmission time while in the current communication speed, it means the communication is finished.
 Example
The following example uses C language to generate CRC value. The function needs two parameters

image.png

 

9.3.3 Communication Exception
Problems that occur during communication are a result of the following:
 Data address is incorrect while reading/writing parameters.
 The data is not within the parameter setting range while writing.
 Data transmission fault or checking code fault when communication is disturbed.
When the first and second communication faults occur, the servo drive is running normally, and will feed back an error frame.
When the third communication fault occurs, transmission data will be recognized as invalid to give up, and no error frame is returned.
The format of error frame:

image.png

image.png

Error frame responses code = [command]+80H
Error code = 00H:Normal communication
= 01H: Servodrive cannot identify the required functions
= 02H: The required data address does not exist in the servo drive
= 03H: The required data in servo drive is not allowed. (exceeds the range of parameter)
= 04H: Servodrive starts to perform the requirement, but cannot achieve it.
For example: Servo drive axis number is 03H, write data 06Hinto parameter Pn100 is not allowed , because the range of parameter Pn100is 0 to 6. The servo drive will feedback an error frame, the error code is 03H (Beyond the parameter’s maximum value or minimum value).

image.png

image.png

Besides, if the data frame sent from host controller slave station address is 00H, it determines the data to be broadcast data. The servo drives will not feed back any frames.

9.3.4 Data Communication Address in Servodrive
The communication parameter addresses are shown in the following table:

image.png

image.png

image.png

image.png

 Parameter area (axis A is 0000 to 0348H, axis B is 2000 to 2348H, axis C is 4000 to 4348H) Parameter address is relevant to the parameters in the parameter list. For example, axis A parameter Pn000 is relevant to communication address 0000H; parameter Pn102 is relevant to communication address 0066H.
 Alarm information storage area (axis A is 07F1 to 07FAH, axis B is 27F1 to 27FAH, axis C is 47F1 to 47FAH)

image.png

 Monitor data area (axis A is 0806 to 0816H, axis B is 2806 to 2816H, axis C is 4806 to 4816H)
The monitor data is corresponding to servo drive panel displays Un000 to Un016.
For example: the corresponding data of communication address 0807H (speed setting) is FB16H. Therefore, the speed setting of axis A is -1258r/m.

 MODBUS communication IO signal
Use communication to control digital IO signal. This data will not be saved after power off.
It is operated with Pn512 as the communication input IO signal. That is to say, when the parameters setting in Pn512 enable the IO bit, the IO can be controlled by communication.

 Software version (090FH)
Use digit to represent servo drive software version. For example, if the read out data is 0100H, it means the software version is t-1.00.