Shop OBEX P1 Docs P2 Docs Learn Events
Drive small motor with 2N2222A Transistor — Parallax Forums

Drive small motor with 2N2222A Transistor

KB3JJGKB3JJG Posts: 95
edited 2008-12-31 04:55 in BASIC Stamp
I just want to verify that I am doing this right, I love my stamp and do lot's with it, but I have always stuck to using motor controllers and servo controllers for this kind of stuff. Anyways, here goes.

I am driving a small 9v hobby motor, I am using a board of education powered by a 9v 500mA class 2 wall wart. I have a bunch of 2N2222A transistors, from a FM transmitter project I did some time ago, that I want to use to power this motor.· I gleened what I could from·my ·microcontroller application cookbook chapter 4, outputs, but my knowledge on the "electronics" part of this hobby is limited at best.

Here is my schematic, based on my research I think I can make p15 high and it should work. Could someone verify that I am doing this properly? Thank you in advance for your time and any assistance!

bs2motorcontrol.jpg





·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-22 05:53
    The only thing missing is a reverse EMF protection diode across the motor. This would be something like a 1N4001 or 1N914 diode connected in reverse with the cathode to Vin and the anode to the transistor collector. This would protect the transistor from the induced reverse voltage when the current is turned off (including when the motor's brushes interrupt the current).

    Depending on the 2N2222A transistor gain, you may need some more base drive. I suggest replacing the 1K base resistor with 470 Ohms.
  • ercoerco Posts: 20,256
    edited 2008-12-22 05:57
    Joseph: looks good, should work. Might have to drop your bias resistor to 330 ohms for full saturation, and watch your current rating on your transistor. 9 volts sounds high for a little motor, 3-6 volts is more standard. REAL 2N2222A's should work fine, but not all substitutes work equally. Beware of the "Shack's" 2N2222 bargain pack!

    When in doubt, use a little 5V reed relay (the Shack has these, OK). The coil only draws 20 mA, so you can drive it directly from an output pin (use a flyback diode)

    erco
    KM6DS

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-22 07:03
    Just to clarify erco's point, if you use the reed relay, you need two flyback diodes: one across the relay coil to protect the Stamp, and one across the motor to reduce arcing — and consequent pitting or "welding" — of the relay contacts.

    -Phil
  • KB3JJGKB3JJG Posts: 95
    edited 2008-12-23 03:59
    Well I swung by the shack today and picked up some parts. I got a multi pack of rectifier diodes, a lower voltage motor, and picked up one of the reed relays erco mentioned. Erco, using that relay will be my next learning excersize.

    Mike, following your advice, I put a 1N4001 diode in place. I got a lower voltage motor, 3V, and put in a 500ohm resistor, I forgot to get some 470's at the shack and the 500's were all I had. Below is an updated schematic, the changes are the addition of the diode, resistor value change, a lower voltage motor,·and changing the the negative terminal on the motor·to Vdd from Vin.·I fired up the stamp, made pin 15 high and it worked!

    I have one followup question to this excersize. I am using what I believe to be quality transistors, ST 2N2222A, I say this in reference to erco mentioning the lower quality ones the shack sells. Anyways I have attached the datasheet for the part to this post. Could someone help me figure out how much current I am sourcing from my stamp. As I move foreword and away from simple projects·using just a few parts and start integrating more, I want to be mindful of the current draw on my stamp.

    Thanks to all 3 of you guys for your guidance and assistance!!!

    bs2motorcontrol2.jpg

    Post Edited (KB3JJG) : 12/23/2008 5:11:53 AM GMT
  • O.T.RobotO.T.Robot Posts: 17
    edited 2008-12-23 08:34
    What is the transistor for? idea.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Omar
    Abunayyan
  • KB3JJGKB3JJG Posts: 95
    edited 2008-12-23 09:42
    O.T.Robot said...
    What is the transistor for? idea.gif

    ···· OT, this is an excerize to drive a small motor without the use of a motor controller like the HB25(which you just got) I have gotten by with my projects and fun stuff for years using the PSSC, HB25, Little Step-U, and Micro Dual Serial Motor Controller. I am Just trying to get beyond my reliance on "controllers" This solution does not provide speed control, but it is a step beyond what I am comfortable with, and I am learning.

    ··· The short answer to your question is that the transistor acts as a switch to turn the motor on.
  • dpeterson3dpeterson3 Posts: 4
    edited 2008-12-23 13:06
    I would measure the current draw of the motor just to be safe. I thought my little motors would use no more than 0.35 amps (what the 2N2222A from the Shack can handle). I found out the motors draw about 1 amp a piece. To test them, put an amp meter, battery, and the motor in series. Hold the motor shaft, and read the meter. This curent is the maximum the motor can draw. If it is more than the transistor can handle, I would not use it. Just get some TIP120 Darlington's from the Shack. They may be $1.50, but they can handle 60V at 10 amps I believe.
  • O.T.RobotO.T.Robot Posts: 17
    edited 2008-12-24 04:04
    May i ask what the transistor is for??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Omar
    Abunayyan
  • KB3JJGKB3JJG Posts: 95
    edited 2008-12-24 04:20
    OT Robot, I responded to you already, look up 2 posts. rolleyes.gif
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-24 04:58
    You need to connect the cathode of the 1N4001 to the same voltage source as the motor. If you switch the motor to Vdd, switch the diode as well. It really should be connected across the motor.
  • O.T.RobotO.T.Robot Posts: 17
    edited 2008-12-24 13:04
    Thank you

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Omar
    Abunayyan
  • GiuseppeGiuseppe Posts: 51
    edited 2008-12-31 01:51
    I had the same problem with this whole transistor thing and my same problem was that my resistor going to my base was also too high. Mine works too! But for future reference, can anybody tell me how to actually fully "saturate" a transistor? For switching application, should saturation be done first then follow the circuit accordingly? My transistor is the same type from the Radio Shack grab bag and is signaling a relay's coil to connect the starter wire in a car for a security system I'm trying to make. Any help is greatly appreciated!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-31 03:59
    To saturate a transistor, you need to know at least the minimum gain of the transistor (hFE - from the datasheet) and the desired maximum output current in your application. Divide the maximum current by the minimum gain to get the minimum base current needed. Take the output voltage of the Stamp (in this case) which is roughly 4.7V, subtract the base to emitter voltage drop (usually 0.7V) to get the voltage drop needed across the resistor (4.0V). Use Ohm's Law to figure out the resistance (R = 4.0V / base current). That's it.
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2008-12-31 04:55
    This link might help...

    http://forums.parallax.com/attachment.php?attachmentid=37701

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • GiuseppeGiuseppe Posts: 51
    edited 2008-12-31 04:55
    Thank you very much. Not my first tinkering with electronics but first time with a transistor! tongue.gif Thanks for the help and I hope you all have a Happy New Year!
Sign In or Register to comment.