Go Down

Topic: two motors running at the same time- PWM (Read 2156 times) previous topic - next topic

kinetical

Hi,

Newbie here, I am trying to make two motors work the same way at the same time using Arduino with Victor 883 Motor speed controllers, I am trying to make adjustments to a program for one motor which works fine for the one motor. http://autonomous-emaxx.googlecode.com/files/victorMotorController.pde

With my changes: int motor_pin = 11;  // define the pin which will send the motor commands
int motor_pinb = 10;  // define the pin which will send the motor commands
int motor_input = 210; // set the input to the motor (must be between 0-255)
int motor_inputb = 210; // set the input to the motor (must be between 0-255)
// For the Victor I'm using, the dead zone is 185-193, below this is rev above is fwd



// Setup the program

void setup()

{

 //General setup

 Serial.begin(115200);



 //Motor pin setup

pinMode(motor_pin, OUTPUT); // sets the motor pin as an output
 pinMode(motor_pinb, OUTPUT); // sets the motor pin as an output
}



// Run the program loop to control the motor speed

void loop()

{

 analogWrite(motor_pin, motor_input);  // writes the specified motor value from the specified pin
 analogWrite(motor_pinb, motor_inputb);  // writes the specified motor value from the specified pin

}

Still only one motor runs- what am I missing?

And then further, I want to know how to change speeds and make it go backwards.  Thanks for your advice.

keeper63

If you comment one or the other analogWrite() out, does the respective motor work then? If it doesn't, try swapping the controller (maybe one of the controllers is bad?). If you still aren't getting anywhere, try a different AnalogWrite pin (3,5,6,9) for the one that isn't working. You might also try hooking up LEDs to those pins, and seeing if the LED lights up (or flickers, depending on the PWM) - also, try hooking a potentiometer up to an analog input, mapping the output of the input (from 0-1023 to 0-255), then feeding that into the AnalogWrites with the LEDs connected to see if you can vary one or both of the LEDs on each line.

As far as I can see (without knowing anything else about your setup), this should work; you're going to have to do a bit more troubleshooting...

Good luck!
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Photo-Worx

I altered the code to make it fade 2 leds and the code works just fine. It could very well be hardware.
Here is the altered code if you want to try it with your controller. if you only want it to go forward change your 0's for motor_input and motor_inputb to 194. Also change the 0's in the for loops to 194.

Dan

Code: [Select]

int motor_pin = 11;  // define the pin which will send the motor commands
int motor_pinb = 10;  // define the pin which will send the motor commands
int motor_input = 0; // set the input to the motor (must be between 0-255)
int motor_inputb = 0; // set the input to the motor (must be between 0-255)
// For the Victor I'm using, the dead zone is 185-193, below this is rev above is fwd



// Setup the program

void setup()

{

//General setup

Serial.begin(115200);



//Motor pin setup

pinMode(motor_pin, OUTPUT); // sets the motor pin as an output
pinMode(motor_pinb, OUTPUT); // sets the motor pin as an output
}



// Run the program loop to control the motor speed

void loop()

{
for (int i=0; i <= 255; i++){
motor_input = i;
motor_inputb = i;
analogWrite(motor_pin, motor_input);  // writes the specified motor value from the specified pin
analogWrite(motor_pinb, motor_inputb);  // writes the specified motor value from the specified pin
delay(10);
}

for (int i=255; i >= 0; i--){
motor_input = i;
motor_inputb = i;
analogWrite(motor_pin, motor_input);  // writes the specified motor value from the specified pin
analogWrite(motor_pinb, motor_inputb);  // writes the specified motor value from the specified pin
delay(10);
}
}


kinetical


Go Up