EasyManua.ls Logo

YASKAWA GPD 315/V7 - Crc-16; Figure 4-1 CRC Calculation in Quick Basic

YASKAWA GPD 315/V7
44 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
GPD315 Modbus RTU Technical Manual TM 4325
Page
18
CRC-16 Calculation Example:
crcsum# = &HFFFF&
crcshift# = &H0&
crcconst# = &HA001&
CLS
PRINT “***************************************************”
PRINT
PRINT CRC-16 calculator”
PRINT
PRINT “***************************************************”
PRINT “If entering data in hex, preceed the data with ‘&H’”
PRINT Example: 32decimal = 20hex = &H20”
PRINT “***************************************************”
PRINT
INPUT “Enter the number of bytes in the message: “, maxbyte
FOR bytenum = 1 TO maxbyte STEP 1
PRINT “Enter byte “; bytenum; :”:
INPUT byte&
byte& = byte& AND &HFF&
crcsum# = (crcsum# XOR byte&) AND &HFFFF&
FOR shift = 1 TO 8 STEP 1
crcshift# = (INT(crcsum# / 2)) AND &H7FFF&
IF crcsum# AND &H1& THEN
crcsum# = crcshift# XOR crcconst#
ELSE
crcsum# = crcshift#
END IF
NEXT shift
NEXT bytenum
lower& = crcsum# AND &HFF&
upper& = (INT(crcsum# / 256)) AND &HFF&
PRINT “Lower byte (1
st
) = “, HEX$(lower&)
PRINT “Upper byte (2
nd
) = “, HEX$(upper&)
Figure 4-1 CRC Calculation in Quick Basic

Table of Contents

Other manuals for YASKAWA GPD 315/V7