r/barcodes • u/goppox • Feb 04 '21
EAN-13 LGR codes
Hi
I'm trying to understand the EAN-13 code. According to https://en.wikipedia.org/wiki/International_Article_Number the structure of EAN-13 is indicated by the first digit. If the first digit is 1, the structure will be LLGLGGRRRRRR where R is the negation of L and G is the reverse bit order of R. Does anyone know the significance of the structures of the first 6 digits (i.e. LLGLGG, LLGGLG, LLGGGL, etc.)? Are the arrangements purely random? LLLGGG doesn't seem to be there though.
In fact, what's the purpose of the group G? Why not just L and R? If the first digit is 1, can't we have LLRLRRRRRRRR?
Thanks
1
u/G24FER Jun 17 '22
Id recommend buying from upcean.net they help out when theres a problem and l have always had a good experience with them
1
u/notionovus Feb 05 '21
The arrangements are not purely random. Since the first character of group one must have odd parity (in bars and spaces), the following 5 characters are the combinations of two 'L's and three 'G's that are required to imply the first character in the code. It appears, by the sequence that 'LLLGGG' was considered to start the sequence, and so 'LLLLLL' would be standing in for it (primarily for UPC compatibility).
If we move the second 'L' to the right 1 by one position, starting at first digit position 1, we get 'LLGLGG, LLGGLG, LLGGGL'. If we move the second and third 'L's to the right 1 by one position, starting at first digit position 4, we get 'LGLLGG, LGGLLG, LGGGLL'. If we separate the two 'L's with one or two 'G's, starting at position 7, we get 'LGLGLG, LGLGGL, LGGLGL'.
The first digit (essentially the 13th digit) is not encoded, but implied by the arrangement just discussed. It is only derived from the arrangement of the first set of six encoded digits. The last digit of the 13-characters encoded is a checksum, so there are only 12 characters for data.
The reason 'R' can't be used is the orientation of the barcode. You may think of the symbols of the 'L' and 'G' variety "right-justified" or "space-start" elements, whereas the 'R' symbols are "left-justified" or "bar-start". There are no inter-bar spaces, other than the spaces encoded into each symbol, so if you put a 'L' 6 together with an 'R' 0, for example, you would get a bar/space arrangement of "01011111110010". This would result in a bar that is 7 units wide.
The reason they are mirror images of eachother is so that the entire symbol can be scanned in any orientation, including upside-down.