Computer Interfacing

# Block check character calculation on ISO/IEC 1155-1978

I'm unable to figure out how to calculate the BCC for ISO/IEC 1155-1978

Goto page 1, 2  Next

Author Message
dbrouwer
New User

Joined: 28 Jul 2007
Posts: 1

 Jul 28, 2007 10:52 pm Hi--I'm new to this forum and fairly new to error correction, so I appreciate any help and especially your patience. My specific need is to communicate with RS485 connected energy meters. My understanding is that they use use the IEC 62056-21 communication protocol, and that protocol states that the block check character (BCC) shall comply with ISO/IEC 1155:1978. I have followed the rules of that standard to the best of my ability and I can't come up with the same BCCs as the meter software and meter generate. Examples of meter communication hex strings are: 02 28 30 30 36 35 34 33 32 31 29 03 6C 02 30 30 33 30 28 33 34 30 30 35 31 30 30 29 03 2E 02 30 30 32 30 28 30 30 30 30 37 33 37 31 29 03 32 My understanding is: 02 (STX) is the start of the BCC calculation group, but is not included 03 (ETX) is the end of the BCC calculation group and is included The last hex character (6C, 2E, 32) is the BCC The rules according to ISO/IEC 1155-1978 are: ************** RULES FOR GENERATING THE LONGITUDINAL PARITY BLOCK CHECK CHARACTER 2.1 Block check character 2.1.1 The block check character shall be composed of 7 bits plus a parity bit. 2.1.2 Each of the first 7 bits of the block check character shall be the modulo 2 binary sum of every element in the same bit 1 to bit 7 column of the successive character of the transmitted block. 2.1.3 The longitudinal parity of each column of the block, including the block check character, shall be even. 2.1.4 The sense of the parity bit of the block check character shall be the same as for the information characters (odd for synchronous transmission, even for asynchronous transmission). 2.2 Summation 2.2.1 The summation to obtain the block check character shall be started by the first appearance of either SOH (Start of Heading) or STX (Start of Text). 2.2.2 The starting character shall not be included in the summation. 2.2.3 If an STX character appears after the summation has been started by SOH, then the STX character shall be included in the summation as if it were a text character. 2.3 With the exception of SYN (Synchronous Idle), all the characters which are transmitted after the start of the block check summation shall be included in the summation, including the ETB (End of Transmission/Block) or ETX (End of Text) control character which signals that the next following character is the block check character. 2.4 No character, SYN or otherwise, shall be inserted between the ETB or ETX character and the block check character. ************ I assume that my breakdown in understanding is somewhere in 2.1.2, 2.1.3, and 2.1.4. If you can give me quite specific guidance on how to calculate the BCC for one of my examples I think that will be enough to get me going. Thanks very much in advance. Doug
Francois
Guest

 Apr 02, 2008 9:28 am Have you or anyone else figured this out? Because i need to do the exact same thing. Any help is greatly appreciated!
lammert

Joined: 13 Mar 2007
Posts: 145
Location: Netherlands and Kazakhstan

 Apr 02, 2008 12:20 pm Francois, welcome on the Computer interfacing Forums! Do you have some valid examples of ISO/IEC 1155-1978 messages, because the examples dbrouwer gave do not match the definition of complete messages given in the standard. The messages should be of the form: SOH header STX [data-identifier US data RS]+ ETX BCC US and RS are the unit and record separators, SOH is the beginning of a message and STX and ETX mark the beginning and end of the message text. The messages dbrouwer provided us miss the header part. They start directly at the STX character. This makes it impossible to test some algorithms to see if they fit, because the header part is also subject to the BCC (block check character) calculation. Two or three complete example strings should be enough to write the algorithm.
Francois
Guest

 Apr 02, 2008 2:16 pm Thank you! dbrouwer is correct in that the block check character shall comply with ISO/IEC 1155:1978 but the scope of the block check character is as specified in ISO/IEC 1745:1975, and is from the character immediately following the first SOH or STX character detected. A data message has the form: [STX] [DATA BLOCK] [!] [CR] [LF] [ETX] [BCC] but a "Programming command message" has the form: [SOH] [C] [D] [STX] [DATA SET] [ETX] [BCC] where C is a Command message identifier and D is a Command type identifier. So some messages seems to start with SOH and some with STX. This is all according to IEC 62056-21 Unfortunately i havent received the meters yet so i cant do any testing or supply any example strings other than dbrouwers. Time is probably going to be a problem since i am new to serial communication, so it would be nice to have this algorithm written before i receive them.
lammert

Joined: 13 Mar 2007
Posts: 145
Location: Netherlands and Kazakhstan

 Apr 04, 2008 1:04 am Please read again what I said a few messages ago. You are only repeating dbrouwers' incomplete text. His examples don't work because those messages are not complete according to the message structure I gave. And you don't provide example messages at all. What do you expect us to do? Buy the ISO specification, read and interpret the text, implement the algorithm and give everything to you for free? In short: You ask for help. The only way you can be helped is by answering my question i.e. provide correct examples. If you don't want to work to be helped, we won't want to work to help you.
Marten
Guest

 Apr 09, 2008 12:11 pm I am working on a cnc machin on the moment and have the same problem as you have. I m working to find out how it works, but it is not the esyest thing i ever did. a awnser whould be welkom
lammert

Joined: 13 Mar 2007
Posts: 145
Location: Netherlands and Kazakhstan

 Apr 10, 2008 12:30 am Hello Marten, do you happen to know the name or manufacturer of the CNC machine? Or are there any examples in the manual? It should be possible with some working examples and additional information to solve this problem.
ahoneybell
Guest

 Aug 04, 2008 4:35 pm Just XOR all the characters in the message together starting AFTER the first SOH or STX character until you reach an ETX or EOT character. Then add it to the end!
themeterguy
Guest

 Oct 29, 2010 2:19 pm Here are some examples that u can refer to: Data set/Pay load: 1. 21 32 03 51 2. 32 31 33 32 30 33 35 31 3. 01 30 02 4D 21 20 20 03 4. 01 55 53 57 53 57 54 41 04 5. 30 34 30 31 34 31 30 31 30 31 39 30 30 31 Expected LRC (or some refer to it as BCC): 1. 41 2. 05 3. 5C 4. 45 5. 08
nvicchi
Guest

 Jan 19, 2011 8:14 pm I assume that everyone might already solved this. But if it's useful to anyone else who drops here, it's very simple. The BCC must be obtained from the STX (not included) until de ETX (included), if no SOH was present. If an SOH was indeed present, then the BCC must be calculates starting from de SOH (not included) until de ETX (included). The way to calculate it's just XORing every byte present. Regards!
jackal183
New User

Joined: 05 Apr 2011
Posts: 1

 Apr 05, 2011 8:23 am i didn't understand exactly how to calculation to create BCC. what i'am gonna stick with what XOR operation. what are the inputs of XOR Could you explain with an example.
guest
Guest

 Apr 20, 2012 9:33 am here is examples: identification... <---2F 3F 21 D A --->2F 4C 54 41 34 4C 30 39 30 36 32 36 31 20 20 20 20 D A read meter... <---6 30 34 30 D A --->2 48 28 .......20 29 D A 21 D A 3 BCC
gokul
Guest

 Apr 20, 2012 12:53 pm hi, you people can find checksum using this : keep in mind that serial port should be opened with following parameters parity =even stopbit=1 databits =1 baud = 300 // should be changed according to protocol mod checkSum =0; i=0; //totalBytes = total recved bytes // fill here //Buffer contains all the rcvd data for(i=0;i
user
Guest

 Apr 20, 2012 1:02 pm IEC 61107 IEC 61107 , formerly called IEC 1107, is an international standard document that describes a widely-used computer protocol used to read utility meters in the European Union. The IEC considers it to be superseded by IEC 62056, but it remains in wide use because it is simple and well-accepted. It sends ASCII data using a serial port. The physical media are either modulated light, sent with an LED and received with a photodiode, or a pair of wires, usually modulated by EIA-485. The protocol is half-duplex. IEC 1107 is related to, and sometimes wrongly confused with, the FLAG protocol. The following exchange usually takes a second or two, and occurs when a person from the utility company presses a meter-reading gun against a transparent faceplate on the meter, or plugs into the metering bus at the mailbox of an apartment building. The general protocol consists of a "sign on" sequence, in which a handheld unit identifies itself to the metering unit. During sign-on, the handheld unit addresses a particular meter by number. The meter and hand-held unit negotiate the fastest communication rate that they can both manage. Next, the meter challenges the hand held unit with a cryptographic password. The hand held unit must return an encrypted password. If the password exchange is ok, the meter accepts the hand held unit- it is "signed on." After signing on, the hand held unit generally reads some registers that describe the current count of metered units (i.e. kilowatt hours, megajoules, litres of gas or water) and the metering unit's reliability (is it still operating ok?). Most metering units have special modes for calibration and resetting meter registers. These modes are usually protected by anti-tampering features such as switches that sense if the meter enclosure has been opened. The hand held unit then sends a sign-off message, and the meter automatically signs off a minute after the last message, if no sign-off message is sent. the companies like kalkitech, ABB etc doing work on this protocols
Guest

 Jun 16, 2012 5:54 am hi all I have a electricity meter and i have some example that you can refer to find BCC 01 57 32 02 43 30 30 33 28 39 31 30 33 32 34 30 39 32 32 33 39 29 03 1b ib is BCC in this paragraph or 01 57 32 02 43 30 30 33 28 39 31 30 33 32 34 30 38 35 34 34 32 29 03 17 17 is BCC of this one i think these make by XOR of all characters but still i cant figure out it completely hope to be helpful regards[/i]

 Page 1 of 2

Running on php BB © 2001, 2009 php BB Group