Skip to main content
Added pullup.
Source Link
Transistor
  • 180.3k
  • 14
  • 194
  • 417

Based on your update and resistance measurements it is a 4-bit rotary encoder with wiping contacts.

enter image description here

Binary and gray encoded 3-bit rotary encoders. Image from Wikipedia.

The image shows two different 3-bit rotary encoder patterns. (Yours is 4-bit as it has four contacts.) The left pattern is a regular binary pattern. The contacts are represented by the yellow circles. White is no-contact. Black is contact.

You can see that as we rotate the encoder disc anti-clockwise we will get a binary pattern:

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

This all would be fine until you line up on the boundary where two bits change simultaneously - e.g. 001 to 010. Now if the contacts aren't exactly aligned (and they never will be) what you read may go 001, 000, 010 or 001, 011, 010 as the contacts change over. This would present spurious position readings to the software trying to keep track of position. Note that going from 111 to 000 is the worst!

The Gray code solves this by only allowing one bit to change at a time. In this case our sequence would be:

0 0 0 
0 0 1
0 1 1
0 1 0
1 1 0
1 1 1
1 0 1
1 0 0

Here we can see that the code changes by one bit at each transition. Note that the software now needs to be able to decode the Gray code - usually by lookup table.

Test your encoder as shown below and record your results.

schematic

simulate this circuit – Schematic created using CircuitLab

Put the results into your original question. It may help someone else.


For an Arduino application you would connect the common to GND and connect the switches to the Arduino inputs. Set the Arduino pinMode() to INPUT_PULLUP which will connect a 20 - 50k resistor internally to each pin so configured.

Based on your update and resistance measurements it is a 4-bit rotary encoder with wiping contacts.

enter image description here

Binary and gray encoded 3-bit rotary encoders. Image from Wikipedia.

The image shows two different 3-bit rotary encoder patterns. (Yours is 4-bit as it has four contacts.) The left pattern is a regular binary pattern. The contacts are represented by the yellow circles. White is no-contact. Black is contact.

You can see that as we rotate the encoder disc anti-clockwise we will get a binary pattern:

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

This all would be fine until you line up on the boundary where two bits change simultaneously - e.g. 001 to 010. Now if the contacts aren't exactly aligned (and they never will be) what you read may go 001, 000, 010 or 001, 011, 010 as the contacts change over. This would present spurious position readings to the software trying to keep track of position. Note that going from 111 to 000 is the worst!

The Gray code solves this by only allowing one bit to change at a time. In this case our sequence would be:

0 0 0 
0 0 1
0 1 1
0 1 0
1 1 0
1 1 1
1 0 1
1 0 0

Here we can see that the code changes by one bit at each transition. Note that the software now needs to be able to decode the Gray code - usually by lookup table.

Test your encoder as shown below and record your results.

schematic

simulate this circuit – Schematic created using CircuitLab

Put the results into your original question. It may help someone else.

Based on your update and resistance measurements it is a 4-bit rotary encoder with wiping contacts.

enter image description here

Binary and gray encoded 3-bit rotary encoders. Image from Wikipedia.

The image shows two different 3-bit rotary encoder patterns. (Yours is 4-bit as it has four contacts.) The left pattern is a regular binary pattern. The contacts are represented by the yellow circles. White is no-contact. Black is contact.

You can see that as we rotate the encoder disc anti-clockwise we will get a binary pattern:

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

This all would be fine until you line up on the boundary where two bits change simultaneously - e.g. 001 to 010. Now if the contacts aren't exactly aligned (and they never will be) what you read may go 001, 000, 010 or 001, 011, 010 as the contacts change over. This would present spurious position readings to the software trying to keep track of position. Note that going from 111 to 000 is the worst!

The Gray code solves this by only allowing one bit to change at a time. In this case our sequence would be:

0 0 0 
0 0 1
0 1 1
0 1 0
1 1 0
1 1 1
1 0 1
1 0 0

Here we can see that the code changes by one bit at each transition. Note that the software now needs to be able to decode the Gray code - usually by lookup table.

Test your encoder as shown below and record your results.

schematic

simulate this circuit – Schematic created using CircuitLab

Put the results into your original question. It may help someone else.


For an Arduino application you would connect the common to GND and connect the switches to the Arduino inputs. Set the Arduino pinMode() to INPUT_PULLUP which will connect a 20 - 50k resistor internally to each pin so configured.

Source Link
Transistor
  • 180.3k
  • 14
  • 194
  • 417

Based on your update and resistance measurements it is a 4-bit rotary encoder with wiping contacts.

enter image description here

Binary and gray encoded 3-bit rotary encoders. Image from Wikipedia.

The image shows two different 3-bit rotary encoder patterns. (Yours is 4-bit as it has four contacts.) The left pattern is a regular binary pattern. The contacts are represented by the yellow circles. White is no-contact. Black is contact.

You can see that as we rotate the encoder disc anti-clockwise we will get a binary pattern:

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

This all would be fine until you line up on the boundary where two bits change simultaneously - e.g. 001 to 010. Now if the contacts aren't exactly aligned (and they never will be) what you read may go 001, 000, 010 or 001, 011, 010 as the contacts change over. This would present spurious position readings to the software trying to keep track of position. Note that going from 111 to 000 is the worst!

The Gray code solves this by only allowing one bit to change at a time. In this case our sequence would be:

0 0 0 
0 0 1
0 1 1
0 1 0
1 1 0
1 1 1
1 0 1
1 0 0

Here we can see that the code changes by one bit at each transition. Note that the software now needs to be able to decode the Gray code - usually by lookup table.

Test your encoder as shown below and record your results.

schematic

simulate this circuit – Schematic created using CircuitLab

Put the results into your original question. It may help someone else.