I am using Nick Gammon’s article on low power, I recommend it. It has been falling off a log easy to create a device that I think will run for, well, a looooong time.
As I add to the basic success I wonder why the default pin mode is INPUT and not INPUT_PULLUP?
Some years ago — never mind how long precisely — when we played with CMOS the rule was to never leave inputs unconnected… the idea was that a floating input might maneuver the chip or gate or whatever into a condition where we would not enjoy the extreme low power CMOS provides.
And around here, many problems are solved with a pull-up resistor or a change to INPUT_PULLUP.
So it seems a more logical default condition would be to have the internal pull-ups enabled.
I understand why that might not be a desirable behavior for the chip out of the box, but with the Aduino propensity to protect all over us because we idiots, it seems like init() might have just enabled all the internal pull-ups.
So. Is there that “floating input leads to power consumption” problem here? Or am I remembering incorrectly the logic behind making sure every input goes somewhere, tied to ground e.g. if unused?
Yes, I saw that ~100 uA with a switch wired to ground. Why would you put an LED on an input pin?
I don’t understand why making all inputs pulled up internally by default is any problem. However that is accomplished.
And what am I misremebering about the floating input thing? Is is OK to leave a CMOS input not pulled up when its logic value (or in-btweeness) is not relevant, like an unused input?
With an logic gate e.g. I know that an unused input must be 0 or 1 because it contributes to the value of the output.
With an input pin one is ignoring on a microprocessor, does it matter that it might be anywhere from 0 to 1? Power consumption or otherwise?
Or exposed, so to speak, to the same thing that makes reading it result in randomly 0 or 1, is that static electricity or moon beams or ions or what?
I’ve long been in the habit of doing something with unconnected pins unless the data sheet marks them as NC.
So… I think I have an idea, but how could I connect, say, a 4 pin DIP switch to 4 inputs and be able to read them during the periodic wakey wake and not have them drawing N * 100 uA where N is the number of switches switched ON to ground?
>Why would you put an LED on an input pin?<
Maybe to display the input-state… There’s an output or a switch, or something, driving that input…
>And what am I misremebering about the floating input thing? Is is OK to leave a CMOS input not pulled up when its logic value (or in-btweeness) is not relevant, like an unused input?<
I’ve always left unused inputs floating and “unconfigured”. I suppose you could configure them as outputs… I don’t know if an unconnected output “consumes” any additional current.
>So… I think I have an idea, but how could I connect, say, a 4 pin DIP switch to 4 inputs and be able to read them during the periodic wakey wake and not have them drawing N * 100 uA where N is the number of switches switched ON to ground?<
You could disable the pull-ups after reading.
Per AVR1010: Minimizing the power consumption of Atmel AVR XMEGA devices
Inputs should not be left floating, to minimize current draw
2.9 State of Digital I/O Pins
All digital I/O pins are by default floating to avoid hardware conflicts. However, since the pins have digital input buffers it is important to ensure that the level on an I/O pin is well-defined to avoid sporadic internal switching and leakage. The leakage caused by floating I/O is relatively small and is mainly observable in sleep, but can be minimized by ensuring that the state of the pins is either high or low.
If a pin is connected to an analog source, the digital input buffer on that pin should be disabled even if it is not configured as an input. This is done by use of the PINnCTRL registers for the individual ports. Please refer to the device manual for information on how to do this configuration.
To minimize power consumption, enable pull-up or -down on all unused pins, and disable the digital input buffer on pins that are connected to analog sources.
I’ll admit this game is addictive. Once I was seeing sub-milliamp current I was looking for every 0,1 uA I could…
I think this kind of obsession must obtain in the design of vast quantities of modern portable electronic equipment we all carry around with us - I wish someone would combine this years batts with the circuits of a few years ago.
Like I always advise people to run the oldest software they can bear on the fastest hardware that it will run on. My newest computer is the fastest I’ve ever had, but it does not feel as that way UI-wise.
Yes IC. I have come to think of we who use Arduino as victims beneficiaries of the preprocessor, that init() off somewhere, and gee, you could be some time before concluding that there has to be a main() involved at all.
Given the number of times it’s a missing pull-up resistor or failure to enable internal pull-up that causes some noob a headache, I would not have been surprised to find that the Arduino ppl hadn’t just included switching them all on in the init().
THX again. All.
I’ll try the several ideas I now have for my DIP switches and when none of them works ask y’all about it…
I think that the analog pin is connected to the ADC input multiplexer, so if you do not read that pin, it is not connected to anything else (except the internal pull-up, if you enable it).
Also for digital inputs, if you do not read the pin, you don’t care if it is floating.
Not true. That sporadic internal switching still draws some power; best to pull the pin high so there is No switching. Think of it as the pullup is charging up some gate capacitance, after that there is no switching, thus no current flow.
Why would they do that though? You can’t do low power on a vanilla Arduino board. You either have to do extensive modification of the hardware, or set up your own circuit. Once you’re that advanced, you should be capable of minding your own inputs.
Unless the pin is used as an interrupt source the digital buffers are disabled in sleep so they do not draw current even in sleep. Worst case current consumption of a floating pin (at room temperature) is 100uA but usually it is much less.
The extra current consumption is not from internal registers changing state but from a “shoot-through” current of the digital buffer when the input voltage is close to its threshold.
You need to be able to connect a pin to a device with its own internal pull-down - at power up that will misbehave if the pin is pulled up as well. (Many motor driver and stepper
driver chips are like this for instance - don’t want them going haywire at start-up!)
No, floating inputs can definitely consume power and read randomly - for a micropower application you’d just tie all the unused inputs to ground to solve the problem.
I wouldn’t worry, the battery chemistry’s self-discharge rate will be now be the
limiting factor, and once you start powering up every hour for 1 second at 25mA,
you already average 7µA anyway… Under 10µA is usually good enough unless using
exotic power sources such as harvesting ambient RF signals.
The only batteries I recall being suitable for very long term use are primary lithium and
silver-oxide - they have decade-long shelf lives. zinc-carbon cells will run down in a year
or two and always leak if left unattended for long periods. alkaline cells are supposed
not to leak, but some do, old NiCd’s tended to leak badly, newer NiMH seem to be much
better. The hybrid NiMH have a longer self-discharge time than standard NiMH (which
discharge on a timescale of months).