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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 710 subscribers
  • Views 10340 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 14 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
Parents
  • e14 Contributor
    e14 Contributor over 13 years ago

    Sorry, I have been out of town most of the week.

     

    I have an update to the schematic to correct errors caught by Michael Kellet.

     

    He made me think about small amount of current heeded by the L239D chip.

     

    Another way to think of it is a high impeadance input.  So we don't need

     

    a lot of current gain in the transistor.

     

    While darlingtons are high current gain.

     

    The current on the chip input/transistor output will be set low by the high chip input impeadance.

     

    When you use a transistor as a switch, you set the Ib * Hfe to be larger than where the ciruit

     

    will operate in order for the transistor to alternate between cut off and saturation.

     

    So I upped the resistor values but did not set Ib * Hfe to match the current needed by the

    chip but rather to provide 10 or more times as much.

     

    The real current will by limited by the chip input impeadance and you have a low voltage

    dropped across R4/R5/R6.

     

    Ib is the transistor base current.

    Hfe is the transistor current gain.

     

    By lowering the base current, we ask the Raspberry Pi to provide less current.

     

    I drove motors with an Arduino.  It runs on 5 Volts.  It has analog inputs.  It has lots of PWM

    outputs.  It won't run Linux or Python.

     

    I have not yet tried the one PWM output on the Pi.  I don't know if a PWM driver is ready or not.

    An 8 but micro-controller normally has PWN hardware outputs.

     

    Software pwm is where you turn the GPIO output off and on and increase the speed

    by having it on a higher percentage of the time.

     

    I've thought of connecting an Arduino to the PI with 5 Volt serial or I2C and having the

    Arduino do motor control but probably not get to it.

     

    I have driven stepper motors directly of a GPIO with Darlingtons but without an H bridge chip.

     

    Any way here is the updated schenmatic in PNG. I am trying to attach the Eagle schematic.

    Attachments:
    ken2..zip
    image
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • e14 Contributor
    e14 Contributor over 13 years ago

    Sorry, I have been out of town most of the week.

     

    I have an update to the schematic to correct errors caught by Michael Kellet.

     

    He made me think about small amount of current heeded by the L239D chip.

     

    Another way to think of it is a high impeadance input.  So we don't need

     

    a lot of current gain in the transistor.

     

    While darlingtons are high current gain.

     

    The current on the chip input/transistor output will be set low by the high chip input impeadance.

     

    When you use a transistor as a switch, you set the Ib * Hfe to be larger than where the ciruit

     

    will operate in order for the transistor to alternate between cut off and saturation.

     

    So I upped the resistor values but did not set Ib * Hfe to match the current needed by the

    chip but rather to provide 10 or more times as much.

     

    The real current will by limited by the chip input impeadance and you have a low voltage

    dropped across R4/R5/R6.

     

    Ib is the transistor base current.

    Hfe is the transistor current gain.

     

    By lowering the base current, we ask the Raspberry Pi to provide less current.

     

    I drove motors with an Arduino.  It runs on 5 Volts.  It has analog inputs.  It has lots of PWM

    outputs.  It won't run Linux or Python.

     

    I have not yet tried the one PWM output on the Pi.  I don't know if a PWM driver is ready or not.

    An 8 but micro-controller normally has PWN hardware outputs.

     

    Software pwm is where you turn the GPIO output off and on and increase the speed

    by having it on a higher percentage of the time.

     

    I've thought of connecting an Arduino to the PI with 5 Volt serial or I2C and having the

    Arduino do motor control but probably not get to it.

     

    I have driven stepper motors directly of a GPIO with Darlingtons but without an H bridge chip.

     

    Any way here is the updated schenmatic in PNG. I am trying to attach the Eagle schematic.

    Attachments:
    ken2..zip
    image
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    How would I subsitute in a Darlington Pair into your schematic?  I have a ULN2003 Darlington IC transistor array.  See the datasheet below:  http://www.jaycar.com.au/products_uploaded/ZK8855.pdf

     

    Also, If I want to run two motors through PWM, then I would have to 'piggy back' off the circiut that is already present.  See My Schematic (experimental) based off yours below.  I think this becasue the raspberry Pi (as far as I know) only supports 1 'connection' of PWM.  Am I correct?

     

    One other thing, is the 5 volts coming out of the Raspberry Pi or an externatal source?

     

    image

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

    I couldn't find an Eagle part model for the darlingtons.

     

    The seen to have all the bias resistor internally.  You are not connecting them to the motor directly,

    so you don't need external diodes.

     

    So 5 Volt supply to ULN2003 pin 9. 

    Ground to ULN2003 pin 8.

    Rasberry Pi pin 7 to ULN2003 pin 1.

    Rasberry Pi pin 5 to ULN2003 pin 2.

    Rasberry Pi pin 3 to ULN2003 pin 3.

    ULN2003 pin 16 to L293D pin 1.

    ULN2003 pin 15to L293D pin 2.

    ULN2003 pin 14to L293D pin 7.

     

    You don't need the external resistors.

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

    Thanks Ken,

     

    I haven't got the H-bridge yet, but I will test when I get it.

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

    There is no 5 volt supply on the ULN2003 (as far has I can see).  Could you tell me the corresponding pin on the IC ULN2003?

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

    image

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

    You need to tie pins 4, 5, 12, and 13 to ground.

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

    I know that. image It was to much time to add to the diagram. image

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

    I have not yet tried the one PWM output on the Pi. I don't know if a PWM driver is ready or not.

    An 8 but micro-controller normally has PWN hardware outputs.

     

    Software pwm is where you turn the GPIO output off and on and increase the speed

    by having it on a higher percentage of the time.

    I need to know how PWM will work in the circuit.  So the Raspberry Pi has ONE (1) PWM channel.  Does this work in a pair or on a single wire tied to ground?

     

    If I want to control the two motors individually then I will need a mircocontroller.  Correct?

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

    Ok.  I just read this article: https://projects.drogon.net/raspberry-pi/wiringpi/software-pwm-library/ Which says this:

    WiringPi includes a software-driven PWM handler capable of outputting a PWM signal on any of the Raspberry Pi’s GPIO pins.

    Is this even possible?

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

    It's certainly possible - the article explains that it is limited because it is a software controlled PWM so can only do 100Hz with a minimum pulse width of 100uS for a range of 100:1. A modest micro might be expected to manage 40kHz, 1uS minimum pulse width and 256:1 range. Fancy micros and DSPs can do much better.

    The software aaproach should be just about OK for lamp control but I'd be a bit cautious with motors - some will be OK but not all.

     

    The RPi IO is pretty hopeless - the sodtware PWm is making the best of a bad job but it could well be OK for some things.

     

     

    Michael Kellett

    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube