1 cracking the code moshe kam ieee educational activities ieee tisp workshop in piura peru...

Post on 27-Mar-2015

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Cracking the Code

Moshe Kam IEEE Educational Activities

IEEE TISP workshop in Piura PeruParticipant Guide

August 2007

Version 001

30 July 2007

2

The UPC Code

3

The UPC-A Code

UPC version A barcodes (12 digits)

UPC version E shortened version (8 digits)

ISBN-13 barcodes on books

ISSN symbols on non-U.S. periodicals

EAN-13 and EAN-8 are used outside the U.S.

JAN-13 and JAN-8 are used in Japan

Vendor number (5)

Product number (5)

Checksum Digit (1)

Prefix (1)

A1A2A3A4A5A6A7A8A9A10A11A12

4

Calculating the Checksum Digit

5

Checksum Digit Calculation (A12)

Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three

Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result

Calculate how much you need to add so that the

number become a multiple of 10 The answer is the checksum digit (A12)

6

In symbols

Calculate 3 (A1+ A3 + A5 + A7 + A9 + A11) +

A2+ A4 + A6 + A8 + A10= S

How much do we have to add to S to make it a multiple of 10

If S=2 we need to add 8 to make it 10 If S=17 we need to add 3 to make it 20 If S=45 we need to add 5 to make it 50

7

088542318258

8

Add the digits in odd-numbered positions

SO = 0+8+4+3+8+5 = 28

Multiply by 3 SO3 = 28 times 3 =84

Add the digits in even-numbered positions (but not the 12th)

SE = 8+5+2+1+2 = 18

Add SO3 to SE S= 84+18 = 102

How much you need to add so that S become a multiple of 10

To get to 110 we need to add 8

So the checksum digit is 8

08854231825 808854231825 8 08854231825 8

9

025467406387

10

Add the digits in odd-numbered positions

SO = 0+5+6+4+6+8 = 29

Multiply by 3 SO3 = 29 times 3 =87

Add the digits in even-numbered positions (but not the 12th)

SE = 2+4+7+0+3 = 16

Add SO3 to SE 87+16 = 103

How much you need to add so that S become a multiple of 10

To get to 110 we need to add 7

So the checksum digit is 7

02546740638?

11

Add the digits in odd-numbered positions

SO = 0+5+6+4+6+8 = 29

Multiply by 3 SO3 = 29 times 3 =87

Add the digits in even-numbered positions (but not the 12th)

SE = 2+4+7+0+3 = 16

Add SO3 to SE 87+16 = 103

How much you need to add so that the number become a multiple of 10

To get to 110 we need to add 7

So the checksum digit is 7

025467406387

12

Activity 1

Detect the Fake Products!

13

Activity 1: detect the fake products!

You are given four products

Some of them are original

Some of them are cheap imitations

The imitators did not know about calculating the checksum digit properly

Which one of the products are original and which are fake?

14

Rolex Watch

Wrangler JeansA DVD Player

A Personal Digital Assistant

15

Rolex Watch

Wrangler JeansA DVD Player

A Personal Digital Assistant

16

Watch – authentic or not?

17

Jeans – authentic of not?

18

PDA – authentic or not?

19

DVD Player – authentic or not?

20

The UPC bar code as an Error Detecting Code

21

The UPC barcode detects single errors

If any one of the digits is corrupted, then there will be an error in the checksum digit calculation and we will know that an error has occurred

22

Activity 2

The Checksum Digit

23

Activity 2: effect of error on the checksum digit

Use code 088542318258 to draw the value of the checksum digit against all possible values of

A2 (A2 = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

A3 (A3 = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

24

Value of digit A2

Value of checksum digit

0

9

0

9

25

Value of digit A3

Value of checksum digit

0

9

0

9

26

Activity 3

Properties of the Code

27

Activity 3: Answer a few questions…

Based on activity 2 – does it appear that if there is a single error in one of the digits, this code will detect it?

If there is a single error in one of the digits, will this code tell us which digit is wrong? Prove your answer!

28

Activity 3 (continued)

Can this code always distinguish between a single error (an error in one and only one of the digits) and two errors (simultaneous errors in two digits)?

Prove your answer!

Is it possible that two errors will occur simultaneously and we will not be able to detect them using this code?

Prove your answer!

29

Error Correcting Code

What happens if one of the digits is missing?

30

Code: 025467406387

025467406387 3(0+5+6+4+6+8)+(2+4+7+0+3)=103 So to complete to 110 we needed 7

Now suppose the fourth digit (4) is missing (M)

025M67406387

31

Code 025M67406387

Can we find M?3(0+5+6+4+6+8)+(2+M+7+0+3)+7=106+M

We know that the only number that would add to 106 to create the nearest multiple of 10 is 4

106 + 4 = 110 So if the single digit 4 was missing the

code can reconstruct it

32

Second example: Code 02M467406387

Can we find M?3(0+M+6+4+6+8)+(2+4+7+0+3)+7=95+ 3M

This is harder… What is the closest multiple of 10?

If it is 100 then 3M=5 No, because M is not an integer

If it is 110 then 3M=15 and M=5 If it is 120 then 3M=25 and M is greater than

9 and non-integer

33

Second example: Code 02M467406387

Can we find M?3(0+M+6+4+6+8)+(2+4+7+0+3)+7=95+ 3M

This is harder… What is the closest multiple of 10?

If it is 100 then 3M=5 No, because M is not an integer

If it is 110 then 3M=15 and M=5 If it is 120 then 3M=25 and M is greater than

9 and non-integer

34

Third example: Code 025467M06387

Can we find M?

3(0+5+6+M+6+8)+(2+4+7+0+3)+7=

98+ 3M

What is the closest multiple of 10? If it is 100 then 3M=2

No, because M is not an integer If it is 110 then 3M=12 and M=4 If it is 120 then 3M=22 and M is not an integer

35

Third example: Code 025467M06387

Can we find M?

3(0+5+6+M+6+8)+(2+4+7+0+3)+7=

98+ 3M

What is the closest multiple of 10? If it is 100 then 3M=2

No, because M is not an integer If it is 110 then 3M=12 and M=4 If it is 120 then 3M=22 and M is not an integer

36

Activity 4

Find the Missing Digit

37

Activity 4: Find the Missing Digit

014M91293368

0347M1295765

38

Transposition Errors

39

Transposition error

Transposition error occurs when two adjacent digits interchange places

Example 025467406387 becomes

024567406387

Does the UPC barcode correct transposition errors?

40

Activity 5

Does the Code Correct Transposition Errors?

41

Activity 5: Transposition Errors

Check whether the UPC barcode detect a transposition error of 4-7, 7-1 and 1-6 in the left-hand side code

Check whether the UPC barcode detect a transposition error of 2-7, 7-1, and 1-6 in the right-hand side code

WHAT ARE YOUR CONCLUSIONS?

42

Summary

43

Summary – what have we learnt today?

The history of bar codes

How barcodes are designed and used

Some properties of UPC bar codes

New terms: Error Detecting Code Error Correcting Code

44

References (1)

Bar Code History Page http://www.adams1.com/pub/russadam/history.html

Bar Codes http://inventors.about.com/library/inventors/blbar_code.htm

UPC Bar Code FAQs http://www.makeupcbarcodes.com/UPC-barcode-FAQ/

45

References (2)

Free Barcode Image Generator http://www.idautomation.com/java/linearservlet.html

Joseph Woodland http://www.mem.drexel.edu/alumni/Joseph_Woodland.php

Bar Code Symbologies http://www.neodynamic.com/Products/BarcodeSysmbologi

es.aspx

Error Detection Schemes http://www-math.cudenver.edu/~wcherowi/courses/m6409/e

rrschemes.pdf

46

References: Wikipedia

http://en.wikipedia.org/wiki/Universal_Product_Code

http://en.wikipedia.org/wiki/Barcode

http://en.wikipedia.org/wiki/Norman_Joseph_Woodland

top related