EasyManua.ls Logo

Delta Electronics ASDA-B2 series - Page 281

Delta Electronics ASDA-B2 series
335 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 8 MODBUS Communications ASDA-B2
8-14 Revision September 2013
End1, End0 (Communication End)
ASCII Mode:
In ASCII mode, (0DH) stands for character ’\r’ (carriage return) and (0AH) stands for
character ’\n’ (new line), they indicate communication end.
RTU Mode:
In RTU mode, a silent interval of more than 10ms indicates communication end.
CRC Program Example
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
VARITEL INGENIERIA ELECTRONICA S.A.
info@varitel.com - www.varitel.com - Tel. (54) 11-4243-1171 / Fax: (54) 11-4292-7545
Manuel Baliña 456, Lomas de Zamora (B1832CCJ) Buenos Aires, Argentina.

Table of Contents

Related product manuals