Designing a circuit that triggers an opto with either 12VDC or GND input

Hey all, I’m excited to finally be partaking here. Sadly my first post is because I’m stuck. Rather embarrassingly so. I’m certain this should be an easy circuit, but it has eluded me for days. I’m working on the 3 channel high level input section of my board. Currently I do selection through a jumper for 12V+ or short to GND input on a Broadcom ACSL-6400-50TE quad channel optocoupler.

I’m trying to get the inputs down to 3 pins with the 4th pin being system GND. To do this I need to sort out the circuit to take both 12v+ and gnd contact to trigger the led in the Opto. My statement of “I’ll have it sorted by dinner” at the beginning of this has haunted me daily. I have tried NOT gates, various NPN and PNP BJT combinations, NPN/PNP MOSFETS, ect. For what ever reason I just cant get my head around it. Any help would be great!
I have made a simple drawing showing the basic idea.


Here is a link to the latest thing I have tried. It is a NOT gate, which does work, but wont turn off. lol. Simpler is better of course. And if it can be found in a quad circuit in a TSSOP even better! lol

Thanks for any input.

Hello and welcome.

We are looking into this and will be back to you as soon as we can.

Thank you


What behavior are you trying to achieve?

Are you trying to energize the Opto with the presence of 12V output and turn off when it’s gone? Or the opposite?

If you’re looking for an inverter maybe instead of giving it a steady 5V input on the Opto you grounded the cathode and then controlled the Opto by connecting a transistor to the output of the below schematic by connecting it to Anode.

Frankly at this point I don’t know what I’m looking for. The behavior I need is to be able to turn on the opto’s LED with either 12v+ or shorting to gnd, but on the same pin. I will have a single pin per opto channel coming into the box. In this case pin 1 above. If someone shorts that pin to the system gnd I need the opto to come on. OR If someone connects the gnd of an external 12v power supply to the system gnd (Through pin 4 in the graphic in post 1) and then connects the 12v to pin 1 I need the opto to come on.

Basically 2 scenarios:

  1. Pin 1 is shorted to pin 4 and the opto turns on.
  2. 12VDC is applied to pin 1 (12VDC+) and pin 2 (Common GND)

Hope this helps!

(post deleted by author)

Hello Evan,

That operation could be performed using a window comparator.

  1. Construct a voltage divider to produce 1/2 VCC. Two 10 k Ohm resistors would work. Connect the 1/2 VCC to your pin 1.

  2. Design the window comparator to trigger at the desired voltage. For example, a voltage higher than 4 or lower than 1.

Note that the window comparator often features devices with open collector output. This allows the outputs to be connected together using what is known as a wired-or configuration. This allows a voltage greater than 4 or a voltage less than 1 to activate the circuit.

Best Wishes,


P.S. Be sure to add a series resistance to the input of the comparator. This is necessary to prevent circuit destruction when voltages higher than the comparator’s VCC are applied to the input. Yet another 10 k Ohm resistor may be a good starting point.


Thank you APDahlen, this sounds perfect. Of course my simulator seems to be broken and I can’t test it. Because I wouldn’t be so lucky. It seems the comparators in the simulation will not let me edit their parameters. Below is a link to what I have so far. I can’t swap the pins on the comparitors so that’s why it has the crazy cris-cross wires.

I do have some confusion though. I can see how this turns things on within the high-low voltage “window” but what changes do I need to make for it to trigger outside of that window and be off within it?

Thanks again,

Hello Evan,

Are you asking how to invert the signal?

If so, the transistor solution presented earlier by Kristof_2649 would be good. You could also implement another comparator. For example you have a few spares if you use a parts such as the LM339:

Have a good weekend,


1 Like

Here is the circuit you linked above:

In the text it states:
A window comparator will have two reference voltages implemented by a pair of voltage comparators. One which triggers an op-amp comparator on detection of some upper voltage threshold, VREF(UPPER) and one which triggers an op-amp comparator on detection of a lower voltage threshold level, VREF(LOWER). Then the voltage levels between these two upper and lower reference voltages is called the “window”, hence its name.

I need to be outside of this window correct? “higher than 4 or lower than 1” Do I do this by
Setting VrefLower to be higher than VrefUpper?

My apologies, like I said, solving this problem has scrambled my brain.

Thank you for the quick responses, It’s nice to have somewhere to discuss this issue!

Forgot to add the “fixed” 2.5V divider image.

Can you change the switch type on the far left? Use three position on-off-on switch or use two independent switches. This should make it easier to see your simulation results.

1 Like

I just checked, but no. I put in the second switch so I could test truly floating inputs. On all of the other circuits I tried I would get the same result floating as I did low input. So I wanted to have a way to test it.

I’ve only been using this simulator for about a week. I normally don’t use one, but trying to sort out this circuit had my brain in knots.

What is neat about it is by going to the URL anybody can edit the simulation.

Did what I post a moment ago make sense?

It seems I cannot post the link to the live simulation.

Understood, then get rid of the simulated switch. Use a DC source in its place. See what happen at 12, 6, and 0 VDC.

1 Like

Without you being able to see the simulation this may never work. I just realized the exported images show nothing like the simulation. I have take a series of screen shots to try and aid explanation.

Are you suggesting my circuit looks correct?

Ok, so with nothin on the input pin at all the voltage is dumping through from the 5V through the 1K, through the Opto and to gnd.
As shown below with my excellent art skills:

When the input pin is grounded very little changes other than some voltages around the input pin dropping.

When the 6V supply is connected the same as GND occurs.

Good point, disconnect the optical isolator and see if the window comparator operates as expected.

When 12V is connected The voltage bypasses the opto and sinks through the bottom comparator.


1 Like

Also replace the input resistor to the other side of the voltage divider. The input pin will connect directly to the voltage divider and the resistor will be placed between the divider and the comparator inputs.


Ok, for 12V+ this is the current paths:

For GND this is the Paths:

It seems there is progress?

There are 2 issues: when I attach the Opto it all goes out the window.

  1. When I attach the Opto it all goes out the window.
  2. I had the resister before the input divider to protect the system 5V from the 12V input. Everything would fry with 12V on the 5V rail.

Although I guess a diode would fix this maybe.


  1. Replace the switch with the DC source for better control in this simulation.

  2. Place the optocoupler’s diode in series with the 1k wired-or resistor (far right on this schematic).

RE “I had the resister before the input divider to protect the system 5V from the 12V input,” the protection is still present with the “input” resistor in either position.

1 Like