Driving dc motors with pololu VNH5019

I have an existing code (working) that was designed to drive two dc motors with an arduino uno and an adafruit motor shield (with two L293D).

Now I changed to code to work with a pololu VNH5019 motor driver. The motors react to the commands (characters) sent by the transmitter. The problem is that motor 1 is always running at full speed, while motor 2 runs according to the case commands.

What I did was:

  • included the VNH5019 library (#include "DualVNH5019MotorShield.h")
  • DualVNH5019MotorShield md;
  • md.init();
  • changed the motor commands (md.setM1Speed()) in each case

Does anyone know why motor 1 is not running at variable speeds?

RX_433Mhz_Robot_mod_delay_vnh5019.ino (2.49 KB)

Could be a wiring problem. You need to post a link to the hardware and a schematic showing how things are wired.

Could be a library problem. You need to post a link to the library.

Hi Paul

A wiring problem can be pretty much ruled out (the motors are connected according to the datasheet). I tested the motors with this code:

The library I took from here:

thanks for Your help!
Laurin

A wiring problem can be pretty much ruled out

A wiring problem can be ruled in or out only by writing a simple sketch that sets the speed of one motor to several different speeds, with delay()s between each change. If one motor works, change the sketch to the other motor. If each works to control the speed and direction of one motor, the wiring is correct.

Hi Paul

I solved this problem. I had a servo attached to pin9, which is used by the shield for the speed of motor 1. I just removed this line and now motor 1 works fine.

But now I'm facing another problem: Every now and then, the two motors get stuck at full speed (forward or reverse). When I turn off the transmitter, the motors keep running. Only powering down both the arduino and the vnh5019 stops them.

I already checked the incoming comands on the receiver side with the serial monitor. They seem to be OK.
It can't be a stack overflow, right?

Thanks in advance!

I have to add: The motors do not necessarely rest at full speed. The code just seems to get stuck in one of the cases randomly.