Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Encoder direction problem

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    1

    Encoder direction problem

    Hello,

    I'm trying to use the Encoder.h library with Teensy. The program compiles without any errors and sort of works but not very reliably. I am using a standard rotary encoder and connecting the output of the encoder directly to pins 7 and 8.

    My code monitors the encoder in a loop and does a serial print on whether it is turned clockwise or counter clockwise. So, when I turn the encoder in one direction, it reports the wrong direction about 25% of the time. Has anyone here encountered a similar problem?

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,624
    Difficult to say since there are tons of different Encoder.h libraries out there in the wild... one common problem with wrong readings is with cheap mechanical rotary encoders where mechanical contact bouncing may lead to extra-pulses. Some libraries do handle that, others don’t and expect you to debounce your encoder in hardware, i.e. with 2 RC low-pass filters and optionally 2 Schmitt-Triggers.

  3. #3
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,756
    How far does the encoder move in one click? Some will jump a fair number of steps per detente which can make life interesting. Posting your code and possibly a photo of your wiring would help here.

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,624
    The problem (as usual) is that the OP did neither share his code, nor schematics, nor details about the used components (i.e. encoder data sheet)...

    Knowing that there are many encoder libraries and an infinite number of encoder hardware, the OP did just not provide enough information to give qualified support. He also did not reply for more that 12 hours. I'm not sure if this is serious.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,595
    Quote Originally Posted by brakecane View Post
    Has anyone here encountered a similar problem?
    Yes, they have. It's usually improperly connected hardware. Noisy mechanical chatter sometimes does this too. Adding the RC filters Theremingenieur mentioned can help.

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,624
    If it was about these cheap rotary encoder knobs which have lots of mechanical chatter, this could be helpful, too.

Posting Permissions

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