Arduino + Victor 888 + CIM

There have been a few threads on this in the past; I referenced to write my code.

I have a Victor 888 hooked up to a 12 V power supply and a CIM motor. Also have wires in the PWM slots, running to slot 10 on Arduino and the 5V and ground.

When I run the program, the CIM only moves in quick, short bursts. It won’t move fluidly. The Victor/CIM will then stop moving for a bit and make a high-pitched sound. I’m getting a yellow flashing signal on the Victor, which means no PWM; however the wires are soundly connected (and shouldn’t the motor not move at all if there’s no PWM?)

Here’s my code, which I think is the issue (but am not really sure either way):

#include <Servo.h>;
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(180); //turn forward full speed
delay(5000);
rightVictor.write(0); //turn off
delay(5000);
}

Never use delay(5000)! Implement a state machine to create this behavior, so that the arduino O/S can do its thing every few milliseconds.

I’m not sure if this is your issue; IIRC, the arduino will continue to pump out PWM signal from a Servo object on pin 10, but I’m not 100% sure. It may depend on which ardunio model you’re using.

This is extremely important, and a whole bunch of arduino libraries (AdaFruit Motor Shield, I’m looking at you…) botch this. Delay() should never, ever, ever be used when you actually care about the accuracy of your timing.

Just curious: what are you trying to accomplish?

Is this mostly a learning experience (if so, great!) or do you have an application in mind for this?

Search is your friend. :slight_smile:

https://www.chiefdelphi.com/forums/showthread.php?t=111424&highlight=arduino

Also, Link to reasons to Avoid Delay.

http://playground.arduino.cc/Code/AvoidDelay

While I can’t say why the motor is doing the weird jumping behavior, the neutral spot for the motor is not 0. It should be somewhere around 90 (you will need to experiment with this some to get it to work, I think in the two talons I’m currently running off an arduino it’s something like 93).

Here is my code I used. The only difference is I use #include “Servo.h” where you use #include <Servo.h>

#include “Servo.h”

Servo lDrive;
Servo rDrive;

void setup() {

lDrive.attach(10);
rDrive.attach(9);
}

void loop() {
lDrive.write(lPow);
rDrive.write(rPow);

}

Based upon the fact that they are nearly identical, I suspect it may be a wiring issue. Could you post a wiring diagram?

Also, 12V power supply? Where did you find one of those that’ll handle a CIM?

It’s a circuitspecialists.com Switching Power Supply (whatever we had laying around in the robotics classroom). Could that be the cause of my issues?

Basically trying to build a simply base bot with two CIMs, four wheels. It’s for team practice/learning.

So I removed delay and changed code to:
#include <Servo.h>;
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(100); // move motor at some speed
}

And the motor will spin constantly. However, if I use any value but 100 (0, 90, 120, etc) then the motor jumps back and forth instead of spinning constantly, and I get a no PWM signal from the Victor again. :confused: Does anyone know what I’m doing wrong??

The above is probably your issue.

Most power supplies have a current limiter (some can be user set within a range).

When the power supply hits or exceeds it’s current limit it folds back and reduces the voltage until it is at it’s current limit. Then every 100ms or so (depending on the brand/settings) it will put full voltage back on the line to see if the short / low resistance (measured as high current) has been fixed. This, in the power supply industry, is called hiccup mode.

CIM, and all electric motors, start in stall which is where they draw the most current. CIMs draw ~113 amps in stall. Your power supply is probably just protecting itself.

try your setup with a battery and breaker. That’ll prove if it’s the power supply or not.

I concur. If you do not have a suitable battery handy, try monitoring the power supply voltage. That’ll show you whether it’s dropping out.

***Hey Helianthium.

Come back and join the discussion.**

Hi everyone! Thank you so much for replying. I tried to reply on Thursday, but it seems my post didn’t go through.

I removed the delay statements and now have:

#include <Servo.h>;
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(100);

}

If the write value is 100, the motor moves continuously. Literally any other value causes the jumping behavior to return. I’m going to try hooking it up to an FRC battery instead of the power supply since some of you think that could be my issue! I’ll keep you updated

Hey everyone, problem solved! It was the power supply. Hooked it up to 12 V battery with a breaker and it works fine, 90 is 0, 0 is full reverse, and 180 is full forward. Thank you!!

I’ve had issues with arduino limits not matching up properly; i.e. write(180) would be out of bounds, use write(175) or so instead.

Yes, I’ve tried calibrating motor controller… no, it didn’t work.

https://www.arduino.cc/en/Reference/ServoAttach

It’s a function of the pulse width being wrong.