OK Try This Problem Please....
OK Try This Problem Please....
I have a circuit that runs from a 5v power supply and is powered from the mains.
I have put a momentary mains switch in to bypass the relay temporarily to power the circuit and then the PIC holds it high once powered all well and good. Press the button and there is a nice click as the circuit jumps into life.
I need to know however if the mains switch can be detected being pressed (remember there is now mains power either side of the switch) once the circuit is up and running? I wonder if I should put a resistor in series with the switch to allow another input on the PIC to detect if it's pressed or what to do. My idea is that the resistor will effectively prevent mains flowing through to the side of the switch it is in series with - if you get what I mean.
I do not want to add another switch to the circuit. Any ideas folks?
Best regards,
James :-}
I have put a momentary mains switch in to bypass the relay temporarily to power the circuit and then the PIC holds it high once powered all well and good. Press the button and there is a nice click as the circuit jumps into life.
I need to know however if the mains switch can be detected being pressed (remember there is now mains power either side of the switch) once the circuit is up and running? I wonder if I should put a resistor in series with the switch to allow another input on the PIC to detect if it's pressed or what to do. My idea is that the resistor will effectively prevent mains flowing through to the side of the switch it is in series with - if you get what I mean.
I do not want to add another switch to the circuit. Any ideas folks?
Best regards,
James :-}
- arizawilmer
- Posts: 69
- Joined: Wed Oct 12, 2011 2:31 am
- Location: Australia
- Has thanked: 5 times
- Been thanked: 13 times
- Contact:
Re: OK Try This Problem Please....
Hi,
Try to connect in series 4-5 1N4001 diodes in series and the same 4-5 in antiparallel. Tie an optocoupler(the led) whith a resistor in series parallel to this diodes so a voltage drop of 2,5-3V being capable to turn on the LED in optocoupler(you have to give some try on that, it depens on the optocoupler).All this, diodes and opto in series with the relay contactor But in parallel with the N.O. Push button. When you press the button, the circuit comes up and the contactor close.When you relese the button the optocoupler gives a feedback. When button is pressed sort circuts the diodes and the optocoupler and you have your signal. The other way is to have a button whith double contacts so the secont one can used as a signal back.
Try to connect in series 4-5 1N4001 diodes in series and the same 4-5 in antiparallel. Tie an optocoupler(the led) whith a resistor in series parallel to this diodes so a voltage drop of 2,5-3V being capable to turn on the LED in optocoupler(you have to give some try on that, it depens on the optocoupler).All this, diodes and opto in series with the relay contactor But in parallel with the N.O. Push button. When you press the button, the circuit comes up and the contactor close.When you relese the button the optocoupler gives a feedback. When button is pressed sort circuts the diodes and the optocoupler and you have your signal. The other way is to have a button whith double contacts so the secont one can used as a signal back.
Re: OK Try This Problem Please....
Here is the schematic - if anyone has a better solution please feel free to enlighten me!
- Attachments
-
- Relay.jpg
- Sorry no scanner....
- (143.01 KiB) Downloaded 955 times
Re: OK Try This Problem Please....
I was thinking if I put a resistor in series with the switch then there would only be a current through the switch when it was pressed? The diodes I get but seems a lot of fuss!
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: OK Try This Problem Please....
Hi James,
Simply using a resistor will probably not work because the mains voltage goes negative which would probably blow the micro pin. You could rectify the mains signal using diodes but there is still the possibility that a large spike will get through and destroy your micro.
The opto solution will give you a reliable level of protection between the mains and the micro.
Also because the input is AC mains there will be periods of time 100 times a second where the mains signal is essentially at 0V so you may have to sample the input over a period of time to ensure it is pressed or not pressed.
I suppose one easy way to see if the switch is pressed is to drop the voltage to the relay, if the micro is still running then the switch is still pressed. Probably not entirely what you want as the micro will power down if the switch is not pressed. Adding a large cap after the PSU stage would allow the micro to power itself for a while with the mains connection severed. After you have tested the switch state you switch the relay back on to charge up the cap again.
Simply using a resistor will probably not work because the mains voltage goes negative which would probably blow the micro pin. You could rectify the mains signal using diodes but there is still the possibility that a large spike will get through and destroy your micro.
The opto solution will give you a reliable level of protection between the mains and the micro.
Also because the input is AC mains there will be periods of time 100 times a second where the mains signal is essentially at 0V so you may have to sample the input over a period of time to ensure it is pressed or not pressed.
I suppose one easy way to see if the switch is pressed is to drop the voltage to the relay, if the micro is still running then the switch is still pressed. Probably not entirely what you want as the micro will power down if the switch is not pressed. Adding a large cap after the PSU stage would allow the micro to power itself for a while with the mains connection severed. After you have tested the switch state you switch the relay back on to charge up the cap again.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: OK Try This Problem Please....
Thanks everyone. I'm going to see what Steve posts but am thinking now of the double pole switch solution where I take the relay latching signal output through the second poles on the switch. That way the relay will still be energised and the switch will either provide bypass power to the circuit or a control signal I can read as an input if the relay is energised. That way no extra parts required just an extra port for the input and I only need to sample it once another condition has been reached. Even if a voltage drop on the relay activation line caused a problem the power would still be provided to the PSU anyway.
Happy days :-}
Happy days :-}
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: OK Try This Problem Please....
I was thinking the same solution of steve..That is easy and hazard-less. But switch should be selected carefully as on NO will carry mains line for short time.
Re: OK Try This Problem Please....
Thanks for the help all - I've actually got something working for a change!
I'd forgotten to put a fuse in as well Steve and I am going on your solution thank you - perfect!
Soon as it's finalised I'll PM you and let you see what it's doing - it's a corker ;-}
I'd forgotten to put a fuse in as well Steve and I am going on your solution thank you - perfect!
Soon as it's finalised I'll PM you and let you see what it's doing - it's a corker ;-}
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: OK Try This Problem Please....
these are the switches we use at work just for an example . . . they are modular in design and maybe a bit big for your application (22.5 mm mounting hole) they do have a 6 amp inductive 10 amp resistive switching capacity.
have listed farnell part numbers for ease , as at work we buy direct from schneider electric.
http://uk.farnell.com/schneider-electri ... dp/3053015
http://uk.farnell.com/jsp/search/produc ... 3052977-pr
http://uk.farnell.com/jsp/search/produc ... 3052990-pr
all the above are required for one switch assembley
steve
have listed farnell part numbers for ease , as at work we buy direct from schneider electric.
http://uk.farnell.com/schneider-electri ... dp/3053015
http://uk.farnell.com/jsp/search/produc ... 3052977-pr
http://uk.farnell.com/jsp/search/produc ... 3052990-pr
all the above are required for one switch assembley
steve
Success always occurs in private and failure in full view.
Re: OK Try This Problem Please....
another solution is to use a secont relay 220vac instead of the push button. The relay will have two contacts(very easy). I send you a patern also with both circuits. The patern with diodes can used also for zero crossing
detection in case you want to handle ac inductive loads.
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: OK Try This Problem Please....
Just saw this post, but for possible future benefit...
The opto-isolated approach could have been significantly simplified with an SPCO relay and a single push-to-make switch (see attached).
The operating principle takes advantage of the hold-up time of the PSU, typically far in excess of the changeover time of the relay. Once activated, the pushbutton then serves to drive only the opto-isolated circuit. Besides immediately driving the relay on, the PIC should start main program execution or deactivate the relay (as appropriate), once the output from the opto-isolator stops, thereby ensuring the button is released in both cases and avoids cycling if the button were held down.
As a side-note, be mindful of power dissipation in dropper resistors operating at mains AC voltages. For example, 230V RMS and LED current at a mere 1mA will dissipate over 200mW in the resistor, but in this configuration power dissipation is limited to the time that the button is held down. 1/4W resistors or better will therefore suffice. No need for large high-voltage diodes (both small-signal general-purpose in this case).
If you're using the double-pole switch approach, I would highly advise resistors on both legs of the outgoing wires to the LT switch (e.g. 47k or greater), primarily to avoid a shock hazard should a bridge fault develop near the switch (broken/dislodged wire, etc). The series switch resistance would adequately work against a 470k (or greater) pull-down, ideally with a small ceramic capacitor across it to filter mutually-coupled mains spikes and avoid false triggers. If using opto-isolators however, it is the immovable tracking that avoids accidental bridging, with wires terminating at the board some distance from the device and LT circuits.
Have fun
Brendan
The opto-isolated approach could have been significantly simplified with an SPCO relay and a single push-to-make switch (see attached).
The operating principle takes advantage of the hold-up time of the PSU, typically far in excess of the changeover time of the relay. Once activated, the pushbutton then serves to drive only the opto-isolated circuit. Besides immediately driving the relay on, the PIC should start main program execution or deactivate the relay (as appropriate), once the output from the opto-isolator stops, thereby ensuring the button is released in both cases and avoids cycling if the button were held down.
As a side-note, be mindful of power dissipation in dropper resistors operating at mains AC voltages. For example, 230V RMS and LED current at a mere 1mA will dissipate over 200mW in the resistor, but in this configuration power dissipation is limited to the time that the button is held down. 1/4W resistors or better will therefore suffice. No need for large high-voltage diodes (both small-signal general-purpose in this case).
If you're using the double-pole switch approach, I would highly advise resistors on both legs of the outgoing wires to the LT switch (e.g. 47k or greater), primarily to avoid a shock hazard should a bridge fault develop near the switch (broken/dislodged wire, etc). The series switch resistance would adequately work against a 470k (or greater) pull-down, ideally with a small ceramic capacitor across it to filter mutually-coupled mains spikes and avoid false triggers. If using opto-isolators however, it is the immovable tracking that avoids accidental bridging, with wires terminating at the board some distance from the device and LT circuits.
Have fun

Brendan
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend