Transistor to be used as DC Motor power switch?
jtrz
Posts: 40
Hi all,
This question is not what you think...I hope...
I have a small DC motor that runs off 1-2 AA batteries.· So we're talking about 1.5-3V max here.
I know there are a few ways to do this too...relay, optoisolator circuit (?), motor controller, etc.· I also read that you could do this with a transistor too.
I have a circuit that uses the PING sensor.· When the sensor is activated, pin 14 goes high and lights up an LED.· I want that pin 14 output to now control that small motor.· I was not able to get it to work by directly connecting it to pin 14...but since I've been doing a lot of reading about what it takes to control a DC motor, I know WHY...and understand why you want it isolated from the microprocessor circuit, have it's own power supply, etc.· Hey!· Whaddaya know?· I'm learnin'!·
But my question is this...
I just want to have the motor turn on and stay on for the duration that pin 14 is high and off when it goes low.· I'm not interested in controlling forward/reverse motion or speed of the motor.
I just need·something simple to act·like a switch on the·pos (+) wire coming from the motor's battery and be controlled by the output of pin 14.· And I do not want to compromise my BS2 in the process.
Can this be done with a transistor?· If so, which transistor?· What rating would be appropriate for this...only 1.5-3v max?· Don't know that much about transistors to know which to get to control this motor (assuming this could be done).
I'm trying to keep this simple and not have to buy a motor controller like the Micro Dual Serial Motor Controller (Parallax part #30052).· They are fairly reasonable $$$-wise, but I think this might be overkill for this application?
Any thoughts are appreciated...
Thanks,
John
·
This question is not what you think...I hope...
I have a small DC motor that runs off 1-2 AA batteries.· So we're talking about 1.5-3V max here.
I know there are a few ways to do this too...relay, optoisolator circuit (?), motor controller, etc.· I also read that you could do this with a transistor too.
I have a circuit that uses the PING sensor.· When the sensor is activated, pin 14 goes high and lights up an LED.· I want that pin 14 output to now control that small motor.· I was not able to get it to work by directly connecting it to pin 14...but since I've been doing a lot of reading about what it takes to control a DC motor, I know WHY...and understand why you want it isolated from the microprocessor circuit, have it's own power supply, etc.· Hey!· Whaddaya know?· I'm learnin'!·
But my question is this...
I just want to have the motor turn on and stay on for the duration that pin 14 is high and off when it goes low.· I'm not interested in controlling forward/reverse motion or speed of the motor.
I just need·something simple to act·like a switch on the·pos (+) wire coming from the motor's battery and be controlled by the output of pin 14.· And I do not want to compromise my BS2 in the process.
Can this be done with a transistor?· If so, which transistor?· What rating would be appropriate for this...only 1.5-3v max?· Don't know that much about transistors to know which to get to control this motor (assuming this could be done).
I'm trying to keep this simple and not have to buy a motor controller like the Micro Dual Serial Motor Controller (Parallax part #30052).· They are fairly reasonable $$$-wise, but I think this might be overkill for this application?
Any thoughts are appreciated...
Thanks,
John
·
Comments
http://profmason.com/wp-content/uploads/2008/01/irl540n.pdf
Rugged. Reliable. Simple to use.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The reason we're all here, is because we're not all there.
I just don't understand one thing about it. The "Gate Threshold Voltage" is listed as a min of 1V. If I understand the MOSFET correctly, the gate is the part that, when a voltage above the threshold is applied, will the close connection between the the sink and the drain?
But in my case, when pin 14 is held high, it does not put out that much. So how will that work?
Thanks,
John
Post Edited (jtrz) : 5/21/2008 3:51:28 PM GMT
It's always a pleasure to hear from you! Thanks for your reply.
I was hoping to not duplicate this basic question about DC motor control. That's why I've been doing a lot of reading on this. I did happen to come across your reply in other posts. And I did read through both docs.
But the difference, at least in my newbie mind, was that those other solutions were dealing with industrial-strength motors like 12v and above. I'm looking at just turning on/off a 1.5-3v motor run by 1-2 AA batteries (for short periods of time). In my mind, it's just a normally-open switch on the pos (+) side that closes and stays closed for as long as pin 14 from the BS2 goes high. I am trying to make sure I'm not overdoing it. But I think I may be oversimplifying it at the same time.
Thanks,
John
Post Edited (jtrz) : 5/21/2008 7:26:39 PM GMT
2) The minimum gate threshold is the voltage where the FET begins to conduct. There are graphs on the datasheet for any particular MOSFET that give the gate voltage vs. the amount of current conducted (between source and drain).
You're very welcome!
Think of these as a 3-pin solid state switch or relay. Just connect the Gate to the stamp pin and away you go. the only thing to remember is you want the·Drain to be more positive than the Source. Yet, I've hooked them up backward and they still work.
Connect a multimeter between ground and pin 7 and run the code below. If you don't see pin 7 toggling between 0 and very close to 5VDC, you've got something else going on...
begin:
HIGH 7
PAUSE 2000
TOGGLE 7
PAUSE 2000
GOTO begin
This also a quick and dirty way to test your set up with a MOSFET.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The reason we're all here, is because we're not all there.
begin:
TOGGLE 7
PAUSE 2000
GOTO begin
Another option besides transistors and mosfets is a simple reed relay. Radio Shack's·# 275-232 is cheap, simple·& easy to find. It can be driven directly by a Basic Stamp: it only·draws 20 mA·and provides a nice switching action, perfect for this little 3 volt motor. Just be sure to add a small reverse-polarity diode across the coil to kill voltage spikes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Post Edited (erco) : 5/22/2008 1:42:02 AM GMT
I have (and used) a bunch of those relays. But you have to admit that by adding the diode, the parts count went up 2X!· It's also prudent practice to add a pull-up/pull-down? YIKES! ow it's 3X!·and starting to eat up board space.·Those relays are currently $3 each, and are rated at half-an-amp. Digi-Key has IRL510s for $0.67 each, and can handle 5.6A continuous. The real-estate occupied by a MOSFET is less than that of one relay -·before you add the·diode and pull-up.
jtrz: Something else that I remembered: Once you have· the motor toggling on and off, it's now *VERY* simple to control the speed using PULSOUT.
Sandgroper: Also very correct. But again,· there went the parts count. You·reminded me·another great aspect of MOSFETs: The on-state impedance is so low that typically, no heat sink·required!
Am I starting to sound like a MOSFET bigot?
Joking aside, I literally have bags of· transistors, and unopened packages of relays that I may never get around to using. The only anomaly that comes to mind while using a MOSFET was motor noise getting back into the stamp. That can and will happen with any of these methods. True? (Another note to jrtz: Remember to add a ceramic cap across the leads at the motor for noise suppression.)
I've·been wondering though, why would one choose a dedicated motor-driver over a stamp/MOSFET arrangement·if only to save space? You still·have to provide step/dir.·(Stamp+ MOSFETs > Stamp+motor-driver ???)·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The reason we're all here, is because we're not all there.
http://www.me.umn.edu/courses/me2011/robot/technotes/motorcontrol/motorcontrol.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The reason we're all here, is because we're not all there.
As Samuel Jackson said in SWAT, "Sometimes doin' the right thing ain't doin' the right thing!" And in "Snakes on a Plane", he may well have said, " I want these (blankety-blank) diodes off this (blankety-blank) relay!"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not a complete idiot! Some of my parts are missing.
In your own sly way, you were suggesting a practical way to reduce the Stamp IO pin current necessary to·activate the relay to keep the Stamp cooler and happier. And so to you I say thanks and Bravo! Senior moment? I think not...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Anyway, it's a form of self-flagellation... since my auto-lobotomy didn't work out.
I hope I haven't scared off jtrz.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not a complete idiot! Some of my parts are missing.
But I did try the Radio Shack reed relay as someone suggested (normally-open SPST reed relay). But I'm not getting it to work. I'm probably not using it correctly. Forget about the reverse diode across the coil for now. I have...
BS2 Pin 14 to one of the coil contacts on the reed relay
The other coil contact to GRND
The NEG (-) of the motor to the common pin on the reed relay
The N.O pin on the reed relay to the NEG side of the single AA battery
The POS (+) side of the battery to the POS (+) wire of the motor
But it seems the relay is not closing. Might be a bad relay too. So I tried this to eliminate the BS2, close the relay, and keep it closed temporarily to just see it the motor would run. It did not.
The POS (+ Vdd?) to one of the coil contacts on the reed relay
The other coil contact to GRND
(Coil should be closed now, right?)
The NEG (-) of the motor to the common pin on the reed relay
The N.O pin on the reed relay to the NEG side of the single AA battery
The POS (+) side of the battery to the POS (+) wire of the motor
But the motor does not turn.
Any ideas where I'm going wrong...
Thanks!
John
Thanks!
John
Three things. First, there's no common connection on that relay. Four connections. The two connections, one on each end, are the NO reed switch. The other two are near one end are your coil connections. Use a multimeter to make sure you measure ~250-ohms across this pair. One of these to pin 14, the other to Stamp ground (AKA Vss, AKA Stamp negative voltage). No polarity concerns here, either wire works.
Second, you can't use a BS2 Homework board with a direct connection to the relay, since it has 220 ohm protection resistors inline with each output pin. If you have a HW board, you'll have to add a transistor switch.
Third, you can't power the motor using the 5 volts coming out of the Stamp. The onboard regulator can't supply that much current and your Stamp will keep resetting. If you're using AA or bigger batteries (not a 9-volt) you might be able to power the motor off those also, but this depends on your particular motor & wiring layout. Best bet is to use seperate batteries for the Stamp and for the motor.
I suggest you start by just getting the reed relay working (no motor). Just hook it up as described, and run a simple program like:
abc:toggle 14[noparse]:p[/noparse]ause 1000:goto abc
Then use your multimeter to verify that the reed switch (end contacts) are making & breaking contact. Only after that, get the motor going. Again, no polarity concerns here. Cheers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Remember, if Tony Stark can make an Iron Man suit in a cave, you can get this motor going! I took the liberty of snapping a few shots of what we've been chatting about. The motor was running for 1 sec and off for one sec, per the attached program. To keep things·clear in the photo, I kept wiring to a minimum and didn't include a diode here. It does work without it, but it is good policy to put one in parallel with the relay coil, banded end to pin 14 in this case, non-banded end to ground (Vss, battery negative). Put one in once you get it all going. Hope it helps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Thanks so much for going above & beyond on the circuit and the photos!· I really appreciate it.·
There·IS a common contact on the relay.· I'm looking at the schematic from the back of the packaging from Radio Shack now.··There 2 cooil contacts.· On the opposite end of the relay from where the coil contacts are, is the Normally Open (NO) contact.· The only contact left, back at the coil end of the relay, is the COM contact (at least according to the schematic from RS).
I did have it connected to the external battery I had.· But I thought I wasn't using it correctly and turns out I was right.· I'm trying it again based on your direction and photos.· I'll let you know what comes of it.
BTW:· I have a BOE (USB) and a BS2.
Thanks!
John
SUCCESS! I made your circuit first. Worked fine. Motor pulsed on and off about each second. Then I worked that one into my original circuit. I think I was just using the reed relay incorrectly.
But I was able to get the PING sensor to work and to turn on the motor! Yeaaaah!
Thanks again everyone for all your suggestions and help!
John
P14 with a 100ohm resistor to base.· Emitter jumped to vss.· I am using the same relay as in this thread.· One side of the relay goes to a +5V.· The other side goes to the collector.· How do I hook up the small motors?
Any help is appreciated.
Steve
Thank you for your quick response.· I guess I am still stumped.· The two leads coming out of the motor, where would they hook up to?·
Steve
Go to the main Parallax webpage and click on the Resources tab and you'll see a link to the Nuts and Volts Columns index.
If you still can't figure it out, ask again and mention what you don't understand after looking at the magazine article. Your motor would be the LOAD shown in Figure 6.1.
Again thanks for the information.· I have read that article a couple of times the last few days.· I have to admit, I am not good at reading schematics.· I understand fig 6.1 and the load.· But in that figure, where does the relay come in?· On the last page I think I understand.· When pin 7 comes high it closes the relay, but I do not see anything else to see how the door unlatches or how it is connected.
Steve
Can you please elaborate on your last post.· I am not following.· Here is what I have.· I have a HW Board.· I want to attach a 3V motor to it.· From reading the thread I thought I need a relay (which I have).· But since I am using the HW board I thought I needed a switching transistor.·
Steve