Ging3rtoby
Posts: 3
Joined: Tue Dec 31, 2013 3:49 pm

Controlling a DC motor

Tue Dec 31, 2013 3:54 pm

Hello my name is Toby I am 14 years old and have got my pi SWEEEET!!

I have 2 DC Motors like the ones here - https://www.sparkfun.com/products/retired/9608
I have a breakout board like the one here - https://www.modmypi.com/raspberry-pi-pa ... ut%20board
And a 9V power supply

Could someone please help me on how to wire up the power to the motor and into the breakout board, I dont want to buy anything else but i do have a soldering iron and solder and wire in case we need to hotten things up a bit. A circuit diagram would REALLY help.

Thanks Toby

User avatar
joan
Posts: 14369
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Controlling a DC motor

Tue Dec 31, 2013 4:11 pm

I'm afraid you will also need to buy a motor driver board (e.g. http://www.ebay.co.uk/itm/200964675895) or at the very least a chip such as an ULN2003A (e.g. http://www.hobbytronics.co.uk/electroni ... gton-array).

The motor driver board has the advantage that you can drive the motors backwards and forwards. Both allow you to start/stop the motor and vary its speed.

If you try to connect a motor directly to a Pi gpio you will likely damage at least the gpio and possibly the Pi.

The gpios won't be able to supply enough current to move the motor and when the motor stops it may generate a high voltage back surge which damages the attached gpio/Pi.

Ging3rtoby
Posts: 3
Joined: Tue Dec 31, 2013 3:49 pm

Re: Controlling a DC motor

Tue Dec 31, 2013 6:36 pm

Ok are you sure there isn't any other option!

User avatar
joan
Posts: 14369
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Controlling a DC motor

Tue Dec 31, 2013 8:34 pm

To control a motor from the Pi you'll have to use the solutions I've mentioned or equivalents, for instance you could build your own controller with resistors, diodes, transistors etc.

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: Controlling a DC motor

Wed Jan 01, 2014 2:32 am

mdrvr.png
mdrvr.png (33.99 KiB) Viewed 714 times
yes, there are many options if you just want to connect the motors and create a program to watch the motors turn while controlling the speed and direction with software.
if you have two transistors and a few resistors you could build this simple motor controller. to run the motor, turn on one GPIO and keep the other one low. to reverse the motor, turn off the first pin and turn on the other. to control the speed, use PWM.
the dc motor is connected where L1 is.

Ging3rtoby
Posts: 3
Joined: Tue Dec 31, 2013 3:49 pm

Re: Controlling a DC motor

Wed Jan 01, 2014 10:05 am

Ok thanks for the help, although this is getting to complicated for me, I will go out and buy a motor controller.

Return to “Beginners”