Skip to main content

9. MODBUSCommunications

9.1 Communication Wiring
The connection terminals CN3-IN and CN4-OUT are used for MODBUS communications.

image.png

 

9.2 Setting Communication Parameters

image.png

 

9.3 MODBUS Communication Protocol
MODBUS communication protocol is only used when Pn700.2 is set to 1. 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
Every 8-bit data is consisted by two ASCII characters. For example: One 1-byte data 64H (Hexadecimal expression) is expressed as ASCII code ‘64’, which contains ‘6’ as ASCII code 36 H and ‘4’as ASCII code 34 H.
ASCII code for number 0 to 9, character A to F are as follows:

image.png

 

RTU Mode
Every 8-bit data is consisted by two 4-bit hexadecimal data, that is to say, a normal hexadecimal data. For example: decimal data 100 can be expressed as 64 H by 1-byte RTU data.

 

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

image.png

image.png

image.png

 11bit character form (8-bit data)

image.png

 

9.3.2 Communication Protocol Structure

ASCII Mode

image.png

 

RTU Mode

image.png

 

Communication protocol data format instructions
 STX (communication start)
− ASCII mode: ‘: ’ character
− RTU mode: Sleep interval of at least 4 bytes transmission time (automatically changed according to different communication speed).
 ADR (communication address)
Valid communication address: 1 to 254
For example: communicate with the servo drive which address is 32 (20 in hex):
− ASCII mode: ADR=‘2’, ‘0’=>‘2’=32 H, ‘0’=30 H
− RTU mode: ADR=20 H
 CMD (command reference) and DATA (data)
Data structure is determined by command code. Regular command code is shown as follows:
Command code: 03H, read N words(word), N ≦ 20.
For example: read 2 words starting from 0070 H from the servo drive which address is 01 H

image.png

image.png

For example: write 1(0001 H) into01 H servo address 0070 H. Reference code: 06 H, write in one word

image.png

image.png

 

LRC (ASCII mode) and CRC (RTU mode) Error Detection Value Calculation
 LRC calculation in ASCII mode:
ASCII mode uses LRC (Longitudinal Redundancy Check) error detection value. The exceeded parts (e.g. the total value is 128 H of hex, then take 28 H 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 01 H servo address 0201 

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 F8 H when 2 is used to compensate 08 H, so LRC is “F”,”8”.
 CRC calculation of 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 ofFFFF H, 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 A001 H;
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 2 to 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. Refer to the following example.
Read 2 words from the 0101 H address of 01 H servo. The final CRC register content calculated from ADR to the last bit of data is 94 H, and then the instruction information is shown as follows. Please be sure that 94 H is transmitted before 37 H.

image.png

 ASCII Mode:
Communication is ended with (0D H) - [carriage return] and (0A H) - [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.

 

9.3.3 Communication Error Disposal
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

image.png

 

Error frame responses code=command+80 H;
Error code=00 H: Normal communication
=01 H: Servo drive cannot identify the required functions
=02 H: The required data address does not exist in the servo drive
=03 H: The required data in servo drive is not allowed (beyond the maximum or minimum value of the parameter)
=04 H: Servo drive starts to perform the requirement, but cannot achieve it.
For example: Servo drive axis number is 03H, write data 5000 into parameter Pn102 is not allowed, because the range of parameter Pn102 is 1~4000. The servo drive will feedback an error frame, the error code is 03H (beyond the parameter’s maximum value or minimum value). The structure is as follows:

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 feedback any frames.

9.3.4 Data Communication Address of Servo State

image.png

image.png

 

Servo Parameter Area
The Pn parameter of corresponding servo. Pn parameter is 32bit, formed by splicing two consecutive hexadecimal data addresses (low- and high-bit). When reading and writing, operate the low-bit first, then high-bit.
For the start parameter Pn000, the low-bit address is 01F0H, and the high-bit address is 01F1H.
For other parameters Pnx, the low-bit address is 01F0H+x*2, and the high-bit address is 01F1H+x*2.
For example: when writing to Pn000, the data written is 1; write 1 to 01F0H first, and then write 0 to 01F1H.

 

Alarm Information Storage Area

image.png

image.png