# Outputs of the Dual VNH5019 Motor Driver Shield for Arduino

Hello, I am using the VNH5019 motor shield and Arduino Mega 2560 to drive two DC motors simultaneously. I use a 11.1V LIPO battery to drive the motors through the motor shield. In my program, I use either md.setM1Speed(400) or md.setM1Speed(-400) to turn the motors. In this case, could you please let me know the voltage that each M1A, M1B, M2A and M2B provide to turn the motors? At full cycle of ±400, do the M1A-M1B and M2A-M2B pair each send 11.1V to the corresponding motor? Thank you

Hello.

`setM1Speed(400)` should produce the battery voltage, VIN, at M1A while M1B is connected to GND (0V). In your case, M1A would nominally be 11.1V.

`setM1Speed(-400)` should flip the polarity of voltage at those outputs so that M1B would be VIN and M1A would be connected to GND (0V). In your case, M1B would nominally be 11.1V.

`setM2Speed()` will behave similarly to control M2A and M2B.

-Jon

Thank you Jonathan. What about the current outputs? The battery I use have 4500mAh of capacity.

I am not entirely sure what it is you are asking when you say “What about the current outputs?”, but it sounds like you might be expecting the motor driver to force current into the motor, which is wrong. Instead, a brushed DC motor will draw current based on the amount of load on its output shaft. At no load, there is some small current draw, which is commonly called free-run current. This specification is provided at the voltage that was applied across the motor leads. If the output shaft of the motor is fixed in place while the motor is being supplied with power, the motor will draw its stall current. We list those motor specifications under the “Specs” tab of our gearmotor product pages; here is an example. You can also find a general plot that shows how current varies with load (torque) under the FAQs tab of any gearmotor product page.

To determine for yourself if your battery has enough capacity (which is not the same as current) for your application, you can start by reading about battery capacity in this blog post.

-Jon

Thanks Jon. I make the motor turns in either direction by using the setM1Speed command. In my case, I use the parameters 400 or -400. Is this motor driver shield speed control, position control or torque control? I suspect it is speed control. Could you please clarify?

Using an Arduino and our VNH5019 motor driver shield to control a motor via the `setM1Speed()` function is an example of open-loop speed control. However, if you add a tachometer (or other device that measures speed) to your setup, the system would be able to achieve closed-loop speed control. In robotics and electronics, phrases like “speed control” commonly imply systems that are closed-loop.

-Jon

Thank you Jon.

Hi Jon, hope all is well. Am I correct that this motor driver shield provides an input signal that approximates a PWM signal? Could you please let me know the (default?) PWM frequency? The product website mentions several different frequencies. Thank you

Hi.

Motor drivers like the VNH5019 output a voltage with a frequency that is the same as the frequency that is supplied at its inputs. The VNH5019 can handle PWM frequencies up to 20 kHz, and our Arduino VNH5019 shield library uses 20kHz PWM. So, if you are using an Arduino board based on the ATmega168, ATmega328P, or ATmega32U4, your system would be using a 20 kHz PWM frequency.

-Jon

Hi, I do not have an oscilloscope to observe the outputs from the VNH5019 M1A-M1B ports. Could you please provide a screenshot or drawing on how the outputs is like if the following are executed in one test?

(Wait for 2 seconds)

md.setM1Speed(400);
delay(300);
md.setM1Speed(0);

(Wait for 3 seconds)

md.setM1Speed(-400);
delay(300);
md.setM1Speed(0);

(Wait for 1 second)
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);

(end)

For the most part, it looks like your code is pretty straightforward: it just switches between full speed forward, full speed reverse, and brake. This should produce VIN, -VIN, and 0V across the motor driver outputs. Showing you an oscilloscope capture of what that looks like for the particular case of your code is beyond the scope of our technical support. However, it sounds like you might be getting behavior that you do not expect from your code, which is something we can help you with. If that is the case, can you specifically describe what you expect to see, and what it is your system is actually doing?

By the way, calling `md.setM1Speed(400);` immediately after `md.setM1Speed(0);` both times in your third piece of code does not seem to be accomplishing much since almost no time is dedicated to the motor trying to achieve zero speed (i.e. brake). This basically has the effect of not changing the motor speed until the last line of that segment of code is executed. In other words:

``````md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
``````

is practically the same as:

``````md.setM1Speed(400);
delay(900);
md.setM1Speed(0);
``````

If you want the motor to brake, you should add some kind of delay after `md.setM1Speed(0);` like:

``````md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
delay(300);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
delay(300);
md.setM1Speed(400);
delay(300);
md.setM1Speed(0);
``````

-Jon

Thanks for the corrections. If I want to buy an oscilloscope for projects that use this motor driver, what specifications (e.g. bandwidth, sampling rate per channel, number of channels, etc.) do you recommend? One possible use is to look at the outputs from this motor driver to the motors in real-time.

In general, I expect most entry-level oscilloscopes to be able to observe the waveform of a single motor output in real time. However, if you just need to run a couple of motors from a VNH5019 shield and an Arduino, you should not need to use an oscilloscope to get that kind of system working. If you are having trouble with that, can you specifically explain what you are trying to do, what you expect to see, and what the system is actually doing?

-Jon