Shop OBEX P1 Docs P2 Docs Learn Events
controlling my motor — Parallax Forums

controlling my motor

vla7vla7 Posts: 79
edited 2007-11-12 20:10 in BASIC Stamp
I built a basic circuit with 1 kohm resistor to a transistor.· Connected the emmiter to ground and to the negative battery terminal.· Connected the positive battery to a small dc motor and from the motor to the collector of the transistor.

Then I typed this basic program for the homework board to turn the motor on for 1 second.

High 2:
Pause 1000:
Low 2:
end

My problem is that the motor continues to spin after 1 second.· You can see and hear it slow down after 1 second but it continues to spin.· I can manually stop it from spinning by placing my finger on the shaft and applying a little pressure.· Also if I manually spin the shaft without running the program it will aslo start spinning and not stop until I manually stop it again.

Can someone please explain what is happening.· Why does the motor continue to spin at the end of the program.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-12 16:15
    It's called "inertia". It's a fundamental property of physical objects that they will stay the way they are unless something changes that.
    An object at rest remains at rest unless something external makes it move. Similarly, an object that is moving will continue to move
    in the same direction and with the same speed unless something external changes its motion. Rotating objects are a little more complex,
    but the same idea applies. They'll continue to rotate at the same speed until something external changes their rotation. Usually, in the
    "real world", this includes friction and usually, with most mechanical objects, someone has tried to minimize friction in their design.

    Do a web search on "wiki inertia". Also try "wiki regenerative braking".
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-11-12 16:30
    vla7--

    Do you mean it continues to spin constantly after you think you have powered it down via the Stamp and your circuitry? Is so, that is not inertia. That means your motor is still getting power.

    Maybe the transistor is allowing enough current to leak through to power the motor? I am not smart enough to tell you how . . . but, Mike is.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • LilDiLilDi Posts: 229
    edited 2007-11-12 17:11
    Could be the transister has been damaged from back-EMF or the transistor is not well suited for this application. Its best to have a diode across the motor with the bar band on the·positive lead of the motor.

    Mike, you do have a sense of humor!

    Post Edited (LilDi) : 11/12/2007 5:16:25 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-12 17:27
    LilDi and Bill,
    What vla7 is describing is the normal behavior of a nicely balanced, low friction (probably ball bearing) motor with a narrow shaft and relatively high rotor mass. Once spinning, it will continue to do so for some seconds unless slowed or stopped by friction with a finger. It will also come up to speed relatively slowly with the power turned on (because of its mass) or with a spin of the fingers.

    LilDi,
    Sense of humor?
  • D FaustD Faust Posts: 608
    edited 2007-11-12 18:07
    OK, thats your problem, but what about the solution.· The only thing that I can think of is to reverse the current quickly as to provide force in the opposite direction to slow it down.· For this you would need an H-bridge.· I think that applying the same current (+,+ or -,-) to the motor you will also slow down the motor, but not as fast as reversing it.· You could do this by adding another transistor between the - lead of the motor and +V.· The +V wire on, there will be + voltage on both of the wire leads.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --DFaust
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-11-12 18:16
    Mike--

    Thanks for the explanation.

    I had the impression that the motor continued to run after his program shut if off. The wording threw me off.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-12 18:20
    D Faust,
    You can also use an H-bridge to apply dynamic braking to the motor where the H-bridge effectively shorts out the motor windings and dissipates the energy of the rotor in the motor windings (as heat). Essentially, the motor is used as a generator. It doesn't need any additional energy and the motor will slow down pretty quickly. Try it on a DC motor you have. Spin it, then time how long it takes to stop. Spin it again with the motor windings shorted and time it.
  • vla7vla7 Posts: 79
    edited 2007-11-12 19:51
    I think Bill is right in saying that my motor must be still getting power. That's because the spinning is constant and doesn't slow down. Also, when I replace the motor with an LED, the LED lights up without me running the programm and sending signal to the transistor. I am using an NPN Transistor MPS2222A from Radio Shack. Does anyone know if this the wrong trasistor to use and if so how do I pick the right transistor for this project.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-12 20:03
    The LED should not be lighting up. It may be that the transistor is bad. I think the 2222 has a maximum current of 600mA which should be enough for most small DC motors. Check your wiring. Also put a diode (like an 1N4001) across the motor with its cathode to the positive power supply.

    The LOW statement should hold the transistor off, but the END statement puts the Stamp into a low power mode and periodically puts the I/O pins into input mode (see the manual for a description). That shouldn't turn the transistor on anyway. Do put a PAUSE after the LOW statement and see what happens.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-11-12 20:10
    The "right" transistor depends on the motor's current requirements. The MPS2222 specs an absolute maximum current of 600mA, but I'd cut that in half to be on the safe side. Also, it's possible that the transistor has been damaged, either from overvoltage (if you left off the protection diode across the motor) or overheating, if it was pulling too much current.

    Another thing to check is whether your BASIC Stamp and motor grounds are, indeed, tied together properly. If not, the transistor's base may still be getting a trickle of current. This would be easy enough to check. With the input "low", measure the voltage between the transistor's base and emitter. It should be zero. If it's more like 0.6V, you've got some stray base current happening.

    -Phil

    Addendum: I think Mike is onto something with the END statement. If the motor is quite small, you may be getting enough leakage current to drive it. To keep this from happening, put a 4.7K resistor between the transistor's base and emitter (ground).

    Post Edited (Phil Pilgrim (PhiPi)) : 11/12/2007 8:15:55 PM GMT
Sign In or Register to comment.