Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

im working on a bluetooth watch project. You may have already seen it on hackaday http://hackaday.com/2011/08/23/bluetooth-wristwatch-based-on-an-arduino/

i kinda need to add some buttons onto the watch and power efficiency is really important in this project. So im wonder which method consumes less power? Multiple buttons on 1 analogRead like here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267115381 or 1 digitalRead for each button

1 DigitalRead per button: Cons: each Pulldown resistor will always be spending power even while the button is not pressed. Pros: no hardtime tweaking pwm interval

Multiple buttons on 1 analog: Cons: each button pwm has to be defined. Pros: Less power consumption "i think"...

im not very good with electronics... please guide me which method i should use to add buttons onto my watch Thanks smiley

share|improve this question
add comment

4 Answers 4

up vote 3 down vote accepted

I think you may be misunderstanding the post. That post has no where on it that it talks about PWM, rather it is talking about reading in the voltage across the voltage divider. Here is the schematic that is in one of the posts:

 Analog pin 5
            |
Ground--1K--|--------|--------|-------|-------|
            |        |        |       |       |
           btn1     btn2     btn3    btn4    btn5
            |        |        |       |       |
         220 Ohm  390 Ohm  680 Ohm   2.2K    4.7K
            |--------|--------|-------|-------|-- +5V

There is still always a pull down resistor to ground regardless of button presses.

Now, it is true that if you switch to the digital method you will have more pull down resistors since you will need one per switch instead of one total, however the amount of power you are talking about is very minimal, and for some one who doesn't have much electronics experience, the power may be practically 0. Also they are using a 1k pull down for the analog method, you could easily get away with 10k and larger for the digital method and be just fine.

If power is still a concern for you, then you will need to learn more about your microcontroller. Many times micros will have internal pull up resistors meaning you don't even have to have a single resistor on your switch. It also may be the case that going with a pull up rather than a pull down will be more energy efficient, but even then this is microcontroller specific.

Overall I would say to go with a pull up that is say 10K or larger and move on with life. If you find that it really is pulling too much power then you can consider looking into it more.

share|improve this answer
add comment

You want digital with a pull-up. Most microcontrollers can provide the pull-up internally, but you can also choose for an external resistor if you want a higher resistance value, for instance. Not that this value matters much because there won't flow any current if the button isn't pressed. Only for the short time the button is pressed there will be a small current; if you use 100k\$\Omega\$ pull-ups you'll have a few tens of \$\mu\$A with a duty cycle probably as low as 0.001%.
A pull-down instead of pull-up is also possible, but is less common. If you use it, be sure to switch the internal pull-ups off.

Especially for tact switches which aren't operated often a 100nF capacitor parallel to the contacts is a good idea. The capacitor will be shorted when the button is pressed, and the small current peak will keep the contacts clean.

share|improve this answer
add comment

As a rule of thumb analog subsystems draw a lot of power, more than digital subsystems. So if the analog solution requires you to enable an A/D converter that would otherwise be off, that alone might make it loose.

If your project is power-critical, are you cyclic your application (active .. asleep)? If so, the active/sleep ratio will be very important for the average power use. Most A/D's are slow, so that might also make it loose.

As for current consumed by digital pull ups: they draw current only when the button is pressed, which is probably an insignificant percentage of time. You can minimise it even further by connecting them to an I/O pin that is pulled high only during reading.

share|improve this answer
    
In most systems, buttons will only be pressed a very small percentage of the time. If a button spends 99.9% of the time not being pushed, saving 1mA during the time the button is pushed would only reduce the overall power consumption by 1uA. It's possible to design analog as well as digital subsystems with essentially zero quiescent current. If one doesn't have enough wakeup-on-change inputs to implement a zero-quiescent-current keyboard wakeup, an analog keyboard may end up using less current than a digital one. –  supercat Aug 29 '11 at 16:33
    
The "Current Consumption of Peripheral Units" section of the ATMega324p tells us that the ADC uses approximately 250 microamps at 1MHz. This guy will almost certainly be better off disabling the ADC entirely. The pin change interrupts allow an AVR to wakeup-on-change on all its IO pins. –  joeforker Aug 29 '11 at 19:09
add comment

Unless buttons are going to be held for an extended period of time, the amount of current required to read analog-coded or digital button inputs is unlikely to be a significant factor in overall energy usage. There are, however, some advantages and disadvantages to each approach:

-1- Many processors can sleep until a digital input switches. While such techniques may be usable with some wiring methods for analog-coded buttons, using such techniques with analog buttons will often add some complexity.

-2- When using analog buttons, great care must be taken to prevent button pushes from being misread. Pushing and releasing buttons at just the right time may cause the input to be sampled at an incorrect value, and--depending upon switch design--lightly pushing a button may cause it to connect with significant resistance. For example, pushing the button tied to a 2.2K resistor in such a way that the button has 1K of resistance may cause it to be misidentified as the button connected to the 3.3K resistor.

-3- It may be possible to connect a group of analog buttons with fewer wires than a group of digital buttons.

The approach I would recommend for analog buttons would be to have a resistor string connect between a digital I/O ports and ground, and have the buttons connect various spots on that string to an analog input which has a very large pull-up resistor and digital-wake-up functionality. When the unit is idle, the digital I/O ports should be set low, and the code should wait for the input to go low. Pushing any button will cause the input voltage to drop to nearly zero volts. At that time, drive the digital I/O port high and read the analog voltage a few times until it seems to be stable. The voltage read will be nearly independent of switch resistance, but the amount of power consumed by the circuit while it's idle will be essentially nil.

Edit/Addendum

If you have four tri-statable I/O pins, two of them have ADC's which can read N distinct levels, and one (may or may not be an ADC one) has a wakeup-on-change ability, it's possible to use those to read NxN switch matrix using 2N+3 resistors and zero quiescent current. Pair up the I/O pins, including one ADC in each pair. Connect strings of N+1 resistors between the pins of each pair, and attach a weak pull-up to the non-ADC end of the string which has the wakeup-on-change feature. Connect the rows and columns of the switch matrix between the middle N spots on the two resistor strings.

When idle, drive the non-wakeup-on-change pins low, and let the wakeup-on-change side float. Until a button is pushed, both pins on the wakeup-on-change side will be high. Assuming the pullup is large enough, pushing any button will drive them both low.

To see what button is pushed, drive one pin on the 'row' side of the matrix high and the other low, while the 'column' pins float. Then read the voltage on one of the column pins wait a little while if necessary for it to stabilize (if it doesn't stabilize pretty quickly, regard the apparent button press as spurious). Then float the 'row' pins, drive the 'column' pins, and read the voltage on one of the 'row' pins (again making sure it's stable). Drive the rows and read the columns at least once more, and if the value matches the previous one, register a key-press.

Note that this approach doesn't allow for any useful two-key or multi-key combinations, but offers the distinct advantage of allowing nearly any size of keyboard to be handled using only four wires and one wakeup-on-change pin. As with the earlier suggestion, button resistance, within reason, will be a non-factor.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.