Should unused a0-a3 on 28X1 be pulled low?

Ralpht

New Member
As a general rule, all Inputs on any form of "*MOS" (Metal Oxide Semiconductor) chip should be tied either high or low, but not floating.

In the case of the 28X1 they are ADC0 - ADC3 or inputs A0-A3. As they are inputs it will not hurt to tie them hi or lo.

Use about a 1K resistor up to 4K7 on each line.

The * means anything that preceeded the MOS ie CMOS etc.

Do not tie outputs to anything if they are not used. No advantage to it and may in the wrong circumstances lead to cursing if the smoke is let out.
 
Last edited:

BeanieBots

Moderator
It's not a REQUIREMENT, but is recommended.
It will also reduce overall power consumption if you tie them up or down.
 

Janne

Senior Member
It's not a REQUIREMENT, but is recommended.
It will also reduce overall power consumption if you tie them up or down.
Hello BB,

I'm curious, why would tying the inputs up / down reduce power consumption? Does it have something to do with the weak internal pull-ups?
 
I am not using any of the pins on PortA but I have a real estate restriction. Could somebody look at the schematic and tell me if it is OK on a 28 X2?
All the pins in PortB and PortC are used, but the connections are not included for clarity.
 

Attachments

Last edited:

KIGX

Member
I assume that with the X2s you could just designate unused pins as output pins and then leave them alone? What does that do to energy consumption?
 

inglewoodpete

Senior Member
Hello BB,

I'm curious, why would tying the inputs up / down reduce power consumption? Does it have something to do with the weak internal pull-ups?
Floating inputs, particularly digital inputs, 'float' up and down in voltage level due to induced electromagnetic and electrostatic fields. Within the chip, there are gates and other circuitry that switch according to the changing input voltage. Eg when the induced input voltage reaches a logic '1' level, the internals will switch high and, similarly, when the voltage reaches the '0' threshold the internals will switch low. Every transition uses a small amount of current.

If the open circuit pin is transitioning at high frequencies, the power wastage will higher. This can be quite important in battery operated equipment where long battery life is important.

All switching in a digital device creates electrical noise which radiates as EMF and also appears on the power pins (and internally) as tiny dips and surges. All very small but it adds up.

Tie the unused pins high or low via a resistor (several inputs can be connected to 1 resistor) and the wasted power and noise are reduced.

Peter
 

BCJKiwi

Senior Member
Working on a very small mains powered board (consumption not an issue) using a 28X1 and would prefer not to have to add the resistors.

Two Qs above remain unanswered;
1. From KIGX - "I assume that with the X2s you could just designate unused pins as output pins and then leave them alone? What does that do to energy consumption?"
Presumably this could be applied to any port on any chip that is an input by default but could be switched to an output. Apart from the current consumption issue, this would presumably eliminate the floating input!

2. As a0-a3 on a 28x1 are analogue by default and cannot be made outputs, what effects occur if left floating. It would seem from the above discussion that floating analogue inputs behave differently from digital inputs.

Also, is there any significant difference in the behaviour of Schmitt Trigger vs TTL type ports. On the 28X1 the analogue ports are TTL and the port C ports, when general I/O (their default presumably) are ST
 
Last edited:

MartinM57

Moderator
For X2 parts, worth looking at the pullup command - enable the weak internal pullups (on some pins) meaning that:
- when reading open-collector outputs you don't need an external resistor
- when the pin is unused, it is an unused input but tied high
 

hippy

Ex-Staff (retired)
All switching draws current and all inputs can switch 'randomly' when floating, even analogue are also connected to digital circuits even if not used as such by the PICAXE.

Schmitt Trigger inputs are probably less of a problem than TTL as there needs to be a wide swing of voltage to cause a change of input. With TTL the worse case is when the voltage is on the boundary of where the input switches between 0 and 1 and vice-versa, just a very tiny induced voltage change shifts it either way.

Though floating input pins can increase current, this is largely unnoticeable and only really important when trying to achieve ultra low power operation or wanting to maximise battery power. Tying inputs high or low also reduces the risk from ESD into the pins.

I rarely do anything other than leave unused inputs floating and have not had any problems so far.
 

BeanieBots

Moderator
It is also possible to enable the weak pull-ups on other chips but it requires a good understanding of base PIC to know how. (a search should reveal what needs to be poked).
With the X2's, before you get too excited about weak pull-ups, there are significant restrictions which vary with X2 type. Check the manual for details.
 

BCJKiwi

Senior Member
So can the unused inputs be set as outputs (where applicable) to avoid any need for pullup/down (where the port allows for it) and where you want to be absolutely certain of no spurious input?
 
Last edited:

BeanieBots

Moderator
Yes, you can do that and IMHO would be better than leaving them floating.

Don't know what effect that has on current consumption but I would GUESS that making an input into an output would increase current draw because of the extra circuitry that is enabled (totem-pole bias current).
The relevant PIC datasheet might shed some more light on that or maybe one the micro power PICAXE gurus can give first hand figures for it.
 

BeanieBots

Moderator
I've not checked your diagram but the idea is OK.
However, if it's a 28X2, why not simply make them outputs?
Less chance of 'accidents'.
 

hippy

Ex-Staff (retired)
Would it be OK to connect all the pins from Port A (on a 28X2) toghether and then to a pull up resistor as shown in the attached schematic?
It works, it's the halfway house between tying the inputs directly to 0V and through individual R's to 0V, and likewise gives you halfway house protection.

Tied directly to 0V, if a pin became an output high through some circumstance it would likely quickly expire and may cause other damage to the chip.

With all via individual R's they are held low when input and a pin becoming output high will source current but not damage the chip ( providing the R is big enough).

With a single R they are held low, any number of I/O may go output low or output high and not be damaged, but if one goes output low and any other output high it's the same as having connected them to 0V and you will likely damage the pins and may cause other damage to the chip.

It's your judgement as to how likely any adverse event is going to be. With the pins left floating it doesn't matter what happens to those pins though current consumption may not be the minimum it could be. The recommended practice would be to pull each I/O low through its own R if you wanted to tie inputs which may become outputs to 0V.
 

BCJKiwi

Senior Member
OK ran a few tests;
28X1, lm7805 regulated supply, total current draw measured with DMM mA scale.
No connections other than supply, enhanced download circuit and reset circuit.

test 1 - current draw 1.94 mA;
Code:
#picaxe 28X1
setfreq m8
main:
if input1 is 1 then
goto main:
endif
goto main
test 2 - current draw 1.89mA
Code:
#picaxe 28X1
setfreq m8
low portc 0
low portc 1
low portc 2
low portc 3
low portc 4
low portc 5
low portc 6
low portc 7
main:
if input1 is 1 then
goto main:
endif
goto main
Test 3 same as test 2 but with portc high instead of low - current draw 1.87 mA

Test 4 1.97mA - moved input test to port a
Code:
#picaxe 28X1
setfreq m8
high portc 0
high portc 1
high portc 2
high portc 3
high portc 4
high portc 5
high portc 6
high portc 7
main:
if porta input1 is 1 then
goto main:
endif
goto main
test 5 code same as test4 - added a 10k pull down to porta 1 - current draw 1.92mA
test 6 code same as test4 - added a separate 10k pull down to each of porta 0 thru 3 - current draw 1.84mA
test 7 code same as test4 - added a single shared 10k pull down to porta 0 thru 3 - current draw 1.88mA
test 8 code same as test1 - pwmout from 08M injected into ports a0 thru a3 - current draw increased from 1.94 to 1.96mA
test 9 - test for resonator input floating
code same as test1 - connections same as test1. With 28X1 pin 9 connected to 0V no change in mA, with 4k7 or 10k to 0V, current increased from 1.94 to 1.95mA

Conclusions;
make unused inputs high outputs if available - no connection else current draw increases!
individual pullups on input only ports
Gives minumum current draw, highest safety against floating inputs.
 
Last edited:

hippy

Ex-Staff (retired)
That's quite interesting so thanks for doing that.

Even though they are quite small savings it still adds up to around 10% which would be significant for battery powered equipment, and it would probably be more if floating inputs were used in an electrically noisy environment.

It also answers the "what current does a PICAXE draw ?" question; "around a couple of mA" as a ballpark figure.

In non-battery powered equipment and larger systems the savings begin to diminish as the PICAXE current becomes a smaller component of the whole. Adding even a single LED driven at high brightness would reduce the saving to less than 0.5% so the lesson is to design the entire system towards low power consumption to see true savings if you are wanting that.

I'd be tempted to say the results generally vindicate those who leave inputs floating when minimum power consumption isn't a necessity but we don't have an indication of what the worse case is in a noisy environment. Would it be possible to run the test again with all inputs, digital and analogue, connected to a high frequency signal ( another PICAXE doing PWMOUT etc ) ? We have a measure of what the advantages are of not leaving the inputs floating and that would give a measure of the disadvantages of leaving them floating.
 

BCJKiwi

Senior Member
See test 8 added to previous post.
Tested at 1 000 000 Hz 50% duty and at 10 000 Hz 50% duty
 
Last edited:

BCJKiwi

Senior Member
@Hippy, no you didn't miss test 8, I added it so the original post was complete - as noted in the edited tag.;)
 

BCJKiwi

Senior Member
In view of the low current issues with no external resonator discussed elsewhere for 28X2_3V, tested the floating pin 9 (resonator input) with the same setup post #21 for the 28X1 at 8Mhz internal resonator.

See results above shown as test9.
 
Top