Long Wire - Digital Input

Thread Starter

brunoudi

Joined May 28, 2016
3
I'm developing a dimmer and have some questions about the switches...

My dimmer is developed based on ESP-12E (3.3V), and I'm worried about the distance of switch can be installed from the device... I'm detecting the changes in switch like this (R1 = 10k):

closeBtn.png

I've thought about adding capacitors and filters, but I'm not sure about how to calculate them. Usually, the cables connecting the switch are single wires going together 220Vac - 60hz.

This circuit can be applyed as solution to my device? http://forum.allaboutcircuits.com/threads/pic16f877a-emi-and-noise-protection.109380/#post-842094
 

Thread Starter

brunoudi

Joined May 28, 2016
3
@Dodgydave I would like to consider in specifications a maximum cable length for connect the switch (or switches in parallel). In your opinion, is it ok I consider 50 meters (25m to go, and 25m to return)?
 

AlbertHall

Joined Jun 4, 2014
12,347
The circuit you link to will invert the switch action. Will that matter to you?
Otherwise you could connect a capacitor (perhaps 10uF) from the resistor to ground, and add a 100ohm resistor in series with the switch.
 

Thread Starter

brunoudi

Joined May 28, 2016
3
The circuit you link to will invert the switch action. Will that matter to you?
Otherwise you could connect a capacitor (perhaps 10uF) from the resistor to ground, and add a 100ohm resistor in series with the switch.
@AlbertHall The swtich action inverted doesnt matter... I programmed the chip like that

I using pullup, instead of pulldown, because I heard it is better to avoid interferences.
 

DickCappels

Joined Aug 21, 2008
10,187
It is unlikely that the resistance will be an issue per Dodgydave, but the capacitance to time varying voltages might be a problem. Consider what might happen in a thunderstorm of in the case of the long run of wire being in parallel with AC power lines. Adding some filtering is an excellent idea.

When I did something similar I found that I had to heavily bypass the signal line. I'm pretty sure it was 50 Hz from the wiring in my house that was getting into the signaling wire.
 

Sensacell

Joined Jun 19, 2012
3,453
This subject gets religious quickly! everybody has a different take.
You can go nuts protecting an input from lots of imaginary and real threats- keep it cheap and simple.

1) Use a low value pull up, like 330 ohms. This reduces the input impedance, which helps mitigate capacitive coupling from AC power lines, you don't want the input floating around. Pushing some current through the contacts also helps keep them free of oxides, especially if not plated with precious metals.

2) Isolate the input with a series resistor.
The inputs are typically clamped with internal diodes to GND and Vcc, a 4.7K ohm series resistor prevents damaging currents from flowing into the input protection diodes.

3) Put a 0.1 uf cap right on the input to GND. This helps to absorb ESD energy and bypasses any RF on the line.

Happy switching!
 

Picbuster

Joined Dec 2, 2013
1,047
I'm developing a dimmer and have some questions about the switches...

My dimmer is developed based on ESP-12E (3.3V), and I'm worried about the distance of switch can be installed from the device... I'm detecting the changes in switch like this (R1 = 10k):

View attachment 107843

I've thought about adding capacitors and filters, but I'm not sure about how to calculate them. Usually, the cables connecting the switch are single wires going together 220Vac - 60hz.\

The best way is to use a normal closed contact then cable followed by resistor and capacitor to gnd and a diode to avoid negative pulses and a input clamp to vcc. ( see attached)
disadvantage the circuit consumes current advantage nor really sensitive however do not make yr cable longer than 50 meter




This circuit can be applyed as solution to my device? http://forum.allaboutcircuits.com/threads/pic16f877a-emi-and-noise-protection.109380/#post-842094
 

Attachments

Top