Problem remapping PWM pins on the Dual VNH5019 Driver

I’m using an Arduino Uno or Mega with an Ethernet Shield and the Pololu Dual VNH5019 motor controller shield. The Ethernet shield uses pins 10, 11, 12 and 13. Therefore I would like to remap M2PWM from pin 10 to pin 8 (and M2INB from pin 8 to pin 3).

However, the comment in the library file says that the PWM lines can’t be remapped because the library assumes timer 1. If that is the case why are they re-mappable on the PCB.

Please can someone more experienced advise how they may be reconfigured so that I can use the Ethernet shield at the same time as the motor controller shield? Thank you.


Our VNH5019 library does not use timer1 to produce PWM signals with the Arduino Mega. Instead, the library produces the PWM signal using analogWrite(). On the Arduino Mega, analogWrite() works with pins 2 - 13 and 44 - 46, so you should be able to remap the shield to use one of those pins to produce the PWM signal instead. Then you can call analogWrite() directly from the program and not use the VNH5019 library to control your motors.

Please note, analogWrite() produces a 490 Hz PWM signal. Some of our customers have modified our library to add support for using timers on the Arduino Mega, which allows them to produce 20 kHz PWM signals. You might find this thread on setting multiple timers for the Arduino Mega helpful.

- Jeremy

Hi Jeremy,

Thanks for explaining that. I will give it a try. Just to clarify, I was using the shield with the Mega to try the example sketch and it worked fine with the functions in the library and not analogWrite(). So just to clarify, this worked because the shield was using the default PWM pins if it was used with a non Mega, but if a Mega is used it used analogWrite().

So If I remap the pins, I use analogWrite (), and a value between 0 and 255?

When using our VNH5019 library with an Arduino Mega, the function setMxSpeed() calls analogWrite() instead of setting timing parameters for hardware PWM. If you remap the pins, you will be able to set the duty cycle of your motor by calling analogWrite().

- Jeremy