I am working on a microcontroller project for a garage door opener. Rather than supply additional magnet+reed switches or other kind of detectors for sensing whether the door is full-open or full-closed, I would prefer to make use of the existing physical limit switches.

In the open state, there is 6.5V across the terminals of the limit switches, and in the closed state, there is about 5mA flowing through. Clearly there is already some current-limiting circuitry in the machine.

In order to provide protection/isolation for my microcontroller, I have been working with an MCT9001 dual opto-isolator chip. With a 1k-ohm resistor in the emitter (input) side of the opto-isolator, I am able to regularly detect the state of the limit switches. However, the garage door opener won't operate when both switches are closed, and with that 1k-ohm resistor, apparently there is sufficient voltage drop that the opener detects that the open switch is closed.

When I increase the resistor to 220k-ohm, the opener operates correctly, but now my opto-isolator isn't operating in saturation mode and so my microcontroller isn't able to reliably determine a clear logic-level signal.

I will continue to try different resistor values, but my question is: Is there a better way to detect whether a voltage is present without drawing any more than a miniscule amount of current?

I see examples of op-amp comparators, but if I power an op-amp with my project power supply, I would have to tie the grounds of the project board and limit switches together and would lose my isolation provided by the opto-isolators. But if I power the op-amp with the switch leads themselves, I (a) will draw too much current to run the op-amp and (b) will not have any power to operate the op-amp when the limit switch is closed.

Is the better solution to find the right resistor value tolerable by the garage door opener, yet which is not so high that the op-amp source emitter is too dim?

  • 2
    \$\begingroup\$ Have you tried like, looking at the optos datasheet and determine the current it needs for reliable operation and then calculating a resistor value for that? \$\endgroup\$ – PlasmaHH Oct 24 '16 at 14:44
  • 2
    \$\begingroup\$ Have you tried putting the opto in series with the switch? \$\endgroup\$ – Daniel Oct 24 '16 at 14:44
  • \$\begingroup\$ Use a high-CTR optcoupler like the 6N139, or build your own by adding a transistor (but drop R3). \$\endgroup\$ – CL. Oct 24 '16 at 14:53
  • 2
    \$\begingroup\$ Sorry to be 'that guy' but some caution is called for in fiddling with garage door openers- people (kids mostly) can die when the safety mechanisms don't work properly. The controllers are rightly treated as safety-critical systems. \$\endgroup\$ – Spehro Pefhany Oct 24 '16 at 15:05

Since it appears that the voltage across the optoisolator input is low enough for the controller to interpret it as a low, just put it directly in series with the switch:


simulate this circuit – Schematic created using CircuitLab

Since the door controller is already limiting the current, you don't need any additional resistors in series with the LED.

If the current sourced by the controller was more than the optoisolator could handle, then a slightly more complicated circuit using a transistor would be required.

  • 2
    \$\begingroup\$ Blindingly obvious. I overlooked it because I wasn't considering cutting any wire in the existing infrastructure. Though I will have to be careful testing, as this has the possibility that the opto's emitter drops the voltage enough that the existing sense circuit is not triggered at the physical limit to the door. \$\endgroup\$ – jose can u c Oct 24 '16 at 15:24

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.