Using XOR to convert a Graycode Encoder

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Using XOR to convert a Graycode Encoder

Postby Roche » Thu Sep 19, 2019 6:12 pm

PM sent
Roche
 
Posts: 46
Joined: Fri Jul 11, 2014 12:35 pm
PIC experience: Professional 5+ years with MCHP products

Re: Using XOR to convert a Graycode Encoder

Postby GettinBetter » Sun Sep 29, 2019 1:53 pm

So I've identified a couple of things....
If I disconnect pin 4 (bit3) from the input because it is always on (well it only dims, which the PIC still sees as on) I can get the low numbers down to zero, and the high numbers up to 512 (I was expecting 512 i.e. half of 1024).
As far as the skipping & jumping numbers go, I found that stopping the spindle at the number it started to reverse and connecting pin 4 gave me the missing numbers.
So all that makes sense and I believe there is an electrical fault in the encoder so I will connect the other one to check. I wonder how likely is it that they will both have the same fault!

So then the reason it isn't going up to 1024 is that pin 10 (bit9), isn't being recognised as an input to the PIC!
Not great but it is progress.
Regards
Les
History teaches us that history doesn't teach us.
User avatar
GettinBetter
 
Posts: 23
Joined: Wed Jun 06, 2018 8:48 pm

Re: Using XOR to convert a Graycode Encoder

Postby GettinBetter » Sun Sep 29, 2019 5:38 pm

Sorted :D

The other encoder worked fine, which will have do for now. The reason for the low reading was the fact that while messing about with the code I removed or left out
the left shift for the second bit of Port C
Code: Select all
    G_PortC_0 = IO_RC0_PORT;                    //Pin RC0 Single bit Binary Input (sends to righter most bit0)
        // 00000001 what I think would be the result assuming all pins are high
    G_PortC_1 = IO_RC1_PORT<<1;              //shift RC1bit to bit1
       // 00000010 what I think would be the result assuming all pins are high

So when or'ing them the result was the same.
All great now... lovely incrementing values through 360 degrees, from 0 up to 1023 (i.e. 0 - 1023 = 1024 values).

Did what you guys suggested, slowed right down, proved each part, used the debugger.

Regards
Les
History teaches us that history doesn't teach us.
User avatar
GettinBetter
 
Posts: 23
Joined: Wed Jun 06, 2018 8:48 pm

Re: Using XOR to convert a Graycode Encoder

Postby Roche » Fri Oct 04, 2019 1:34 pm

Well done for perseverance...
Roche
 
Posts: 46
Joined: Fri Jul 11, 2014 12:35 pm
PIC experience: Professional 5+ years with MCHP products

Previous

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 2 guests