The ‘frame value’ for the CRC byte is calculated applying a XOR func-
on to the ‘frame value’ (see secon 2.4.5) of all bytes in secons
‘Header’ and ‘Data’, from byte ‘0’ (‘STX’) to the last data byte (‘Dn’).
• if the calculated CRC value is lower than ‘32’, it is normalized by ap-
plying the ‘one’s complement’ funcon .
CRC0=STX ^ ID ^ RSV ^ FROM ^ TO ^ REG ^ RSV ^ LONG ^ D0 ^...^ Dn
• if (CRC0<32) -> CRC=!CRC0 (one’s complement funcon)
• if (CRC0>31) -> CRC=CRC0
//example of CRC calculaon in C language
int8 Calculate_CRC(int8 CRC_Posion)
{
int8 i,CRC=0;
for(i=0;c<CRC_Posion;c++)
{
crc=crc ^ frame[i];
}
if(crc<32) CRC=~CRC;
return(CRC);
}
Header Trail
STX ID RSV FROM TO REG RSV LONG CRC ETX
2 32 32 32 54 32 32 32 52 3
Start Ping --- 0 22 0 --- 0 CRC Stop
Header Trail
STX ID RSV FROM TO REG RSV LONG CRC ETX
2 33 32 54 32 32 32 32 53 3
Start Pong --- 22 0 0 --- 0 CRC Stop
Example - ‘Master’ (address ‘0’) requests conrmaon of existence to
the ‘Slave’ at addrress ‘22’ (‘PING’ frame) and the ‘Slave’ replies to
the ‘Master’ with a ‘PONG’ frame.
Frames ‘PING’ (32) and ‘PONG’ (33)
2.4.7 Frame examples
Frames ‘RD’ (36) and ‘ANS’ (37)
Example - ‘Master’ (address ‘0’) requests the value of register ‘0’ (dis-
play value) to the ‘Slave’ at address ‘28’ (‘RD’ frame) and the ‘Slave’
replies to the ‘Master’ with a reply frame (‘ANS’ frame) containing
the requested data (765.43).
Header Trail
STX ID RSV FROM TO REG RSV LONG CRC ETX
2 36 32 32 60 32 32 32 58 3
Start RD --- 0 28 0 --- 0 CRC Stop
Header Data Trail
STX ID RSV FROM TO REG RSV LONG D0 D1 D2 D3 D4 D5 D6 D7 CRC ETX
2 37 32 60 32 32 32 40 43 48 55 54 53 46 52 51 15 3
Start ANS --- 28 0 0 --- 8 +0765.43 CRC Stop
Frames ‘ERR’ (38)
Header Trail
STX ID RSV FROM TO REG RSV LONG CRC ETX
2 38 32 43 32 33 32 32 46 3
Start ERR --- 11 0 1 --- 0 CRC Stop
Example - ‘Slave’ at address ‘11’ replies to the ‘Master’ (address ‘0’)
with an error frame (‘ERR’ frame) indicang that the requested regis-
ter number is unknown (‘UNKNOWN_REGISTER’, error code ‘1’). The
*Instruments with 4 digits also send reading values formaed with 6
digits : value -321.5 is transmied as -00321.5
error code is codied into the ‘REG’ byte. For a list of error code see
secon 2.4.6.
2.4.8 CRC calculaon