high current usage on inputs

Combining the power of the ATmega2560 MCU with onboard Ethernet, a microSD card slot, an efficient switchmode power supply, and a small prototyping area. [Product page]
Post Reply
JonathanM
Posts: 6
Joined: Sun Apr 21, 2013 11:40 am

high current usage on inputs

Post by JonathanM » Sun Jun 23, 2013 1:15 pm

Been having an issue with my ether mega.
Was unable to get some of the inputs working that used a pull up resistor (5K).

Investigated further and found that when a pin is configured for input (only affects pins configured for input) in order for the pin to register as high you need to provide 82ma.

I have tested ports 14 - 18 & 40 - 46 (evens) and it seems that all digital inputs are performing the same way (not tested the analog ports).

Any ideas why the inputs are requiring such high current ?
Has anyone else ever had an issue like this ?

PS

This will be the third ethermega I have used, normally the inputs require only a few ma to register.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: high current usage on inputs

Post by angusgr » Sun Jun 23, 2013 11:11 pm

Hi Jonathan,

What a strange and frustrating problem! I have a few questions and things for you to test out.

How are you measuring the input current? When set as inputs in the Arduino IDE, the pins on the EtherMega should be in a state called "Tri-state (Hi-Z)" which essentially means they display a very high impedance to ground, the current through the pin itself should be neglible - nowhere near 82mA (which is actually well above the absolute maximum per-pin current of 40mA, that the pin can safely sink when configured as an output.)

If 82mA really is flowing into the pin, are you sure the correct pin is being set to an input and not configured as an output driven low? (which will sink large amounts of current, and could explain the behaviour you're seeing.)

High input values should be seen any time the pin sees more than 3V[1]. If you measure the voltage directly at the pin using your multimeter, what do you see there?

Is there anything else connected to the pin apart from the 5K pull up, that might be pulling it down too far for it to register a high enough voltage? Can you draw us a simple schematic of what's connected to the pin?

Regards,

Angus

[1] If you're wondering where I'm pulling these numbers from this one, this is from the ATMega2560 datasheet section 31.1 DC Characteristics. The table above that in the datasheet has the absolute maximums.

JonathanM
Posts: 6
Joined: Sun Apr 21, 2013 11:40 am

Re: high current usage on inputs

Post by JonathanM » Mon Jun 24, 2013 1:09 am

Hi Tron & Angus,

I'll build a blank project to put your ideas through the ringer (to remove any miss configurations).

I'll then send you through the code and schematic for validation.

PS

I was seeing the 82ma when connecting the 5V regulated pin directly to an input pin (the code would then register it as a high). It was connected directly using a dmm to measure the current required (as any resister I used wouldn't allow to to register as high - not enough current - tried a few right down to 470ohm at which point I knew something was wrong).

JonathanM
Posts: 6
Joined: Sun Apr 21, 2013 11:40 am

Re: high current usage on inputs

Post by JonathanM » Mon Jun 24, 2013 1:12 am

I'm using the sdk 1.0.4. Will update to 1.0.5 this evening.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: high current usage on inputs

Post by angusgr » Mon Jun 24, 2013 6:37 am

Hi Jonathan,
JonathanM wrote: I was seeing the 82ma when connecting the 5V regulated pin directly to an input pin (the code would then register it as a high). It was connected directly using a dmm to measure the current required (as any resister I used wouldn't allow to to register as high - not enough current - tried a few right down to 470ohm at which point I knew something was wrong).
While the pin is in the input mode you should be able to connect 5V directly to it (ie no resistors), and still measure much less than 1 mA of input current (in fact it's likely your multimeter won't be able to measure the current, it's so small.)

Is there something else connected to the pin that might be connecting it to ground (meaning the current is going there, so the voltage at the pin is being pulled down and keeping it below the HIGH threshold)? That could explain it, you effectively end up with a voltage divider across the pin.

If there's nothing else connected to that pin then this means either the pin is not being set to a digital input correctly, or the microcontroller is damaged. If at some point it was not set to a digital input and it did sink 82mA of current then this by itself may have been enough to damage it, unfortunately.
JonathanM wrote:I'm using the sdk 1.0.4. Will update to 1.0.5 this evening.
[/quote]

I don't think this is likely to be an Arduino bug, but I guess it can't hurt to run the latest software regardless.

Please let us know how your investigations go.

- Angus

JonathanM
Posts: 6
Joined: Sun Apr 21, 2013 11:40 am

Re: high current usage on inputs

Post by JonathanM » Mon Jun 24, 2013 10:09 am

Hi Guys,

When using the "digital->button" example I am unable to reproduce the issue (facepalm).

I have no idea what I have done in my code, but ... it has to be acting as an output set to low.

Will investigate further and advise.

JonathanM
Posts: 6
Joined: Sun Apr 21, 2013 11:40 am

Re: high current usage on inputs

Post by JonathanM » Mon Jun 24, 2013 11:46 am

Now I'm feeling really silly.

I had a whole bunch on defines and this one eventually stood out:
> #define INPUT 3

That means that:
> pinMode(buttonPin, INPUT);

Doesn't exactly do what you would expect.

Thanks for your help guys, will rename that define :)

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: high current usage on inputs

Post by angusgr » Mon Jun 24, 2013 10:08 pm

JonathanM wrote:Now I'm feeling really silly.
In my experience that's the nature of computer programming, silly mistakes hidden in the parts that you think are so straightforward they can't possibly be the culprit. Happens to us all, don't let it get you down. :)

Glad it's working now.

- Angus

Post Reply