using transistor to control relay
Jayguy5000
Posts: 139
For those following along my project I have gotten the IR working! awesome. now I need to re learn how I was using a 2222 transistor to control a small spst reed relay, takes 5vdc across the coil to flip it. my set up was connected to the relay and the basic stamp so when the bs2 sent out a signal to the 2222 it opened up and let 5vdc from the vdd through to the coil of the relay and it worked. The nominal current of the relay coil is 20ma which the bs2 could power, but only one relay, I want to set up multiple relays all controlled by transistors. This set up has worked pleanty in the past I just forget how it was done. I would imagine I had the 5vdc from the vdd connected to the coil and the coil grounded to the transistor and the transistor back to vss. Ofcoarse the other pin of the transistor was connected to a I/O pin and I think I sent a HIGH signal it. Well you get the picture, can you either correct my set up or verify it is correct before I try some smoke testing please? Thanks! this should be my last question for a while.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
Comments
Connect the base of the transistor to the stamp with a 1k or so resisitor. Connect the emitter of the transistor to ground. Connect one side of the relay to +5V and the other to the collector of the transistor. To make sure t doesn't have any false triggers, connect a 10 to 47K resistor from ground to the base of the transistor. Don't forget to put a back EMF diode across the coil of the relay.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
The diode should be connected to the coil wires of the relay, as close to the relay as possible, just as Chris's schematic shows. The 10-47k would go to the base of the transistor to ground, where the 1k series resistor and base of the transisitor connect. The reason for it is to make sure that noise (small voltage spikes) don't trigger the transisitor. Connecting the base to ground with the resistor means it won't turn on unless you want it to by sending the Stamp pin high.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Guess I have been wasting resistors for years. [noparse]:)[/noparse] Thanks for setting me straight. Erco, I knew I would find a use for all those flux capacitors I have been saving.[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
OK, not quite 8.7 Gigawatts. Not even 8.7 Watts. More like 0.1 Watt. Now where did I misplace·that decimal? [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
It depends on the type of transistor and configuration of the circuit as to whether or not you need a pull-up or pull-down resistor. It just happens that in this configuration with an NPN-BJT you would need to draw current (IBE) relative to the load you’re driving based on the HFE of the transistor.
Now, if you have a (MOS)FET these are voltage driven rather than current and stray signals on the gate can cause it to turn on. So you would put a 10K – 100K pull-down resistor on an N-Channel FET in this configuration.
There are times in certain circuits where you need to override the startup state until your MCU can get control. In these cases you would use a pull-up or pull-down resistor on the base.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thanks for the explanation, and it makes perfect sense. I knew that transistors are current driven and FETS are volatge driven, I just never thought it through. I picked up the pulldown habit long ago, goodness knows where, and then stuck to it. Being self taught has some disadvantages, I've learned more what works than what's right.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I too am self-taught and still pick up stuff here and there. I went to college but never finished due to some personal circumstances in my family life. But I recall my Digital Electronics Professor coming in, giving us a brief dissertation on the current logic gate or whatever and then leaving us to do some project to learn from it while he graded papers from his Math and Science classes. After correcting him on several issues with various diagrams I knew I wasn’t going to get anything from my first 2 years as everything pre-req for EE I learned back in high school. I had a mentor for a few years after that. Being old school I have noticed that some of the ‘standards’ I was taught seem to have changed slightly. I still tend to do things the old way unless protocol dictates otherwise. But the reason I bring this last part up is that a few times in the past on these very forums someone has suggested an alternative or even better way of doing something than what I posted and I too learn from this when it happens. Of course, since I remember you from your first Hydrogen Fuel Cell project I would say there’s something you could probably educate a lot of us on. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Oh, I don't mind being wrong, especially when someone sets me straight. It's all about learning in the end. After all, we are all usually wrong before we are right. I'm just glad to learn!
Thanks!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Oops, didn't see answers on the next page. :nerd: