Chapter 8 Communications
ASDA-B2
8-16
Revision May, 2018
Example of CRC program:
Produce CRC in C language. This function needs two parameters:
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
unsigned char rdat[60];
/* read 2 data from address 0200H of ASD with address 1 */
unsigned char tdat[60]={‘:’,’0’,’1’,’0’,’3’,’0’,’2’,’0’,’0’,’0’,’0’,’0’,’2’,’F’,’8’,’\r’,’\n’};
Содержание ASD-B2-1521-F
Страница 1: ......
Страница 20: ...ASDA B2 Chapter 1 Installation and Model Explanation Revision May 2018 1 7 1 4 Servo Drive Features...
Страница 81: ...Chapter 3 Wiring ASDA B2 3 42 Revision May 2018 This page is intentionally left blank...
Страница 103: ...Chapter 5 Trial Operation and Tuning ASDA B2 5 12 Revision May 2018 5 5 2 Inertia Estimation Flowchart with Mechanism...
Страница 124: ...ASDA B2 Chapter 6 Control Modes of Operation Revision May 2018 6 13...