Chapter 8 MODBUS Communications
8-14
Revision June 2010
RTU Mode:
In RTU mode, a silent interval of more than 10ms indicates communication end.
The following is an example of CRC generation using C language. The function takes two
arguments:
unsigned char* data;
unsigned char length
The function returns the CRC value as a type of unsigned integer.
unsigned int crc_chk(unsigned char* data, unsigned char length) {
int j;
unsigned int reg_crc=0xFFFF;
while( length-- ) {
reg_crc^= *data++;
for (j=0; j<8; j++ ) {
if( reg_crc & 0x01 ) { /*LSB(bit 0 ) = 1 */
reg_crc = (reg_crc >> 1)^0xA001;
} else {
reg_crc = (reg_crc>>1);
}
}
}
return reg_crc;
}
PC communication program example:
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<process.h>
#define PORT 0x03F8
/* the address of COM 1 */
#define THR 0x0000
#define RDR 0x0000
#define BRDL 0x0000
#define IER 0x0001
#define BRDH 0x0001
#define LCR 0x0003
#define MCR 0x0004
#define LSR 0x0005
#define MSR 0x0006
Summary of Contents for ASD-B2-0121-B
Page 1: ......
Page 13: ...Table of Contents xii Revision June 2010 This page intentionally left blank...
Page 17: ...Chapter 1 Unpacking Check and Model Explanation 1 4 Revision June 2010 ECMA Series Servo Motor...
Page 87: ...Chapter 4 Display and Operation 4 12 Revision June 2010 This page intentionally left blank...
Page 131: ...Chapter 6 Control Modes of Operation 6 22 Revision June 2010 Time Domain...
Page 267: ...Chapter 8 MODBUS Communications 8 18 Revision June 2010 This page intentionally left blank...
Page 271: ...Chapter 9 Maintenance and Inspection 9 4 Revision June 2010 This page intentionally left blank...
Page 291: ...Chapter 11 Specifications 11 8 Revision June 2010 11 3 Servo Motor Speed Torque Curves...