In my battery powered mouse design, for the main switches I was initially using the traditional SPDT switch circuit, but after realizing how bad it is for low power applications I moved to a low-power circuit:

enter image description here

The main difference between the two is that the traditional circuit continuously draws current, whereas the low-power one only needs as much current to charge the capacitor. I've done the math and determined that the RC low-pass filter does not add a noticeable delay in the switch operation.

This optimization is especially useful in scenarios where the switch will be in the on position for long periods of time.

Question: Should I put the capacitor near the switch or near the MCU pin? enter image description here Is this even something I should worry about? The maximum distance from a switch to the MCU is 50mm.

I'm inclined to put the capacitor near the MCU like a standard decoupling capacitor for power pins.

What should I consider in making this choice?

  • \$\begingroup\$ What are you using the capacitor for? \$\endgroup\$
    – Andy aka
    Commented Aug 20, 2023 at 10:34
  • \$\begingroup\$ My one and only reason for putting it in is that after the switch closes and the line goes high, current will stop to flow through the switch, given that the switch I'm using is rated for 1mA min, I fear that the electrical connection between the two internal plates would sever until the next pressing event. When the MCU samples the line it will inevitably sink the current that was put into it, effectively lowering the voltage on that line, so I add capacitance to be able to "store" the pressing event for longer. First time doing this, so feel free to correct me. \$\endgroup\$
    – StefanoN
    Commented Aug 20, 2023 at 12:28
  • 2
    \$\begingroup\$ You can do this if you expect strong RF noise around your circuit. In such a case the capacitor should be next to the MCU. \$\endgroup\$
    – Jens
    Commented Aug 20, 2023 at 20:44


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.