
Barcodes and barcode scanners
Last updated: May 27, 2009.
Blip! Blip! Blip! Buying things at a grocery store has never been
easier or quicker thanks to barcode technology. You must have seen the
black-and-white zebra stripes on everything from cornflake packets to
library books and the laser wands that are used to read them. But have
you ever stopped to think how they work?
Photo: An electronic zebra? A barcode represents the line of numbers printed underneath it with a pattern of black and white bars. Barcodes are designed for
computers to read quickly
by scanning red LED or laser light across them.
What are barcodes used for?

If you run a busy store, you need to keep track of all the things
you sell so you can make sure the ones your customers want to buy are
always in stock. The simplest way of doing that is to walk around the
shelves looking for empty spaces and simply refilling where you need
to. Alternatively, you could write down what people buy at the
checkout, compile a list of all the purchases, and then simply use that
to reorder your stock. That's fine for a small store, but what if
you're running a giant branch of Wal-Mart with thousands of items on
sale? There are many other difficulties of running shops smoothly. If
you mark all your items with their prices, and you need to change the
prices before you sell the goods, you have to reprice everything. And
what about shoplifting? If you see a lot of whisky bottles missing from
the shelves, can you really be certain you've sold them all? How do you
know if some have been stolen?
Photo: This compact, portable printer prints labels with
barcodes on them for keeping track of stock items. Photo by Damon J. Moritz courtesy of
US Navy.
Using barcode technology in stores can help to solve all these
problems. It lets you keep a centralized record on a computer system
that tracks products, prices, and stock levels. You can change prices
as often as you like, without having to put new price tags on all your
bottles and boxes. You can instantly see when stock levels of certain
items are running low and reorder. Because barcode technology is so
accurate, you can be reasonably confident that any items that are
missing (and don't appear to have been sold) have probably been
stolen—and maybe move them to a more secure part of your store
or protect them with RFID tags.
A barcode-based stock system like this has three main parts. First, there's a central
computer running a database (record system) that keeps a tally of all the products you're selling, who makes it, what each one costs, and how
many you have in stock. Second, there are the barcodes printed on all
the products. Finally, there's one or more checkout scanners that can
read the barcodes.
How barcodes represent the numbers 0-9

A barcode is a really simple idea: give every item that you want to
classify its own, unique number and then simply print the number on the
item so an electronic scanning device
can read it. We could simply print the number itself, but the trouble
with decimal numbers is that they're easy to confuse (a misprinted
eight could look like a three to a computer, while six is identical to
nine if you turn it upside down—which could cause all sorts of chaos at
the checkout if you scanned your cornflakes the wrong way up). What we
really need is a completely reliable way of printing numbers so that
they can be read very accurately at high speeds. That's the problem
that barcodes solve.
If you look at a bar code, you probably can't make head or tail of
it: you don't know where one number ends and another one begins. But
it's simple really. Each digit in the product number is given the same
amount of horizontal space: exactly 7 units. Then, to represent any of
the numbers from zero through nine, we simply colour those seven units
with a different pattern of black and white stripes. Thus, the number
one is represented by colouring in two white stripes, two black
stripes, two white stripes, and one black stripe, while the number two
is represented by two white stripes, one black stripe, two white
stripes, and two final black stripes.
Photo: Each digit in a barcode is represented by seven equal-sized vertical blocks.
These are colored in either black or white to represent the decimal
numbers 0-9. Each block has been designed so that, even if you turn it upside down,
it can't be confused with any other.
You've probably noticed that barcodes can be quite long and that's
because they have to represent three different types of information.
The first part of a barcode tells you the country where it was issued.
The next part reveals the manufacturer of the product. The final part
of the barcode identifies the product itself. Different types of the
same basic product (for example, four-packs of Coca-Cola bottles and
six-packs of Coca-Cola cans) have totally different barcode numbers.
Most products carry a simple barcode known as the UPC (universal
product code)—a line of vertical stripes with a set of numbers
printed underneath it (so someone can manually key in the product
number if the barcode is misprinted or damaged in the store). There is
another kind of barcode that is becoming increasingly common and its
stores much more information. It's called a 2D (two-dimensional)
barcode (or a data-matrix code) and you sometimes see
it on things like self-printed postage stamps.
How barcode scanners work
It would be no good having barcodes if we didn't have the technology
to read them. Barcode scanners have to be able to read the
black-and-white zebra lines on products extremely quickly and feed that
information to a computer or
checkout terminal, which can identify them immediately using a product
database.

Different types of barcode scanners are available for all kinds of
applications. In small, convenience stores, you'll typically find a
basic wand scanner. The simplest ones look line electronic pens or
giant, oversized razors. They shine red LED
light onto the black and white barcode pattern and then read the
pattern of reflected light with a light-sensitive CCD or a string of photodiodes. If you
have a pen scanner, you have to run it across the barcode so it can
reach each block of black or white in turn; with a wand scanner, the
CCD or photodiodes read the entire code at once.
Photo: A typical wand-type barcode scanner (also called a barcode reader).
In a busy superstore, you're more likely to see a very sophisticated
laser scanner. It'll be built into the base
of the checkout lane next to the conveyor belt and you may be able to
see the laser beam being spun around by an electric motor at high-speed so it
reads products (literally) in a flash! Another technology uses a small video camera to take an instant digital photograph of the barcode. A
computer then analyzes the photograph, picking out only the barcode
part of it and converting the pattern of black and white bars into a
number. Scanners like this can accurately read dozens of products waved
past them each minute and are far more accurate than old-style
checkouts (where you have to key in the price of every item by hand).
The best barcode scanners are so accurate that they make only one
mistake in something like 70 million pieces of scanned information!
(Compare that to typing on a keypad, where you're typically likely to
make one error in every 100 characters you type.)
Barcode scanning technology has been around since the early 1970s
but only really caught on in the 1980s and 1990s after stores started
to invest in sophisticated, computerized electronic point-of-sale
(EPOS) checkout terminals. Back then, store
checkouts cost many thousands of dollars. Today, scanners are much more
affordable. You can buy a simple, USB barcode
scanner and software and hook it up to an ordinary laptop or computer
for just a few dollars. Thanks to barcodes, even tiny convenience
stores can run as smoothly as Wal-Mart these days!