UART Communication Function Usage
UART Communication Protocol
- Baud Rate: 115200
- Data Bits: 8 bits
- Stop Bits: 1 bit
- Parity: None
- Response Mode: Query‑and‑response
The UART communication protocol uses a fixed 10‑byte frame format:
| Device Address | Command Code | Object Address | Error/Clear | Data Field | Checksum | ||||
|---|---|---|---|---|---|---|---|---|---|
| Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 | Byte9 | Byte10 |
| ID | CMD | AddrH | AddrL | ErrR | Data(MSB) | Data(N-1) | Data(N-2) | Data(LSB) | Check |
- ID: Slave device address, default value:
0x01. The device will return no response if the ID does not match. - CMD: Command code, including read command
0xA0and write commands0x51,0x52,0x54.
Detailed definition of command codes is shown below:
-
Read Command: Host reads data from the specified object address on the drive
Host‑sent CMD Drive Response CMD Description 0xA0 By0xA1 Object data is 8‑bit: [Data(LSB)] 0xA0 0xA2 Object data is 16‑bit: [Data(N‑2) - Data(LSB)] 0xA0 0xA4 Object data is 32‑bit: [Data(MSB) - Data(LSB)] 0xA0 0x5F Object address does not exist; data field is invalid 0xA0 0x80 Checksum error; data field is invalid -
Write Command: Host writes data to the specified object address on the drive
Host‑sent CMD Drive Response CMD Description 0x51 0x61 8‑bit object data: [Data4], write succeeded 0x50 Data type mismatch, write failed 0x58 Object address is read‑only, write failed 0x5F Object address does not exist, write failed 0x52 0x62 16‑bit object data: [Data3 - Data4], write succeeded 0x50 Data type mismatch, write failed 0x58 Object address is read‑only, write failed 0x5F Object address does not exist, write failed 0x54 0x64 32‑bit object data: [Data1 - Data4], write succeeded 0x50 Data type mismatch, write failed 0x58 Object address is read‑only, write failed 0x5F Object address does not exist, write failed
-
- AddrH, AddrL: High‑byte and low‑byte of the object address
- ErrR: Error Report & Clear
- When
ErrR=0xCEin any valid host read/write frame, the drive's error flag will be cleared. - The value returned in
ErrRby the drive contains fault information. Each of the 8 bits represents one fault condition:0= no fault,1= fault detected. Fault definitions are listed below:ErrR returned by device Error description bit0: [LSB] Reserved bit1: Following error exceeds allowed value bit2: Encoder error bit3: Motor overload bit4: Drive over‑temperature bit5: DC‑bus voltage too high bit6: DC‑bus voltage too low bit7: [MSB] Drive output short circuit
- When
- Data(MSB)-Data(LSB): Data field, most significant byte first, least significant byte last.
- Check: Checksum, Check = sum of [Byte1-Byte9] taken as the lower 8 bits.
UART Communication Examples
Example 1: Read the actual DC‑bus voltage of the drive
Referring to "Table F1‑3 Measured Data" in Object Dictionary List, the object address for "Actual DC‑bus Voltage" is 0x5001, stored as a 16‑bit signed integer. Assume the actual DC‑bus voltage is 36 V.
| Device Address | Command Code | Object Address | Error/Clear | Data Field | Checksum | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Host Send | 0x01 | 0xA0 | 0x50 | 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0xF2 |
| Drive Response | 0x01 | 0xA2 | 0x50 | 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x24 | 0x18 |
Example 2: Read the actual motor encoder position
Referring to "Table F1‑3 Measurement Data" in the Common Object List, the object address for "Actual Position Value" is 0x7071, stored as a 32‑bit signed integer.
| Device Address | Command Code | Object Address | Error/Clear | Data Field | Checksum | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Host Send | 0x01 | 0xA0 | 0x70 | 0x71 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x82 |
Assume the current encoder actual position = -8237, hexadecimal: 0xFFFFDFD3 | ||||||||||
| Drive Response | 0x01 | 0xA4 | 0x70 | 0x71 | 0x00 | 0xFF | 0xFF | 0xDF | 0xD3 | 0x36 |
| If the drive has an error, e.g., "Following error exceeds allowed value" | ||||||||||
| Drive Fault Response | 0x01 | 0xA4 | 0x70 | 0x71 | 0x02 | 0xFF | 0xFF | 0xDF | 0xD3 | 0x38 |
Example 3: Write target speed (rpm)
Referring to "Table F1‑2 Basic Modes & Control" in Object Dictionary List, the object address for Target Speed (rpm) is 0x70B1, stored as a 16‑bit signed integer. Assume the value to be written = 100, hexadecimal: 0x0064.
| Device Address | Command Code | Object Address | Error/Clear | Data Field | Checksum | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Host Send | 0x01 | 0x52 | 0x70 | 0xB1 | 0x00 | 0x00 | 0x00 | 0x00 | 0x64 | 0xD8 |
| Drive Response | 0x01 | 0x62 | 0x70 | 0xB1 | 0x00 | 0x00 | 0x00 | 0x00 | 0x64 | 0xE8 |
Example 4: Write Target Speed (High‑resolution speed command)
Referring to "Table F1‑2 Basic Modes & Control" in Object Dictionary List, the object address for High‑Precision Target Speed is 0x70B2, stored as a 32‑bit signed integer.
To set a speed command of 3.21 rpm, apply the conversion formula:
U[y,x]:[DEC]=([rpm] * 512 * [Feedback_Resolution])/1875. Where Feedback_Resolution = 4096.
DEC = (3.21 × 512 × 4096) / 1875 = 3590, hexadecimal: 0x0E06.
| Device Address | Command Code | Object Address | Error/Clear | Data Field | Checksum | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Host Send | 0x01 | 0x54 | 0x70 | 0xB2 | 0x00 | 0x00 | 0x00 | 0x0E | 0x06 | 0x8B |
| Drive Response | 0x01 | 0x64 | 0x70 | 0xB2 | 0x00 | 0x00 | 0x00 | 0x0E | 0x06 | 0x9B |