Simple 1 Byte Checksum Method


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: Simple 1 Byte Checksum Method

    Richard,

    Wow!
    That is so clean and easy.
    (I do have a tendency of making things complicated.)

    Thank you very much!

    Jay Zebryk
    Southbridge, Massachusetts

  2. #2
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Simple 1 Byte Checksum Method

    This information may not pertain to your current goal since you are trying to decode an existing checksum method being used by your transmitter.

    However, for a simple tried and true method of byte level checksums on a datastream, the Intel Hex8 checksum method works well and is very simple.
    I use this method in many projects with good success.

    The Intel Hex8 file (I8HEX) checksum is the 2s compliment of the sum of the payload bytes.
    The beauty of using the 2s compliment of the sum of the payload bytes is that the validation check is simple.
    To validate the payload at the receiving end, the receiver sums the received payload bytes including the received checksum byte.
    The result should equal zero (0).

    This works because of the use of unsigned byte variables and the rollover from 255 to 0 for overflows.
    In this context a number plus the 2s compliment of itself will equal zero (0) as a 2s compliment of a number behaves like the negative of the original number.

    Computing the 2s compliment of a byte can be done by first computing the 1s compliment of the number, then adding one to the result.
    1scomp = (number ^ $FF) This computes the 1s compliment
    2scomp = 1scomp + 1

    For example:
    number = 73
    1scomp = (73 ^ $ff) = 182
    2scomp = 182 + 1 = 183

    To validate just add the number to its 2s compliment.
    73 + 183 = 0

    This checksum method can be used for just about any length of payload bytes.
    Regards,
    TABSoft

Similar Threads

  1. Reading a speed sensor best method?
    By davewanna in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 27th January 2012, 02:37
  2. Calculate Byte Value Checksum in PBP Pro
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th July 2009, 22:50
  3. ASM Addressing method help needed
    By sougata in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th January 2007, 17:01
  4. Current Calculation Method
    By DynamoBen in forum Off Topic
    Replies: 4
    Last Post: - 16th September 2006, 09:21
  5. Which is the method to use
    By dtit in forum General
    Replies: 0
    Last Post: - 18th January 2005, 09:53

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts