Page 1 of 1

OK Try This Problem Please....

Posted: Wed Jan 02, 2013 2:17 pm
by Sparkoids
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 :-}

Re: OK Try This Problem Please....

Posted: Wed Jan 02, 2013 10:46 pm
by Steve001
could you post a drawing ? of what you have now

Steve

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 1:09 am
by arizawilmer
Can you post a schematic please...?

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 9:23 am
by saakis
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.

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 10:36 am
by Sparkoids
Here is the schematic - if anyone has a better solution please feel free to enlighten me!

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 10:38 am
by Sparkoids
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!

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 10:49 am
by Benj
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.

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 11:00 am
by Steve001
you could change the switch to a two pole device will post a drawing later

steve

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 11:19 am
by Sparkoids
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 :-}

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 11:37 am
by Sparkoids
In fact I'm making it overly complicated and just need to use the 5V line from the PSU to be detected when the button is pressed....

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 6:48 pm
by Steve001
here is a drawing, but i cannot see a reason why you would do this . .. .

Steve

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 7:21 pm
by Enamul
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....

Posted: Thu Jan 03, 2013 7:46 pm
by Sparkoids
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 ;-}

Re: OK Try This Problem Please....

Posted: Thu Jan 03, 2013 10:26 pm
by Steve001
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

Re: OK Try This Problem Please....

Posted: Fri Jan 04, 2013 1:00 am
by saakis
SCAN_20130104_012553808_small.gif
(68.19 KiB) Downloaded 905 times
Hi,
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.

Re: OK Try This Problem Please....

Posted: Sat Jan 12, 2013 3:10 pm
by Brendan
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).
Pushbutton_PWR_Control_to_LT_Circuits.pdf
Circuit diagram
(8.16 KiB) Downloaded 351 times
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