The maths of bar codes

Investigate the maths behind bar codes and QR codes.

On-line quiz

Create a Pinterest board or a Glog and pin or stick text, images or multimedia that answer some or all of the following questions. All the answers are easily available using a Google search or searching with Wolfram Alpha

  • How many digits does a bar code have on an item you might buy in a supermarket?
  • Where were the first bar codes used and why?
  • What is the difference between a 1D bar-code and a 2D bar code?
  • Universal Product Codes (UPC) that can be scanned on consumer goods have been around since 1974. What was the first package to carry one?
  • the current bar coding system on ‘point of sale’ consumer goods is called EAN13. Find out what each block of numbers represents.
  • Look at a bar code in detail. Use a magnifying glass if necessary. Where are the long lines and where are the short lines?

(Answers at the bottom!)

Cracking the code of Control Numbers are for and how they work

The control number in an EAN bar code is the last digit. It just tells you whether the bar code on the tin of beans you have just bought was scanned properly. Some times the control number is the same size as the other digits. Sometimes it is a little smaller or moved to the right. The control number is calculated from all the other digits. Each of the other 12 digits is weighted alternately by 1 or 3,  with the last number being weighted by a 3. The weighted numbers are summed and subtracted from the nearest multiple of 10 which is equal or higher.  Get groups working on representing this as a series of mathematical statements, first in words using symbols.

The nearest multiple of 10 that is equal or higher than the sum is 90.  So 90 – 89 = 1. This will be the last digit of the bar code.

The reason for saying that the last number must be a 3 is that some bar code systems other than EAN13 have more or fewer digits.  In these cases you count the digits backwards from the right to determine whether to begin with a x3 or x1. (So it follows that a code with an even number of digits starts with a x1 weighting but an odd number of digits starts with a x3 weighting. )

You could ask children to collect examples of e.g EAN8 bar codes and say why they think certain products have a bar code with fewer numbers (It is a system primarily designed for small products like chewing gum or cigarettes where the packaging simply does not have room for a longer number!)

Bar code sums

Each child to bring in an item with a bar code.  Ask them to calculate the control number and use the actual last digit of the bar code printed on their item to check if their answer was right.  Ask them to make a record of the control number. Then ask them to hide the control number e.g by blacking it out with a pen. Then they can swap their barcoded item with a friend and see if they can work out the hidden control number. You can also do this in groups where everyone records their control number before blacking it out and then all the items are put in the middle and everyone has to complete the sum.

Another variation that we quite like is that the teacher takes in several pairs of items e.g 2 identical tins of beans, 2 tins of sardines, 2 packets of sweets etc.  Black out the control number for one of each pair and distribute these on each table.  (You need at least one item per table).  Let them work out the control numbers and write it on a piece of paper.  Put the other items of the pair in a row on the teacher’s desk with the control number visible. As soon as they have finished, they can run up and check their answer against the same item on the teacher’s desk. Make sure that one of the items is a tube of smarties which can be used as a ‘reward’! (recording their answer on a piece of paper is to make sure they are not cheating!)

You can either do this as a speed competition to see which group can do it fastest or, to give them more practice, as soon as they get an answer, they give their item to the next table and start again.

How do control numbers identify scanning mistakes?

Ask them for any suggestions as to how they thing control numbers can check for errors. Then give them a problem to solve e.g

  • Supposing there was an error such as an ‘8’ being read as a ‘3’ – what would happen? Check this out with a real life example.
  • Supposing 12 got read as 21 – what would happen?

So what are the black lines above the numbers?

Explain that the numbers are represented by the long black lines above them.  The lines are the same length except for the longer pair at either end and in the middle, which just tell the scanner when to start and stop ‘reading’ the bar code. Each digit from 0-9 is represented by a series of lines of different thicknesses.

There are 95 lines in a standard bar code. Ask why they think all these lines are needed? The answer is because each number has to be converted into binary. If you have worked with binary numbers, you could ask each group to write the numbers 0-9 in binary then add up all the 0’s and 1’s.

Watch the following video on bar codes.

Making a reader and play the game

Each child makes a slot in the middle of a piece of card (does not have to be exact!) about the width of their finger and about a cm in length. This is fiddly so you may have to do it.

Get each child to write down the numbers 1-15 in binary, if they can do it. Otherwise give them a chart or use on on-line converter.

Let everyone practice making binary numbers with their fingers. It doesn’t matter which hand you use as long as you start with the finger on the left and keep the back of the hand towards the person making the number and the viewer.  A zero is finger up, a ‘1’ is finger down.  This is great fun to practice and can be a game in itself – as in “what number is this?”.

Then play the game in pairs. Both children sit at a table. One child chooses a binary number and represents that number by placing the right number and position of fingers on the edge of table. (Using the edge of a table makes it easy to keep fingers not in use tucked out of the way.)    They should hide the number of fingers with their other hand or ask their partner to keep their eyes shut.  They then place the card, with the longer side of slot orientated along the length of the finger on the left.  The second child is the bar reader and slowly moves the slot from left to right and works out the number.

Here are our answers to some of the quiz….

  • 13 in total.  12 are EANs – European Article Numbers – and one is a control
  • Railway trucks – so that people did not have to climb in to look to see what was inside
  • Originally barcodes represented data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D). Later they evolved into rectangles, dots, hexagons and other geometric patterns in two dimensions (2D). Although 2D systems use a variety of symbols, they are generally referred to as barcodes as well.
  • Wrigley’s chewing gum
However, there are lots of people who would legitimately answer that some of these are wrong. Everything depends on definitions, interpretations, claims and counterclaims! But this is part of the fun – give the same children the same questions and depending on their sources, there will be a range of answers. This can generate heated discussion and makes the interest board far more interesting. Take the opportunity to talk about searching, reliability of data etc.










Tags: , , , ,

No comments yet.

Leave a Reply

This blog is kept spam free by WP-SpamFree.