Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firmware, Rotary Encoder is double incrementing, Incorrect Sense Of Rotation #118

Open
nk25719 opened this issue Dec 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@nk25719
Copy link
Collaborator

nk25719 commented Dec 24, 2024

Describe the bug
A clear and concise description of what the bug is.
Short Summary of the expected behavior: Proper increments or decrements for each detent. Rotate the rotary encoder by one detent and get one increment.
Rotate clockwise. The count should increase.

Short Summary of the buggy behavior: Rotating the rotary encoder by one detent and getting two increments
The count decreased.

To Reproduce
Steps to reproduce the behavior:

  1. Go to krake\Firmware\factoryTest\Rotarty Encoder\InterruptRotatorESP32
  2. Click on upload
  3. Scroll down to Serial monitor
  4. See error

Screenshots
If applicable, add screenshots to help explain your problem.
This was the serial output for a single clock wise detent rotation.
image

Hardware description
Tested on Models: MockingKRAKE USA1 and MockingKRAKE LEBNA

@nk25719 nk25719 added the bug Something isn't working label Dec 24, 2024
@nk25719 nk25719 added this to the Firmware Release milestone Dec 24, 2024
@ForrestErickson ForrestErickson changed the title Fiemware, Rotary Encoder is double incrementing Firmware, Rotary Encoder is double incrementing, Incorrect Sense Of Rotation Dec 24, 2024
@ForrestErickson
Copy link
Collaborator

Note I have tried to change the polarity of the rotation by changing the edges of the ISR asseignment with no success.
All combinations below give the same results. Two steps for each encoder detent.

  // register interrupt routine
  attachInterrupt(digitalPinToInterrupt(PIN_IN1), checkPosition, CHANGE);
  attachInterrupt(digitalPinToInterrupt(PIN_IN2), checkPosition, CHANGE);

  // register interrupt routine
  attachInterrupt(digitalPinToInterrupt(PIN_IN1), checkPosition, RISING);
  attachInterrupt(digitalPinToInterrupt(PIN_IN2), checkPosition, RISING);

  // register interrupt routine
  attachInterrupt(digitalPinToInterrupt(PIN_IN1), checkPosition, FALLING);
  attachInterrupt(digitalPinToInterrupt(PIN_IN2), checkPosition, FALLING);

//and

  // register interrupt routine
  attachInterrupt(digitalPinToInterrupt(PIN_IN1), checkPosition, RISING);
  attachInterrupt(digitalPinToInterrupt(PIN_IN2), checkPosition, FALLING);

@ForrestErickson
Copy link
Collaborator

Changing Increment

From " encoder = new RotaryEncoder(PIN_IN1, PIN_IN2, RotaryEncoder::LatchMode::TWO03);"

To: " encoder = new RotaryEncoder(PIN_IN1, PIN_IN2, RotaryEncoder::LatchMode::FOUR0);"
fixes the problem

See results:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants