Instrutech The Hornet IGM402 User Manual page 60

Hot cathode ionization vacuum gauge with dual convection
Table of Contents

Advertisement

Instruction Manual
The <data> portion of the command or response can be multiple bytes in length, depending upon the command
byte (<cmd>) sent. Do not include the '<' or '>' within the message string. They are used in the context of these
instructions to delineate between various bytes within the serial data string.
The Cycle Redundancy Check <CRC> is calculated for each message as follows:
// *ptr is a pointer to the message to be sent.
// Length is the length of the message.
char Calculate_CRC8(char *ptr, char Length)
{
char CRC_Value;
char Counter;
char BitCounter;
char XOR_Byte;
char TransmitByte;
// Initialize the local variable.
CRC_Value = 0xFF;
// Calculate the CRC.
for(Counter = 0; Counter < Length; Counter++)
{
TransmitByte = *ptr;
ptr++;
BitCounter = 8;
while(BitCounter != 0)
{
BitCounter--;
XOR_Byte = TransmitByte ^ CRC_Value;
if((XOR_Byte & 0x80) != 0)
{
CRC_Value ^= 0x0E;
CRC_Value <<= 1;
CRC_Value |= 1;
}
else
{
CRC_Value <<= 1;
}
// Left shift the calculation byte.
TransmitByte <<= 1;
}
}
// Return the calculated CRC value.
return(CRC_Value);
}
This code is written in the 'C' language. Contact InstruTech technical support for code written for Visual Basic.
InstruTech
IGM402 Hornet
Page 58

Advertisement

Table of Contents
loading

Table of Contents