On Off Auto switch wiring for micro controller recognition?

Discussion in 'The Projects Forum' started by marmil, Dec 13, 2014.

  1. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    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

    [​IMG]
     
  2. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    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?
     
  3. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    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.
     
  4. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    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.
     
  5. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
  6. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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?
     
  7. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    Doh! Didn't even think about the forward drop. Good catch!
     
  8. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    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?

    [​IMG]
     
  9. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    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?
     
  10. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    Ah, I think I understand what you're getting at now. I don't really need to be switching Vss at all right? Just remove that from being switched?
     
  11. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    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.

    [​IMG]
     
  12. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    Well now it looks like a DPDT switch with an off position.
     
  13. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    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.
     
  14. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    or ditch the resistor.
    [​IMG]

    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.
     
  15. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,795
    830
    Umm, connecting pin 6 to Gnd would result in a direct short when the switch is in that position! Pin 5 is connected to Vcc.
     
  16. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    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.
    "
     
  17. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,795
    830
    Oops, misunderstood that part. My mistake. That's what I get for posting too soon after I wake up.
     
  18. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    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.

    [​IMG]
     
  19. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    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.
     
  20. marmil

    Thread Starter Member

    Oct 31, 2009
    18
    0
    Thank you for your ideas and help all.
     
Loading...