Absolute encoder with Petherick code


Closed Thread
Results 1 to 4 of 4
  1. #1

    Cool Absolute encoder with Petherick code

    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?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    http://www.pldesignline.com/196604078
    http://www.et.byu.edu/groups/it548/C...s/encoders.pdf
    http://en.wikipedia.org/wiki/Gray_code
    From the above link:
    Code:
     // 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 . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3


    Did you find this post helpful? Yes | No

    Cool

    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?

  4. #4
    Join Date
    Apr 2016
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Absolute encoder with Petherick code

    hi everybody, someone kwon how can convert the gray code 10 bit to petherick code 10 bit?
    thanks in advance

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 10:02
  2. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 15:45
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 22:56

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts