element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Wiring a motor to the RPi?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 63 replies
  • Subscribers 672 subscribers
  • Views 7284 views
  • Users 0 members are here
  • help
  • rc
  • pi
  • control
  • raspberry_pi
  • please
  • motor
  • raspberr
Related

Wiring a motor to the RPi?

wallarug
wallarug over 13 years ago

What do I need?

 

I am told that I need some transitors.  I have a 12v powerpack and 2 x12v motors.  How do I set this up so that I don't blow-up the RPi and that I can control the motors through the GPIO?

 

I have a gertboard on the way but I would like to see if I can do it without it first.

 

I have little knowlegde about transitors and electronics but I do know how to build circuits.

  • Sign in to reply
  • Cancel
  • Former Member
    Former Member over 13 years ago

    This is fairly easy using modulation interpreters. I don't know how savvy you are but I drew up a schematic for you! It consists of a few drivers (which cost like 2 bucks) and a couple of transistors:

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to Former Member

    What do all the lines mean? (I know they are wires/joining components) Could you label all the individual parts please.  This looks a bit complicated as well.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 13 years ago in reply to wallarug
    [deleted]
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to Former Member

    tom smith wrote:

     

    I already did you faggot. I put all that effort in... image

    Srry, I should have been more specfic.  Also, can someone explain why/how some connections go in three directions (I don't know how I would wire that).

    image

     

    Anything with a yellow circle.  I worked out where the motors were.

     

    PS: Please be nice to people on the forums, not everyone is an expert.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • michaelkellett
    michaelkellett over 13 years ago in reply to wallarug

    @ fergus, At the risk of being called something worse than you were - the schematic that Tom has posted is not suitable for a beginner to use to build a motor driver so I suggest you look elsewhere. The Gertboard has  a motor driver section and the ciruit is published so you could either buy a Gertboard (best bet for the inexperienced) or build the relevant parts on stripboard if you are up to it. Either way you can use the software published for the Gertboard and have  a bit more confidence that the design will work.

     

    Michael Kellett

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 13 years ago in reply to michaelkellett

    Yeah I agree with that guy, unless your a coding and electronics master I'd just use the gertboard!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • johnbeetem
    johnbeetem over 13 years ago

    If all you want to do is turn a small DC motor on and off, all you need is Gert van Loo's circuit in this thread's 7th post: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=13473.  The motor is driven by an NPN Darlington Pair (http://en.wikipedia.org/wiki/Darlington_pair), which is a great way to convert a small current into a really big current.  The three diodes in series are for people are afraid the Darlington pair might accidentally conduct from collector to base.  Gert says they're not necessary, but with 12V present I'd worry about framboise flambée and put them in. 

     

    The diode next to the motor coil is critically important.  It's called a flyback diode (http://en.wikipedia.org/wiki/Flyback_diode).  When you turn on the transistor, the flyback diode is reverse-biased and has no effect.  However, when you turn off the transistor, the magnetic field in the motor will cause current to continue to flow for a while.  If that current can't go anywhere (because the transistor is off), it will charge the node to a very high voltage and turn the transistor into a fuse and possibly destroy anything connected to the transistor.  It's how spark plugs work.  The flyback diode gives the current somewhere safe to go to prevent Spitzensparken.  The diode should have a current rating higher than the current through the motor.

     

    Gert doesn't give a value for the resistor between the GPIO and the base of the Darlington pair.  I'd start with 1 KOhm which gives you 3.3 mA.  But then, I usually start with 1K image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to johnbeetem

    Could someone confirm if the GPIOs are a ground or send out signals.  I think they are grounds but I can't be certain.

     

    If they are grounds, then how would the transitor work if it is a NPN?  wouldn't you need some positive current comming from somewhere?

     

    Sorry if these are silly questions but I am only learning.

     

    could someone also point me towards a sample code please.  I have heard that the code is the tricky bit.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • bodgy
    bodgy over 13 years ago in reply to wallarug

    The GPIO outputs can be high or low in output, in other words they can be made to switch from 0v (ground) to 3v3 or be held at 3v3 and switch low. You get the choice of deciding which level equals on or off.

     

    If you decide low (0v) is to be off then if using an NPN transistor switching the output high (3v3) would turn the transistor on. If you wanted it the other way around you'd would then use a PNP. However in your case it probably is better for you to start by using an NPN transistor, as from a beginners point of view they work in a more logical fashion.

     

    Do you have a circuit in mind that you've seen where you could provide a link so that we can see if it achieve what you are hoping it will.

     

    Do you know the type of motor - voltage, current requirements you are going to use?

     

    As for code, I think the code for the Gertboard would be a good start especially as it also can run a small motor. I'll have to find the link but on the Pi forums is some example code. are you looking for code in Python or C ?

     

     

    Colin

     

    P.S. I live in the same country as you, so feel free to contact me if you need any further assistance.

     

    Message was edited by: Colin Barnard  corrected maximum voltage to show 3v3 instead of the incorrect 5v

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to bodgy

    bodgy wrote:

     

    The GPIO outputs can be high or low in output, in other words they can be made to switch from 0v (ground) to 5v or be held at 5v and switch low. You get the choice of deciding which level equals on or off.

     

    If you decide low (0v) is to be off then if using an NPN transistor switching the output high (5v) would turn the transistor on. If you wanted it the other way around you'd would then use a PNP. However in your case it probably is better for you to start by using an NPN transistor, as from a beginners point of view they work in a more logical fashion.

     

    Do you have a circuit in mind that you've seen where you could provide a link so that we can see if it achieve what you are hoping it will.

     

    Do you know the type of motor - voltage, current requirements you are going to use?

     

    As for code, I think the code for the Gertboard would be a good start especially as it also can run a small motor. I'll have to find the link but on the Pi forums is some example code. are you looking for code in Python or C ?

     

     

    Colin

     

    P.S. I live in the same country as you, so feel free to contact me if you need any further assistance.

    Firstly, what firmware do I need to swap between 5v and 0v.  Currently I am using GPIO-0.2.0 which does not have this capability.

     

    Secondly, I would like it to be in python becasue I know that a lot better than C.

     

    I am thinking of using a motor rated at 12 volts, 14A. 

     

    wallarug

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube