Strange behaviour driving a gear motor

I’ve got this motor I’m trying to drive.

When I connect it directly to 3v3 and Gnd it turns.
When I connect it directly to vin and Gnd, it turns faster.

I’m trying to control it via D pins. They output the same 3v (confirmed with multimeter).

The problem is when I connect the motor and set the pin high the voltage drops to 0.35v and the motor doesn’t spin.
If I disconnect the motor, it goes right back to 3v again.

What am I missing?

Edit: Pretty sure it’s because the Core can’t supply enough current. I’ve got a 4AA batter cell I can use. How can I go about powering these motors from the battery but controlling from the Core?

When you supply more voltage, more current passes so it turns faster. Be careful with Vin. IF you happen not to be using the USB, you might blow the servo. For now, Vin at 5V is fine for servos in general.

The suggested is 4.5v for yours though. not sure if it’s ok with the 5v…

It sounds like it got shorted due to wrong connection or the servo control ping is just asking for too much current. Do a check on your connection…

Triple checked connections. I just took the motor’s positive lead from 3v3 and put in on D6. Then set D6 high. Should be the equivalent right?

The max curent you get is like 20ma out of the GPIO and the servos need more than that. You’re gonna kill that pin.

So quickly pull it out and use 3.3v instead!

kareem613, first things first. From what I can see, this unit is NOT a servo but a simple gear motor. You can use PWM to control the speed whereas with a servo you control its angle. You cannot connect the motor positive lead to D6. This motor has a no-load current rating of 190mA (250mA max!) and a digital pin can only supply 20mA.

For this motor to work for you, it will need to be supplied with a separate 4.5V supply through a power transistor (eg. NPN or FET) to switch the heavy current. You would control the transistor with a PWM output to vary the speed of the motor. I don’t recommend powering off the USB either since if you have a load on the motor, the current draw of the Spark and the motor will exceed what the USB can supply. So a separate supply is a good idea (as long as your Spark, transistor and Motor share a common ground).

Pololu makes some great motor control breakouts that can handle the high currents and make controlling much simpler. :smile:

Awesome info everyone. Thanks!
Lesson learned. GPIO is very low current. Too bad this kit didn’t come with all the pieces to make this happen. I was hoping this was my morning project. Trying to build a car and a library for my daughter to learn some autonomous vehicle control. Did anybody here learn to program with the Logo Turtle? I’m building that but physical.

I’m all for simpler @peekay123. Pololu looks great. Didn’t know about them before. Is there anything special I’m looking for in terms of motor control breakouts?
Does servo vs. gear motor matter?

Something like this?

Hi @kareem613

That controller from Pololu will work, but it might be more than you need. Do you need to spin the motor both ways, for instance?

Servos and gear motors are different animals. A servo has electronics inside that make it (generally) hold position based on a signal you send it. Inside the servo there is a feedback loop that tries to hold it where you are commanding it to go and if you push it with your finger, it will go back to the spot you are commanding it to. There are also “continuously rotating” servos where the command you send to it sets the speed, not the position, but the electronics and the command are the same. Servos almost always use gear reduction to convert a high-speed motor to a lower speed at higher torque.

A simple gear motor does not have any extra electronics inside. It is just a high-speed motor that has gears added to the output shaft to reduce the speed and increase the torque. No feedback or position holding or speed control electronics are there for you, just the motor.

Here’s a nice Arduino tutorial on controlling high-current devices. Notice the separate voltage supply for the motor or lamp etc. If you need to have your motor spin both directions, you need a more complicated driver circuit and it might be worth using a motor controller IC like the one above.

Thanks for that link. That’s exactly what I need.

No need for reverse. There are two motors driving two separate wheels. That’s enough to turn left and right and move forward. I think I have all the parts for this right now too.
I’ll take a crack at it.

kareem613, that polulu motor driver is great and there is also this one:

Either way, these use an H-Bridge drive circuit allowing you way better control of the motors, especially when accelerating and decelerating. Make sure to read the controller datasheet to learn how to control them.

You could supply the motor and the board with 4.5V from a set of 3 1.5V batteries or with a step-up/step-down DC-to-DC converter using a LiPo rechargeable battery for example. Again, polulu has that hardware. Have you considered buying a simple robot chassis like this from polulu to save you time and hassles?


Thanks. Got plenty of things to try now… and order. :smile:

As for kits, that’s what I though this was.
Didn’t come with anythings besides the motors. ie. No controllers or circuitry.

1 Like

Ha! At least now we know the motors can handle a max of 6V! Do you happen to have the Spark shield shield? If you do, you can plug your battery pack into that and it will supply the correct voltage to the Spark. You can then use the Vin board connection to supply your motors with 6V. You can probably then sit the breadboard that came with your Spark between the risers so you can wire up the polulu motor controller. The entire assembly can sit on top of the chassis.

If you don’t have a shield shield, you can power the Spark (with 6V on the Vin pin) and the motors from the batteries with a suitable connector or just cut the connector off and wire the power directly. You can mount the Spark breadboard on the chassis.

MAKE SURE you don’t put 6V directly on any of the Spark pins except the Vin pin. Also make sure you power the motor control board at the correct pins. That controller is powered by the voltage going to the motors so it does not need any power from the Spark, only a common ground. :smile:

1 Like