Arduino & MC33926 Motor Driver Carrier problem

Hello,
I have been trying to connect the MC33926 motor driver to an Arduino Mega 2560, using these connections:

EN – 5v
GND – GND
IN1 – 7 (PWM)
IN2 – 8 (PWM)
D2 – 11 (PWM)

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.

Thanks,
Boris.

Hello, Boris.

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.

- Ben

Hello,
Thank you for answering.

Can you give me more information on how to set D1 to LOW?
Also, I am using a 9v NiMH battery pack, not a 9v battery.’

Thanks.

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?

- Ben

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:

digitalWrite (in1, LOW);
digitalWrite (in2, HIGH);

or the other way around.

Anyway, the motor still does not run even with D1 on ground or set to LOW.

Thanks.

Can you post a picture of your setup? What is the stall current of your motor?

- Ben

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.

Boris.

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?

- Ben

Okay, here are the links to photobucket:

http://s1052.photobucket.com/albums/s443/WhaetleyCore/?action=view&current=36d8301c.jpg
http://s1052.photobucket.com/albums/s443/WhaetleyCore/?action=view&current=54000163.jpg

Boris.

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:

void loop()
{
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(pwmPin, HIGH);
}

While the program is running, can you look at the motor outputs with a multimeter? Also, can you post a picture of your driver’s solder joints?

- Ben

Okay, here is the photo of the solder joints:

http://s1052.photobucket.com/albums/s443/WhaetleyCore/?action=view&current=752b5476.jpg

When I used your piece of code I got 0.05 volts on my mutimeter,
(the battery is fully charged: 9.6v on the multimeter).

?

Boris.

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.

- Ben

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.

Hello.

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.

-Nathan