Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help finding a rotary encoder with interupt capabilities

  1. Aug 25, 2016 #1
    In this project,

    14 // Change these pin numbers to the pins connected to your encoder.
    15 // Best Performance: both pins have interrupt capability1Q
    16 // Good Performance: only the first pin has interrupt capability
    17 // Low Performance: neither pin has interrupt capability
    18 Encoder knobEnc(0, 1);
    19 Encoder scrollEnc(2, 3);
    20 int encoderPins[] = {2,3,4,5,};
    21 // (avoid using pins with LEDs attached)​

    It states that a rotary encoder with "interrupt capabilities" is recommended for this project (which connects to the Teensy 2.0++ pins, which the Teensy connects to the Raspberry Pi 2 via usb)


    I'm guessing that interrupt capabilities are knobs that also act like pushbuttons, in the same way that car radio volume control knobs are (which you can push like buttons) "...the knob also acts as a pushbutton which sends an interrupt to your target board\'s MCU."



    He states that the rotary encoder's knob should also act like a push button, so that it's a mouse that alternates between diagnal and horizontal movements.

    •Move Map Cursor
    ○Mouse Move
    (Knob on back of hand: rotational encoder with switch - alternates between X/Y movement when pushed down)​
  2. jcsd
  3. Aug 25, 2016 #2


    User Avatar
    Science Advisor

  4. Aug 26, 2016 #3
    I appreciate your insightful response and for your clarification, thank you Billy! I've got one more question, since this switch encoder has 6 pins and the Teensy needs to connect to it through these 6 pins (0, 1, 2, 3, 4, 5),


    Encoder knobEnc(0, 1);​

    just the pins for the knob when the switch is not pressed on the encoder,

    Encoder scrollEnc(2, 3);​

    pins where the knob is pressed down, and

    int encoderPins[] = {2,3,4,5,};​

    are the the remaining pins which would be used for the interrupt features?
  5. Aug 28, 2016 #4


    User Avatar
    Gold Member

    One side of the switch and the common pin of the encoder are usually connected to ground. Also one of the pins is clipped short and has no documented function. If I had to guess it is connected to the encoder common. It might also not be connected at all. It is removed during manufacture to add polarization to the part. Just ignore it.

    So now you have three signals. At minimum you will want an interrupt on the two encoder signals. The switch function would be wired up however is most convenient. Either interrupt or polled should be adequate.

  6. Sep 1, 2016 #5
    I appreciate your Help rbelli1!

    After building this circuit based off of Neal Corbett's [the guy who created the Raspberry Pip Boy project alongside Grieve] posts and videos



    I've got confused with pins 4 and 5 found here

    *Highlighted in red are the pins and circuit that I don't understand, which are 4, 5 (or rotary encoder) and how to wire the voltage divider battery pins 44, & 38

    My personal setup is a little different from his and I wont include the temperature sensor nor the radiation-gauge running off of a stepper motor (I will add a real one, similar to some of the ideas from this NASA Pip Boy xD :DD)

    Pictures of my personal setup are down bellow, but they are subject to change.

    So primarily, how would I wire pins 4 and 5 to the rotary encoders? Are they pins or are they just numbers? :confused:

    If possible too, how do I wire together the voltage divider circuit?

    Thank you for your guy's time and I hope that these schematics may help others too if they are interested in this project! :biggrin:

    *my own set-up which is not the traditional Pip Boy 3000, it's my own modern and functional version, I plan on adding wearable technology in the glove and inside the Pip Boy to add more information about the environment, your own vitals and tools to help you out

    *An old visual representation of how I plan to put together my own set-up
  7. Sep 2, 2016 #6


    User Avatar
    Gold Member

    The pin numbers are all port designations per the CPU datasheet. D4 and D5 are port D bits 4 and 5. To connect them to the encoder you put a resistor of the appropriate value from each pin to VCC and usually a capacitor from the pin to ground. The resistor by convention is 10K and you need to select a capacitor to make the rise time slow enough so as to filter out switch bounce but also fast enough to allow the encoder to work fast enough. Connect these inputs to the two encoder output pins and the common to ground.

    The battery voltage divider appears to be measuring an approximation of VCC through a port pin. If you are using some other battery power source you will want to connect to that voltage. Use higher values of resistor to minimize current draw.

  8. Sep 2, 2016 #7
    Thank you rbelli1 for your help again!

    So to make sure I understand you correctly, is this correct the way I have it wired up, or when you say "encoder output pins" do you mean all the pins except the common ground pins?

    *the diodes I used have a voltage drop of 0.6 volts and are called 1N4001*

    And for the capacitor ratings, which one would you suggest I use? In terms of voltage, frequency etc.?

    Thank you again for your help valuable help !
  9. Sep 3, 2016 #8
    I apologize for the bad drawing, I fixed it a little better.

    I'm not sure if just the B is the output pin of both encoders or its both A and B.
  10. Sep 3, 2016 #9
    Here, I drew out other ways I think it could be wired.

    (I feel like its most likely this one, because Pin D4 would correspond to both outputs (A & B) Pins of one encoder, and Pin D5 the other output of the other encoder)

    (The thought behind this one is that D4 focuses on the output of one of the Pins from both encoders whereas D5 focuses on one of the output pins from both of the other encoders)
    (Where I connect D4 and D5 to all of the output pins)

    I apologize for all of the confusion, I still consider myself new to electronics :P
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted