Sensing the same NC switch from two controllers

Hi,

I had thought that this might be a common situation, but a lot of googling and forum searching hasn't turned up anything, so I thought I'd ask here - apologies in advance if this is the wrong board, as I'm new to these forums! Perhaps I'm searching with the wrong terms? If so, any hints on what to search for existing solutions welcome!

Background

I'd like to add a gate controller to a home automation system. The gate controller is in place and working, and has a terminal block to allow wiring in external switches for both:

  • sensing (e.g. open & closed limit switches, and photocells - these are already wired in as NC switches, and being used by the gate controller), and
  • actuation (e.g. start open, start closed - not yet wired, but intended to be NO switches).

The controller is a CTR-06 and the full spec is here. An extract of the wiring diagram (pg 8 ) for the terminal block is attached.

I'm comfortable with the actuation (I've tested shorting terminals 11 & 12 and it successfully starts and stops the gate), but I would like to be able to sense the status of the limit switches and photo cells without impacting on the existing controller's functionality.

I've done some measurements, and the 3 input terminals (5,6,7), are at 0V compared with COM when the switches are closed (i.e. the normal situation), but go up to 5V when the switch is activated - e.g. when the limit is reached, or when the photo cell is blocked.

Based on this, I speculate that the existing gate controller has an internal pull-up resister to a 5V reference - and this is at the heart of my uncertainty about how to sense the status of these switches.

Considered Options and Concerns

I've considered 3 possible devices, but I'm nervous that all 3 options have risks, and I'm wondering if anyone has any suggestions or alternatives to help me avoid releasing the magic smoke - from either the existing controller, or anything I add!

The 3 options I'm considering are: Arduino, ESP8266-based device, Shelly 2.5

Arduino

It seems that if I configure Arduino GPIO pins as INPUT and leave them as floating (i.e. not INPUT_HIGH), then I could just wire them to the existing terminals (e.g. 5, 6 7), wire between the controller's terminal 8 (COM) and the arduino's GND, and leverage the existing controller's pullup resister to ensure that the pin isn't actually floating.

When the switches are closed, the existing gate controller's input and the arduino's input would both be pulled to ground by the switch, registering as LOW input, when the switches are open, the gate controller's input would pull up to 5V and the arduino input would also be pulled up to 5V.

My concern here is that the gate controller's 5V reference may be different to the arduino's power supply, and I'm nervous about an over-voltage or over-current on the arduino input.

I'm also nervous that this would effectively create two parallel circuits through the two inputs and since I don't really know the internals of the gate controller, I'm not sure what the impact might be on either of them.

ESP8266

As the ESP8266 is at 3.3V, I have a similar concerns to with the Arduino, but even stronger as it's definitely above the ESP8266's voltage. I have read that in theory the ESP8266 is tolerant to 5V inputs, but also lots of people commenting that they toasted their chips with inputs over the standard voltage. In theory any solution to the Arduino concerns could also solve for an ESP8266 (with adjustments for 3.3V).

Shelly 2.5

The Shelly 2.5 is basically an ESP8266, however I think it is default configured to utilise it's own internal pull up resister. I suspect this is a bad idea as it basically creates a potential difference between the two internal reference voltages across the two pullup resisters and I'm not sure what that will do! I think if I flash the Shelly with something non-standard I might be able to explicitly configure it to not use the pullup, but I haven't been able to verify that.

Considered Solutions

I have considered some solutions to the issues noted above, but not sure if there is more I should think about:

Adding components to avoid over-current or over-voltage

I wondered if adding some combination of diodes & resisters could help protect the arduino/esp without impacting the existing gate controller. In particular a resister between the switches and the arduino input pin to help limit current flowing into the arduino - but without knowing the internal pullup resistance in the existing gate controller, I'm not sure what resistance to use to ensure the resulting voltage doesn't disrupt the existing controller's input.

Opto-coupler

It seems that if I wire an opto-coupler between the existing switches and my device (arduino or esp), it should ensure electrical isolation, but still allow to signal whether the input is HIGH or LOW into my device. I have found a cheap board with 4 optocouplers on it, so this seems like it might be a good bet.

One thought here is that since the gate usually closed, the 'closed limit switch' is normally active and since it's NC that means it's usually HIGH, so one of the opto couplers will be almost permanently 'ON'/'HIGH', not sure if that is a concern.

Put my controller between the switches and the gate controller

Another option might be to wire the switches directly into my controller, so that they are not shared, and then wire outputs from my controller into the gate controller, and use software to mirror the inputs to the outputs. At first glance this seems safe, but also seems to add risk - ideally I want the existing gate system to work fine, even if my home-grown kit fails for some reason (likely my error!).

Duplicate Sensors

I could just wire up reed switches to sense gate limit, and a second photo cell dedicated for use in my own controller. This seems simple enough, but also doesn't seem ideal to be sensing statuses that may not be the actual statuses sensed by the actual gate controller, so not a preference.

Replace the gate controller

I suppose in theory it should be possible to replicate the functionality of the gate controller in my own controller, as well as have access to the inputs, and completely remove the existing controller. The main issue here is that it would involve rewiring mains power to motors, and in my country that requires an electrician - I was really hoping to be able to do this on my own.

Conclusion

Thanks for reading, and as this is my first post please do let me know if I'm in the wrong area, or have inadvertently breached etiquette. For some context, I do have a degree as an electrical engineer, but it was > 20 years ago, and I've spent my whole career working in business software systems, so this relatively new foray into home automation electronics (this is my second project) is an exciting mix of nostalgia and faint memories resurfacing :slight_smile: Suffice to say, I feel like I should be able to answer this question myself, but I just don't trust my memory of long ago ELEC subjects!

If both are 5V it will work fine. One or both should have pull-ups (or both could have pull-downs).

It's generally OK to connect two more more inputs together (as long at they run at the same voltage) but you should never short multiple outputs together.

It's rare that I see a first post that compells me to say this but as everyone knows I call it like I see it.
Well done Grasshopper !
This is one of the most detailed, well organized and researched first posts I have seen in the seven years and 16,000 some odd posts I have read.
Keep up the good work !

Thanks for your thoughts!

If both are 5V it will work fine. One or both should have pull-ups (or both could have pull-downs).

It's generally OK to connect two more more inputs together (as long at they run at the same voltage) but you should never short multiple outputs together.

I guess is the point I'm worried about about them both being 5V - I should have clarified - I don't have access to the gate controller's internal 5V reference, so I will be powering the arduino separately. It will hopefully be from the 12V pin (pin 1 in the terminal block diagram). Since the two 5V references might be 'different' 5Vs (e.g. theirs might be 4.9, the arduino might be 5.0), I was worried that would cause damage to their 5V source - since I have no info on the internal design of their system, it's hard to be sure.

Is my reasoning sound or am I being overly concerned?

raschemmel:
It's rare that I see a first post that compells me to say this but as everyone knows I call it like I see it.
Well done Grasshopper !
This is one of the most detailed, well organized and researched first posts I have seen in the seven years and 16,000 some odd posts I have read.
Keep up the good work !

Feels weird to be called a grasshopper at my age, but I'll take it! Thanks!

Put a resistor between the arduino input and the switch connection on the gate controller. Around 10K ohm or more would not affect the input reading at all, and would limit any current flow caused by the arduino voltage being different than the gate controller. Note that the arduino input is fairly high impedence, so there is essentially no current flow when not using the internal pull-up.

You would really need to have a fairly significant voltage difference to cause any current flow, the arduino voltage being higher would not cause any problems, since that's almost always the normal condition, the only time you would see current flow is when the gate controller voltage was high enough above the arduino voltage to cause the input protection circuitry to function.

If you used an ESP8266, you could use a pull-up resistor on the ESP8266 side, then a diode to the switch input so that the switch can only pull the input to ground. That would prevent any problems with the pull-up from the gate controller because the diode would not allow any current flow to a higher voltage than the ESP8266 supply.

Feels weird to be called a grasshopper at my age, but I’ll take it! Thanks!

Don’t tell me you’re that old and don’t remember David Carrodine in Kung Fu ? (and Master Po)

There might be another way . If you have access to the controller GND and have verified with a meter that the signals that go through the limit switches are 5V logic. The TTL XOR Gate has the following truth table
The XNOR Gate acts the same but inverts the output.
XOR
IF one AND ONLY ONE of either input is H , the
output is H. If BOTH inputs are H OR LOW the output is L.
Put differently, If both contacts of a limit switch are the same (because they are shorted) the output is L. If they are different, the output is H.
The XNOR is the same but with an inverter tacked on the output. What you need to do is find out the voltage on both sides of the limit switches when they are open. You’re looking for one side to be L while the other is H. TTL inputs float H so if nothing is connected to a TTL input it will probably read H on the input.
TTL L is 0.8 or below.
TTL H is 2V or above.
If the switches read L/H or H/L when open, the an XOR gate will output a H when it is open.
It doesn’t matter if both sides are H or both sides are L when it is closed because an XOR gate only responds to conflicting inputs. If you need to convert the TTL to 3.3V you can use a CD4050BE logic level converter. To convert
5V to 3.3V power the chip with 3.3V. To convert 3.3V to 5V, power the chip with 5V.

High-to-Low Level Logic Conversion

As an irrelevant side note , the CMOS XNOR can be used to sense a 12V power transistor that is open or shorted by comparing the control signal with the collector voltage. OFF should be H because the transistor is not shorting the collector to GND. ON should be L because the collector is shorted to GND. If a L OFF control signal yields a L on the collector it’s shorted. If a H ON control signal yields a H on the collector then it’s open because the collector isn’t shorted to GND. That means a defective device will give a L output from an XOR gate. But what you need is a H to turn on the DPDT relay that switches the load from the bad primary device to the good backup device so you use an XNOR gate which will output a H (that turns on the 12V relay) if the control signal and collector are either both H (open transistor) or both L (shorted transistor) I used darlington transistors that were driving 96 12V neon transformers mounted on the ceiling of a 200 ft movie sound stage in a dark room where
real time troubleshooting was out of the question and the lighting system had to be redundant. Funny thing is when it works you can’t tell because device failures are invisible.
Take the measurements on the limit switches.

david_2018:
If you used an ESP8266, you could use a pull-up resistor on the ESP8266 side, then a diode to the switch input so that the switch can only pull the input to ground. That would prevent any problems with the pull-up from the gate controller because the diode would not allow any current flow to a higher voltage than the ESP8266 supply.

Thanks for the suggestions, everyone! I ended up going with this option - it seemed simplest (at least easiest for me to understand) - in fact, it's so simple I feel a little silly for not thinking of it!

I've prototyped it on a breadboard and verified all working as expected with some button switches prior to installing in the gate controller and it seemed to all be good - so I went ahead and connected it up with the gate controller and it's working a treat!

I went with an LM2596S regulator to get 16V off the gate controller down to 3.3V for the esp8266, the Sparkfun Thing Dev board for the controller itself, 3 x 1N4001 diodes to protected the esp8266 inputs, and a 5V relay module to switch the open/stop/close input on the gate controller. Using the in-built INPUT_PULLUP mode on the esp8266, I didn't add any extra pullup resisters.

With ESPHome it was super easy to configure and add to Home Assistant, and I'm looking forward to driving home tomorrow and having the gate open automatically on entering my 'home' zone!

Now that the breadboard/Thing Dev board prototype is working, I'm going to order a different (smaller) esp8266 board to solder up a proper device for installation, and will recycle the breadboard and Thing Dev board into my next project.

Thanks again for everyone's ideas - I learnt a lot reading them all! Looking forward to participating more in the forum, and getting into some more projects :slight_smile: