Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Question about Encoder Motors with DualG2 18v18 Driver


I’m using this driver: Pololu Dual G2 High-Power Motor Driver 18v18 Shield for Arduino
With these motors: Pololu - 150:1 Metal Gearmotor 37Dx73L mm 12V with 64 CPR Encoder (Helical Pinion)
Using a Mega as the processor (powered by the driver) and a 11.1 V Lipo battery.

I tried using the default example code provided by the driver library however the motor never powers on. Will it only power on if the encoder is hooked up and receiving/sending info as well? I ask because I left the encoder wires out/unplugged when using the example code just to make sure things were wired properly, could this have been the issue?

I’ve never used an encoder DC motor before so if anyone could point me in the right direction as well that would be very helpful.


I expect the motor to run by applying power to just the red and black wire on the connector without connecting the encoder wires. Could you try connecting your battery directly to the motor power wires?

Our library for the G2 high-power motor drivers does not have any provisions in it for encoders. What do you mean by the encoders “receiving/sending info”? Could you post pictures that show how you have everything connected?


It does run with the battery connected directly to it.

How would I run that motor (which has an encoder) using that driver if it doesn’t have provisions?

What do you mean by the encoders “receiving/sending info”?

  • I should have been more clear; do the encoder pins need to be pulled high/low or communicating with the board in order for the motor to run or can it run without them? Since it runs off just the battery the answer to my question seems to be, yes :slight_smile:

Here are the connections.

Thanks for posting the pictures. The connections between the motor and your shield and Arduino Mega look fine. It looks like the header for the ARDVIN jumper is not soldered in. How are you powering the Arduino?


Turns out the ardvin jumper was not in fact soldered in :slight_smile: Everything works fine now.

As a final step, could you please explain how I’d go about rewiring this shield (and a second one) so that they can stack? I’d like to power 4 motors but at the moment that isn’t possible. The diagrams provided on the wiki for remapping the connections were a little hard to follow.

I’m glad to hear your shield is working now! To stack two shields and control 4 motors, I recommend leaving the bottom shield as you have it. For connecting the second shield there are two options.

One; mount it physically with no electrical connections and use the single row of logic connections along the left side. This is not really stacking since you would not use the Arduino headers on the second shield. but it would not require cutting any traces and might be easier.

Two; use the Arduino headers and stack the shields but remap all the necessary connections on the second shield. It sounds like you might already have seen the Remapping the Arduino connections section of the user’s guide. If you want to go this route and are having trouble, please post which features you plan to use (i.e. fault, sleep, and current sense) and if you plan to have anything besides the two shields connected to your Arduino.


Could you clarify what you mean by the first method? You just mean leading the left side logic connections OFF of the first shield TO the second shield? Where on the second shield would I connect them to?

Yeah, I just mean instead of mounting it on top as a second shield, you can add jumpers to connect the pins you plan to use from the second driver to unused Arduino pins (through the headers of the stacked shield). The pins you choose are up to you, though you should make sure to connect the PWM pins to PWM capable Arduino pins and the CS pins to analog inputs.


Got it, OK. And just to confirm, that would allow me to control a total of 4 motors correct?

Yep. That would let you independently control 4 motors.


Ok, looking at it right now, what would need to change in the code that I upload? Where would I reference what pwm pins I’m using on the mega (since they’re not the default ones that the first shield is using)

Also, don’t I also need to connect the 6 pins on the side that has rst, Vdd, ardvin etc?

If you are using our Arduino library, you can initialize the stacked driver with the standard constructor DualG2HighPowerMotorShield(). For the second (not stacked) driver, you can use the alternate constructor which lets you assign the Arduino pin you are using for each of the driver’s pins. Details can be found in the Library Reference section of the library’s GitHub page. This Arduino page about creating libraries might also be useful in understanding how to use a constructor.

“Also, don’t I also need to connect the 6 pins on the side that has rst, Vdd, ardvin etc?”

It sounds like you are asking about the Arduino’s header with IOREF through VIN. You should make sure that both drivers have a common ground connection with your Arduino, but besides that, you do not need to make any connections between the second shield and that strip of headers.


Perfect! Got it to work BUT only briefly…

M1 on the shield that isn’t remapped stopped working for some reason (it did work last night and nothing was changed between then and now). I’m powering both shields as follows:
“Stacked shield” - not really stacked, just connected by all it’s important pins (M2 and M1 FLT, SLP, DIR and PMW, and M1/M2CS all going to their defaults i.e. 12 on shield going to 12 on arduino mega) and connecting ardvin, vreg and vreg on the side which powers the arduino. Defined that class in my code as DualG2HighPowerMotorShield md(those pins). 11V battery connected to shield 1.

Then second shield, same thing but remapped (DualG2HighPowerMotorShield(remapped pins)) making sure that PMW M1 and M2 go to PWM pins (3 and 5 I believe on the Mega). Common ground. BUT connected a second battery to it to power the shield (not sure if this is a bad thing or not but it has worked OK and the shield powers both motors fine).

Two questions however:

  1. Running my code NEVER powers M1 on shield 1 (not getting high/low V measuring with a voltmeter on the pins of M1 either). The motor itself works if I power it with a battery. Even just using the test code. It did last night, like I said, all 4 motors were running A OK. Could I have burned out M1 somehow?

  2. Running the code WILL power M1 and M2 on shield 2 BUT the lights on M1 and M2 blink red/green at the same time and nothing else (so they’re not actually moving the motors). Not sure what the problem is here.

Oh by the way, DualG2HighPowerMotorShield blah(remapped pins) for the second shield is what I used (instead of md)

It is possible M1 on the first driver is damaged. Could you measure the signal coming from pin 9 on the Arduino to make sure it is going high and low? Could you also post pictures of all your current connections along with your code? It should be fine to power the two shields off separate batteries.


Will do that, ok. Here are pictures in the meantime.

Code I’m running is just the default test code provided

It is hard to follow all those connections, but I see a few potential issues:

  • On one shield I do not see a connection to motor power and on the other it looks like there is no connection to the GND terminal block. Is that how the battery is being disconnected? How are you connecting your jumper wires to the batteries?

  • I see white and grey jumper wires connected to ARDVIN on the shields. You mentioned you are connecting them to VREG., but since the shields are not stacked, the ARDVIN pins don’t connect to anything, so it is kind of pointless to connect them to anything. In general, it makes more sense to just directly connect VREG from one shield to VIN on your Arduino, or since you are using 11V batteries, you could directly connect those to the Arduino.

  • It looks like the shields’ extended headers are resting on your metal channeling, potentially creating shorts.

Is there a reason you don’t want to physically and electrically stack one of your shields? It would make the connections simpler to follow. Are your motors currently connected to your wheels or chassis?

Since you mentioned you are controlling both shields from your code, it’s not possible you are using the unedited demo code. Even if the changes you made seem trivial, please post the exact code you are using.