Top Banner
1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007
46

1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

Mar 27, 2015

Download

Documents

Jesus Byrd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

1

Cracking the Code

Moshe Kam IEEE Educational Activities

IEEE TISP workshop in Piura PeruParticipant Guide

August 2007

Version 001

30 July 2007

Page 2: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

2

The UPC Code

Page 3: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 4: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

4

Calculating the Checksum Digit

Page 5: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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)

Page 6: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 7: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

7

088542318258

Page 8: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 9: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

9

025467406387

Page 10: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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?

Page 11: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 12: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

12

Activity 1

Detect the Fake Products!

Page 13: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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?

Page 14: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

14

Rolex Watch

Wrangler JeansA DVD Player

A Personal Digital Assistant

Page 15: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

15

Rolex Watch

Wrangler JeansA DVD Player

A Personal Digital Assistant

Page 16: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

16

Watch – authentic or not?

Page 17: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

17

Jeans – authentic of not?

Page 18: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

18

PDA – authentic or not?

Page 19: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

19

DVD Player – authentic or not?

Page 20: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

20

The UPC bar code as an Error Detecting Code

Page 21: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 22: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

22

Activity 2

The Checksum Digit

Page 23: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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)

Page 24: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

24

Value of digit A2

Value of checksum digit

0

9

0

9

Page 25: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

25

Value of digit A3

Value of checksum digit

0

9

0

9

Page 26: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

26

Activity 3

Properties of the Code

Page 27: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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!

Page 28: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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!

Page 29: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

29

Error Correcting Code

What happens if one of the digits is missing?

Page 30: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 31: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 32: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 33: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 34: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 35: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 36: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

36

Activity 4

Find the Missing Digit

Page 37: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

37

Activity 4: Find the Missing Digit

014M91293368

0347M1295765

Page 38: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

38

Transposition Errors

Page 39: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

39

Transposition error

Transposition error occurs when two adjacent digits interchange places

Example 025467406387 becomes

024567406387

Does the UPC barcode correct transposition errors?

Page 40: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

40

Activity 5

Does the Code Correct Transposition Errors?

Page 41: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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?

Page 42: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

42

Summary

Page 43: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 44: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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/

Page 45: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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

Page 46: 1 Cracking the Code Moshe Kam IEEE Educational Activities IEEE TISP workshop in Piura Peru Participant Guide August 2007 Version 001 30 July 2007.

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