Herunterladen Inhalt Inhalt Diese Seite drucken

In Betrieb Nehmen - Rs 485 Modbus-Schnittstelle - Leuze Cml720I-R05-1600.R/Cv-M12 Originalbetriebsanleitung

Messender lichtvorhang
Inhaltsverzeichnis
In Betrieb nehmen – RS 485 Modbus-Schnittstelle
Indexing the CRC in this way provides faster execution than would be achieved by calculating a new CRC
value with each new character from the message buffer.
This function performs the swapping of the high/low CRC bytes internally. The bytes are already
swapped in the CRC value that is returned from the function.
Therefore the CRC value returned from the function can be directly placed into the message for
transmission.
The function takes two arguments:
Argument
unsigned char *puchMsg;
unsigned short usDataLen;
CRC Generation Function:
unsigned short CRC16 (puchMsg, usDataLen);
unsigned char *puchMsg;
unsigned short usDataLen;
{
unsigned char uchCRCHi = 0xFF;
unsigned char uchCRCLo = 0xFF;
unsigned uIndex;
while (usDataLen--)
{
}
return (uchCRCHi << 8 | uchCRCLo) ;
}
High-Order Byte Table:
/* Table of CRC values for high-order byte */
static unsigned char auchCRCHi[] = {
0x00,
0xC1,
0x81,
0x40,
0x01,
0xC0,
0x80,
0x41,
0x01,
0xC0,
0x80,
0x41,
0x00,
0xC1,
0x81,
0x40,
0x01,
0xC0,
0x80,
0x41,
0x00,
0xC0,
0x80,
0x41,
0x00,
0xC1,
0x81,
0x40,
0x00,
0xC1,
0x80,
0x41,
0x01,
0xC0,
0x80,
0x41,
0x00,
0xC1,
0x81,
Leuze electronic GmbH + Co. KG
Description
A pointer to the message buffer containing binary data to be used for generating the CRC
The quantity of bytes in the message buffer.
uIndex = uchCRCLo ^ *puchMsgg++ ;
uchCRCLo = uchCRCHi ^ auchCRCHi[uIndex} ;
uchCRCHi = auchCRCLo[uIndex] ;
0x40,
0x01,
0xC0,
0x80,
0x80,
0x41,
0x00,
0xC1,
0xC0,
0x80,
0x41,
0x00,
0x00,
0xC1,
0x81,
0x40,
0x40,
0x01,
0xC0,
0x80,
0x80,
0x41,
0x00,
0xC1,
0xC1,
0x81,
0x40,
0x00,
0x00,
0xC1,
0x81,
0x40,
0x40,
0x01,
0xC0,
0x80,
0x81,
0x40,
0x01,
0xC0,
0xC0,
0x80,
0x41,
0x00,
0x01,
0xC0,
0x80,
0x41,
0x40,
0x00,
0xC1,
0x81,
/* The function returns the CRC as a unsigned short type */
/* message to calculate CRC upon */
/* quantity of bytes in message */
/* high byte of CRC initialized */
/* low byte of CRC initialized */
/* will index into CRC lookup table */
/* pass through message buffer */
/* calculate the CRC */
0x41,
0x01,
0xC0,
0x81,
0x40,
0x00,
0xC1,
0x81,
0x40,
0x01,
0xC0,
0x80,
0x41,
0x00,
0xC1,
0x81,
0x40,
0x01,
0xC1,
0x81,
0x40,
0x01,
0xC0,
0x80,
0x41,
0x01,
0xC0,
0x80,
0x41,
0x00,
0xC1,
0x81,
0x40,
0x00,
0xC1,
0x81,
0x40,
0x01,
0xC0,
CML 720i
0x80,
0x41,
0x00,
0xC1,
0xC1,
0x81,
0x40,
0x01,
0x00,
0xC1,
0x81,
0x40,
0x41,
0x01,
0xC0,
0x80,
0x81,
0x40,
0x00,
0xC1,
0xC0,
0x80,
0x41,
0x01,
0x01,
0xC0,
0x80,
0x41,
0x41,
0x00,
0xC1,
0x81,
0x80,
0x41,
0x00,
0xC1,
0xC1,
0x81,
0x40,
0x01,
0x00,
0xC1,
0x81,
0x40,
0x40,
0x01,
0xC0,
0x80,
0x80,
0x41,
0x00,
0xC1,
0x81,
0xC0,
0x01,
0x41,
0x81,
0xC0,
0x01,
0x40,
0x81,
0xC0,
0x01,
0x41,
0x81,
150
Inhaltsverzeichnis
loading

Diese Anleitung auch für:

Cml 720i50120141

Inhaltsverzeichnis