The Below mentioned circuit switches 12V when the OPTO sense high voltage

The Strings of LEDs is connected to OUT1 and also an SPST switch is also connected externally (not shown in image). The Switch is connected to 12V on side and another side to OUT1.

When Switch(SPST) is ON, i.e 12V is short with OUT1 for short time, the OPTO senses High-level voltage and MCU turns on the MOSFET producing flashing effect at OUT1. The moment MOSFET is turned ON, there will be high voltage at the OPTO as well as at the OUT1. This won't have any effect until the OPTO continuously senses High Voltage for 5 secs and MCU will turn off the MOSFET, which will happen only when the switch (SPST) is short for 5 secs, the output from MOSFET will in switching state (1sec on/off), so it can't be continuous of 5 secs.

The 5 secs delay in sensing is used to differentiate between the Actual high voltage from the switch(SPST) and the output from MOSFET.

Now the issue is with 5 sec delay which is undesirable, 1sec can work but with the kind of switching pattern, it will overlap and the everytime pattern starts the MCU will shut it off.

How can the circuit be modified with very fewer components so that, the voltage from the MOSFET side does not go to OPTO and only goes to the OUT1 ? And Whenever Voltage comes from the OUT1 Connector, the Opto should sense that. enter image description here

  • \$\begingroup\$ I'm having a hard job reading your description of operation. I'm also having difficulty understanding how T3 and PC817 are doing anything when neither have a path to ground. They're fighting each other. Can you clarify? \$\endgroup\$ – Transistor Oct 28 '17 at 12:05
  • \$\begingroup\$ Updated the post. Hope it's clear now. \$\endgroup\$ – Embedded Geek Oct 28 '17 at 12:27

How can the circuit be modified with very fewer components so that, the voltage from the MOSFET side does not go to OPTO and only goes to the IN/OUT connector? And Whenever Voltage comes from the IN/OUT Connector, the Opto should sense that, doesn't matter if it goes to MOSFET drain or not.

My deciphering of this requirement is:

  • I want to detect if LEDs are being powered from the MOSFET or from the manual switch.
  • How can I signal this via opto-isolator to the MCU?


simulate this circuit – Schematic created using CircuitLab

Figure 1. (a) Original circuit. (b) By reconfiguring the opto isolator we can sense current direction.

How Figure 1b works:

  • If MOSFET is on current flows to LEDs through D3. You will lose 0.7 V on the LED supply. 12 mA will flow through R2. Opto-LED will be reverse biased and will be off.
  • If MOSFET is off and MANUAL switch is on then D2, the opto-LED is forward biased and Q2 will turn on.
  • If MOSFET is on AND the manual switch is on then D2 will be off.

If the MOSFET is on and you want to detect whether the manual switch has been closed or not you will have to periodically switch the MOSFET off for long enough to detect the opto-isolator turn on. A short blink every 100 ms or so shouldn't be noticable.

| improve this answer | |

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.