Modification to Push-button power switch (item 1400)

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Starbuck3733T
 
Posts: 7
Joined: Thu Jul 18, 2013 11:37 am

Modification to Push-button power switch (item 1400)

Post by Starbuck3733T »

I've got a couple of the http://www.adafruit.com/products/1400 boards, and I'm attempting to modify them in 2 ways
- 1 separating the poles of the switch so one still toggles the power, but the other one is an input to my microcontroller (DONE, not hard, cut some traces)
- 2 if I increase the capacitor C1 from 0.1uF to 1.0uF, this SHOULD cause the circuit to need a LONG press to actually toggle the latch

#2 is what I'm trying to concern before I go ordering more SMT caps to do the mod... Does this make sense? will it work?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Modification to Push-button power switch (item 1400)

Post by adafruit_support_mike »

Changing C1 from 0.1uF to 1uF will make the cap take 10 times as long to reach the threshold voltage, but the resistor feeding it current is 100k. The RC time constant will be 0.1s for those values.

I wouldn't call that a 'long' press, but it's longer than the ~0.01s of the stock unit.

Starbuck3733T
 
Posts: 7
Joined: Thu Jul 18, 2013 11:37 am

Re: Modification to Push-button power switch (item 1400)

Post by Starbuck3733T »

Okay, so my basic theory was correct. I just need to change some resistor values as well. If I want the cap to charge more slowly, I guess it makes sense to swap 100K R3 out for something larger. if 1.0uF gives 0.1 seconds with that 100K, a 1M and 2.2uF ought to push the delay to 2-3 seconds - right?

Can you run me through the RC math for this, if you would be so kind?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Modification to Push-button power switch (item 1400)

Post by adafruit_support_mike »

The simple version is that sending 1A into a 1F capacitor will cause the cap voltage to rise by 1V per second. The basic formula is:

dV = C / I

- dV is the change in Volts per second
- C is the capacitance in Farads
- I is the current in Amperes

You can scale that up and down by multiplying the C and I by the same factor.. 1uA into a 1uF cap will also produce a dV of 1V/s. You can speed up the rate of voltage change by making the current bigger or the capacitor smaller.

When you add a resistor, things get a bit more complicated. The resistor limits the current flowing into the cap, but the amount of current flowing through the resistor depends on the voltage across the resistor. If the input on one side of the resistor sits at a fixed voltage and the voltage across the cap on the other side of the resistor increases, you get less and less current through the resistor as the cap voltage gets closer and closer to the input voltage.

Fortunately, there's a convenient way to think about the problem: Somewhere along the way, the voltage across the capacitor has to reach 1/2 the input voltage, and it will take a certain amount of time for it to get there. The way the math works out, it always takes the same amount of time for the cap voltage to reach half the original voltage across the resistor, no matter what the original voltage was.

The curve you get is called an 'exponential decay curve' because the problem was originally formulated for the problem "say I have X much material, and I lose half of it every second. How much is left at the end of N seconds?"

We actually do the math using the fraction 1/e (about 37%) because that translates directly to our resistor and capacitor values. The exact function is:

V.t = V.in * ( 1 - e^(-RCt) )

- V.t is the voltage at time t
- V.in is the original voltage across the resistor
- e is Euler's Constant (2.71828...)
- R is the resistance in ohms
- C is the capacitance in Farads
- t is the time in seconds

.. but people rarely use that version. It's easier to calculate the 'RC time constant':

k = RC

then remember a few rules of thumb:

- the voltage across the resistor will be half its original value in about 0.7k seconds
- the voltage across the resistor will be 1/e (37%) its original value in k seconds
- the voltage across the resistor will be 5% its original value in 3k seconds
- the voltage across the resistor will be less than 1% of its original value after 5k seconds

So.. a 1M resistor (1e6) and a 1uF cap (1e-6) have an RC time constant of 1s. Most logic chips use threshold voltages around 1/3 and 2/3 the supply voltage, close to the 'one time constant' value either way (a deliberate choice by the chip designers). That means a 1M resistor and 1uF cap will toggle the switch in about 1s. A 2.2M-1uF pair should toggle the switch after 2.2s, as would a 1M-2.2uF pair.

The timing gets less reliable as the RC time constant gets longer though.. the voltage changes so slowly that factors you can normally ignore, like parasitic resistance and thermal noise, start to become large fractions of the overall signal.

Starbuck3733T
 
Posts: 7
Joined: Thu Jul 18, 2013 11:37 am

Re: Modification to Push-button power switch (item 1400)

Post by Starbuck3733T »

Wow, that formula looks familiar! thanks for the refresher and great explanation.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”