BobNorway

MrPLC Member
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About BobNorway

  • Rank
    Hi, I am New!

Contact Methods

  • Website URL http://
  • ICQ 0

Profile Information

  • Country Norway
  1. Ascii Checksum In A Plc

    This is totaly dependent on who you talk with. Not everyone defines the string length count the same way. You need a protocol description of the ascii string you are trying to decode or make. Either you've got a fixed length string or a variable length to loop through. For the variable type you have to count bytes between start and end. Often STX (start transmition) ETX (end transmition) characters are used. Example for 5 data bytes the STX ETX are not included: Byte___ascii___hex___dec 1______STX___ 02____ 2 2______ H____ 48____ 72 3______ E____ 45____ 69 4______ L____ 4C____ 76 5______ L____ 4C____ 76 6______ O____ 4F____ 79 7_____ ETX___ 03_____ 3 8_____ CHK___ 75____ 372-255=117 The check sum is a hex value. 255 is the largest possible 8 bit value. A longer string can include more individual variables and probably has a delimiter character between values. Depending on how things are set up you may need to send an AKN (06)character if the checksum is OK. or a NAK (15) if its not. http://www.lookuptables.com/ will give you the most common characters. CR (0D) and LF (0A) are for printers and are usually not in data transmition. A word of caution. There are two common types of string storage in the world ASCII and ASCIZ. ASCII has the string length as two bytes at the begining. ASCIZ has a NUL (0) as the last byte. S7 storage uses ASCII and needs the two bytes at the beginning. An S7 DB for 8 characters takes 10 bytes! Ignore the first two bytes of a DB string when doing the checksum. S7 can pad out strings with a NULL (00) character to get a correct length. A device like a PC often uses ASCIZ and if gets a NULL byte it will stop reading the string. (sorry my tabs and spaces don't get through correctly)
  2. Ascii Checksum In A Plc