Modified VNH5019 shield library for 20kHz PWM with Mega

For pin 3, I used OCR3C, not OCR3B. I got it to work on Motor1, next to try Motor2 with the demo code. I’m very grateful for your help!

Once its fully working, If anyone else would find it useful. let me know and I’ll attach the library.

Thanks for letting us know you got it working for one motor. I am sure that others would find it really useful if you post your final code.

-Claire

Here is my modified Dual VNH5019 library for the Arduino Mega that does 20 kHz PWM on pins 3 and 5, together with some other remappings so that the Ethernet shield can be used at the same time as the Dual VNH5019 Shield.

Pin mappings

Pin 2 M1INA no change
Pin 3 M1PWM remapped from pin 9 (20kHz)
Pin 4 M1INB no change
Pin 5 M2PWM remapped from pin 10 (20kHz)
Pin 6 M1EN no change
Pin 7 M2INA no change
Pin 8 M2INB no change
Pin 9 M2EN remapped from pin 12

So now, both PWM outputs to control the motors are on Timer3, and pins 10 to 13 are free for the Ethernet shield, as mentioned in a previous post.

I have tested this with Ethernet control and it’s been working fine. Thanks again, Claire for your help to get this done.
DualVNH5019MotorShieldMega.zip (3.61 KB)

Thank you for sharing your modified library, Paul; I am glad you were able to get it to work with your Ethernet shield!

-Brandon