On Off Auto switch wiring for micro controller recognition?

Thread Starter

marmil

Joined Oct 31, 2009
28
Hello all.
I have a On/Off/On style DPDT switch that I'd like to setup as to act as a On/Off/Auto switch with a micro controller. I'm thinking of having the micro monitor a pin set as an input (A3 in attached example) and if reads a HIGH signal then the program can appropriately set something to be in "auto" mode.

My thought is that Diode D1 allows a HIGH signal to reach A3 in only one of the switches On positions.
I'm not sure if I would need resistor R1 or not, but figured it might be good to have a small value there.

Would this work, or how might I better wire this?
-marc

 

Attachments

Art

Joined Sep 10, 2007
806
That looks odd, how can a DPDT switch have three positions?
It looks like if you turn it off the micro is not powered so how can the switch be of any use?
If the micro is powered the program can know that because it's working, so what additional function can the switch provide?
 

Art

Joined Sep 10, 2007
806
Ok, now I get it.
There should be another resistor between t2 of R1 and Gnd to normally tie the input pin low.
Your schematic is also not a DPDT switch, but a DPST one.
There will be a break time while flicking the switch where the chip is not connected to ground
or power, possibly causing a reset or bung program without additional capacitors at the power supply.
 

ebeowulf17

Joined Aug 12, 2014
3,307
Agreed on the pull-down resistor for A3 input pin. With that addition, looks like a solid plan to me.

As for switch behavior, I think the op is using a switch like this, which does have a third position in the middle for turning the whole system off, and that the system wouldn't be expected to switch from on to auto without cycling off and back on in between.
 

MikeML

Joined Oct 2, 2009
5,444
Why are you switching the Vss pin of the Arduino?
Can you tolerate the diode forward drop when powering the Arduino with the switch in that position.
R1 in your schematic should go to ground as a pull-down resistor for the port pin; not as a series resistor going to the pin.
Can you tolerate the Arduino rebooting every time you move the switch?
 

Thread Starter

marmil

Joined Oct 31, 2009
28
Thank you for these suggestions and thoughts Art. You bring up a good point that switching from On to Auto does briefly cut power and would indeed cause the micro to restart. After thinking about it, for this particular project I'm ok with that.

I've updated the drawing to better represent the On-Off-On switch, and added resistor R2 to GND. Is that how it would be configured? What sort of values would be good for R1 and R2?

 

Attachments

Thread Starter

marmil

Joined Oct 31, 2009
28
Humm, you guys replied why I was typing and have given me more to think about. :)
Yes, ebeowulf17, that's the sort of switch I have. On, Off in middle, On.

Yes, the voltage drop across D1 when in Auto mode could be a problem.

Powering the Arduino at Vin should be fine. From the Arduino website:
"VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin."​

Maybe I need to use some sort of switching transistor instead to trigger the A3 input?
 

Thread Starter

marmil

Joined Oct 31, 2009
28
After thinking about this a bit more here's version 5. I removed the ground from being switched through the On-Off-On switch and rewired things as shown. Would this work? Is it this simple, haha?
I've left a resistor R1 in the diagram figuring it might be a good idea to limit the voltage to the input pin just a bit for safety.

 

Attachments

Art

Joined Sep 10, 2007
806
Not quite, take R1 out and connect the cut straight together,m
then put a 10K resistor between where R1 was and Gnd.
Now it's high when switched high, and pulled low by the resistor when it's not.

A rough way to handle switching quickly from auto to on is to put some fat electrolytic capacitors between Gnd and positive near the chip.
 

Art

Joined Sep 10, 2007
806
or ditch the resistor.


for this part of the switch, you could connect A3 straight to the switch terminal 5,
6 to ground, and 4 to the power coming in from the left side of the diagram (was connected to 5).
That way the bottom part of the switch is toggling A3 from high to low.
 

Art

Joined Sep 10, 2007
806
Only if that's all you did, but I said:
"
for this part of the switch, you could connect A3 straight to the switch terminal 5,
6 to ground, and 4 to the power coming in from the left side of the diagram (was connected to 5).
That way the bottom part of the switch is toggling A3 from high to low.
"
 

Thread Starter

marmil

Joined Oct 31, 2009
28
Thank you for the additional suggestions. I've updated the drawing to reflect the new switch wiring suggestion, and added caps on the right side. What sort of values would be good for "fat caps" C1 and C2?

I'm wondering if it would still be a good idea to have a small value resistor in the line that connects to input pin A3? Just wouldn't want to burn out the pin, but I might be concerned over nothing here.

 

Attachments

Art

Joined Sep 10, 2007
806
A low value resistor wouldn't hurt if it makes you feel better but so long as you're regulating the 5 Volt supply already
the chip should be able to take it's supply voltage at it's input pin.
 
Top