MORECHEMISTRY.COM::MORE CHEMISTRY ON THE WEB    
Home Member Area Links Events Publications Promotions
#GOOGLELINKS#  

LabVIEW programming topics - Calculating the checksum

CRC or checksum calculation

When transmitting a string of characters over some cable using a checksum is a good way establish proper transmission. One type of checksum can be calculated by xor-ing an initial value (0, zero) with all the values of all characters in the string.

Here is the checksum calculation for the following string:

0 1 <STX> R 0 1 0

	C H A R A C T E R      C H E C K S U M
step	ASCII hex bin          bin        hex
0	                       0000 0000  00		<== start with 0
1	0     30  0011 0000    0011 0000  30
2	1     31  0011 0001    0000 0001  01
3	<STX> 02  0000 0010    0000 0011  03
4	R     52  0101 0010    0101 0001  51
5	0     30  0011 0000    0110 0001  61
6	1     31  0011 0001    0101 0000  50
7	0     30  0011 0000    0110 0000  60
or more elaborate
step	calculation	comment
	0000 0000 	<== start with 0
1	0011 0000 	add '0'
	0011 0000 	<== checksum; equals first character

	0011 0000
2	0011 0001 	add '1'
	0000 0001 	<== checksum

	0000 0001
3	0000 0010 	add '<STX>'
	0000 0011 	<== checksum

	0000 0011
4	0101 0010 	add 'R'
	0101 0001 	<== checksum

	0101 0001
5	0011 0000 	add '0'
	0110 0001 	<== checksum

	0110 0001
6	0011 0001 	add '1'
	0101 0000 	<== checksum

	0101 0000
7	0011 0000 	add '0'
	0110 0000 	<== checksum; final result
As can be seen, after adding each character a bit in the checksum turns into '1' only if one of the corresponding bits in the character and previous checksum is '1'.

Downloads

crc.vi
This sub vi calulates the checksum which is used in some communication protocols.

Bart Boshuizen, 2005/02/01
#GOOGLEDISPLAY#
© copyright 2000-2014, morechemistry.com
design by Bb.