Loading...
Pages: [1]   Go Down
Author Topic: Introducing the Pololu Dual VNH5019 Motor Driver Shield  (Read 3405 times)
0 Members and 1 Guest are viewing this topic.
Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 503
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.

We at Pololu are happy to present the Dual VNH5019 Motor Driver Shield for Arduino, an easy way to control two high-power, brushed DC motors with an Arduino or Arduino clone.  The shield operates from 5.5 to 24 V and can deliver a continuous 12 A (30 A peak) per motor.  Our Arduino library simplifies interfacing with the shield by providing methods for setting the motor speed and direction, reading the motor current, and checking for motor faults.



The VNH5019, just released by ST, is essentially a more versatile version of the VNH2SP30, so the dual VNH5019 motor shield's performance is similar to Sparkfun's Monster Moto shield, except with several key improvements:

  • Operation up to 24 V (overvoltage protection on the VNH2SP30 can kick in at 16 V).
  • Works with 3 V systems and 5 V systems (logic high threshold is 2.1 V on the VNH5019 compared to 3.25 V on the VNH2SP30).
  • Ability to power the Arduino from the motor shield through a removable jumper.
  • Ability to reconfigure the Arduino pin mappings if the defaults aren't convenient or to disconnect pins you don't want to use (e.g. diagnostic pins).
  • Motor driver pins are also broken out along the left side of the shield for general-purpose use.
  • The power inputs and motor outputs are on the opposite side of the board from the Arduino's USB connector and power jack, and they don't short to the grounded USB connector like on the Monster Moto.
  • Driver PWM pins are connected by default to Timer 1 PWM outputs rather than Timer 0 like on the Monster Moto, so ultrasonic (20 kHz) PMW frequencies can be used for quieter operation (the shield library configures the timer this way)
  • Arduino analog inputs aren't wasted on the driver's digital fault outputs.
  • Terminal blocks, 0.1" male headers, and stackable Arduino headers are included.
  • High-side reverse-voltage protection.

For more information, please see the dual VNH5019 motor driver shield product page.  The motor shield library is available now on github, and a detailed user's guide will be available in the next few days.  Please don't hesitate to ask if you have any questions, and we welcome your feedback!



- Ben
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm working on an Arduino lawn mower which runs with two DC gear motors and a brushless mowing motor.

First I ran my program on the Duemilanove without the brushless motor where the DC motors worked nice and quiet.

Then I added servo.h for running an additional brushless motor controller which unfortunately doesn't work with the Duemilanove.

With the Duemilanove:
VNH5019 uses Timer 1 which cannot be changed  smiley-confuse
Servo.h uses Timer 1 which cannot be changed  smiley-confuse

With the Mega:
VNH5019 uses Timer 1
Servo.h uses Timer 5 (I'm using Pin 11 as Pin 12 is already in use by the VNH)

The Mega now does a loud pwm-beeping (the DC-motors). (sounds like about 5-10kHz)
I took all the servo.h including etc. out of the program and tested again - the DC-Motors are still beeping.  smiley-cry

For me it looks like the VNH lib doesn't set the Timer1 correctly doesn't it?

Does anyone know what I could do?

have a nice sunday
FipsJr
« Last Edit: April 29, 2012, 07:14:42 am by FipsJr » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found the following code in the VNH cpp:

Code:
#if defined(__AVR_ATmega168__)|| defined(__AVR_ATmega328P__)
  // Timer 1 configuration
  // prescaler: clockI/O / 1
  // outputs enabled
  // phase-correct PWM
  // top of 400
  //
  // PWM frequency calculation
  // 16MHz / 1 (prescaler) / 2 (phase-correct) / 400 (top) = 20kHz
  TCCR1A = 0b10100000;
  TCCR1B = 0b00010001;
  ICR1 = 400;
  #endif

So it seems Timer1 is not set correctly with the Mega.
I'm a total Timer beginner - how is this implemented within the setup of the arduino sketch?

still whishing you a nice sunday
FipsJr
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 503
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, FipsJr.

The VNH5019 motor shield connects to digital pins 9 and 10 on the Arduino.  On the Uno, these pins correspond to the hardware PWM outputs of Timer 1, the ATmega328's only 16-bit timer.  This allows for an ultrasonic PWM frequency.  Unfortunately, for some reason, these same pins on the Arduino Mega 2560 correspond to the hardware PWM outputs of Timer 2, which is an 8-bit timer.  This seems like a poor pin-assignment choice given that the Arduino Mega 2560 has four 16-bit timers that could have been assigned to those pins instead, including Timer 1, but maybe there are some other constraints I'm not aware of that led to that decision.

You will not be able to get a 20 kHz PWM from an 8-bit timer, so you will either need to live with hearing the PWM-induced whine from your motors, or you can reassign the motor driver shield's PWM pins to the PWM outputs of a 16-bit timer.  The shield was designed to somewhat easily allow for customized pin assignments, and the shield user's guide explains how to do this.  I suggest you reassign MIPWM to Arduino digital pin 11 and M2PWM to Arduino digital pin 12.  You should also reassign M2EN/DIAG to some unused digital pin because that is assigned to digital pin 12 by default.

If you reassign the driver connections this way, the VNH5019 shield library code should just work after a few small modifications:

1) In DualVNH5019MotorShield::init(), delete or comment out the lines:
#if defined(__AVR_ATmega168__)|| defined(__AVR_ATmega328P__)
#endif

2) In void DualVNH5019MotorShield::setM1Speed(int speed), delete or comment out the lines:
#if defined(__AVR_ATmega168__)|| defined(__AVR_ATmega328P__)
#else
analogWrite(_PWM1,speed * 51 / 80); // default to using analogWrite, mapping 400 to 255
#endif

The only line from that block remaining should be:
OCR1A = speed;

3) Do the same thing for DualVNH5019MotorShield::setM2Speed(int speed), except in this case, the only line remaining should be:
OCR1B = speed;

4) Do the same thing for the setM1Brake() and setM2Brake methods.

Remember to use the constructor that provides the shield pin mappings so that the library knows about the new location for M1EN/DIAG.  Please let me know if you have any questions or run into any trouble getting it to work.

- Ben
Logged


Pages: [1]   Go Up
Print
 
Jump to: