Arduino UNO + Jaguar Speed Controller + CIM Motor

I have connected a CIM motor to a Jaguar speed controller, powered by 12V battery. The jaguar is connected to an Arduino UNO via the signal and ground. Also, I have two switches connected to the Arduino, for forward and reverse of the motor.

In the code, for speed of the motor, I have set 90 as the mid point and 100 for forward and 80 for reverse. When I push the reverse button, the motor runs smoothly in the reverse direction at the set speed. However, the problem is, when I press the forward button, the motor runs seemingly slower in the forward direction than the set speed. My logic here was, if I have set speeds in forward and reverse at +/- 10 from the mid-point, the motor should run at the same speed in the forward and reverse direction, but this is not happening.

I am pasting my code below. Any help would be much appreciated. Thank you!

#include <Servo.h> 

int forwardPin = 2;
int reversePin = 4;
int motorPin = 10;
int fwdReading = 0;
int revReading = 0;

Servo myservo;

void setup() 
{ 
  TCCR1B = TCCR1B & 0b11111000 | 0x04; // PWM Freq. at 122Hz
  
  pinMode (forwardPin, INPUT);
  pinMode (reversePin, INPUT);
  myservo.attach(motorPin);
  myservo.write(90);  // set servo to mid-point
} 

void loop() 
{
  fwdReading = digitalRead(forwardPin);
  revReading = digitalRead(reversePin);
  
  if (fwdReading == HIGH)
  {
    myservo.write(100); // forward
  }  
   else if (revReading == HIGH)
  {
    myservo.write(80); // reverse
  }
  else
  myservo.write(90); // neutral
}

You are expecting precise calibration from cheap hobby RC components - they are not precision components, they are cheap hobby devices designed for RC toys.

@MarkT The components are used in FIRST Robotics competitions. We have been using CIM motors and Jaguar speed controllers for years to compete and they are highly reliable. This is my first time using the arduino to control the motor through Jag, so don't really know why the forward direction is slower than the reverse direction :neutral_face:

Most dc brushed motors will have a variance in speed from forward to reverse at the same voltage. Its just the nature of the mechanical tolerances and friction and brush shape/design.

Sometimes changing direction just sounds different. Even at the same speed.

That speed controller is quite nice .. it has closed loop speed control modes and does PID calcs for you. You do need some type of encoder for proper speed control for this type of motor. You can probably get a nice ready made encoder that goes on the shaft of the motor depending on the size.

@alka Oh okay that makes sense. So, basically the system is perfect as desired then. Including the code right? Thanks alot! Appreciate it :slight_smile: