OUT1 – Motor (+)
OUT2 – Motor (-)
VIN – POWER (9v)
GND – (-) GND
And using this Arduino code:
int ledPin = 13; // LED connected to digital pin 13
int pwmPin = 11; // PWM Motor driver (/D2 pin pin on MC338870 motor board)
int motorPin1 = 28; // Motor pin 1 (IN1 on MC338870 motor board)
int motorPin2 = 30; // Motor pin 2 (IN2 on MC338870 motor board)
//Leave D1 and /FS and /FB unconnceted
//Connect the EN to +5V on Arduino board
void setup() {
pinMode(ledPin, OUTPUT); //initialize the digital pin as an output:
pinMode(pwmPin, OUTPUT); //initialize the digital pin as an output:
pinMode(motorPin1, OUTPUT); //initialize the digital pin as an output:
pinMode(motorPin2, OUTPUT); //initialize the digital pin as an output:
Serial.begin(9600);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin,HIGH); //set led HIGH
digitalWrite(motorPin1,LOW);
digitalWrite(motorPin2,HIGH);
analogWrite(pwmPin,100); //set speed to 100
delay (5000);
digitalWrite(ledPin,LOW); //set led LOW
digitalWrite(motorPin1,HIGH);
digitalWrite(motorPin2,LOW);
analogWrite(pwmPin,-100); //set speed to -100
delay(5000);
}
This code is supposed to make the motor go forward for five seconds then
reverse for five seconds (loop).
When I upload the program to the Arduino (with all the connections made), the led blinks every five seconds but the motor does not move.
I also tried connecting IN1 and IN2 to the digital pins on the Arduino (28, 30), but that didn’t work either.
I don’t know what’s wrong.
PS. It would be useful to add a LED to the Motor Driver Board.
I know it’s a little late now, but did you see that we carry a motor driver shield for the Arduino that uses that same MC33926 motor driver? That shield does incorporate power and motor indicator LEDs.
I suspect your problem is that you are not properly enabling the board. Note that both of the disable pins (D1 and D2) default to “disable”, so you must enable the board by pulling/driving any unused disable pins to the appropriate level. In your case, it looks like you need to be setting D1 low.
Another problem I notice is with your code:
analogWrite(pwmPin,-100); //set speed to -100
It is not valid to supply analogWrite() with a negative argument. Do you understand what the signal looks like on the pwmPin when you call analogWrite(100)? What do you expect it to look like when you pass it a -100?
Finally, it sounds like you might be using a 9V battery to power your motors. In general, 9V batteries are very poor choices for high-current applications like this. If this is what you are currently using, I suggest you switch to a more appropriate power supply, such as a NiMH battery pack.
Just connect D1 directly to ground or to a digital output from your Arduino that is driving low. You did not address my question about supplying a negative argument to analogWrite(), so I am not convinced you understand the proper procedure for making the motor turn in the other direction. Do you know why an analogWrite() value of -100 doesn’t make sense?
9V is not a possible nominal NiMH voltage. Are you using an 8.4V, 7-cell pack?
Sorry to confuse you, but I’m using a 8-cell Ni-Cd 9.6V battery.
I did understand my error in analogWrite(). To make the motors run in reverse, you do this:
Hello,
For some reason I cannot upload the photos (says “The image file you tried to attach is invalid.”).
I this will give you anything, I have two 0.1u capacitors on the motor.
What kind of image file are you trying to attach? If they are not working as forum attachments, could you try uploading them to a free image hosting site (e.g. photobucket.com/) and linking to them?
Thank you for the pictures. Your connections on the driver look correct, though I cannot see enough of your Arduino to verify that they are going to the right places. Assuming the connections are as you described, I suspect that either your motor is too powerful for this driver and is triggering a protection fault (do you have any idea how much current it draws?) or you have a bad solder joint.
Can you disconnect your motor from the driver and change your loop() function to:
Thank you for the additional picture. Your solder joints look good from what I can see. I am not sure why it isn’t working for you, but I think the way to get to the bottom of your problem is to simplify as much as possible. For example, take the Arduino and motor out of the picture entirely and just connect IN1 to 5V, IN2 to GND, and D2 to 5V while doing the appropriate things with the various enable pins. Check with your multimeter that the inputs have the voltages you want, and look at the outputs. You might also use your multimeter to verify that your solder joints are good, and to look to make sure your input voltages are making it to various points of the driver you expect. If you still get nothing on the outputs, the driver might be damaged, but note that we test every board before it ships and these are relatively robust drivers, so I am optimistic that the board is still functional.
Is it not necessary to connect VDD to 5 V ? From the picture attached I can not see it connected. Actually this afternoon I was just trying to setup the simple configuration using just IN1 and IN2 (and the rest of default pins) and could not get the motor going, now I am just missing VDD pin.
The VDD pin is only required to be connected to use the optional jumpers or if monitoring the SF pin. You can see how VDD is connected to the circuitry of the board in the schematic diagram shown on the product page for the MC33926 carrier board.