Jump to content

One of sixteen from gray code?


John_R

Recommended Posts

Hey All,

Any of you have have a Vision  routine made up to decode 1-16 from a 4-bit Gray Code?

I'm picturing a lot of logic for a seemingly simple task...


        ABEF
1 -   0000
2 -   0001
3 -   0011
4 -   0010
5 -   1010
6 -   1011
7 -   1111
8 -   1110
9 -   0110
10- 0111
11- 0101
12- 0100
13- 1100
14- 1101
45- 1001
16- 1000

Regards,

JohnR

 

 

 

Link to comment
Share on other sites

  • MVP 2023

I played with a data table (4 columns of bits) in which I wrote down possible codes for the position of the turret.

With one command (Data Table Find (Extended), I searched for the line number in which the required combination was found.

The task was to automatically find the position number as a decimal number. In my case it was the row numbe r of the data table.

Link to comment
Share on other sites

What I have here is a piece of audio gear that uses this encoder wheel to scroll through options.
And sometimes it goes wanky, when it should be scrolling "up", it will go up one step then down a step (or vice-versa).
I first assumed it was a quadrature encoder, either Incrementing or Decrementing some counter, and was missing pulses that confused direction.
Turns out the encoder outputs this Gray code, which gives a consistent output step by step, checking with a meter.
So I thought I would make a "quick and dirty" test program on a PLC, where I could watch the results of spinning the encoder at normal speed, maybe something is floating...
The encoder is a 16 position mechanical switch encoder (CTS series 288), which I have already sprayed with De-Oxid contact cleaner, with no improvement.
And following up on years of troubleshooting experience, programmed controllers don't go wanky (it either works or doesn't), more than likely a problem with the input devices..
So here I am trying to find a way to real-time test this encoder..

Link to comment
Share on other sites

  • MVP 2023
4 hours ago, John_R said:

So here I am trying to find a way to real-time test this encoder..

Similar to your task, I set up a PLC to detect problems with the turret encoder. It should be noted that your code is slightly offset from the standard Gray code. Therefore, standard conversion methods need "improvement".

Link to comment
Share on other sites

7 hours ago, kratmel said:

It should be noted that your code is slightly offset from the standard Gray code

Hmmm, well this is the Gray Code truth table taken from the CTS spec sheet. and my encoder does follow this pattern (checking each output step by step with a meter).

I've never played with a Gray code (so it's a gray area to me).🥴

Anyway, like I said, I thought a PLC program would be a good way of testing (but after 3 years of retirement, my coding is getting slow and rusty).

JohnR

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.