I’m interested in using three Pololu Dual VNH5019 Motor Driver Shield for Arduino (https://www.pololu.com/catalog/product/2502) to run 6 motors. I do not plan on stacking them as actual shields. My arduino is a duemilanove ATMega328.
I have already purchased one shield and have been successful in running two motors, controlling their speed based upon feedback from a proximity sensor I am using. I do not need individual direction control for each motor from the arduino, as they will all always be moving forward. I also will not be using any of the feedback from the driver.
My general plan is to add to the existing library (http://github.com/pololu/Dual-VNH5019-Motor-Shield) for this shield to add commands for motors 3 through 6. I’ll provide direction control to each of the motors from the default pins for motor 1 on the arduino, pins 2 and 4.
As a first proof of concept for myself, I’ve attempted to modify the library to remap the speed control for motor 1 from pin 9 to pin 10. (The library warns specifically against this, I guess I’m just a fool rebel.)
I believe there are only two portions of the library I need to change, one in the header and one in the main body file. Is this correct?
Here’s the first bit, from the header:
private: unsigned char _INA1; unsigned char _INB1; static const unsigned char _PWM1 = 9; // NEED TO CHANGE THIS LINE TO 10
The second part is what I think is giving me trouble. From the comments I learned that the default pins are on timer1. From my reading I’ve learned that the arduino has 3 timers, with different clock speeds. But I can’t figure out how to modify the following few lines to be able to use pin 10 for speed control of motor 1. How do I do this?
#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
Help would be greatly, greatly appreciated, and rewarded with a beer if you come to Boston!
EDIT: I just realized that pin 10 also uses timer1, but the same question still applies, as I want to use all of the arduino PWM outputs.
P.S. Thank you to Pololu for the awesome user guide, it persuaded me to purchase the driver from you even though I suspect that equally capable drivers could be had for less.