Version: 3.0.0
Release Date: 2018-04-11
www.pololu.com
This is a library for the Arduino IDE that interfaces with the Pololu Dual VNH5019 Motor Driver Shield. It makes it simple to drive two brushed, DC motors.
This library is designed to work with the Arduino IDE versions 1.6.x or later; we have not tested it with earlier versions. This library should support any Arduino-compatible board, including the Pololu A-Star 32U4 controllers.
The Dual VNH5019 Motor Driver Shield can be purchased from Pololu's website. Before continuing, careful reading of the product page as well as the product user's guide is recommended.
If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library:
If this does not work, you can manually install the library:
An example sketch is available that shows how to use the library. You can access it from the Arduino IDE by opening the "File" menu, selecting "Examples", and then selecting "DualVNH5019MotorShield". If you cannot find these examples, the library was probably installed incorrectly and you should retry the installation instructions above.
The demo ramps motor 1 from stopped to full speed forward, ramps down to full speed reverse, and back to stopped. Then, it does the same with the other motor. Current readings for each motor are sent over serial and can be seen with the serial monitor. If a fault is detected, a message is sent over serial.
DualVNH5019MotorShield()
DualVNH5019MotorShield(unsigned char INA1, unsigned char INB1, unsigned char PWM1, unsigned char EN1DIAG1, unsigned char CS1, unsigned char INA2, unsigned char INB2, unsigned char PWM2, unsigned char EN2DIAG2, unsigned char CS2)
void init()
void setM1Speed(int speed)
void setM2Speed(int speed)
void setSpeeds(int m1Speed, int m2Speed)
void setM1Brake(int brake)
void setM2Brake(int brake)
void setBrakes(int m1Brake, int m2Brake)
unsigned int getM1CurrentMilliamps()
unsigned int getM2CurrentMilliamps()
unsigned char getM1Fault()
unsigned char getM2Fault()
The current readings returned by getM1CurrentMilliamps
and
getM2CurrentMilliamps
will be noisy and unreliable if you are using
a PWM frequency below about 5 kHz. We expect these readings to
work fine if you haven't remapped the PWM pins and you are using a
board based on the ATmega168, ATmega328P, ATmega328PB, or ATmega32U4,
since this library uses 20 kHz hardware PWM on those boards.
On other boards, this library uses analogWrite
to generate PWM
signals, which usually means that the PWM frequency will be too low to
get reliable current measurements. If analogWrite
uses a frequency
of 490 Hz or more on your board, you can add a 1 µF
(or larger) capacitor between each current sense line you are using
and GND. To make getM1CurrentMilliamps
work well, you would add the
capacitor between M1CS and GND. To make getM2CurrentMilliamps
work
well, you would add the capacitor between M2CS and GND.