1
\$\begingroup\$

it's my first question on here so please be nice. I want to design a 3 way switch that works with a MOSFET. Aka I want it to work in the same way as a household light would work where it is able to be turned on or off with either switch:

schematic

simulate this circuit – Schematic created using CircuitLab

I have designed a MOSFET circuit already to be controlled by the microcontroller that I am using:

schematic

simulate this circuit

The switch in parallel with the MOSFET just doesn't do what I want to achieve though and I am struggling to think of a way to achieve this.

To clarify: If the MCU is holding the lamp on, I would like to be able to actuate a switch to turn the lamp off. If the microcontroller is holding the lamp off, I would like to be able to actuate a switch to turn it on.

I hope my problem makes sense.

\$\endgroup\$
  • 5
    \$\begingroup\$ Why not connect the switch to the microcontroller and put all the switching logic in software? If I understand your question correctly, you can simply XOR the physical switch input with the internal microcontroller switch state to get the output state. \$\endgroup\$ – uint128_t Feb 17 '16 at 16:27
  • 1
    \$\begingroup\$ You could have the MCU control a suitable SPDT relay, with the relay contacts connected in place of one of the "three-way" switches in your fist drawing. \$\endgroup\$ – Peter Bennett Feb 17 '16 at 16:38
1
\$\begingroup\$

Something like this? You can still use the 3 way switch and have the micro also function as a 3 way. I left off the gate ctrl because you already know how to do this. You would need two gate controllers for each line, when you want to turn the light on or off with the micro, just toggle one control line high and one line low. Make sure you get the polarity right, NMOS does not turn on if the gate voltage is not higher than the drain voltage.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Oh, if your building this you may want to account for ESD, mosfets don't like it and I've put some pretty hefty sparks near light switches. \$\endgroup\$ – laptop2d Feb 18 '16 at 6:25
  • \$\begingroup\$ An elequent solution, thankyou very much!!! It seems to simulate fine so thats good. Perhaps when I implement it in real life I could use an inverter on one of the MOSFET control lines to avoid tying up too many of the microcontrollers GPIO's as I'll be controlling quite a few seperate lights. \$\endgroup\$ – user100675 Feb 19 '16 at 16:33
0
\$\begingroup\$

If the MCU is holding the lamp on, I would like to be able to actuate a switch to turn the lamp off. If the microcontroller is holding the lamp off, I would like to be able to actuate a switch to turn it on

It sounds like a latching action is what you need i.e. a little digital latch circuit and a push button. If you want to use two push buttons then wire them up in parallel. Circuit idea: -

enter image description here

Each time you press the pushbutton, the inverters change state and remain in that state. You even get switch debounce due to the capacitor thrown in for free.

The output from either inverter can drive the gate of a mosfet to control the lamp/load. Here's one that drives an LED via a BJT: -

enter image description here

If you are intent on using a micro then do it all digitally in code.

\$\endgroup\$
0
\$\begingroup\$

Following up on what @Peter Bennett said in his comment. See schematic, just to give an idea. There are a lot of parts in the BOM; pulling the switch into the uC might help reduce count and ease complexity (as @Andy aka said in his post).

PS - Please note this is not a fully working schematic. Coil voltages on relays would need to be selected correctly, properly select Mosfet, a pull down on the Mosfet, etc.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ So show the pulldown... It'll allay confusion and reduce the comment load, and it doesn't cost a lot to show. \$\endgroup\$ – EM Fields Feb 17 '16 at 18:45
  • \$\begingroup\$ It seems that the mosfet is largely redundant in this circuit. \$\endgroup\$ – Andy aka Feb 17 '16 at 18:49
  • \$\begingroup\$ @Andyaka Totally agree... Just giving the customer what they asked for. =) I am thinking may this is a learning exercise for him and / or wants a "fail safe" way to turn the light on if his uC fails. \$\endgroup\$ – Tyler Feb 17 '16 at 18:51
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

One problem with this approach. The MCU has no idea if lamp is on or off, because of external switch. But it should work as a three-way switch.

Each time MCU pin changes state OR switch changes, lights will go ON or OFF. Three-way switch.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy