A Checksum Algorithm


Results 1 to 4 of 4

Threaded View

  1. #3


    Did you find this post helpful? Yes | No

    Default Get the hardware right first

    I assume that the hardware at each end will have their own power supplies. Sometimes that means each end will be driven from a different phase of the mains and this can lead to significant earth potential differences. I have measured over 40 volts between the earth pins on two adjacent power outlets in a factory where one power outlet was on one phase and the other on a separate phase. The power outlets were only a metre apart but that was where the electrician split the feeds. The potential difference varied with factory electrical loading and it took days to track down the intermittent errors.

    If you try to connect TTL over 40 metres you can only tolerate about one volt of earth difference before the system stops working. No amount of checksum, CRC or retransmission scheme will save you if the earth potential difference is higher than that.

    I suggest you use an opto coupler at each end and two twisted pair wires for transmit and receive. Ethernet UTP is high grade cable and the different twist rates for each pair minimise crosstalk and noise pickup. Optocouplers are generally not as good as transformers at all terminations but the transformer approach needs a proper modulation scheme to eliminate any DC component (Google Bi-Phase modulation)which is another layer of complexity best avoided unless you are in a very high electical noise or lightning prone environment.

    At one end the transmitter is direct connected to the line with a current limiting resistor. The corresponding receiver at the other end is driven by an optocoupler. The system is then a current loop and the maximum distances can be several hundred metres.

    Only AFTER you have reliable communications do you think about adding a checksum or CRC. The end application will dictate how robust the error checking needs to be. If human life is at stake a 32 bit CRC might be wise. If you are just turning a lamp on or off simply sending the command information repeatedly, with no error checking will be fine. I personally use an 8 or 16 bit simple addition checksum for scientific instruments and data loggers and this makes the error rate vanishingly small for a tiny code overhead.

    HTH

    BrianT
    Last edited by BrianT; - 8th December 2008 at 00:25. Reason: expanded reply

Similar Threads

  1. NMEA CheckSum Routine
    By Tom Gonser in forum Code Examples
    Replies: 2
    Last Post: - 6th June 2015, 22:24
  2. 4 Bytes one button press
    By Dennis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th January 2010, 22:36
  3. Checksum
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th October 2009, 04:09
  4. Creating Checksum in PBP
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th March 2005, 04:49
  5. Checksum problem!
    By atomski in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2004, 07:21

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