Post Go back to editing

I wanted to ask what are the equations used to generate the PN9 and PN23 sequence of the ADC test patterns.

In the manual, it is said that the first values are:

PN9: 0x0092 -- 0x125B, 0x3C9A, 0x2660, 0x0c65, 0x0697

PN23: 0x3AFF -- 0x3FD7, 0x0002, 0x26E0, 0x0A3D, 0x1CA6

But I am unable to generate those using the typical LFSR shifted by one and X-ored. I believe there is a more complex equation behind, right?

• Ok, I think the issue was that I was assuming that the LFSR was the random number itself. The idea is to get the last bit of fourteen consecutive LFSRegisters, and tie them together into a 14-bit word, right?

• All right, I have managed to create a C++ code to reproduce these numbers.

Here is what I get por PN9 (notice that the seed given in the manual is big endian, so you need to swap it, but it does not make any difference):
125b 3c9a 2660 c65 697 3d16 eb2 33c7 3741 2b6e 305a 3eaa 14a 3cbb 2073 293d 1d44 219c bdb d0e 3c3f 383d 3c5c 3209 13b4 1e7c 362a 11c6 3571 c44 84 184e 1561 2f4d 3228 15a7

which matches quite well the manual, table 39. However, when I measure, I see totally different sequence (decimal):

3492, 9061, 14751, 5018, 6504, 8937, 4429, 11320, 10430, 13457, 12197, 8533, 7861, 9028, 16268, 14018, 699, 15971, 5156, 4849, 9152, 10178, 9123, 11766, 3147, 387, 10709, 3641, 10894, 5051, 8059, 1969, 2718, 12466, 11735, 2648, 9435, 12806, 4787, 12263, 11634, 5125, 5346, 1688, 15377, 16169, 10399, 12930, 2813, 14982, 575, 9773, 325, 15804, 4584, 12901, 6279, 15, 263, 12699, 7000, 1475, 8595, 2780, 15509, 10087, 15870, 7631, 14549, 12065, 14619, 3028, 3081

Why are the values not matching? Shouldn't the manual be updated?

Maybe related:

For PN23 (notice that the seed given in the manual is big endian, so you need to swap it, and it makes a big change if you do not swap it), my code predicts now for the first values:
3aff 3fd7 2 26e0 a3d 1ca6

which again matches well the manual, table 39, however when I measure I see a different sequence (decimal):

8232, 8189, 14623, 5570, ...

How are these related with data words from the manual ??

• Any insights on this question? (I noticed that you found the solution for other ADC models). Thanks in advance.

• Ok, I finally figured out with the help of two colleagues. The issue was that there was a bug in my vendors' firmware which was causing the ADC data to be inverted. On top of that, there are several things that are not mentioned in the manual. Here a reminder of all tricks:

For PN9:

- pow(2,9) -1 = 511 is the period

- Start with 0x92 as seed in a 9-bit register. It does not matter if you assume big endian or little endian, it is a palindrome.

- Get the XOR 9 and 5, call it e.g. newBit

- Create a new 9-bit register, which is the like the previous register shifting all bits to the left, and then bit0 = newBit.

- Calculate again newBit, etc.

- Finish the sequence whenever you reach the PN9 period, which is 511. You will have thus created 511 9-bit registers.

- Then, self-duplicate this array of registers, namely as many times so that it is aligned with 14. (so that we can then divide the array in groups of 14). newArraySize = least_common_multiple(511, 14) = 1022 ; nCopies = newArraySize/originalArraySize = 2; so that 1022/14 = 73 exact groups or data output words.

- Now, form the real 73 output words using groups of fourteen trans-consectuve bits, namely the highest bit (bit 8) of every consecutive 9-bit register that you in your extrapolated array.

- For example, you will obtain 0x125b, 0x3c9a by grouping the first 28 highest bits in two output words.

- Finally, configure your ADC to not invert the data (register 0x561) and to not use binary mode, but the default two's complement. Otherwise you would have to flip the last bit of your output words.

Similar for PN23:

- pow(2,23) -1 = 8388607 is the period

- Get XOR 23 and 18 as newBit

- Create a 23-bit register, etc. as before

- newArraySize = lcm(8388607, 14) = 8388607*14, nCopies = 14

- etc.

Attached is a spreadsheet illustrating the calculation.

PNsequence.ods.zip

• Great work Ferdymercury. Thanks for sharing your results on EngineerZone.

• Thank you for the clue to put it back to two's complement mode. This helped a lot.

I am not sure I understand how many copiess or repeats of the table you nedd. I made a single 511 point table like this:

#define NPTS_PRBS 511

...

int16_t prbs[NPTS_PRBS];

...

x = 0x125B;
for (i=0; i<NPTS_PRBS; i++)
{
prbs[i] = x;
for (k=0; k<14; k++)
x = (x<<1 | (x >> 8 & 1 ^ x >> 4 & 1)) & 0x3fff;
}

For the first test word received, I search to find the first macth, then roll around the table using rpos = (rpos+1) % NPTS_PRBS

William.

• You are welcome. Concerning the 'repeats' of the table, you do not really need it if you use the % operator to roll around. The 'repeat' is only relevant if you are interested in knowing after how many 'rolls' you will get the same 14-bit word you started with. For PN9, you will need to go twice through the table, as shown in my attachment with 511*2 rows, and you get a closed sequence 0x92, 0x125B, ... 0x13F6 that gets repeated on an on. The sequence length is 1022, that's why I copy-paste the table twice. nCopies = least-common-multiple of (2**N-1, 14)