5
\$\begingroup\$

I'm making a simple microcontroller based circuit to turn on a computer when certain events are triggered. I am interfacing it using the PCs soft power switch pins on the front panel header:

Front panel header

There are two relevant pins on this header, I'll call them SW+ and SW-. SW- shares the PCs system ground, though I'm not sure this is always the case. SW+ is, in my test system, 3.3v above ground, although I suspect this could be more or less.

In a typical computer, a NO momentary switch on the front panel shorts these two pins when the power button is pressed. I want this to instead be controlled based on a logic level signal from a microcontroller.

My first attempt at a test circuit is as follows:

Test circuit

I tested the polarity of my header and made sure SW+ really was the positive pin. My microcontroller was powered from USB, therefore sharing system ground, so connecting SW- and controller ground was not a problem.

The circuit worked as intended, but it's obviously not very great. I want to make this circuit as universal (not system dependent) as possible. This poses the following problems:

  • The polarity is not indicated - the user can not be relied on to insure a specific polarity.
  • The voltage is not exactly known - it's better to assume it will be somewhere between 2-12v.
  • The controller should be isolated - it might share the computer's ground, but this is not guaranteed.

The simplest solution that comes to mind is using a relay. I may end up doing this, but I really would like to avoid it due to reliability, size and price.

Is there any transistor based solution (essentially like a relay) meeting the criteria above?

\$\endgroup\$
2
  • \$\begingroup\$ A solid state relay? \$\endgroup\$ – gbulmer Sep 16 '14 at 17:10
  • \$\begingroup\$ @gbulmer This is probably the nicest possible solution, though it could be a little bit expensive in some situations. \$\endgroup\$ – tehwalris Sep 16 '14 at 17:30
6
\$\begingroup\$

My first reaction is to use a opto-coupler. That isolates your microcontroller from the PC ground, which is a good idea. This solution still requires that the device be installed with the correct polarity, which personally I don't think is a big deal.

I also don't think that worrying about the voltage being high makes any sense. The front panel button is going to be a logic level signal. However, the output of optos will be a bare transistor. Most can withstand 20 V at least, which will surely be enough.

If you really insist that the output should be polarity-independent, then use two optos with outputs wired opposite but in parallel:

Check the maximum allowed reverse bias voltage of whatever optos you use. These are good to 6 V, which will be fine for a PC power switch which isn't going to operate on more than 5 V logic, most likely less. This example puts about 10 mA thru the LEDs, and draws around a mA from the logic output. Nothing is being pushed to the limit here, and the output is polarity independent.

\$\endgroup\$
1
\$\begingroup\$

If you put a diode in series with transistor collector it is likely that this would work. If someone wired this up in reverse, placing a high value leakage resistor across the transistor (maybe 1Mohm) would protect the transistor. Duplicate this circuit so that one of the transistors would always work no-matter what the polarity and you have a bipolar solution.

Then get rid of the transistors and replace with opto-couplers. Now you have a biploar and isolating solution.

I did think of using a single opto "encased" within a bridge rectifier but I believe the overall volt-drop (when activated) may be too great but it's also worth a try.

As mentioned by @gbulmer a solid state relay would work but availability and cost may be an issue.

\$\endgroup\$
3
  • \$\begingroup\$ The optocoupler idea is good, I thought of something very similar when reading about how solid state relays work. \$\endgroup\$ – tehwalris Sep 16 '14 at 17:31
  • \$\begingroup\$ Panasonic makes nice small SSRs that cost next to nothing. \$\endgroup\$ – venny Sep 16 '14 at 17:33
  • \$\begingroup\$ @venny For future readers, I ended up going with this and it worked perfectly. \$\endgroup\$ – tehwalris Aug 2 '17 at 20:18
0
\$\begingroup\$

So, I tried the suggested avenue with a relay.

Additional detail [the relay is a Wi-Fi controlled device by eWeLink from Amazon. The eWelink is then paired with an Amazon Alexa which then allows me to control the PC from anywhere.]

I found that the PC is ok with a fast momentary pulse to start (eg. 0.5s), but it requires a long pulse to shutdown (eg. 5s). The problem with just using a relay is that the shutdown works fine, but the slow pulse when used for startup causes the PC to start and then immediately shutdown.

This seems to be a debouncing problem. I surmise that the PC may have a very short debounce circuit for the power switch. This is not enough when the used with the 5s timing to start the machine. So using the 5s relay pulse causes multiple pulses which start it and then starts the long timer which ends after the 5s causing the PC to shut back down.

I have not tried this, but a debounced relay contact at 5s with the dual opto circuit proposed above would be the Cadillac solution for universal use - particularly with the web based wi-fi relay setup.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This doesn't really look like an answer. Also note you should not be using the power button to routinely shut down a PC, but rather command a safe shutdown. Ultimately the problem you seem to be having comes from using a fixed function relay controller rather than an MCU (as the question is actually about) which could easily produce different pulse lengths for different purposes. \$\endgroup\$ – Chris Stratton Dec 27 '19 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.