Inconsistent Encoder Readings Inquiry

Hello,

I hope this post finds you well. I’m working on a project involving two 15:1 Micro Metal Gearmotor HPCB 6V with 12 CPR Encoder, Side Connector, and use the DRV8833 motor driver. I’m programming this with a Waveshare Zero ESP32. I have some simple code that spin the motors “forward”:

void straight(char direction){
    moveLeftMotor(100);
    moveRightMotor(100);
    while(1){
        Serial.printf("%d\t%d\n",encLeft.read(),-encRight.read());
        // delay(100);
    }
}

The move function works as intended, spinning the motors correctly. The issue lies where the encoders will start to increase in value but decrease, despite moving in the same direction. What’s more peculiar, the encoders work perfectly when I rotate them by hand. What are potential causes of this issues, and what recommendations would you all make? Thank you for your time, and I look forward to a response. Cheers!

Hello.

I’m moving your post to the motors support category since that seems a little more appropriate.

Can you post the libraries you are using for the motors and encoders as well as a sample output from your program that demonstrates the problem? Also, please post some pictures of your setup that show all of your connections.

- Patrick

Hello,

Thank you for your response and for moving my post! I had another look at my dependencies and might suspect it’s a library issue. I’ll have a go with another library and get back to you. Once again, thank you for your time.

UPDATE:

fortunately, I was able to solve the issue. It was with the encoder library I was using. I replaced the library with this, and it works like a charm. Thanks once again for the help.

2 Likes