Go Down

Topic: motor drive shield - reverse rotating doesn't work (Read 1 time) previous topic - next topic

wangxinghe88

Mar 15, 2013, 11:10 pm Last Edit: Mar 15, 2013, 11:21 pm by wangxinghe88 Reason: 1
I used arduino due and Cytron 10A, 3-25V Single DC Motor Controller
(http://www.robotshop.com/ca/cytron-single-dc-motor-controller-3.html)
to control Banebots 12V 15500rpm, 16.65oz-in (stall) RS-395 Brushed DC Motor (http://www.robotshop.com/ca/banebots-12v-15500rpm-16-65oz-in-stall-rs-395-brush-dc-motor.html)

I tested the driver shield with the program below:


// PWM is connected to pin 3.
const int pinPwm = 3;

// DIR is connected to pin 2.
const int pinDir = 2;

// Speed of the motor.
static int iSpeed = 0;

// Acceleration of the motor.
static int iAcc = 1;


/*******************************************************************************
* FUNCTIONS                                                                    *
*******************************************************************************/

// The setup routine runs once when you press reset.
void setup() {                
 // Initialize the PWM and DIR pins as digital outputs.
 pinMode(pinPwm, OUTPUT);
 pinMode(pinDir, OUTPUT);
}



// The loop routine runs over and over again forever.
void loop() {
 
 // Control the motor according to the speed value.
 // Positive speed value = CW,
 // Negative speed value = CCW.
 if (iSpeed >= 0) {
   analogWrite(pinPwm, iSpeed);
   digitalWrite(pinDir, LOW);
 }
 else {
   analogWrite(pinPwm, -iSpeed);
   digitalWrite(pinDir, HIGH);
 }
 
 // Increase/Decrease the speed according to the acceleration.
 iSpeed += iAcc;
 
 // Change the acceleration sign when full speed is reached.
 if ((iSpeed >= 255) || (iSpeed <= -255)) {
   iAcc = -iAcc;
 }
 
 
 delay(10);
}

but the result is the motor works well on the CW part, speed up to the highest speed and then slow down to zero.
but the speed keeps zero in the CCW part. which is very wield. So then I test the program below:

// PWM is connected to pin 3.
const int pinPwm = 3;

// DIR is connected to pin 2.
const int pinDir = 2;



void setup() {                
 // Initialize the PWM and DIR pins as digital outputs.
 pinMode(pinPwm, OUTPUT);
 pinMode(pinDir, OUTPUT);
}



// The loop routine runs over and over again forever.
void loop() {
 

   analogWrite(pinPwm, 200);
   digitalWrite(pinDir, HIGH);

 delay(10);
}

Nothing happens, the motor is off and the LED B on the motor drive controller is off.
Can anyone tell me if I have made any mistakes? Thanks a lot.


Grumpy_Mike

A 10mS delay is very short, meaning the motor will ramp up in just over 2 seconds.

Use some print statements to see what values your variables are taking.

wangxinghe88

I tested the controller with another program posted above. I didn't connect the motor in my circuit, and observe the CW/CCW LED A and B, I found the the CCW LED B is always off. Why?

Grumpy_Mike

Quote
Why?

Hard to say.
Do some investigating.

Move the wire from the arduino to 3V3 and to ground, does the direction LED change?
Attach a 1K resistor and an LED to the arduino pin and ground, does that change when you expect it to?

wangxinghe88


Quote
Why?

Move the wire from the arduino to 3V3 and to ground, does the direction LED change?
Attach a 1K resistor and an LED to the arduino pin and ground, does that change when you expect it to?


I use a battery(12V) to power the drive controller and USB to power the arduino.
I test the pin DIR of the drive controller and found it is high when I want the motor rotate CCW, which is right.
but the motor seems stop when the DIR is high

wangxinghe88

problem solved. I should use 5V from the board for the controller instead of from the battery. :)

Go Up