Before we see how a barcode works, lets be sure that we are talking about the same thing.
What are barcodes?
Barcodes, invented in 1973 are the black and white images that appear on just about every product that we buy, manufacture or sell today. There is a wide array of barcode types available from QR codes (a form of barcode) to datamatrix codes to aztec codes. Today we are going to talk about the good old UPC barcode. UPC stands for Universal Product Code.
The primary barcode used around the world is the UPC. The UPC is also the first kind of barcode, designed for the grocery and shopping industry. Because of the large number of items stocked and traded in shops and stores a need arose to eliminate human error and to streamline efficiency. This led to the development of the humble barcode.
To the average person, a barcode looks confusing and complex, but to a computer, which barcodes are actually designed for, they are as easy to read as as traffic signs are for us to read.
How does a scanner read a barcode?
A single number on a barcode is made up of seven units. Each unit is either black or white. A unit that is black would display as a “bar”. A unit that is white would display as a “space”. Another way of writing a barcode unit is “1” for a single unit “black bar” and “0” for a single unit “white space”. The number “1” is made up of units “0011001” or “space-space-bar-bar-space-space-bar”. These units are then read by a barcode scanner and turned int numbers on the other side.
On a UPC barcode the numbers on the left-hand side (the Manufacturer Code) are coded differently to the numbers on the right-hand side (Product Code). The left side numbers are actually the “inverted” or “mirrored” codes of the right side numbers.
The reason that this happens is so that the machine reading the code knows which way the barcode is facing and can read the barcode even if it is upside down. What would normally be a “bar” on the right-side, is a “space” on the left-side. The right-side codes are called even parity codes because there is an even number of black bar units. For instance the right-side “6” is “101000” – 2 even-numbered “black bar” units. The left-side is called odd-parity because there is an odd number of black bar units. For instance, the left-side “6” is “0101111” – 5 odd-numbered black bar units.
The following tables are the left and right side codes matching the corresponding numbers, separated into the seven single units.
As you can see the left and right numbers are inverted copies of each other.
Looking at the chart above, we can see that each number is represented by four marks. Either black , white, black, white or the opposite, depending on the orientation, left or right. The black, white, black, white pattern that makes up the numbers vary from number to number with some spaces(white) being bigger or smaller, and with the black (the actual line in the barcode) varying from thin to quite thick. These make up the numbers on the barcode, and put together, look like the barcode as we know it.
The left side codes always begins with a space or 0 and ends with a bar or 1. The right is just the opposite, it begins with a bar or 1 and ends with a space or “0”.
A computer does not read the numbers underneath the barcode. These numbers are printed on a code so that a human can easily read the barcode if necessary.
So what are the Guard Bars?
There are 3 guard bars on every UPC barcode. They are located at the beginning, middle and end, and are used to tell the barcode-scanner when the various parts of the code begin and end. When the scanner reads the first 101 or guard bar (the firt and last guard bars are encoded as 101 or bar space bar), the computer knows the next series of numbers is either the manufacturer or product code. And when the computer reads the “01010” or middle guard bar, the computer knows to expect the next sequence of numbers.
The other very important function of a guard bar is to calibrate the machine scanning the barcode. The first bar scanned is used by the computer to calculate the “width” of one unit, and this bar comes from either the first or last guard bar. This helps make sure that errors aren’t made by reading the widths of the bar spacing incorrectly.
And where does the price come from?
The price is kept in the store’s centralized computer database and not on the barcode itself. The barcode is merely a means of identification rather than price and other data storage. The store’s database contains a record for every item the store stocks and when the barcode is read by the barcode scanner, the item is identified and then the associated price, which would have been entered by an employee beforehand, is displayed on the machine.