Resistive vs capacitive dropper for 230V AC button sensing

Thread Starter

AleMonti

Joined Aug 11, 2024
30
How much current do you need?
Do you need the current every switch closure or can you live with high current 25% of the time?
I wasn't able to find a definitive number nor datasheet recommendation. So my strategy was to just push it as high as I reasonably could and hope it holds up. Not great I know :I
Switching mains instead 12 or 24V should also help.

What do you mean by 25% of the time?
 

ronsimpson

Joined Oct 7, 2019
4,703
What do you mean by 25% of the time?
I understand the need for 20mA. There are times in the 60hz cycle where the switch will see 20mA at closure. There is also a time when the switch will see 0mA. The switch current is dependent on phat part of the phase the switch closes.

I don' know how to do this with AC, but with DC I have used a 100uA source of current then added a cap across the switch. When the switch is open the cap charges up. When the switch is closed the cap is discharged at high current, then falls back to the 100uA level.

R2 limits the current to some very low level. D4 to get DC. C1 to store some current. D2 to limit the voltage to 5.1V. (could use an LED as a Zener) S1 is the switch. You might want to add a resistor in series with C1 to limit the current. 0.1uF or 1uF I don't know.
1776724671761.png
 

MrAl

Joined Jun 17, 2014
13,711
I appreciate everyone's feedback!



Great! So this is were we are at:
View attachment 366090



BTN is connected to a GPIO on the RP2040 so the opto is only driving a logic level signal. The board will interpret the button presses, dim the led strips accordingly, handle RS485 communication to a central node, etc.


No one has really addressed this so far, so I'll re-state again: using higher currents is intentional to hopefully clear oxidation on the contacts. I'm worried that running just a few mA though the wall buttons, which don't have gold plated contacts, would make them unreliable in the future. As far as I'm aware the manufacturer doesn't have specific ones for SELV systems.


My electrician recommended and wired the whole house already with 1.5mm² cable. It's simpler, abeit slightly more expensive, and if I sell the house or want to revert to standard AC lighting most of the wiring is already there. Also the series of sockets we installed doesn't have buttons suitable for SELV systems as far as I can tell. So I accepted the tradeoff and adapted the design of my board. I agree 12V signals for example would have been much easier to work with, but for the stated reasons I decided against it.
Hi,

Oh ok, so you want a little extra current through the actual switch, that's great. That does not mean you have to drive the opto with that current though.
One of the goals with an opto is long life. The lower the current, the longer the life. If you can provide another path for current that is not too complicated, then you can extend the life of the opto. If not, then you have to live with it.

One other thing I noticed before. You have an averaging filter on the output. I did not go through the dynamic operation, but if your opto transistor switches at 50 percent duty cycle you will not get much output at the BTN output. The charging time constant is 11 times higher than the discharging time constant, so you'd need a duty cycle that was something like 92 percent just to get one half of 3.3v output, which is around 1.6 volts. That probably still does not constitute a valid logical high voltage. We could do a more accurate calculation of that, but you get the idea. That's with R4=10k and R6=1k. If R6=100k it would be more reasonable, but I think you would be better off reading that with the ADC, or using a rectifier to keep the output high for a longer time period, or something similar.
 

MisterBill2

Joined Jan 23, 2018
27,607
REALLY, although I am not sure if it was adequately explained, in post #28, a series diode and then a shunt capacitor will drive the opto with a steady current instead of the 50 HZ AC voltage. THAT adition will tend to prevent the issue that is presented in post #43.
Of course, since we do not know what sort of switching device will be used, that might not matter. Certainly without any specifications of the actual requirements is is a challenge to suggest a specific scheme to meet those requirements.
 

drjohsmith

Joined Dec 13, 2021
1,613
REALLY, although I am not sure if it was adequately explained, in post #28, a series diode and then a shunt capacitor will drive the opto with a steady current instead of the 50 HZ AC voltage. THAT adition will tend to prevent the issue that is presented in post #43.
Of course, since we do not know what sort of switching device will be used, that might not matter. Certainly without any specifications of the actual requirements is is a challenge to suggest a specific scheme to meet those requirements.
i thought the op stated it was a standard wall mounted mains light switch, so it can be changed back later.
not certain they havevmuch of a spec regarding opperation at DC or wetting current as they are "just mains"
 

MisterBill2

Joined Jan 23, 2018
27,607
i thought the op stated it was a standard wall mounted mains light switch, so it can be changed back later.
not certain they havevmuch of a spec regarding opperation at DC or wetting current as they are "just mains"
The TS stated that the wiring was all suitable for mains service. That is probably reasonable, EXCEPT that typically, in most residential, and commercial, installations, controlling lighting from multiple locations is achieved by means of what are called "three way switches" and "four way switches", which have been quite adequate for at least 80 years, without any added electronics required.
Possibly in the homes of the "UBER WEALTHY" folks, those installations might be different. I am not aware of pushbuttons rated for mains voltages that are good looking enough to be used in those high end residenses that are decorated by professional interior decorator types. Of course, my experiences in that class of residences has been limited to that of a consultant, rather then a guest.
 

MrAl

Joined Jun 17, 2014
13,711
REALLY, although I am not sure if it was adequately explained, in post #28, a series diode and then a shunt capacitor will drive the opto with a steady current instead of the 50 HZ AC voltage. THAT adition will tend to prevent the issue that is presented in post #43.
Of course, since we do not know what sort of switching device will be used, that might not matter. Certainly without any specifications of the actual requirements is is a challenge to suggest a specific scheme to meet those requirements.
Hi there,

With a suggestion like that you really have to draw the circuit. That's because there is a little more to it, in that we have to keep an AC current going one way or another to take advantage of the capacitors reactance to drop voltage without dissipating the power of a resistor. So it has to be something like resistor, capacitor, resistor load, then rectifier from the resistor load, then second cap, something like that. This means a circuit drawing would be better than a verbal description just to make it clear.
 

MrAl

Joined Jun 17, 2014
13,711
i thought the op stated it was a standard wall mounted mains light switch, so it can be changed back later.
not certain they havevmuch of a spec regarding opperation at DC or wetting current as they are "just mains"
Hi,

Now I am wondering what ELSE the switch is operating: is it a 100 watt filament light bulb or a 100 milliwatt LED bulb. Did he mention this yet?
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
I understand the need for 20mA. There are times in the 60hz cycle where the switch will see 20mA at closure. There is also a time when the switch will see 0mA. The switch current is dependent on phat part of the phase the switch closes.
The surge magnitude does depend on the phase at the exact moment of contact, but a press lasts multiple AC cycles, so the 16mA current passes through the contacts several times per press.

One of the goals with an opto is long life. The lower the current, the longer the life. If you can provide another path for current that is not too complicated, then you can extend the life of the opto. If not, then you have to live with it.
I could decrease the shunt resistor (R3) to divert more current away from the led. For instance, dropping it to 220Ω would give the opto 11mA while the led only sees 5mA. It's good idea and could allow me to increase the current even further, as the heat dissipation through R3 is minimal. However, this really only matters for an always on device. For a button that is pressed for a few seconds a few times a day, the optocoupler will probably outlive the house even at >16mA.

One other thing I noticed before. You have an averaging filter on the output. I did not go through the dynamic operation, but if your opto transistor switches at 50 percent duty cycle you will not get much output at the BTN output. The charging time constant is 11 times higher than the discharging time constant, so you'd need a duty cycle that was something like 92 percent just to get one half of 3.3v output, which is around 1.6 volts. That probably still does not constitute a valid logical high voltage. We could do a more accurate calculation of that, but you get the idea. That's with R4=10k and R6=1k. If R6=100k it would be more reasonable, but I think you would be better off reading that with the ADC, or using a rectifier to keep the output high for a longer time period, or something similar.
Not sure I was able to follow you here. I only need to read a logic high or low. R4 is the pull-up, R6 to limit the current into the GPIO in case something goes wrong, and C2 was optional for very soft smoothing in case of ghosting. I don't need to smooth the 100Hz pulse train into a on/off logic signal. The microcontroller can handle it just fine.

Of course, since we do not know what sort of switching device will be used, that might not matter. Certainly without any specifications of the actual requirements is is a challenge to suggest a specific scheme to meet those requirements.
The button was linked to in post #37. Here it is again for reference.

The TS stated that the wiring was all suitable for mains service. That is probably reasonable, EXCEPT that typically, in most residential, and commercial, installations, controlling lighting from multiple locations is achieved by means of what are called "three way switches" and "four way switches", which have been quite adequate for at least 80 years, without any added electronics required.
Possibly in the homes of the "UBER WEALTHY" folks, those installations might be different. I am not aware of pushbuttons rated for mains voltages that are good looking enough to be used in those high end residenses that are decorated by professional interior decorator types. Of course, my experiences in that class of residences has been limited to that of a consultant, rather then a guest.
I'm starting to wonder if mains rated momentary pushbuttons are common in other countries. It looks exactly like a wall switch and they are generally used in combination with a step relay when you want to control lights from more than 3 or 4 locations. Doing this with traditional switches would require 2 way switches, intermediate switches and lots of cables looping around the room.

Now I am wondering what ELSE the switch is operating: is it a 100 watt filament light bulb or a 100 milliwatt LED bulb. Did he mention this yet?
The button is of course only operating this sensing circuit. The wiring is super simple. I have a single wire coming from each button that becomes live when pressed and is floating when released. My circuit needs to sense this state change reliably. The lights are on 24V DC and are controlled accordingly by the rest of the board. Dimming, colour temperature, etc.
 

MisterBill2

Joined Jan 23, 2018
27,607
Hi,

Now I am wondering what ELSE the switch is operating: is it a 100 watt filament light bulb or a 100 milliwatt LED bulb. Did he mention this yet?
At THIS present time the light switch is only operating the control circuit that we are discussing. THAT circuit, in turn, operates a mysterious block identified to us as BTN followed by a number. My conclusion is that it has been decided that we do not need to know. It can be described by an ancient "Southern" expression as "A Pig In A Poke", which means an unidentified entity shielded from our view.
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
At THIS present time the light switch is only operating the control circuit that we are discussing. THAT circuit, in turn, operates a mysterious block identified to us as BTN followed by a number. My conclusion is that it has been decided that we do not need to know. It can be described by an ancient "Southern" expression as "A Pig In A Poke", which means an unidentified entity shielded from our view.
See post #37: BTN goes directly to a digital GPIO of a RP2040. Nothing secret. The rest of the circuit is unrelated to this thread. Unless we want to go off topic and discuss mosfets, blown fuse detection, isolated RS485 etc... I might post those in a new thread later for a full board review.
 

MrAl

Joined Jun 17, 2014
13,711
The surge magnitude does depend on the phase at the exact moment of contact, but a press lasts multiple AC cycles, so the 16mA current passes through the contacts several times per press.


I could decrease the shunt resistor (R3) to divert more current away from the led. For instance, dropping it to 220Ω would give the opto 11mA while the led only sees 5mA. It's good idea and could allow me to increase the current even further, as the heat dissipation through R3 is minimal. However, this really only matters for an always on device. For a button that is pressed for a few seconds a few times a day, the optocoupler will probably outlive the house even at >16mA.


Not sure I was able to follow you here. I only need to read a logic high or low. R4 is the pull-up, R6 to limit the current into the GPIO in case something goes wrong, and C2 was optional for very soft smoothing in case of ghosting. I don't need to smooth the 100Hz pulse train into a on/off logic signal. The microcontroller can handle it just fine.


The button was linked to in post #37. Here it is again for reference.


I'm starting to wonder if mains rated momentary pushbuttons are common in other countries. It looks exactly like a wall switch and they are generally used in combination with a step relay when you want to control lights from more than 3 or 4 locations. Doing this with traditional switches would require 2 way switches, intermediate switches and lots of cables looping around the room.


The button is of course only operating this sensing circuit. The wiring is super simple. I have a single wire coming from each button that becomes live when pressed and is floating when released. My circuit needs to sense this state change reliably. The lights are on 24V DC and are controlled accordingly by the rest of the board. Dimming, colour temperature, etc.
Hello,

Ok so you plan to use the uC to detect the pulses, that seems fine. Did you figure that if you have 10 times the charge time as the discharge time that would be adequate edge smoothing?

If this is the only load then the life of the original 230vac switch may be shorter. How much shorter is difficult to say. We'd probably have to try to find some empirical data somewhere.
 

MrAl

Joined Jun 17, 2014
13,711
At THIS present time the light switch is only operating the control circuit that we are discussing. THAT circuit, in turn, operates a mysterious block identified to us as BTN followed by a number. My conclusion is that it has been decided that we do not need to know. It can be described by an ancient "Southern" expression as "A Pig In A Poke", which means an unidentified entity shielded from our view.
Hi,

Regular light switches are known to build up oxidation over time when they only operate very low current devices. I don't have any actual data on this right now though.
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
If this is the only load then the life of the original 230vac switch may be shorter. How much shorter is difficult to say. We'd probably have to try to find some empirical data somewhere.
Regular light switches are known to build up oxidation over time when they only operate very low current devices. I don't have any actual data on this right now though.
To find a baseline, I looked at the native application for these buttons: step relays (such as the Finder 26 series), which are common here for multi location light control. According to the datasheet, the 230V coil draws approximately 20mA (page 4, bottom left). This supports the conclusion that 15-20mA is a reliable operating current these buttons were engineered for.

You cannot beat this little circuit for AC line voltage detection.
No high-voltage parts.
Vanishingly low power dissipation
Full isolation
Cheap as dirt
I appreciate the suggestion! That’s an elegant circuit for simple AC detection (eg. sensing if a pump is running), but it’s effectively the opposite of my design goal. My application requires current loading the switch, not just detecting voltage. A circuit drawing only 0.5mA wouldn't provide the energy needed to break through the oxidation layers that form on these power rated buttons over time.
 
Top