Offline
Jr. Member
Karma: 1
Posts: 87
|
 |
« on: February 28, 2012, 05:39:39 pm » |
If I am deploying a stand alone projevt and only use 1 of the analog inputs, does it provide any benefit to enable the pull up resistors on the unused pins? I am thinking of stability more than anything else.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #1 on: February 28, 2012, 05:46:51 pm » |
It probably won't hurt. The analog reading is actually done "on command" (ie. when you do an analogRead), it isn't just reading away for its amusement. But setting unused pins to a known value is probably going to help keep noise out of the processor.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 87
|
 |
« Reply #2 on: February 28, 2012, 05:51:43 pm » |
Thank you Nick, So following what you said, I shouldnt add anything to the current draw either? The device is battery operated.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #3 on: February 28, 2012, 05:58:13 pm » |
Well you could put in pull-down resistors to tie them low. That shouldn't consume much, if anything. Pull-ups will add to the current drawn (as you would expect) according to my measurements here: http://www.gammon.com.au/forum/?id=11497
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #4 on: February 28, 2012, 05:58:54 pm » |
You can save substantial amounts of power by just running from 3.3V rather than 5V, BTW.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 87
|
 |
« Reply #5 on: February 28, 2012, 06:10:01 pm » |
Wow, that is a great article, thank you. I am using my own board in my device si it has no USB,
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Faraday Member
Karma: 47
Posts: 2573
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #6 on: February 28, 2012, 08:55:32 pm » |
Well you could put in pull-down resistors to tie them low. That shouldn't consume much, if anything. Pull-ups will add to the current drawn (as you would expect) according to my measurements here: http://www.gammon.com.au/forum/?id=11497Actually, I'm not sure I would expect pull-ups to add to the current drawn, if nothing else is connected to the pins. Where is the current flowing to? In fact, in my experimenting with sleep modes, I make all the pins inputs and enable pull-ups before going into power-down mode, and supply current waffles around between 0.1µA and 0.2µA.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #7 on: February 28, 2012, 09:10:16 pm » |
According to my measurements on the page quoted above, the difference is about 0.9 uA. I presume where the current is "going" is making the input MOSFETs "work harder" by amplifying noise. See page 43 of the datasheet: If the input buffer is enabled and the input signal is left floating or have an analog signal level close to VCC/2, the input buffer will use excessive power. and: An analog signal level close to VCC/2 on an input pin can cause significant current even in active mode.
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Faraday Member
Karma: 47
Posts: 2573
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #8 on: February 28, 2012, 09:20:41 pm » |
According to my measurements on the page quoted above, the difference is about 0.9 uA.
I presume where the current is "going" is making the input MOSFETs "work harder" by amplifying noise.
See page 43 of the datasheet:
Right, I saw the measurements, and hence the question as my results seem different. Shouldn't having the pullup turned on reduce noise? As opposed to a floating pin? Datasheet section 14.2.6, p81, recommends enabling pull-ups to provide a well-defined level for unconnected pins. Recently I've been thinking about starting each sketch with the following in setup(): PORTB = PORTC = PORTD = 0xFF; //enable all pullups
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10380
|
 |
« Reply #9 on: February 28, 2012, 09:23:20 pm » |
an analog signal level close to VCC / 2 A pullup would put the signal level close to VCC not close to VCC divided by 2. My results have been similar to Jack's. For unconnected pins, I have not measured a difference between input with pullup, output low, or output high. But my Extech multimeter may not be up to the task.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #10 on: February 28, 2012, 10:02:46 pm » |
Er, yes you both make good points. The pull-up on the face of it would result in not-floating pins. However to check, I re-measured using the board shown on the page I linked above. First with this sketch: #include <avr/sleep.h> void setup () { for (byte i = 0; i <= A5; i++) { pinMode (i, INPUT); // changed as per below digitalWrite (i, LOW); // ditto } // disable ADC ADCSRA = 0; set_sleep_mode (SLEEP_MODE_PWR_DOWN); sleep_enable(); // turn off brown-out enable in software MCUCR = _BV (BODS) | _BV (BODSE); MCUCR = _BV (BODS); sleep_cpu (); } // end of setup
void loop () { } Results: Meter: 0.11 uA Using Dave Jones' uCurrent device: 120 nA So, around 110 to 120 nA with pins as input and no pull-ups. Now with the revised sketch: digitalWrite (i, HIGH); // enable pull-ups Results: Meter: 75 uA Using Dave Jones' uCurrent device: 75 uA I admit that neither figure agrees with my previously-posted results (maybe the fuses were different). I can't explain why my figures are so different to yours, except that we must be using different hardware, and maybe different fuse settings.
|
|
|
|
« Last Edit: February 28, 2012, 10:22:33 pm by Nick Gammon »
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #11 on: February 28, 2012, 10:29:56 pm » |
However let's assume you aren't planning to sleep. Then the results are a bit different. This sketch: void setup () { for (byte i = 0; i <= A5; i++) { pinMode (i, INPUT); digitalWrite (i, LOW); } } // end of setup
void loop () { } Current measured: 15.3 mA. Changing to set all pins to pull-ups gives 11.8 mA. So in that case, we saved 3.5 mA by turning the pull-ups on.
|
|
|
|
|
Logged
|
|
|
|
|
Grand Blanc, MI, USA
Offline
Faraday Member
Karma: 47
Posts: 2573
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #12 on: February 28, 2012, 10:44:32 pm » |
However let's assume you aren't planning to sleep. Then the results are a bit different. This sketch:
Current measured: 15.3 mA.
Changing to set all pins to pull-ups gives 11.8 mA.
So in that case, we saved 3.5 mA by turning the pull-ups on.
Pretty sure I observed something similar recently, unfortunately did not record the results. But hence the idea of starting a sketch with all pullups on. That plus a couple of my projects which have been occasionally acting a bit funny, like they're responding to capacitive effects or maybe static electricity.
|
|
|
|
|
Logged
|
|
|
|
|
Austin, TX
Offline
Full Member
Karma: 0
Posts: 122
I make my own electricity.
|
 |
« Reply #13 on: February 29, 2012, 01:06:00 am » |
However let's assume you aren't planning to sleep. Then the results are a bit different. This sketch:
Current measured: 15.3 mA.
Changing to set all pins to pull-ups gives 11.8 mA.
So in that case, we saved 3.5 mA by turning the pull-ups on.
Pretty sure I observed something similar recently, unfortunately did not record the results. But hence the idea of starting a sketch with all pullups on. That plus a couple of my projects which have been occasionally acting a bit funny, like they're responding to capacitive effects or maybe static electricity. On an unaltered Arduino (I have a dozen or so Pro Mini's lying around, some adulterated, so virginal ...) I see pins floating to the voltage of other pins in the same port. For digital pins, I see them signal close to whatever is nearby -- most often around line frequency. So, I'm guessing they are sensitive to capacitive effects (parasitic capacitance on the die, maybe?) as well as RF.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #14 on: February 29, 2012, 01:10:05 am » |
Good point. Probably to get defined behaviour you should have defined inputs into the pins. I would have thought that tying a pin low through a 10K resistor would do that at minimal cost, but maybe I'm wrong.
|
|
|
|
|
Logged
|
|
|
|
|
|