0
\$\begingroup\$

The circuit consists of a 12V DC supply, there is a GPIO to turn on the solenoid rated at 12V 500mA. Also, a manual switch is there to turn on the solenoid when needed.

The placement of LED and 1K resistor is such that LED would turn ON whenever Solenoid is turned on, be it either due to GPIO high OR by manual switch. My requirement is to Turn on a LED if Manual Switch is ON irrespective of GPIO level.

  • Manual ON , GPIO ON : LED ON
  • Manual ON, GPIO OFF : LED ON
  • Manual OFF, GPIO ON : LED OFF
  • Manual OFF, GPIO OFF : LED OFF

How can it be accomplished?

NOTE: TIP122 is transistor used. The diode is flyback diode

Circuit Diagram

\$\endgroup\$
5
  • \$\begingroup\$ I remember you ;) Hey, why do you want to do this??? It doesn't make sense. What you are asking for is "SWITCH ON, LED ON" and "SWITCH OFF, LED OFF". Those are really the only 2 combinations you have specified. The state of the transistor/solenoid would be irrelevant. Are you sure this is what you want??? \$\endgroup\$ – Kyle B Dec 3 '20 at 6:33
  • \$\begingroup\$ @KyleB Hi. Thanks. The reason i want a separate LED for Manual ON button is for end user to know he has turned ON solenoid using manual button. The MCU controls when to turn on or off the solenoid. Manual Switch is for override. So there needs to be an indication that the Switch has been turned ON. \$\endgroup\$ – Ouroboros Dec 3 '20 at 6:37
  • \$\begingroup\$ Ahh... OK, so the switch still controls the solenoid... I didn't catch that. Got it... Gimme another minute I'll sketch you something.... Important question though --- How much current can your CPU I/O pin provide??? \$\endgroup\$ – Kyle B Dec 3 '20 at 6:40
  • \$\begingroup\$ Hi Kyle. Thank you so much! The gpio provides max 25mA. \$\endgroup\$ – Ouroboros Dec 3 '20 at 6:46
  • \$\begingroup\$ Both the gpio or switch can turn on the solenoid. Do let me know if you need any other inputs @kyleB \$\endgroup\$ – Ouroboros Dec 3 '20 at 6:47
2
\$\begingroup\$

Adding a diode like in the following picture will do the job:

enter image description here

\$\endgroup\$
9
  • \$\begingroup\$ will it be able to handle spark as Kyle's answer indicates? What diode would you recommend? \$\endgroup\$ – Ouroboros Dec 3 '20 at 7:26
  • 1
    \$\begingroup\$ sparks will be short circuited by the freewheeling (flyback) diode. don't forget that the flyback works when the swicth is open (high resistance). \$\endgroup\$ – Paul Ghobril Dec 3 '20 at 7:27
  • 1
    \$\begingroup\$ Okay. Will 1n4001 suffice @paul? \$\endgroup\$ – Ouroboros Dec 3 '20 at 7:36
  • 1
    \$\begingroup\$ yes 1N4001 or any 1N400x if you do not have 1N4001 will be perfect. \$\endgroup\$ – Paul Ghobril Dec 3 '20 at 7:39
  • \$\begingroup\$ I already have 1N4007. Would that work? \$\endgroup\$ – Ouroboros Dec 3 '20 at 8:05
1
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

There's a million ways to do most anything. What Paul drew is clever and would work. So would this one.

Mine has 1 more component, but Pauls has two minor tricks you should be aware of...

One is that diode has to be able to handle all the solenoid current (500mA)... not all diodes can do this. What I wrote uses 2 small-signal diodes --- 1N4148's can't handle 500mA (not even close). So these 2 diodes would be cheaper, but there's 2 of them. Pauls circuit, you'll need a power diode like 1N4001.

Another catch with his circuit, all the current flows through the switch so it also has to handle 500mA (and the associated spark that occurs when a coil is interrupted), with mine the current in the switch is a trickle and not inductive i.e. you can use a smaller switch, or if using the same switch, it would likely last MUCH longer.

BTW, The 270 resistor is presuming a 5V I/O. If it's only 3.3V, that resistor should be made smaller.

\$\endgroup\$
3
  • \$\begingroup\$ Just for simplicity I chose Paul, but if I could I'd also choose this as the accepted answer. Thanks Kyle for all the details! \$\endgroup\$ – Ouroboros Dec 3 '20 at 7:55
  • \$\begingroup\$ Haha don't worry, I don't take it personally ;) \$\endgroup\$ – Kyle B Dec 3 '20 at 8:06
  • \$\begingroup\$ do you agree with Paul that flyback diode will take care of the sparks? Can 1N4007 suffice for flyback in his circuit? \$\endgroup\$ – Ouroboros Dec 3 '20 at 8:12

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.