Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Using a transistor as a relay

Status
Not open for further replies.

StealthRT

Member
Is there anyway i can use a transistor in place of a relay in order to turn on the power switch to my PC?

Any help would be great!

David
 
Possibly, but it depends on what you are trying to do.

1) I assume that power to your PC is AC. A standard transistor won't work for AC. You could use a Triac though.

2) Neither a transistor nor a Triac will give you isolation. A relay does give you galvanic isolation between the coil and the contacts. But you could achieve that by using an opto coupler t drive the Triac.

Is there a specific reason you don't want to use a relay?
 
Last edited:
Possibly, but it depends on what you are trying to do.

1) I assume that power to your PC is AC. A standard transistor won't work for AC. You could use a Triac though.

2) Neither a transistor nor a Triac will give you isolation. A relay does give you galvanic isolation between the coil and the contacts. But you could achieve that by using an opto coupler t drive the Triac.

Is there a specific reason you don't want to use a relay?

I am looking to use an Arduino with a touch sensor to turn the computer on or off. The relay makes noise everything it does something so i wanted to find something that made no sound.
 
I suggest using a solid state relay then. Which is an opto coupler and a triac in a single module.
 
They are expensive :)

Are we talking an ATX or AT power supply?

If you are talking about replacing the small switch on a regular PC with an ATX power supply (or anything recent, where the switch is actually a "soft switch" - that is, the BIOS monitors the switch state), then all you need is something very small to make a momentary contact. Look into an SPST reed relay; they are very small, some (I note -some-!!!) can be driven directly from an Arduino's output pin (such a relay needs to have coil that pulls 20ma or LESS), and they are nearly silent (inside a PC case you'll be unlikely to hear it, unless you put your ear right next to it).

Otherwise, if you can find out whether the pin is pulled low or high when it is pressed (likely low, but check it first), then you might be able to use a small transistor (if pulling low, a 2n2222, for instance). You won't be isolated, but you're not dealing with mains voltages either. Just make sure you put on a base resistor to allow you to put the transistor into saturation.

Now - if you're talking an AT power supply - that's a whole 'nother ball game (in that case, an SSR is called for if you want it to be silent).
 
Alright so this:

Well - first off you may want something smaller than a 1K resistor to put the 2n2222 fully saturated (maybe 470 ohm, or 330 ohm); but try the 1K first, can't hurt.

I am not sure why you are connecting it to one of the analog input pins, unless you have no other pins left over, and you intend to set the pin to use it as a digital output...?

As far as the "PC Neg" and "PC +5V" - I don't know what these are. If your PC is an ATX power supply with soft-power switching (that is, there is a small momentary pushbutton that connects to the pins on the motherboard), then what you need to do is determine whether, when those pins are shorted (as they are by the pushbutton), whether one pin is being pulled low or high (and if high, what that voltage is - it may be 3.3V and not 5V, for instance). I don't know what motherboard you are using, or what the pins are labeled, or how they work - but you need to determine this first.

If you -are- pulling the pin LOW, then your circuit may work fine; in this case, the wire you have labeled "PC Neg" would go to the "ground pin" of the motherboard soft-power on pin set, and the "PC +5v" would go to the other pin in the set.

But you need to verify this information first! Otherwise you risk damage to the motherboard as minimum. It still may be more prudent to use that 2n2222 to control a reed relay, and then put the contacts of that relay across the power-on pins of the motherboard (believe me, a reed relay does not make a loud click sound).
 
Updated the image in my previous post to reflect the changes suggested.

Ok - you really should've posted a new image, instead of updating the old (because now my old message doesn't make any sense for people in the future); anyhow...

You show an image of a PC power switch connector - but I don't know if this is -your- power switch, or a random image off the net; also - which pin/wire color is "what"? Have you determined that with your board? The thing is, one of the pins is going to be either a ground pin, or a voltage pin (whether that is 3.3V or 5V, I don't know), and the other pin is going to be a "power on pin"; that is, that pin will be connected in some manner to the BIOS to generate a "power-on interrupt" or similar, so the BIOS can tell the power supply to turn on via the ATX connector. You need to determine both what and which these pins are on the motherboard, so you can connect it right (and, especially if the "power-on" pin is an active HIGH pin, and the other pin is a "voltage source" of 5V or 3.3V - then you need a different transistor (2n3907, IIRC - I think that's the PNP complement of the 2n2222), and to hook the transistor up completely differently. Otherwise the circuit won't work.

So get that figured out first (or - use a reed relay - you haven't said why you don't want to use a reed relay or anything about it - is there an issue there?)...
 
Along with what cr0sh has presented here is an image of an ATX form factor motherboard:

**broken link removed**

The circled pins would normally be connected to the front panel momentary on push button. In this case one pin is +5V and the other pin is common (ground). Now you can use either a NPN transistor like a 2N2222 or as mentioned a small reed relay across those pins. If a transistor is used the collector is connected to the +5V pin and the emitter to the ground pin. The +5V is held at 5 volts using a pull up resistor on the board and when it is placed at logic low momentarily the system starts. Hopefully the image will help clarify things.

Ron
 
Alright correction. This is the type of switch i will be connecting to:

View attachment 65573

When i connect those points shown in the picture together the PC starts up. Holding the wire on them for a couple seconds turns it right back off.

Would the same setup be needed for this as well?

David
 
I just checked with a voltmeter those 2 points. When the motherboard is OFF it reads around 2.96v (So i'm going to call that 3v) and when i push the button down it goes to 0v. Releasing the button makes it go back to 2.96v (3v).

David
 
Well i tested this out and i'm not sure about the setup values.

At both times i get 0v when the 5v port is on (HIGH) or when its off (LOW) using a 330ohm resistor.

At this point it would seem it would turn on the pc even in the off (low) state?

Any ideas?
 
hello David,

you are not answering question about power supply. also your "PC Neg" is floating, should be connected to GND (see red jumper).

in general digital electronics is running on lower and lower voltages. based on your post #13, it appears that that I/O portion of the motherboard is running on 3.3V.

digital inputs are largely using pull up resistor and sink input (PB wired from input to GND). your measurements confirm this. usually pullup resistor value is high (over 10k, more like 100k or sometimes even higher). this also means that you may have a problem if leakage current in your circuit is significant or if you are touching things with your hands for example (skin resistance).

note that not all 3.3V logic is 5V tolerant so poking around can be risky if you are not careful (specially if not current limited). connecting to switch terminals that are diagonal to each other is ok (just verify polarity) although any motherboard will have headers for power on switch (don't recall ever seeing power on switch soldered on motherboard, what is the form factor or board model?).

not sure what is 330 Ohm value you mention. Is that base resistor for 2N2222? that is on the low side but should be fine. if your arduino port changes state but PC does not respond, it is likely because of mentioned missing GND connection.
 
OK im going to switch gears here. I got a 5v relay that i will now be using.

I hooked it up and it triggers the relay closed when the digital output is high. And i have it feeding a gnd to the middle and the output pin on the relay is reading 0v. However when i hook that end up to one side of the switch and the other side to the arduino gnd it does not trigger the motherboard on once the relay is closed.

**broken link removed**
 
Fixed by doing the following:

CocaCola said:
attachmentphpattachmentid4897stc1d134256-1.jpg
 
Last edited by a moderator:
congratulation.
mission accomplished...?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top