Martin Kirk wrote: [...] I am now exploring linear encoding for a more digital solution. I have come across a type of absolute position linear encoding called binary chain code which is a _non-repeating_ pattern of ones and zeros of length 2^N. In an N-bit code _any_ N-bit sequence appears only once in the entire 2^N pattern so you always know where your are. My sensor is a Texas Instruments TSL213. It is a 64x1 pixel array with a simple 64-bit shift register output. I can supposedly print my pattern on a mylar strip and encode away. I am asking you guys if anyone has experience with this type of position encoding especially with a PIC. Maybe one if you has some code written to deal with this. --------------------------------------------------- Hi all, it seems, that the above problem has something to do with 'random bit generation'. an (electric) example: - take a shift register, length 8 bit (bit0..bit7), - the content of the shift register MUST not be b'00000000'! - exor proper bits, e. g. bit7 xor bit6 xor bit4 xor bit2 - shift left this result bit into the shift register with each shift you get a new 'random' byte. the principle can be expanded to the desired length. the byte sequence will repeat after 2^N-1 shifts (when xor-ing the correct bits), here it is after 255 shifts. your problem will be to read 8 following bits from the sensor and recalculate the order number in the range of 0..255. An unefficient way would be to initialize the shift reg. with b'00000001', and call the shifting procedure repeatedly until the result matches with the sensor byte. the number of calls is equal to the position. it is easy to calculate / compare with the following random number, but I do not know an algorithm to calculate the preceeding value. when using only 255 positions you could create a lookup-table, too :-) I use this shifting principle for PIC-based software generation of random numbers, it is also part of an application note. By the way, what exactly does the TSL213? Siggi Siegfried Grob, | student of electrical engineering, | university of ulm, germany | e-mail: siegfried.grob@student.uni-ulm.de | tel&fax: +49 731 25148 | --------------------------------------------------'