APC 6000 user manual Example of CRC 16 computation in C using table lookup

Page 16

JBUS protocol (continued)

Example of CRC 16 computation in "C" using table lookup

#define CPH 0 /* most significant bytes */ #define CPL 1 /* least significant bytes */

/* TABLE OF MOST SIGNIFICANT BYTES FOR CRC16 COMPUTATION */

char tbcrch [ ] =

{

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

1,192,128,65,0,193,129,64,0,193,129,64,1,192,128,65,

0,193,129,64,1,192,128,65,1,192,128,65,0,193,129,64,

};

/* TABLE OF LEAST SIGNIFICANT BYTES FOR CRC16 COMPUTATION */

char tbcrcl [ ] =

{

0,192,193,1,195,3,2,194,198,6,7,199,5,197,196,4,

204,12,13,205,15,207,206,14,10,202,203,11,201,9,8,200,

216,24,25,217,27,219,218,26,30,222,223,31,221,29,28,220,

20,212,213,21,215,23,22,214,210,18,19,211,17,209,208,16,

240,48,49,241,51,243,242,50,54,246,247,55,245,53,52,244,

60,252,253,61,255,63,62,254,250,58,59,251,57,249,248,56,

40,232,233,41,235,43,42,234,238,46,47,239,45,237,236,44,

228,36,37,229,39,231,230,38,34,226,227,35,225,33,32,224,

160,96,97,161,99,163,162,98,102,166,167,103,165,101,100,164,

108,172,173,109,175,111,110,174,170,106,107,171,105,169,168,104,

120,184,185,121,187,123,122,186,190,126,127,191,125,189,188,124,

180,116,117,181,119,183,182,118,114,178,179,115,177,113,112,176,

80,144,145,81,147,83,82,146,150,86,87,151,85,149,148,84,

156,92,93,157,95,159,158,94,90,154,155,91,153,89,88,152,

136,72,73,137,75,139,138,74,78,142,143,79,141,77,76,140,

68,132,133,69,135,71,70,134,130,66,67,131,65,129,128,64,

};

Page 16 - 6739389EN/FB

Image 16
Contents Mgetm GalaxyTM GTC link communication interface2 6739389EN/FB Contents Presentation IntroductionACQ module COM moduleCommunication settings InterfaceJbus protocol Synchronizing data exchanges PrincipleDescription of request and response frames Checking received messages on the slave side Functions Function 1 and 2 read N bitsFunction 3 and 4 read N words Function 5 writing a bitFunction 8 reading error diagnosis counters Function 6 writing a wordFunction 11 reading event counters Function 15 writing n consecutive bitsFunction 16 writing n consecutive words MSB LSB MSB LSB MSBCRC 16 algorithm Example of CRC computation Example of CRC 16 computation in C using table lookup Table of Most Significant Bytes for CRC16 ComputationJbus protocol UPS theory of operation Unitary UPSOperation without battery Parallel connected UPS with Static Switch cubicleUPS without Mains Operation with battery Unitary UPS Block diagramMeasured quantities Main status bits UPS operating information Normal operation Load on batteryOperating modes Load on Mains Load on bypass Parallel connected UPS Normal operation Load on battery Disconnected Main status bits of system operationsStatic Switch cubicle Main indicators of system operations Static SwitchNormal operation Load on Mains Load on bypass Example of read data array commands sent by the terminal Sample commands List of variable fieldsSystem information Message formatTables of measured data General definitions Signaling fieldCurrent fields Power fields Frequency fields Voltage fieldsTables of binary data Battery and adjustments fieldsRectifier-charger Inverter ConnectivityTable of control devices Global informationGlossary of information descriptors Word addressInverter stack overload 0=no/1=overload Word address 4A Word address 4CWord address 4D Word address 4E summaryC10 call reset 0= not activated / 1=activated Word address C1
Related manuals
Manual 46 pages 29.39 Kb