Topic: DMD0305

Help File Version: 2.9.4.37

CHECKSUM - Checksum Algorithm


The Checksum Algorithm (CHECKSUM) instruction is used to calculate a checksum value for the contents of the specified data buffer. This checksum value can be added to the String or stored in a separate memory location in the CPU. Checksum values are typically used in this manner:

 

  1. A checksum value is calculated by the transmitting device, which appends that checksum value to the message then sends the message.

  2. The receiving device recalculates a checksum during receipt of the message.
     
  3. At the end of the message the receiving device compares the calculated value to the value it received in the checksum field. An error results if the calculated value does not equal the value in the checksum filed of the message.

 

Parameters:

Note: Use the F9 key to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.

 

On Buffer - the data buffer that contains the data used to calculate the checksum. Although this any readable numeric location in the CPU, it will typically be a user-defined data buffer, or one of the system-defined Short Strings (SS0 - SS127), or system-defined Long Strings (SL0 - SL63), or any of the user-defined Strings.

 

Checksum Function - selects the type of checksum calculation to be performed

 

  • Checksum:8 - The checksum value is the 8-bit sum of the ASCII values of all of the characters within the string. The checksum is an integer value between 0 and 255.
     

  • Checksum:16 - The checksum value is the 16-bit sum of the ASCII values of all of the characters within the string. The checksum is an integer value between 0 and 65535.
     

  • Checksum:32 - The checksum value is the 32-bit sum of the ASCII values of all of the characters within the string. The checksum is an integer value between 0 and 4294967295.
     

  • LRC - The Longitudinal Redundancy Check (LRC) field contains a single eight-bit binary value that is calculated by adding together successive eight-bit bytes in the message, discarding any carries, then two's complementing the result. The checksum is an integer value between 0 and 255.

     

  • CRC:16 - This is the CRC (Cyclic Redundancy Check) calculation that is typically used when implementing Modbus protocols. The CRC field contains a 16-bit binary value between 0 and 65535.
     

  • CRC:32 802.3 - This is the CRC (Cyclic Redundancy Check) checksum calculation as described in the IEEE 802.3 Ethernet specification. The CRC field contains a 32-bit binary value between 0 and 4294967295.

 


Initial Value - specifies the initial value for the CRC calculation

 

  • 0 - starts the calculation with a value of 0
     

  • -1 - starts the calculation with a value of -1
     

  • Existing Value in Destination - starts the calculation with whatever value is currently in the Destination location

 


Starting Offset - specifies the offset into On Buffer in String to begin the checksum calculation. This can be any readable numeric location or any constant value from 0 to the maximum length of the string.

 


Ending Offset - specifies how many of the remaining elements in On Buffer in String to include in the checksum calculation

 

  • To End of String / Data Block - designates that all of the remaining characters in the String or Data Block should be included in the checksum calculation
     

  • Ending Offset - specfies the last element of the String that is to be included in the checksum calculation. This can be any readable numeric location or any constant value from the Starting Offset to the maximum length of the string.

 


Destination - specifies a memeory location to store the calculated checksum value. This can be any writable numeric location. Make sure the specified location is large enough to store the result of the checksum calculation.

 


Status Display:

The Status display of the Checksum Algorithm instruction will only display as many of the location in the source String or data buffer as will fit within the borders of the instruction, typically this is about 50 characters.

 

 


See Also:

STREAMIN - Stream In Data from Device

 

STREAMOUT - Stream Out Data to Device


CHECKSUM - Checksum Algorithm


STRGETB - Get Bytes Out of a String

 

STRPUTB - Put Bytes Into a String


PACKETIN - Input Data from Packet Device

 

PACKETOUT - Output Data to Packet Device

 


Rung Example: