stojakovicv
- 14th May 2009, 14:01
I have an Absolute encoder with Petherick code. It gives me 5 separate digits. Every digit have 4 bits with Petherick code system, so I have this situation:
xxxx xxxx xxxx xxxx xxxx - 5 separate groups with independent circular code advance:
encoder output / decimal value
0101 0
0001 1
0011 2
0010 3
0110 4
1110 5
1010 6
1011 7
1001 8
1101 9
1001 8
1011 7
1010 6
1110 5
0110 4
0010 3
0011 2
0001 1
.
.
.
.
.
.
.
0101 0
0001 1
0011 2
0010 3
0110 4
1110 5
1010 6
1011 7
1001 8
1101 9
1001 8
1011 7
1010 6
1110 5
0110 4
0010 3
0011 2
0001 1
.
.
.
As you can see, I have an circular sequence of 18 digits in clockwise turning.
On which way I can measure absolute position?
Archangel
- 16th May 2009, 07:17
http://www.pldesignline.com/196604078
http://www.et.byu.edu/groups/it548/ClassNotes/encoders.pdf
http://en.wikipedia.org/wiki/Gray_code
From the above link:
// parameters: value, base, digits
// Convert a value to a graycode with the given base and digits. Iterating
// through a sequence of values would result in a sequence of graycodes in
// which only one digit changes at a time.
int baseN[digits]; // Stores the ordinary base-N number, one digit per entry
int gray[digits]; // Stores the base-N graycode number
// Put the normal baseN number into the baseN array. For base 10, 109
// would be stored as [9,0,1]
int power = 1;
for(i = digits - 1; i >= 0; i--) {
baseN[i] = (value / power) % base;
power *= base;
}
// Convert the normal baseN number into the graycode equivalent. Note that
// the loop starts at the most significant digit and goes down.
int shift = 0;
for(i = digits - 1; i >= 0; i--) {
// The gray digit gets shifted down equal to the sum of the higher
// digits.
gray[i] = (baseN[i] + base - shift) % base; // + base to prevent neg
shift += gray[i];
}
// EXAMPLES
// input: value = 1899, base = 10, digits = 4
// output: baseN[] = [9,9,8,1], gray[] = [0,1,7,1]
// input: value = 1900, base = 10, digits = 4
// output: baseN[] = [0,0,9,1], gray[] = [0,1,8,1]
looks like C, apparantly Gray code and Petherick code, run down similar roads. Sorry best I can do . . .
stojakovicv
- 18th May 2009, 06:41
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?
Alby70
- 1st April 2016, 16:36
hi everybody, someone kwon how can convert the gray code 10 bit to petherick code 10 bit?
thanks in advance
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.