ANALOG Reads across A0 - A7: nice but strange pattern

This is to verify a pattern I noticed when testing analog port reads in succession.
I am hoping somebody can verify it and maybe explain it.
Also, if the pattern is valid for all multiport MCs, then coding might be simplified accordingly.

Program to test with is attached.

I was initially getting what looked like random values that jumped all over the range. I started using averaging and other methods described in the forums which got my code really convoluted. And since I am not good at all with electronics, I was shying away from electronic stabilization methods of using caps etc.

Upon further analysis I noticed that port 7 was always accurate on every read. This was regardless of the delays I used in between the readings (from 10ms to all the way to 2secs).

Then I also noticed that port 6 would get correct reads on every other read.

When I verified all other ports it became clear:

Highest number port reads correctly on every cycle.
Every other port (n) away from the highest port reads correctly on every highestPort - n read.
i.e.: On an A0-A7 port MC, port 7 reads correct on every cycle, (7-7); throw away 0
port 6 reads correct on first, and then on every other one (7-6); throw away 1
port 5 reads correct on first, and then on every other two (7-5); throw away 2
port 4 reads correct on first, and then on every other three (7-4); throw away 3
port 3 reads correct on first, and then on every other four (7-3); throw away 4
port 2 reads correct on first, and then on every other five (7-2); throw away 5
port 1 reads correct on first, and then on every other six (7-1); throw away 6
port 0 reads correct on first, and then on every other seven (7-0); throw away 7

I tested this on only my NANO and PRO MINI and it was the same behaviour.

Corresponding Serial Monitor printout is as shown below:
I added the “[” and “]” s to highlight the bad reads.
Since I only use 20 cycles to test, not all series are complete.

First series is with volts set at 0, second series is with volts set at 5.16. Your values might be different.

Select port(0-n): 7
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Select port(0-n): 7
1022 1023 1022 1023 1021 1023 1023 1023 1022 1022 1023 1023 1022 1022 1022 1023 1022 1022 1022 1023
Select port(0-n): 6
0 [106] 0 [34] 0 [15] 0 [13] 0 [16] 0 [22] 0 [27] 0 [32] 0 [36] 0 [40]
Select port(0-n): 6
1022 [779] 1023 [918] 1022 [961] 1022 [976] 1022 [981] 1023 [983] 1022 [984] 1023 [987] 1022 [991] 1023 [995]
Select port(0-n): 5
0 [126 168] 0 [39 133] 0 [44 42] 0 [12 101] 0 [45 28] 0 [12 102] 0 [44
Select port(0-n): 5
1023 [811 633] 1023 [940 834] 1023 [984 940] 1023 [1007 951] 1023 [991 1008] 1023 [1018 946] 1022 [989
Select port(0-n): 4
0 [105 169 223] 0 [47 87 136] 0 [28 66 88] 0 [22 71 63] 0 [20 79 47]
Select port(0-n): 4
1023 [740 606 498] 1023 [907 802 709] 1023 [971 901 865] 1023 [997 939 955] 1023 [1007 950 993]
Select port(0-n): 3
0 [95 166 202 266] 0 [47 92 150 156] 0 [25 73 93 160] 0 [27 52 94 95]
Select port(0-n): 3
1023 [742 570 502 429] 1023 [910 788 682 632] 1022 [977 885 828 727] 1023 [992 950 886 850]
Select port(0-n): 2
0 [158 161 196 226 251] 0 [55 120 146 190 192] 0 [23 136 138 189 155] 0 [14
Select port(0-n): 2
1022 [667 555 445 402 360] 1022 [847 729 625 545 530] 1022 [971 803 746 652 685] 1022 [1023
Select port(0-n): 1
0 [197 163 227 231 255 259] 0 [54 67 153 177 223 215] 0 [26 250 138 172 176
Select port(0-n): 1
1022 [900 557 560 441 445 360] 1023 [822 893 650 578 509 486] 1023 [940 741 736 662 597
Select port(0-n): 0
0 [86 461 261 372 320 334 289] 0 [7 340 124 276 275 294 251] 0 [2 131 76
Select port(0-n): 0
1023 [698 843 426 473 385 405 333] 1023 [771 988 546 600 501 483 373] 1023 [774 787 544

ReadAnalogVoltageAcrossPins.ino (6.73 KB)

Did you use a ratiometric low impedance source (<=10k potentiometer) or a voltage source (bad).

Did you use a 7-9volt supply on the Nano’s raw pin (= 5volt Aref) or USB supply (= less stable ~4.6volt Aref).

This test is meaningless without listing the exact conditions.
Leo…

I used USB connection for power.
POTs used were 10k and 500ohm. Both gave the same results.
Did not try with 9v battery on RAW pin.

A Nano has a schottky USB backflow protection diode, so runs on ~4.6volt on USB power.
You must have powered the ProMini a different way (no USB socket).

Not sure what is going on.
The A/D should be stable within two values.
It is common, if you want accurate results, to do one dummy read after you have switched to a different analogue input. No delays.
Leo..