1
\$\begingroup\$

Sorry for the dumb question, but my electronic skills are even lower than basic level.

I need to switch on a relay when PC turns on. I made a simple scheme on the run, but I'm afraid it isn't good enough not to damage the USB controller.

I tested it on EveryCircuit, and it draws about 50mA current. My only doubt is about directly connecting the relay coil to USB power. Is it good or I need to change it?

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
  • \$\begingroup\$ "I need to switch on a relay when PC turns on." - there might be a problem. Most desktop PCs keep VBUS on even if the system is in standby (off) mode. So you might end up with the relay always on (unless PC is disconnected from mains AC power). \$\endgroup\$ May 1, 2019 at 4:10
  • \$\begingroup\$ I think my PC is ok with that. I have a USB mouse and, when I turn off my PC, the mouse led shuts down. On my former PC it stayed on even when shut down. \$\endgroup\$
    – Jager
    May 1, 2019 at 23:58

2 Answers 2

2
\$\begingroup\$

The relay needs a freewheeling diode to prevent damage to the USB socket and/or LED if it is unplugged while powered on.

In the 1980s 100 ohms would be appropriate as the resistor but since then LEDs have become much more efficient and 330 is probably a better choice

The series diode does nothing useful so I moved to to be the freewheel diode. as you relay uses less than 100mA the 1n4148 is suitable here. but rectifier diodes like 1N4001 can be used instead. However, personally I like the 1N4148 mainly because I have 1000 of them sitting in a jar.

schematic

simulate this circuit – Schematic created using CircuitLab

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

You will find that your Status LED will be VERY bright, you will probably end up with a 220 ohm resistor instead of the 120.

Where you have the diode at this time will force all the current your relay coil draws to go through the diode. The diode is probably not needed in this circuit.

As long as your relay is rated at 5VDC it should work as you have it in the circuit.

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Also add a flyback diode. \$\endgroup\$
    – user253751
    May 1, 2019 at 2:16
  • \$\begingroup\$ A flyback diode, sometimes called a snubber circuit, is to allow the energy from the magnetic field of the coil to go back to the supply instead of destroying the driver circuit. Since there isn't anything driving the circuit it is not required. \$\endgroup\$
    – Wendall
    May 1, 2019 at 2:32
  • 1
    \$\begingroup\$ What do you mean that there isn't anything driving the circuit? Where do you believe the 5V comes from? \$\endgroup\$
    – Ron Beyer
    May 1, 2019 at 2:56
  • \$\begingroup\$ The magnetic field of the relay will collapse when the device is unplugged, so where can the induced voltage possibly go since it isn't plugged in any more. There won't be a reason for the diode until the relay is de-energized and when it is the USB source is already unplugged... \$\endgroup\$
    – Wendall
    May 1, 2019 at 15:39
  • \$\begingroup\$ I added the diode because, when I tested on EveryCircuit, I noticed that, without the diode, I have a -15V spike on the VBUS line. I know it's just simulated behaviour and that USB controllers have their own protection circuit, but I'm afraid I could destroy something. I've only studied very basic electronics in high school, not enough to be sure about how stuff really works. @Wendall Technically, the device will never be unplugged. The induced voltage will still go through the USB circuitry. Or at least I think so, according to the simulation. \$\endgroup\$
    – Jager
    May 2, 2019 at 0:09

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.