I do not have problem with converting Petherick code to any other.

If encoder is rotating clockwise, it give us sequence(in decimal): 0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0
and afther that again , repeated the same: 0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0

My main problem is how to convert transient from 9 to 8 when it rotate clockwise!

I think the way to find the absolute position=ABCDE is:

dim position as DWORD

1.
X=read 4 inputs for digit A
X=convert it to binary
position=x
position=SHIFT LEFT for 4 bits

2.
X=read 4 inputs for digit B
X=convert it to binary
position=position+X
position=SHIFT LEFT for 4 bits

3.
X=read 4 inputs for digit C
X=convert it to binary
position=position+X
position=SHIFT LEFT for 4 bits

4.
X=read 4 inputs for digit D
X=convert it to binary
position=position+X
position=SHIFT LEFT for 4 bits

5.
X=read 4 inputs for digit E
X=convert it to binary
position=position+X

On this way for I can do the job for sequence 0,1,2,3,4,5,6,7,8,9:

1. position=A
2. position=AB
3. position=ABC
4. position=ABCD
5. position=ABCDE
end of job

But, What to do after that. After that I have sequence numbers falling down: 8,7,6,5,4,3,2,1,0.
Before adding to "position", I must convert them:

8 to 1
7 to 2
6 to 3
5 to 4
4 to 5
3 to 6
2 to 7
1 to 8

So after adding I have progressive advance of position.

All of this I must do for counter-clockwise to.

Am I right?