Hi all, my current project requires the use of a radio link. These links can introduce errors in the messages. My message frame contains 8 Bytes; Address, Command, 5 data Bytes and a check Byte appended to the end. In doing some research on check methods I found a lot of “Mumbo-Jumbo.” The simplest form of a check is the “Check sum.” This consists of summing all the Bytes and then performing a modulo 255 to generate a check sum. They claim this is 95% effective, whatever that means. It is clear this will catch single bit errors. For 99.99% effectiveness they suggest a “CRC” code.
After looking at the “Mumbo-Jumbo” for a while, I throw up my arms and decided to call in the BIG GUNS, my Brother Robert, who has a Ph.D. and is a genius in Math and an expert in computer science.
He coded up an 8 bit CRC in basic and I converted that to GCBasic. He claims the reason for the “Mumbo-Jumbo” is an attempt to make simple things look complicated, popular amongst many math types.
He writes:
This polynomial p(x) = x^8 + x^5 + x^4 + 1 detects:
1. Any odd number of errors anywhere within the 8-byte packet.
2. All double-bit errors anywhere within the 8-byte packet.
3. Any cluster of errors that can be contained within an 8-bit "window" (1-8 bits incorrect).
4. Most larger clusters of errors.
Start with CRC = 0 and call repeatedly with each new byte:
Maxim 8-bit CRC
Width: 8 bits
Polynomial: 0x31
Initial: 0x00
Xor out: 0x00
Reflected data: yes
Reflected remainder: yes
Here is the code:
Sub CRC8
CRC = CRC XOR NewCRCByte
Repeat 8
IF CRC.0 = On Then 'Is low bit set?
Set C = Off 'clear carry bit
Rotate CRC Right
CRC = CRC XOR h'8C' 'Use reflected polynomial in Hex
ELSE
Set C = Off 'clear carry bit
Rotate CRC Right
End If
End Repeat
End Sub
Here is a code snippet for how to use it for transmitting 4 Bytes:
Hi all, my current project requires the use of a radio link. These links can introduce errors in the messages. My message frame contains 8 Bytes; Address, Command, 5 data Bytes and a check Byte appended to the end. In doing some research on check methods I found a lot of “Mumbo-Jumbo.” The simplest form of a check is the “Check sum.” This consists of summing all the Bytes and then performing a modulo 255 to generate a check sum. They claim this is 95% effective, whatever that means. It is clear this will catch single bit errors. For 99.99% effectiveness they suggest a “CRC” code.
After looking at the “Mumbo-Jumbo” for a while, I throw up my arms and decided to call in the BIG GUNS, my Brother Robert, who has a Ph.D. and is a genius in Math and an expert in computer science.
He coded up an 8 bit CRC in basic and I converted that to GCBasic. He claims the reason for the “Mumbo-Jumbo” is an attempt to make simple things look complicated, popular amongst many math types.
He writes:
This polynomial p(x) = x^8 + x^5 + x^4 + 1 detects:
1. Any odd number of errors anywhere within the 8-byte packet.
2. All double-bit errors anywhere within the 8-byte packet.
3. Any cluster of errors that can be contained within an 8-bit "window" (1-8 bits incorrect).
4. Most larger clusters of errors.
Start with CRC = 0 and call repeatedly with each new byte:
Maxim 8-bit CRC
Width: 8 bits
Polynomial: 0x31
Initial: 0x00
Xor out: 0x00
Reflected data: yes
Reflected remainder: yes
Here is the code:
Sub CRC8
CRC = CRC XOR NewCRCByte
Repeat 8
IF CRC.0 = On Then 'Is low bit set?
Set C = Off 'clear carry bit
Rotate CRC Right
CRC = CRC XOR h'8C' 'Use reflected polynomial in Hex
ELSE
Set C = Off 'clear carry bit
Rotate CRC Right
End If
End Repeat
End Sub
Here is a code snippet for how to use it for transmitting 4 Bytes:
start:
CRC = 0
NewCRCByte = B1
call CRC8
NewCRCByte = B2
call CRC8
NewCRCByte = B3
Call CRC8
NewCRCByte = B4
call CRC8
Goto Start
Best regards, Ed.