APC 6000 user manual Jbus protocol

Page 17

JBUS protocol (continued)

*****************************************************************************************************/

*/

/*

FUNCTION CALL: crc = crc16 (message, length);

*/

/*

with char *message; message = address of message

*/

/*

 

*/

/*

int length; length of received message (including CRC)

*/

/*

expressed in number of bytes

*/

/*

int crc; = CRC16 calculated from the "address", "code" and

*/

/*

"information" fields.

*/

/*

 

*/

/*

RETURN VALUE: calculated crc 16 (int crc)

*/

/***************************************************************************************************** */

int crc16 (message, length)

 

 

 

unsigned char message [ ];

/*

buffer containing message

*/

 

 

/*

for which the crc16 is to be calculated.

*/

int length;

/*

length of message to be checked

*/

 

 

/*

(including crc16)

*/

{

 

/*

beginning of the function

*/

int

i ;

/*

loop variable

*/

int

j ;

/*

calculation and displacement variable

*/

union {

/*

calculated crc16:

*/

int

ival ;

/*

- whole

*/

unsigned char cval [ 2 ];

/*

- table of 2 characters

*/

 

 

/*

unsigned is important since otherwise the sign

*/

 

 

/*

extension causes negative displacements with

*/

 

 

/*

respect to the beginning of the table

*/

 

} crcal;

 

 

 

 

 

/*$

initialization of calculated crc

*/

crcal.ival = 0XFFFF;

 

 

 

i = 0;

 

 

 

 

 

/*$

correction of the length to be checked: remove the

*/

 

 

/*$

received crc16 from the length to be checked

*/

length = length - 2;

 

 

 

 

 

/*$ WHILE there are bytes to be checked DO

*/

while ( i < length )

 

 

 

 

{

 

 

 

 

 

/*$

calculate the table index

*/

 

j = (int) ( message [ i ] ^ crcal.cval [ CPH ] );

 

 

 

/*$

most significant byte

*/

 

crcal.cval [ CPH ] = tbcrch [ j ] ^ crcal.cval [ CPL ];

 

 

 

/*$

least significant byte

*/

 

crcal.cval [ CPL ] = tbcrcl [ j ];

 

 

 

/*$

next byte

*/

 

i++;

 

 

 

 

};

/*$

END WHILE there are bytes to be checked

*/

 

 

/*$

return the calculated crc

*/

return ( crcal.ival );

 

 

 

}

 

/*

end of function

*/

Note: if the CRC16 is computed using table lookup, the most significant byte is transmitted first.

6739389EN/FB - Page 17

Image 17
Contents GTC link communication interface Mgetm GalaxyTM2 6739389EN/FB Contents Introduction PresentationACQ module COM moduleInterface Communication settingsJbus protocol Description of request and response frames PrincipleSynchronizing data exchanges Checking received messages on the slave side Function 1 and 2 read N bits FunctionsFunction 5 writing a bit Function 3 and 4 read N wordsFunction 6 writing a word Function 8 reading error diagnosis countersFunction 15 writing n consecutive bits Function 11 reading event countersMSB LSB MSB LSB MSB Function 16 writing n consecutive wordsCRC 16 algorithm Example of CRC computation Table of Most Significant Bytes for CRC16 Computation Example of CRC 16 computation in C using table lookupJbus protocol Unitary UPS UPS theory of operationUPS without Mains Parallel connected UPS with Static Switch cubicleOperation without battery Operation with battery Measured quantities Block diagramUnitary UPS Operating modes Normal operation Load on batteryMain status bits UPS operating information Load on Mains Load on bypass Parallel connected UPS Main status bits of system operations Normal operation Load on battery DisconnectedStatic Switch cubicle Normal operation Load on Mains Load on bypass Static SwitchMain indicators of system operations Sample commands List of variable fields Example of read data array commands sent by the terminalSystem information Message formatCurrent fields General definitions Signaling fieldTables of measured data Voltage fields Power fields Frequency fieldsRectifier-charger Battery and adjustments fieldsTables of binary data Connectivity InverterGlobal information Table of control devicesWord address Glossary of information descriptorsInverter stack overload 0=no/1=overload Word address 4C Word address 4AWord address 4E summary Word address 4DWord address C1 C10 call reset 0= not activated / 1=activated
Related manuals
Manual 46 pages 29.39 Kb