2
\$\begingroup\$

I'm designing a microcontroller based device which spends most of the time in deep sleep. Every 10 seconds it wakes up, reads a potentiometer connected on an ADC line then goes back to sleep. My aim is to achieve a long battery life.

How should I wire the potentiometer up to the microcontroller in order to minimise power use?

For my first attempt, I wired a 1K pot to 3V3 and GND with the wiper attached to the ADC. No matter what resistance is set on the pot, this seems to consume 3-5mA continuously.

Should one or more of the pot pins be connected to GPIOs and driven only when needed? If so, should the pins be driven low or tristated when not in use?

\$\endgroup\$
5
\$\begingroup\$

I would suggest wiring both ends of the pot to port pins that can be configured not to burn quiescent current while sitting at half-rail (many processors have pins that can be configured to be either digital outputs or analog inputs) and float both ends of the pot while not taking readings. Connect the midpoint of the pot to an ADC input, with a significant-value cap to ground. If you have multiple pots and can't afford to use three processor pins for each one, you could e.g. use external chips to connect and disconnect the ends of the pots. Note that the ends of the various pots should not be tied together; when a pot is disconnected, it should not connect to anything else.

If you do things this way, the ADC input voltage, with its cap to ground, should remain roughly constant when the pot is connected and disconnected. When powering up the cap, take readings repeatedly until either they stabilize or it becomes clear they won't (because they go up and down, rather than asymptotically approaching some value). If there isn't too much leakage in the circuit, you shouldn't have to have the pot powered up very long if it isn't being moved, since the cap should start out at, and remain at, the proper voltage.

\$\endgroup\$
6
\$\begingroup\$

Your 1k pot is causing most of your quiescent (standby/off-state) current: I=V/R, and you've got 3-5mA and 3.3V/1000 = 3.3mA. You can either connect one side to a GPIO pin and drive it only when needed (as you suggested) and/or use a larger pot.

Be careful when using very large pots (1M and higher), as the input impedance of your A/D pin might cause a slight variation in the voltage you read. This may or may not be significant for your project.

I'd compromise by using a 100k pot and connecting one side of the pot straight to ground, and the other to the source of a P-channel MOSFET. Connect the center to your A/D pin, and the MOSFET gate to the microcontroller. That way, you can allow the microcontroller's weak internal pull-up resistor to bring it to 3V3, and dissipate minimal power.

An additional power savings might be to add a constant voltage divider to your circuit (and an additional A/D line), and run straight from the batteries, eliminating the voltage regulator and its quiescent current requirements.

Also, you might want to run the numbers and see what kinds of battery life you get with quicker pulses. Even if you slow your microcontroller down to 100kHz or so, you can probably take an A/D reading in a millisecond. Ten seconds between pulses gives you a duty cycle of 0.01%, which isn't that different from 0.1% or 0.3% for many applications. I'd speed it up to take a reading every 300ms or so to avoid having users resetting and otherwise fiddling with the device when it doesn't respond instantly. On second thought, I'm assuming a human is turning the pot, which may not be the case.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the MOSFET idea. The pot is actually a placeholder for an analogue sensor board which hasn't been designed yet, it won't be user controllable. \$\endgroup\$ – Toby Jaffey Dec 14 '10 at 21:59
  • 2
    \$\begingroup\$ @Joby: If you want a fairly accurate reading (>8-bit)?, I'd connect the switched analog supply to another analog pin and use that to scale the pot signal. Or, if you have a separate Vref, you could simply use that. \$\endgroup\$ – Nick T Dec 14 '10 at 22:49
  • \$\begingroup\$ @Nick 12bit. You mean wire the GPIO pin supplying the pot to Vref? Makes sense - I hadn't been getting the full ADC range since moving the pot to a GPIO. \$\endgroup\$ – Toby Jaffey Dec 15 '10 at 0:00
4
\$\begingroup\$

Instead of connecting the high end of the potmeter to +3V3 you could connect it to an I/O pin. Before going in sleep mode set the pin to input, so that there's no current running through the potmeter. (The resistor keeps both the high end and the wiper at ground.) When the uC wakes up set the I/O pin to output and set it to high level.
Though 1K may not be a problem -- you'll draw 3.3mA from the output pin -- I suggest you take at least a 10K potmeter.

\$\endgroup\$
  • \$\begingroup\$ Using the output pin to 'power' the potmeter will result in a voltage on the potmeter that is slightly lower than the 3V3. When this is a problem, check whether your chip has an external 'reference' input to the A/D. If so you can connect that input to the top of the potmeter to eliminate the error. \$\endgroup\$ – Wouter van Ooijen Aug 31 '11 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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