First of all, want to thank you for creating this great library!
I’m trying to get two encoders to work, with following setups:
int encoderPinA = P0;
int encoderPinB = P1;
int encoderPinC = P2;
int encoderPinD = P3;
pcf8574.encoder(encoderPinA, encoderPinB);
pcf8574.encoder(encoderPinC, encoderPinD); And read values by calling these functions:
However, the encoderValue1 and encoderValue2 can only goes up, no matter which direction I turn, but if with only one encoder, it works fine (clockwise +1 & counter -1)
Wondering if you could give some suggestions what I can implement this?
Hi Poky,
I never test the internal implementation with 2 encoder, It’s possible that there is a bug,
to bypass the problem you can try to implement externally the management of 2 encoder, there is an example of external implementation on the relative tutorial
Hi Renzo, basic encoder algorithm is still doing the same (only increment when rotate)
However I get by this problem by modify the if statement as following:
if (na && !nb) {
if (encoderPinBLast) *encoderValue = *encoderValue + 1;
else *encoderValue = *encoderValue - 1;
changed = true;
}
Hi Poki,
thanks for your solution, but your solution not work with my encoder, the first encoder only increment when rotate, the second work correctly.
I think there are some difference from the encoder, so I’m going to add you r algorithm to the library for all people that have your same type of encoder.
Now we have:
The strange thing is that if I only used a single encoder, the original algorithm works fine (01-10 clockwise, 01-11 counter)
But whenever I connected two encoders, the behavior changed to (00-10 counter)
Do have you a spare encoder to test when two connected? Thanks!
Hi Poki,
if you have some exception on the behavior probably It’s the noise, the encoders have a lot of noise.
Try to change the algorithm, or add some capacitor to absorb It.
Bye Renzo
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.