# What comes next in this binary sequence?

J-001 10111111 11100000

J-002 01001111 11110011

J-003 01110011 11111100

J-004 10000011 11101111

J-005 01010101 11100110

J-006 10010101 11111001

J-007 01101001 11101001

J-008 10101001 11110110

J-009 01011110 11101101

J-010 ??????? ???????

Also what would these series be?

J-100 ??????? ???????

J-999 ??????? ???????

• @moonbutt74 This is actually a representation of a barcode cross-posted from link Sep 6 '15 at 8:08
• Are you sure it isn't just random? Sep 6 '15 at 11:25
• It looks like the middle six bits are a counter that increments every other code (I'm treating black as 1 and white as 0). Sep 6 '15 at 20:50
• @moonbutt74 Try Discussion on "What comes next in this binary sequence?" Sep 6 '15 at 22:09
• @moonbutt74 I suspect the order you posted below is correct due to the sensors on the reader being labeled SNS1, SNS2 etc from R-L, Top row then Bottom (when inverted against the barcode). I don't currently have access to a reader that will spit out any useful information, only one that will beep if a valid barcode is detected. I do have access to a sample set of barcodes up to J-140 however I want to generate more up to J-999 if possible. Sep 7 '15 at 0:30

I'm cheating a little and basing my answer off of the 120 barcodes the OP provided in chat.

I'm reading the squares as bits from right-to-left, bottom-to-top, with black as 0 and white as 1. Here is the bit numbering I use:

16 15 14 13 12 11 10  9
8  7  6  5  4  3  2  1


Note that this disagrees with the silkscreened labels on the barcode reader PCB. I don't think that the hardware labels necessarily correspond to the software's processing order though.

The first thing I noticed was that bits 6-11 of the barcodes are just ((J - 1) >> 1) & 0x3F (where J is the number printed on each barcode).

However, J-045, J-093, and J-101 do not follow this pattern:

• J-045: should be 0x16 (22), actually 0x3E (62)
• J-093: should be 0x2E (46), actually 0x3F (63)
• J-101: should be 0x32 (50), actually 0x3F (63)

There are two other patterns that I am fairly sure about though:

1. Bits 15 and 16 are always opposite of each other.
2. Excluding bit 16, the number of 1s is always even.

Therefore I believe that bits 15 and 16 are some form of parity check.

The remaining bits, 1-14, seem to have an additional parity check. For all the barcodes we have, I found the following relations:

xor(    b2, b3, b4, b5, b6, b7             ) = b11
xor(b1,     b3, b4, b5,         b8, b9     ) = b12
xor(b1, b2,     b4, b5, b6,     b8,     b10) = b13
xor(b1, b2, b3,     b5,     b7,     b9, b10) = b14


My best guess is that the first fourteen bits contain a ten-bit value and some sort of four-bit checksum. However, an exhaustive search of all 4- and 5-bit CRC generator polynomials has not yielded any results.

• I have added a photo of the barcode reader circuit to the my dsp question. The labeling of sensors seems to imply that the barcode is read from right-to-left, top-to-bottom. Sep 6 '15 at 22:21
• @user1224615 The problem with using the board labeling as the order is that it implies the two parity check bits are in the middle of the full 16-bit word, which my brain doesn't like. However I'll try that order to see if I can pull a CRC out of the barcode. Sep 9 '15 at 4:38

From the barcode image as per OP's
suggestion of read order [R->L&T->B]
and by 2012rcampion's suggestion of
BLACK=1 WHITE=0

j-001 11111101 00000111

j-002 11110010 11001111

j-003 11001110 00111111

j-004 11000001 11110111

j-005 10101010 01100111

j-006 10101001 10011111

j-007 10010110 10010111

j-008 10010101 01101111

j-009 01111010 10110111

j-010 01100001 00101111

j-011 01011101 11011111

j-012 01000110 01000111

j-013 00110001 01010111

j-014 00100110 11111111

j-015 00011010 00001111

j-016 00001101 10100111

j-017 11111001 01111110

j-018 11101110 11010110

j-019 11010010 00100110

j-020 11000101 10001110

• This is about as far as I got. One thing to note is that the sequence is not necessarily read from left to right. Sep 6 '15 at 20:49

I tried to convert the Second Byte of Binary to ASCII from J-001 to J-009 and I got:

à ó ü ï æ ù é ö í the English vowels in Latin so maybe it's a coincidence, but I think The second bit of J-010 is à so it would be 11100000, But I don't know about the first Bytes and how they are connected, Maybe they tell which vowel letter is the second byte...