Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Cannot drive two motors at the same time using the Dual VNH5019 Motor Driver Shield for Arduino


#1

Hello, I bought this motor driver shield to use with Arduino Mega 2560. I have the shield connected to both Motor 1 and Motor 2. I used an external power supply to provide power to the motors. The Arduino is powered by either a battery box of 2xAA batteries or via the usb port of my computer.

When I commanded both motors to turn forward at the same time using:

md.setM1Speed(motor_speed);
md.setM2Speed(motor_speed);

Motor 2 turned reasonably fast but Motor 1 either did not turn or turned so slooooooowly that it looked like it did not turn. I also heard strange noise like “dooooooo doooooo dooooooo” continuously. However, when I disconnected Motor 2 from the shield, Motor 1 immediately turned reasonably fast.

When I changed the program so that only one motor turned at a time, there is no such problem.

Know how to correct this problem?


#2

Hello.

From your description, it sounds like you might need to upgrade your power supply. What are the specs of the external power supply you are using for powering the motors? What are the specs of your motors (e.g. rated voltage and stall current)? Can you post some pictures of your setup that show all of your connections, as well as close-up pictures of both sides of your VNH5019 shield?

By the way, it sounds like you are trying to power your Arduino Mega from 2 AA batteries; the minimum recommended operating voltage for the Arduino Mega is 7V, so 2 AA batteries is not an appropriate supply. It should be fine to power the Arduino from your computer via USB and power the VNH5019 shield from a separate power supply.

Brandon


#3

Are we supposed to put a delay statement after each call of md.setM1Speed or md.setM2Speed? What is the recommended parameter valu?


#4

You do not need to have a delay after calling setM1Speed or setM2Speed. The parameter passed to those functions should be between -400 and 400, with -400 being full speed in one direction and 400 being full speed in the other.

If you continie having problems, can you answer the questions in the first post?

Brandon


#5

Hi BrandonM,

The specs of the power supply are: Output: 5-15V, Max amp: 30A
Motor: rated voltage: ; voltage: 7.2V, stall current: 38A; current when there is no load: 1.2A

The motors are connected in the same way as shown in the left figure above the Section Features at:

Thanks for the reminder about the voltage requirement of the Mega. Is it OK to use a 9V battery?


#6

Thank you for that information. What voltage do you have your variable supply set to? Do you have any load on the motors? It sounds like those motors can draw significantly more current than the continuous rating of the VNH5019 shield. Brushed DC motors can briefly draw spikes of current when they try to turn full speed from rest, and the over-current protection on the driver can kick in as low as 30A. You might try running the shield at 6V and ramping up their speed to see if you can get them to both move with no load. You could use the Demo.ino from our Dual VNH5019 Motor Driver Shield Arduino library to test this.

A 9V battery should be fine for powering the Arduino Mega (although we generally do not recommend them for powering motors since they are not typically capable of supplying enough current to drive high current devices like motors).

Brandon


#7

I set it to 12V as the motors did not turn at all at 7.2V. Even a motor has no load and a motor is connected to a wheel, the problem remains. Do you have other shields that can provide more current for two DC motors?


#8

Hello.

Since the current draw of a DC motor is proportional to the operating voltage, your motor’s stall current would be upwards of 60A when running it at 12V. We generally recommend choosing a motor driver that has a continuous current rating equal to or greater than your motor’s stall current. The VNH5019 shield is the highest power motor driver we carry in an Arduino shield form factor. and the only motor controller we carry that has a continuous rating of 60A of higher is the RoboClaw 2x60A Motor Controller. Since this is a motor controller, it uses higher level interfaces than our motor drivers do and has a lot more features. I recommend reading through the product page and user’s guide found in the “Resources” tab of the product page to see if it seems appropriate for your application.

Brandon


#9

Hi Brandon,

Thanks for the suggestion. I did some more testings.

When there was no load, at 7.5V, commanding both motors to turn forward or backward led to strange “doooooooo” sounds. Sometimes one motor turned very very slowly and the other not turning at all. Sometimes both motors did not turn.

When there was no load, at 11V, commanding both motors to move forward led to both motors moving forward. However, commanding both motors to turn backward led to one motor turning only. Strange “dooooo” sound was heard.

When there was no load, at 12V, both motors turned forward or backward as commanded.

At 12V, both motors turned as desired even with loads.
This time even at 11V with load, both motors turned as desired.

Do you know what is going on?

It seems that the system is unstable and unpredictable depending on the day I tried. How come even the recommended operation voltage for the motor is 7.2V, I need to increased the voltage to 11V to see some turning.

How come without load, I needed 12V to make both motors turned as desired. However, with load, both motors turned as desired at 11V. Also, sometimes one motor turned much faster than the other.


#10

Just to be clear, are you using the VNH5019 shield in all of these tests? If so, what value of “motor_speed” are you using with the md.setM1Speed and md.setM1Speed commands? If you are not sending 100% duty cycle (e.g. a value of 400), the motor might not be getting the full input voltage and not have enough torque to turn. However, as I mentioned in my previous post, the VNH5019 shield is quite underpowered for those motors (especially at 12V). If the motor draws too much current, it can trigger the over-current protection on the VNH5109 and cut off the outputs. It is also possible that some of the variations you are seeing are due to the motors heating up. I strongly recommend switching to a more appropriate driver, and I do not think it would be useful to keep troubleshooting issues with using those motors with the VNH5019 shield.

Brandon


#11

Hi Brandon, yes I am using the VNH5019 shield in all these tests. As for the value of “motor_speed”, I use either 100 or -100 depending on which direction I want the motor to turn. Do you mean I should have used 400 or -400? Motors did not get heated up in any situation.

I tried ±200 and ±400, the original issue is fixed. However, now I have a new problem. The motors moved more than required at each iteration of the loop. For example, pressing F button turned the motors forward while pressing the B button turned the motors backward. Using ±100, the motors turned by 20 degrees when I pressed F. Then, they turned by -20 degrees when I pressed B. When I increased the values to ±200, pressing F turned the motors by say, 50 degrees. Even I pressed button B immediately after button F, the motors continued to move forward for awhile before they moved backward. Is there a solution to this?


#12

Yes, our Arduino library for the VNH5019 shield accepts speed values from -400 (full-speed reverse) to +400 (full-speed forward).

It sounds like you are doing open-loop position control of a DC motor using timing, which is typically inaccurate. If you need precise position control, you might consider looking into adding a potentiometer or encoder for doing closed-loop feedback control.

Brandon


#13

Thanks Brandon. Actually what does md.setM1Speed(speed_parameter) really do when Arduino encounters this statement? How long does such statement takes to complete? I suppose if it takes 500ms to complete, then the motor turns more if I use ±400 as the speed parameter. If I use ±100 as the speed parameter, then the motor turns less perhaps by 1/4. That might be why when I increased the value of the speed parameter, I got some kind of overshoot problem. Also, before the statement is completed (500ms in this example), whatever command I issue (e.g. changing the direction) is ignored. Am I correct? Is it true that when I use ±400, the board can generate more current to create more torque than when I use ±100?

Usually potentiometer or encoder came with some motors. Do you have ones that are generic for a wide variety of DC motors?


#14

The VNH5019 (like most motor drivers) outputs a duty cycle-controlled PWM signal. The speed_parameter you are referring to specifies the duty cycle of the PWM, so a higher duty cycle increases the effective voltage to the motor (resulting in increased speed and torque). The delay between receiving the signal and changing the output should be on the order of miliseconds (e.g. a couple orders of magnitude less than 500ms), and it should not ignore any commands issued directly after it. The direction signal is on another input pin, so a change in this signal should always affect the driver (e.g. once you set the direction output on the Arduino, it will stay outputting that signal until it is changed again). I suspect the overshoot you are seeing is due to the motor coasting to a stop.

We do not carry any generic feedback solutions; the only encoders that we carry separately are the encoders intended for our micro metal gearmotors.

Brandon


#15

Thanks Brandon, is there a way to reduce or avoid the overshoot? Imagine I am controlling the spinning direction of the motor using a remote controller. Right now, it takes time for the motor to change direction. Sometimes it causes problems due to a delay in responding correctly from the motor.


#16

My recommendation for avoiding overshoot with your motor would be to add some type of feedback, as I mentioned before.

Brandon


#17

Thanks Brandon. You mentioned that I should have used ±400 as the parameters since a higher duty cycle increases the effective voltage to the motor (more torque). I found that the problem of one motor turning while the other either turning very very slowly or not turning at all could be eliminated when I had large values as the parameters. So, it is good to use ±400. However, larger values also means motors turning faster. What if I want to have a lower speed motion? I suppose the reason md.setM1Speed(motor_speed); accepts values from -400 to 400 is to allow a wide range of speeds depending on the user’s need. I have already added a gear head to each motor.


#18

The speed and torque of a DC motor is proportional to the operating voltage. Since the duty cycle controls the effective voltage to the motor, you can adjust the duty cycle to set the speed and torque your application needs, as you mentioned.

Brandon


#19

Hi Brandon, can I set the speed and the torque independently? From you replies, I use md.setM1Speed(400) to create high speed turning and high torque. What if I want lower speed but higher torque? Can adding a delay statement after each call of md.setM1Speed(400) achieve this?


#20

Speed and torque of a brushed DC motor are both proportional to the operating voltage and are properties of the gearmotor you are using. The driver cannot adjust the parameters of the motor beyond the relationship they have with the operating voltage. Adding a delay statement after setting the duty cycle will simply run the motor at the specified duty cycle for the delay time before moving on to the rest of your code.

It sounds like you might not have tried to research or understand the problem before coming up with possible solutions. If the problem is still the same as you described before, I have already given you my recommendation of adding feedback. Beyond that, if you just need your motor to move slower with higher torque, you might consider switching to a higher gear ratio or adding an additional reduction.

Brandon