Troubleshooting DC motor encoder


#1

I need help with the dc motor encoder.
I am using:

  • 25MM DC Encoder motor (The motor specs are 86 RPM, and a gear ratio of 1:75)
  • Me Encoder motor driver v 1.1
  • MeOrion board.
  • Using the old motor encoder example ( the new one doesn’t work for me)

I can’t get the motor to rotate a consistent number of turns.
motor1.runTurns(1, 100);
Only results in the motor making about 2/3 a full turn. When I check the position, it shows a rotation of about 358 ticks.

If my math is right for this motor (1 rev = 75 turns * 8 encoder ticks), then it should be more like 600 ticks for 1 revolution.

I’m guessing the encoder library is made for a different sized motor, so is there a way to change the program to fit the motor I’m using? Or is there another way to get a consistent number of turns?


#2

Not sure what to do with that. :grimacing:

@rvondrak do you have a link to the products you are using, or an image of them? If I can understand a bit more, I might be able to help with the code part.


#3

The setup
The motor driver (product page)
The motor. (product page)
The Orion board

When I run this code
#include “MeOrion.h”
#include <Wire.h>
#include <SoftwareSerial.h>

MeEncoderMotor motor1(0x09, SLOT1);
float pos = 0;

void setup()
{
  motor1.begin();
  Serial.begin(9600);

  Serial.print("Position: ");
  Serial.println(motor1.getCurrentPosition());
}

void loop()
{
  motor1.runTurns(1, 100);
  Serial.print("Position: ");
  Serial.print(motor1.getCurrentPosition());

  Serial.print("  Change in position: ");
  Serial.println(motor1.getCurrentPosition()-pos);
  pos = motor1.getCurrentPosition();
  delay(3000);
}

I get this in the serial monitor
And this is what the motor does


#4

@rvondrak Not very sure how to help you…

Thanks for providing all the info you did. @CommandeR you got anything that might help?


#5

@rvondrak This is an automated AI response. Verify important information.

It looks like you’re having trouble with the encoder ticks not matching up with the expected number of turns for your motor. Let’s break down the problem and see if we can find a solution.

Understanding the Encoder Ticks

For your 25MM DC Encoder motor with a gear ratio of 1:75 and 86 RPM, you mentioned that 1 revolution should be 75 turns * 8 encoder ticks, which equals 600 ticks per revolution.

However, your code shows that the motor only makes about 2/3 of a full turn and registers about 358 ticks. This discrepancy suggests that the encoder library might not be configured correctly for your motor.

Adjusting the Encoder Library

To adjust the encoder library for your motor, you need to ensure that the library is correctly interpreting the encoder ticks. Here are a few steps you can take:

  1. Check the Encoder Resolution: Verify the encoder resolution for your motor. Some encoders count both the rising and falling edges of the signal, effectively doubling the number of ticks per revolution.

  2. Modify the Code: Adjust the code to account for the correct number of ticks per revolution. You can do this by modifying the runTurns function to match the expected ticks.

  3. Calibration: Perform a calibration to determine the exact number of ticks per revolution for your specific setup. This can be done by running the motor for a known number of turns and measuring the ticks.

Example Code Adjustment

Here’s an example of how you might adjust your code to account for the correct number of ticks per revolution:

#include "MeOrion.h"
#include <Wire.h>
#include <SoftwareSerial.h>

MeEncoderMotor motor1(0x09, SLOT1);
float pos = 0;
const int ticksPerRevolution = 600; // Adjust this value based on calibration

void setup() {
  motor1.begin();
  Serial.begin(9600);

  Serial.print("Position: ");
  Serial.println(motor1.getCurrentPosition());
}

void loop() {
  motor1.runTurns(1, 100);
  Serial.print("Position: ");
  Serial.print(motor1.getCurrentPosition());

  Serial.print("  Change in position: ");
  Serial.println(motor1.getCurrentPosition() - pos);
  pos = motor1.getCurrentPosition();
  delay(3000);
}

Calibration Steps

  1. Run the Motor: Run the motor for a known number of turns (e.g., 10 turns).
  2. Measure Ticks: Measure the number of ticks recorded by the encoder.
  3. Calculate Ticks per Revolution: Divide the total number of ticks by the number of turns to get the ticks per revolution.

By following these steps, you should be able to adjust the encoder library to match your motor’s specifications and achieve consistent turns. If you have any further questions or need additional assistance, feel free to ask!


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.