Hello, I am beginner I am working on project, tying to connect VNH5019 Motor Driver Shield for Arduino (Item# 2507) to two Metal Gearmotor 25Dx65L mm MP 12V with 48 CPR Encoder(Item# 4863).
How to i need to make the connections between Motor and VNH5019
|Red|motor power (connects to one motor terminal) - M1A
|Black|motor power (connects to the other motor terminal) - M1B
|Green|encoder GND| - GND ? is this right?
|Blue|encoder Vcc (3.5 V to 20 V) - ? What should go here
|Yellow|encoder A output - ? is this M1INA? is this right?
|White|encoder B output - ? is this M1INB? is this right?
What should go to M1EN/DIAG and M1PWM ?
and what should the Blue (encoder Vcc ) connect to?
As you described, the red and black wires from the motor should go to the M1A and M1B motor output pins on the Dual VNH5019 Motor Driver Shield. The rest of the wires from the gearmotor are for the encoders, so the red and black wires are the only connections you need to drive the motor.
Please note that the VNH5019 shield does not have any special support for reading or processing encoders, but if you are mounting the Dual VNH5019 Motor Driver Shield on top of the Arduino (i.e. as a shield), you can use the pass-through headers to make the connections to the Arduino. First, you can power the encoders by connecting the green wire to one of the shield’s GND pins and the blue wire to the shield’s VDD pin. The yellow and white wires are the encoder signals; what pins you use to read these signals is up to you and should match your code, but you should not connect them to any of the pins already used by the shield (including the M1INA and M1INB pins). So, unless you know how to account for any potential conflicts it could cause, it would be best to avoid any of the pins called out in this diagram:
Thank you Brandon. I used pins 3 and 5 for the encoder outputs. I connected the blue wire to the 5v pin and the green to the GND beside the 5v pin. I used 8 AA batteries to power the Motor. M1A and M1B are connected to the red and black wired, I used USB power for the Audrino Uno.
I used below code to test the motor. Nothing happened. Also, no LED lights were ON on the shield.
Could you post some pictures of your setup that show all of your connections, including some close-up pictures of both sides of your dual VNH5019 motor shield?
It looks like some of your solder joints are not wetting properly to the pads, especially the ones on the larger power and motor output pins. Those pads are fairly large and require quite a bit more heat compared to the smaller 0.1" pins (some of which might also benefit from some rework). Could you try re-flowing those solder joints until they are fully wetted to both the pin and the pad? I recommend referring to Adafruit’s Guide to Excellent Soldering for help identifying and fixing potential trouble joints.
Also, a 9V battery is almost certainly not suitable for powering the #4863 gearmotors. You can find more information about why 9V batteries are not recommended for this kind of application in our “Understanding battery capacity: Ah is not A” blog post.
Thanks Brandon for the Information. I will certainly redo the solder joints and try again.
Also, I was planning on using 8 AA battery pack for the motor power. Will that work with #4863 gearmotors? Also are there any led indicators on VNH5019 for troubleshooting? Any led lights that indicate that it is receiving power?
8 AA batteries should generally be fine for those #4863 gearmotors.
The dual VNH5019 shield has a blue power indicator LED that should turn on when power is applied to VIN. Additionally, it has two pairs of green and red LEDs that indicate the state of the outputs (one pair per motor channel). I have indicated the location of the LEDs in the picture below:
It was a soldering issue. After I redid the soldering, I got the motors running. Thank you for you help.
Have another question, When I ran the example program from the github library, I always got M2 current as zero. The M2 motor was running but it was showing 0 M2 current. I switched the motors thinking one motor had an issue, but still M2 Pin’s current was zero. Do you know why that could be?
Could you measure the voltage between GND and the duplicate M2CS pin on the edge of the board that you have not soldered anything to yet, and compare the voltage when the motor is not running and when it is running?
When the motor is not running the voltage was 0. When the motor is running it is M2CS voltage was 19.1 mV. Also for M1CS it is 23.8mV
with below code, our vehicle is going straight, so i think we are good. Thanks for your help so far.
// Example: Rotate Motor 1 forward at half speed
digitalWrite(M1INA, HIGH);
digitalWrite(M1INB, LOW);
analogWrite(M1PWM, 128);
// Example: Rotate Motor 2 backward at half speed
digitalWrite(M2INA, LOW);
digitalWrite(M2INB, HIGH);
analogWrite(M2PWM, 128);
Should i look in to adding a capacitor, as mentioned in the github? " To make getM1CurrentMilliamps work well, you would add the capacitor between M1CS and GND. To make getM2CurrentMilliamps work well, you would add the capacitor between M2CS and GND."
when can i but the capacitor? and which capacitor to buy?
Earlier, you were saying that you get a reading of 0 from your Arduino on the M2CS pin; if the reading you get is still 0 when you can measure a voltage on it, then I recommend inspecting that solder joint and reworking it if it looks suspect.
The voltage on the current sense outputs are 140 mV per amp, so it looks like the current draw from your motors is very low in your test. As the VNH5019 shield product page states, the current sense readings are more accurate at higher currents.
We recommend adding a capacitor if you’re using PWM signals under 5kHz. So, if you are going to use analogWrite() (which is at 490Hz on the Arduino Uno), then you can add a 1 µF (or larger) capacitor on the current sense pins; however, you do not need to add a capacitor if you use our library with the Arduino Uno, since it will use a 20kHz PWM frequency. Capacitors are widely available, and if you can’t find them at a local hobby store, you can get them from online retailers like Amazon, DigiKey, and Mouser.