Arduino UNO to CIM Motors via Victor Sp

I have my connections pretty much as it says in the title. I am having issues getting my motors to turn competently. I am using the Servo library and I’ve been fiddling around with the template program but I cannot seem to get my motor to stop turning in one direction. Theres no while loop,

Servo rightVictor;// create servo object to control a servo
int rightVictorPin = 10; // twelve servo objects can be created on most boards

void setup()
{
rightVictor.attach(rightVictorPin);
pinMode (rightVictorPin, OUTPUT);
analogWrite (rightVictorPin, 192);
}

void loop ()
{

rightVictor.writeMicroseconds(1000); 

delay (15); 

}

Why wont the motor stop?

Have you calibrated the Victor? It may be offset from a previous calibration. What are the Victor LEDs telling you?

What language is it you’re using?
It appears you just need to send a value of 0 to the output pin. In C++ the speed range is -127 to 127, with 0 being stop.

In an arduino sketch, the code in the void loop() section gets called repeatedly forever.

void loop () {
    rightVictor.writeMicroseconds(1000);
    delay (15);
}

Why wont the motor stop?

You never told it to.

What your code is doing is repeatedly updating the output PWM signal going out to the motor controller to the same value (1000). It never changes the “speed” you’ve commanded the motor to travel at. If you wanted the motor to drive for a period of time, then change speed/stop, you need to have that change of event occur within the loop() function.

Something else, you’re setting the speed of the motor in the setup function using the AnalogWrite function. AnalogWrite would be used when you’re actually trying to approximate an analog voltage. The output frequency is lower than what you need for some motor controllers. Side note: on paper it looks like it should work with the Victor SP.

I’d suggest revising your code to something more like the following. The reason is the values you use to command the motor speed are different depending on which library you use, and the following code examples won’t work correctly unless you are using the servo library.


Servo rightVictor;// create servo object to control a servo 
int rightVictorPin = 10; // twelve servo objects can be created on most boards

void setup() {
  rightVictor.attach(rightVictorPin);  // attaches the servo on pin 10 to the servo object
}

void loop() {
    rightVictor.write(23);  // turn the motor at 75% speed in one direction 
    delay(5000);
    rightVictor.write(90);  // stop the motor
    delay(5000);
}

The above code will loop through the following actions repeatedly:

  • run the motor at ~75% speed in one direction
  • wait for 5 seconds
  • stop the motor from tuning
  • wait for 5 seconds

The above code uses the Servo write() function. It accepts values from 0 to 180. where 0 is full speed in one direction and 180 is full speed in the other direction. Speeds output by the motor controller will be scaled for values between 0 and 180. So a value close to 90 will be off. For this to work perfectly, you may need to calibrate the motor controller for outputs of the above range (0, 180, 90).

Hopefully that helps get you moving in the right direction.