Pulling up or down on unused pins

reconchris

New Member
Hi there, I'm using a picaxe surface mount 08m2 for a project of mine and I want it to be stable and draw as little power as possible while having a small component count. I read online that there are some pins that have an internal pull up resistor and some that don't. My question is what pins will use power if they are not pulled up/down? What pins have an internal pull up/down resistor in them? For the pins that have a built in resistor how to I engage them?
 

techElder

Well-known member
The first question that occurs to me is, "How equipped are you to measure very small changes in very small currents?"
 

GrahamGo

Senior Member
@westaust55 pointed you at the command. If you want really low consumption you also need to look at other things too, like reducing the supply voltage to a minimum. The spec sheet says 2.3v-5v, how you achieve that voltage efficiently is another question. Then there is the operating speed, I mistakenly ran my last little project continuously at 32kh/z, it worked fine. But later when I trawled the posts I found one that implied that I might have achieved even lower power levels by running at full speed and sleeping in between activity. I think to help others to help you, you need to give a brief description of what you are attempting to achieve. Then you should receive some good focused help.
 

Circuit

Senior Member
From the Microchip Presentation "Getting Started - Power Considerations";

"To conserve power, the PICmicro MCU can be put into a SLEEP mode. This is
especially useful in battery powered applications. In this mode, the oscillator circuit
is turned off and the device stops executing code. In order to obtain the lowest
possible current consumption in SLEEP mode, all unused I/O pins should either be
configured as inputs and connected to VDD or VSS, or configured as outputs and left
unterminated. The power down current specification does not include current
sourced or sunk by any I/O pins. In addition, modules such as the Watchdog timer
and the Brown-Out Detection circuitry will increase the amount of current draw.
The power down current specifications and the increases due to enabling Brown-
Out Detection or Watchdog timer circuitry are given in the DC Characteristics
section of the device datasheet."


Given this guidance, it seems that the simplest approach is to configure as outputs and leave unterminated.
 

AllyCat

Senior Member
Hi,

In the M2 family, ALL the base PIC chip pins have Weak Pullups, but the Programme Editor will not allow you to activate them on the Serial Input and Serial Output pins (where they might be used for "advanced" applications). On an 08M2, all the other pins can be activated with a PULLUP %11110 (=30) command, which is probably worthwhile to potentially save a little power. Also the SI and SO pullups can be activated with a POKESFR WPUA,%111111 (if you know what you're doing) ! The PIC data sheet implies that their resistance could be as high as 200k or as low as 16k, but all the ones that I've measured have been quite close to 30k. And they do appear to behave as "resistors", not as current-sources.

Yes, a sleep/nap between "bursts" at 4MHz (or maybe even higher) probably has the lowest average power drain. But the "Brownout detector" takes as much current as the rest of the "core" when sleeping, so a DISABLEBOD is probably worthwhile. But beware of a recent thread which reported corruption of some EEPROM data locations when that command had been used.

Cheers, Alan.
 

hippy

Technical Support
Staff member
For the 08M2, given internal pull-ups can be applied to all input pins, it would seem best to leave those unused unconnected, and activate the pull-ups if required or desired. The Serial In will need to be pulled-down for the 08M2 to start at power-up.

We would recommend fitting the full download interface or a means to allow downloads to the boards, and this may be essential when using surface mount PICAXE chips.
 

GrahamGo

Senior Member
Hi, I found some notes that I made a few weeks ago. I was testing current consumption of an 08M2. Circuit as described by @hippy. Code as follows to provide two measurements I then applied three different supply voltages and measured the current drain

Code:
main:
disablebod      ; in test #2
pullup %00011110   
setfreq K31
	do
  	sleep 2   ; low power for 5 secs
  setfreq m4
  	wait 5    ; 4mh/z for 5 secs
	loop
	stop
Code:
                 Enablebod                      Disablebod                          Enablebod                       Disablebod
Pullups on C.1 to C.4 active                                                    Pullups on C.1 to C.4 inactive
-----------------------------------------------------------------------        -----------------------------------------------------
voltage          Sleep         4mh/z             Sleep          4mh/z           Sleep         4mh/z               Sleep          4mh/z
2.3v             16ua          500ua             12ua           440ua           -             -                     -              -
3.3v             17ua          560ua             13ua           550ua           19ua          552ua                17ua           549ua                  
5.0v             20ua          600ua             14ua           590ua           20ua          595ua                17ua           590ua

My conclusion:- The optimum is to use Pullups=ON and Disablebod. With this combination there is a clean switch between the two 
current levels. In the situation where the Pullups=OFF something is going on in between the transitions, there is a sort 
of voltage ramp between the measured currents before they settle and the 08M2 is certainly taking more current whilst doing this.
All you need now is a way to measure your run time vs sleep time in order to calculate the average average power consumption. Unfortunately I dont think that a MS elapsed timer is available (anyone?). Someone mentioned the difficulty of measuring small currents. This is a trivial problem, any decent DVM will measure microamps.
 
Last edited:

techElder

Well-known member
Someone mentioned the difficulty of measuring small currents. This is a trivial problem, any decent DVM will measure microamps.
I queried the OP's equipment capability. Please define "decent DVM". How often does a hobbiest have a meter certified? What affect does a decent DVM have on the circuit measured?
 

lbenson

Senior Member
Perhaps someone who can take measurements with a certified meter can tell us by how much those measurements differ from the ones provided by GrahamGo.
 

tmfkam

Senior Member
The first question that occurs to me is, "How equipped are you to measure very small changes in very small currents?"
I don't like to criticise such senior forum member's posts, but on behalf of ReconChris, I felt rather irritated by this post.

I understood that ReconChris posted in the hope that a member might have some prior knowledge as to whether PicAxe processor pins should have the internal pull up or down resistors activated for minimum current drain, at minimum component count.

Asking whether or not the OP has or does not have the ability to measure small currents does not help them determine which pins do have pull up/down resistors in any way. Nor does it answer which pins might be expected to draw leakage current should those pull up/down resistors not be engaged. Yes they could indeed measure the current drain, with pull up/downs enabled but if unable to determine the command to enable or disable them how would they determine the difference?

Further, please define "Very small currents". Would I need to lend them a microammeter, nanoammeter or picoammeter? As any decent DVM will measure microamps, and all we are looking for is a change in current from one state or another, would a calibrated meter be any more beneficial? If a calibrated meter measured 10uA with pullups engaged and 8uA with them disabled, would it matter if an uncalibrated meter (with unknown burden resistance) measured 5uA with pullups engaged and 3uA with them disabled the answer would still be the same: Use pullups for a lower current drain.
 

GrahamGo

Senior Member
Sorry, a DVM means Digital Volt Meter. By decent, I guess a $25 unit with a 2 m/a range would be fine. Here is a cheap home hobbyist unit for just $10 https://www.amazon.com/Multimeter-Tester-Display-Voltage-Ohm-2000K/dp/B005EK3NUU/ref=pd_sim_469_5?_encoding=UTF8&pd_rd_i=B005EK3NUU&pd_rd_r=FH1R1P6Q03F1R6BQ3VQ6&pd_rd_w=w3ulF&pd_rd_wg=jNDiK&psc=1&refRID=FH1R1P6Q03F1R6BQ3VQ6
This units internal shunt is 100 ohm on the 2mv scale. Therefore the worst case voltage drop across the meter is 100 ohm x 0.0006v (using 600ua) = 0.06v So no measurable effect on this circuit. I am at a loss as to why a certified meter is required, or should it read calibrated?

What I did miss is to check the numbers with all the pullups disabled, I will do this and post the results.
 

GrahamGo

Senior Member
Perhaps someone who can take measurements with a certified meter can tell us by how much those measurements differ from the ones provided by GrahamGo.
Hi, I have just updated the chart to include the Pullon=On and Off situation. I also added my conclusions. I think more measurements on other 08M2 chips could be useful to account for manufacturing tolerances. But my measurements on this particular chip are pretty accurate.
 

premelec

Senior Member
High accuracy for these measurements is not necessary considering all the variations of manufacture and environment - often data sheets will show distribution of a typical test lot of the components' variations and give maximum and minimum values...
 

techElder

Well-known member
I don't like to criticise such senior forum member's posts, but on behalf of ReconChris, I felt rather irritated by this post.
You just made 173 forum members gag deeply by calling this goofball a "senior forum member." :D :D :D

Anyway, I'm not so ignorant on some matters. :D I never said "calibrated", because there would be very little to calibrate inside a typical meter today. I did say "certified", because one should know how closely to standards that one's meter is reading. There would be many ways to do that and none of them would have to reach the requirements that businesses have to follow.

... draw as little power as possible while having a small component count....
So, if the OP is asking this question, which was ignored in the response above, then shouldn't the responders know how the OP will determine when "as little power as possible" has been reached?

I'm not a snob about a $10 meter, but I'd be damn sure to compare it to a standard before I started quoting readings from it.

Comparative readings with the same meter under the same conditions interest me a little more.

I suppose in this hobby environment its to each his own.
 

rq3

Senior Member
Hi there, I'm using a picaxe surface mount 08m2 for a project of mine and I want it to be stable and draw as little power as possible while having a small component count. I read online that there are some pins that have an internal pull up resistor and some that don't. My question is what pins will use power if they are not pulled up/down? What pins have an internal pull up/down resistor in them? For the pins that have a built in resistor how to I engage them?
1) All pins will require power, whether pulled up, or not, but it may be just a few electrons. When the pins are designated as inputs, they are basically CMOS gates, generally with protection diodes that leak a bit.
2) Which pins this applies to can be determined either by referring to the appropriate PIC datasheet, or trying to apply a "pullup" command in your code and seeing if the Picaxe editor accepts it.
3)To apply an internal pull-up, you use the "pullup" command for the appropriate pin. The value of the pull-up resistor is determined by the silicon doping used to fabricate the chip itself, and can be anywhere between about 16 kilo-ohms and 200 kilo-ohms.

Keep in mind what you are trying to do, and the magnitude of the currents involved. If your final circuit needs, say, 100 microamps when it is "resting" (and that's a lot of current), and is supplied by a 1 ampere-hour battery, (and that's a small battery) it will work for 10,000 hours (or about a year) before the battery needs recharge or replacement.

Lots of SWAG here, but I'm sure you get the idea.
 
Last edited:

GrahamGo

Senior Member
An addendum to my earlier post.

Code:
Enablebod                                         Disablebod           
C.1 to C.4 linked to ground                                                   
-----------------------------------------------------------------------           
voltage          Sleep         4mh/z              Sleep          4mh/z           
2.3v             -             -                   -             -          
3.3v             17ua          552ua              13ua           550ua                            
5.0v             19ua          593ua              14ua           589ua
Final test. C.1 thru C.4 grounded, Pullup = inactive, Disablebod = On and Off.

My conclusion is that for the ultimate low power this is the best solution (Disablebod, C.1-4 grounded), of course this prevents the I/O ports being used. The next best solution is to activate the Pullups. The worst case is to leave the ports floating. As mentioned in my earlier post with the ports left floating, something strange is going on and in the transition time between the sleep and 4mh/z modes the current goes through some sort of gradient. I have no way to present this info, but it is easy to see on the DVM. PS. I did not bother doing the 2.3v test, during test Serial in and out were disconnected. Cheers.


IMG_20170606_155650.jpg
 
Last edited:

AllyCat

Senior Member
Hi,

during test Serial in and out were disconnected.
Presumably you mean the Serial Comms (USB interface) was disconnected (to avoid any risks of "Phantom Powering"); The PICaxe Serial Input pin (Leg 2) must be tied to ground (via a resistor).

IMHO the best starting point is the base PIC Data Sheet where most of these parameters are specified, not just "typical" but also "worst case" and at elevated temperature, etc., almost impossible to measure yourself and avoiding the risk of measuring an unfortuantely "good" or "bad" sample. So most of the influence of the Brownout Detector and oscillator speeds, and much more, can be determined directly from the manufactuer!

But a few words of warning: Read the "grey" (background) data which applies to the PICaxe chips, not the "white" data which applies to the (sometimes much lower current) LP or XLP "nanowatt" versions. Also beware that when an M2 PICaxe is "sleeping", the WDT oscillator is still running (to wake it up again).

The data sheet tells us that the "input leakage current" of an I/O pin is typically only 5 nanoAmps at up to 85 degrees C and the maximum is 200 nA, so difficult to measure and of little consequence (even over 18 pins of a 20M2). Note that this current includes not just the digital input (gate), but the ADC input (if available), the Output stage (in tri-state mode) and also any leakage through the electrostatic protection diodes! However, the /MR pin (aka the Input Only pin, Leg 4), appears to have rather higher leakage and "special attention" may be worthwhile here.

HOWEVER, that is not what the OP asked, nor can I find the required information in the Data Sheet! What is required is expained in the excellent Microchip "Hints 'n Tips" document as follows:


"TIP #3 Configuring Port Pins

All PIC MCUs have bidirectional I/O pins. Some of these pins have analog input capabilities. It is very important to pay attention to the signals applied to these pins so the least amount of power will be consumed.

Unused Port Pins

If a port pin is unused, it may be left unconnected but configured as an output pin driving to either state (high or low), or it may be configured as an input with an external resistor (about 10 kΩ) pulling it to Vdd or Vss. If configured as an input, only the pin input leakage current will be drawn through the pin (the same current would flow if the pin was connected directly to Vdd or Vss). Both options allow the pin to be used later for either input or output without significant hardware modifications.

Digital Inputs

A digital input pin consumes the least amount of power when the input voltage is near Vdd or Vss. If the input voltage is near the midpoint between Vdd and Vss, the transistors inside the digital input buffer are biased in a linear region and they will consume a significant amount of current. If such a pin can be configured as an analog input, the digital buffer is turned off, reducing both the pin current as well as the total controller current."
In CMOS logic there are two (Complementary) input transistors connected in "Push-Pull" configuration across the supply rail. If the input voltage is close to zero volts, the "top" transistor actually conducts (to push the internal voltage High to Vdd, but the lower transistor is "off", so no current flows between the supply rail and ground. Similarly, if the input voltage is close to Vdd then the lower transistor conducts, but the upper transistor has no (Vgs) bias, so again no cuurent flows. However, if the input voltage is "somewhere in the middle" then potentially both FETs are close to or above their threshold voltage, so there might be a through current from supply to ground!

In practice this doesn't seem to be a major problem and I often just leave any "spare" pins floating (even on chips with a large number of pins) with no obvious effects. But where power consumption may be a significant issue then it definitely is worth configuring unused pins as ADC inputs (if available and convenient) or with (internal) Weak Pullup resistors. But of course ensure that the pins really are "floating" (i.e. with no external impedance at all to ground) or you may increase the supply drain by far more than you intened to save. ;)

Cheers, Alan.
 
Last edited:

lbenson

Senior Member
It's interesting that GrahamGo's measurements for BOD enabled/disabled for the 08M2 are the opposite of Mycroft2152's measurements for the 08M showing significant savings with DISABLEBOD: http://www.picaxeforum.co.uk/showthread.php?4826-Low-Power-PICAXE-08M-BOD

[PURESPECULATION]
If everybody's measurements have been accurate, then perhaps it indicates that Microchip found a problem with power consumption with BOD enabled, and fixed it in later versions of the PIC chips.
[/PURESPECULATION]
 

GrahamGo

Senior Member
Hi,
Presumably you mean the Serial Comms (USB interface) was disconnected (to avoid any risks of "Phantom Powering"); The PICaxe Serial Input pin (Leg 2) must be tied to ground (via a resistor).
Cheers, Alan.
Hi, well almost. Check the attached a photo of the bread board. During the testing, the grey and Orange wires were unplugged (Sin & Sout). It does use the recommended resistor network. The red wire from the USB is my 3.3v (actually 3.35v), the other red wire is 5.0v from the other PSU. It just made it quicker to switch voltages. The info about the unused ports that you supplied agrees with what I found. Unused ports without pullup or pulldown of some sort is bad news.

Just to comment to @Ibenson Although the table only shows a single reading. I actually made several sets of results to check consistency. The meter used was a Fluke 83V, not a $10 one :) Is the meter certified?, no. Is it necessary? no, this is just a about comparing readings. As a side note. My wife sometimes claims that I am (certifiably crazy).
 
Last edited:

lbenson

Senior Member
comment to @Ibenson
I hope I didn't leave the impression that I questioned either the validity or usefulness of your measurements, or the suitability of your equipment. That was not my intention.

--Contented user of sub-$10 DVMs.--
 

GrahamGo

Senior Member
I hope I didn't leave the impression that I questioned either the validity or usefulness of your measurements, or the suitability of your equipment. That was not my intention.

--Contented user of sub-$10 DVMs.--
Hi, no absolutely not, forgive me if I gave you that impression. Someone else's comments did bother me a bit though. With a meager 90 odd posts I am a beginner here, except I do have 30+ years of electronics behind me. I am now retired after selling my company at 54yrs young. Meant to start another company, just never got around to it, now it's 12 yrs later. So all is good.
 

bpowell

Senior Member
Same but different phrased - disablebod active is actually the same as BOD disabled
Came here to say this...those numbers threw me for a loop at first as well...it's like a double-negative... "DisableBOD - Inactive" means "BOD is ACTIVE"

Good stuff though...always fun to see real-world measurements!
 

GrahamGo

Senior Member
Came here to say this...those numbers threw me for a loop at first as well...it's like a double-negative... "DisableBOD - Inactive" means "BOD is ACTIVE"

Good stuff though...always fun to see real-world measurements!
Thats my fault I used DisableBOD and then commented it out to disable it, now I find that there is an EnableBOD Sorry! I will change the tables to fix it, then I am done.
 

bpowell

Senior Member
Thats my fault I used DisableBOD and then commented it out to disable it, now I find that there is an EnableBOD Sorry! I will change the tables to fix it, then I am done.
It's no problem...just took me a second to adjust.

I like all the work / research you've put into this...it's very cool! Thanks GrahmGo!
 

tmfkam

Senior Member
Hi,



Presumably you mean the Serial Comms (USB interface) was disconnected (to avoid any risks of "Phantom Powering"); The PICaxe Serial Input pin (Leg 2) must be tied to ground (via a resistor).

IMHO the best starting point is the base PIC Data Sheet where most of these parameters are specified, not just "typical" but also "worst case" and at elevated temperature, etc., almost impossible to measure yourself and avoiding the risk of measuring an unfortuantely "good" or "bad" sample. So most of the influence of the Brownout Detector and oscillator speeds, and much more, can be determined directly from the manufactuer!

But a few words of warning: Read the "grey" (background) data which applies to the PICaxe chips, not the "white" data which applies to the (sometimes much lower current) LP or XLP "nanowatt" versions. Also beware that when an M2 PICaxe is "sleeping", the WDT oscillator is still running (to wake it up again).

The data sheet tells us that the "input leakage current" of an I/O pin is typically only 5 nanoAmps at up to 85 degrees C and the maximum is 200 nA, so difficult to measure and of little consequence (even over 18 pins of a 20M2). Note that this current includes not just the digital input (gate), but the ADC input (if available), the Output stage (in tri-state mode) and also any leakage through the electrostatic protection diodes! However, the /MR pin (aka the Input Only pin, Leg 3), appears to have rather higher leakage and "special attention" may be worthwhile here.

HOWEVER, that is not what the OP asked, nor can I find the required information in the Data Sheet! What is required is expained in the excellent Microchip "Hints 'n Tips" document as follows:



In CMOS logic there are two (Complementary) input transistors connected in "Push-Pull" configuration across the supply rail. If the input voltage is close to zero volts, the "top" transistor actually conducts (to push the internal voltage High to Vdd, but the lower transistor is "off", so no current flows between the supply rail and ground. Similarly, if the input voltage is close to Vdd then the lower transistor conducts, but the upper transistor has no (Vgs) bias, so again no cuurent flows. However, if the input voltage is "somewhere in the middle" then potentially both FETs are close to or above their threshold voltage, so there might be a through current from supply to ground!

In practice this doesn't seem to be a major problem and I often just leave any "spare" pins floating (even on chips with a large number of pins) with no obvious effects. But where power consumption may be a significant issue then it definitely is worth configuring unused pins as ADC inputs (if available and convenient) or with (internal) Weak Pullup resistors. But of course ensure that the pins really are "floating" (i.e. with no external impedance at all to ground) or you may increase the supply drain by far more than you intened to save. ;)

Cheers, Alan.
Thanks Alan. Some really useful information there. I appreciate your time.
 

tmfkam

Senior Member
An addendum to my earlier post.

Code:
Enablebod                                         Disablebod           
C.1 to C.4 linked to ground                                                   
-----------------------------------------------------------------------           
voltage          Sleep         4mh/z              Sleep          4mh/z           
2.3v             -             -                   -             -          
3.3v             17ua          552ua              13ua           550ua                            
5.0v             19ua          593ua              14ua           589ua
Final test. C.1 thru C.4 grounded, Pullup = inactive, Disablebod = On and Off.

My conclusion is that for the ultimate low power this is the best solution (Disablebod, C.1-4 grounded), of course this prevents the I/O ports being used. The next best solution is to activate the Pullups. The worst case is to leave the ports floating. As mentioned in my earlier post with the ports left floating, something strange is going on and in the transition time between the sleep and 4mh/z modes the current goes through some sort of gradient. I have no way to present this info, but it is easy to see on the DVM. PS. I did not bother doing the 2.3v test, during test Serial in and out were disconnected. Cheers.


View attachment 21325
Some very useful data there. Next time I'm building a low power device, I'll try to remember where I read that.
 
Top