So lately I have been working towards becoming as efficient as possible at work. Why? Because I'm lazy, which is why I choose to work smarter and not harder. What does that have to do with barcodes? I'm trying to create a system to manage our inventory to keep numbers straight. My first step was to learn how exactly barcodes work and are read. Now I'm going to share that information with you because those seemingly random lines may not be magical, but instead very much logical.
How to barcodes work?
Barcodes provide a pattern that scanners that "Point of Sale" systems (Scanners at checkouts) can reference with a database to provide item names and prices. The most common type of barcodes are EAN/UPC barcodes. Those types of barcode are found on just about every retail product. The "bars" on barcodes as well as the spaces between the bars represent numbers. There are multiple patterns to the numbers that the POS system is able to decode extremely quickly. As it turns out, anyone can decode these magical little assortments of bars and spaces, you just need to know the rules and patterns.
- Barcodes are not always universal. In my case I will be creating my own barcodes for in-house use only. What I mean by that is that I will be using the same format as a UPC barcode but there may be extra numbers added on.
- Legitimate barcodes are not free. In fact, registering UPC barcodes can be somewhat pricey.
|# of Items Needing a Barcode||Initial Fee||Annual Renewal Fee|
|1 - 10||$250||$50|
|1 - 100||$750||$150|
|1 - 1,000||$2,500||$500|
|1 - 10,000||$6,500||$1,300|
|1 - 100,000||$10,500||$2,100|
|NDC/NHRIC Company Prefix||$10,500||$2,100|
- The numbers that are often at the bottom are not necessary. They they help when it comes to referencing pricing on the shelf and if something alters the barcode cosmetically, the numbers will often stay legible to the human eye. The picture below is a good example of this.
How to read a barcode
I'm not going to sugarcoat it... being able to read barcodes is not the easiest thing to do, nor the most practical skill in the world, but it can be done. I will explain the patterns and how I came up with my own barcode generator in a way that hopefully makes sense.
In explaining how to read barcodes I will refer to a "bar" and a "space" as units of measure. The patterns for each of the numbers conist of multipliers for bars and spaces. (e.g. 1 = 1 bar or space. 2 = 2 consecutive bars or spaces.)
Every 12 digit UPC barcode will have the same beginning, middle, and end.
Beginning = 1-1-1 (bar-space-bar)
Middle = 1-1-1-1-1 (space-bar-space-bar-space)
End = 1-1-1 (bar-space-bar)
This can be seen highlighted in the image below.
There will be 6 numbers between the beginning and middle and six more between the end and the middle. We will refer to those as the left side patterns and right side patterns. This is important because the right side is optically inverted from the left side. This will make more sense shortly.
Left Side Pattern = space-bar (alternates starting with a space)
Right Side Pattern = bar-space (alternates starting with a bar)
The patterns for the numbers are as follows. (Just remember, numbers on the left side start with a space, and numbers on the right start with bars.)
0 = 3-2-1-1
1 = 2-2-2-1
2 = 2-1-2-2
3 = 1-4-1-1
4 = 1-1-3-2
5 = 1-2-3-1
6 = 1-1-1-4
7 = 1-3-1-2
8 = 1-2-1-3
9 = 3-1-1-2
To be scanners perform calculations to verify the last number in the barcode. This digit is called the "Module Check Digit" and is the result of a calculation based on the first 11 digits. The steps below explain how to find that number.
First we will start with this barcode number: 01234567890? (? = Module Check Digit, we don't know what that is yet)
1. Add together the value of all of the digits in odd positions, digits 1, 3, 5, 7, 9 and 11. (0 + 2 + 4 + 6 + 8 + 0 = 20)
2. Multiply that number by 3. 20 * 3 = 60
3. Add together the value of all of the digits in even positions, digits 2, 4, 6, 8 and 10. (1 + 3 + 5 + 7 + 9 = 25)
4. Add this sum to the value in step 2. 60 + 25 = 85
5. - Take the number in Step 4. To create the check digit, determine the number that, when added to the number in step 4, is a multiple of 10. 85 + 5 = 90 The check digit is therefore 5.
Now that you know all of that information, understanding how to read barcodes is "clear as mud" right? Reading barcodes isn't easy, but it can be done. There are very few logical reasons why someone would want to know this information but for those of you in a similar situation as myself, this info can be extremely handy.
As I was learning about barcodes I made a barcode generator that may be of some use to some people. It is pretty rough but it gets the job done. Enter a UPC number you see on a product, generate a barcode, and use an app on your phone to scan it. As you will be able to see, the app will pull up the product you entered.
See the Pen Barcode Generator by Nick Santini (@npsantini) on CodePen.
About the Author:
Nick Santini is a web developer and college student from Louisville, KY. Aside from his work as a web developer, he is also the man behind SANTINI.IO, a blog dedicated to technology, web design/development, self improvement, and more.
11 Oct 2015 06:20:10
Hi, just wanted to tell you, I enjoyed this post. It was inspiring.Keep on posting!