Critical Velocity Motor Controller & Arduino

Hi guys--

We're having some issues with controlling the speed of our motor using a Critical Velocity Motor Controller.

Parts:

  • Arduino duemilanove
  • Critical Velocity Motor Controller - 5.5-36V and 15A
  • A PMDC 36V, 12.8A motor (350W)

The manual for the controllers say that in order to control the motor speed, we can just pulse the Up and Down lines on the controller:

But by using this code, we can't achieve that. The motor either runs at full speed or at zero speed when the up and down lines are pulsed respectively.

Code:
int RUp = 3; //Right Motor Speed Up
int RDown = 5; //Right Motor Speed Down
int REnable = 7; //Right Motor Disable

void setup()
{
pinMode(REnable, OUTPUT); // sets the digital pin as output
pinMode(RUp, OUTPUT); // sets the digital pin as output
pinMode(RDown, OUTPUT); // sets the digital pin as output
digitalWrite(REnable, HIGH); // Raise Right Motor speed by 0.4%
analogWrite(RUp,10);
}

void loop()
{

}

So at this point, we have no control of the motor speed. It either goes max speed or zero speed with this code.

I think the frequency of the Arduino is too high for the controller. The controller is at about 200Hz. And the Arduino at about ~400Hz. So the arduino is sending pulses so many times that the controller just ends up running the motor at max speed and at min speed.

How can we change the frequency the arduino outputs at? Can someone help please?

Thanks.

How can we change the frequency the arduino outputs at?

Isn't the 200Hz the output frequency of the controller?

Have you got the jumpers set correctly?

If you feed PWM to the UP pin, it'll reach max speed very quickly and stay there.

You need to pass individual pulses to UP until you reach the desired speed. (bottom of page 2) - it clocks on rising edges.

digitalWrite(REnable, HIGH);   // Raise Right Motor speed by 0.4% Wrong.

Hey you're right. We got it working by pulsing the up signal high, doing a delay, then pulsing it low.

And we put this code in a for-loop to be able to control the number of pulses.

Btw another is that we didn't realize that we had to reset the signals on all of the pins every time we made a change to the code. Because the old settings of the pins still stay on the MCU even when u change the code and recompile.

another is that we didn't realize that we had to reset the signals on all of the pins every time we made a change to the code. Because the old settings of the pins still stay on the MCU even when u change the code and recompile

I think it more likely that the ESC remembers the settings, rather than the Arduino!

Looking over that manual you linked to there appears to be two ways to control the speed of the motor with that PWM motor controller.

  1. Pulsing the up and down digital inputs on the controller. This allows one to use two manual monentary switches or as you are doing two digital outputs pins from an Arduino.

  2. If accepts a analog voltage from an external pot. Or if you used a Arduino PWM output pin followed with a low pass filter (a resistor/cap) you could control speed using the Arduino analogWrite() commands.

Both methods have the same basic limitation, your Arduino has no idea what the actual speed of the motor is at anytime. That is, there is no speed feeback information avalible to the Arduino. One could attach a optical or magnetic speed sensor to the motor shaft and read the pulses directly into the Arduino and then calculate the speed. This could then be used in your Arduino sketch to decide when and how much to increase or decrease the speed commands to the PWM controller.

Lefty