Safe to apply analog input at ATtiny24 pin without supply voltage?

I am designing an ATtiny24 based charger for NiMH batteries, one of the pins on the ATtiny24 is supposed to measure the battery terminal voltage, the maximum voltage at that analog input will be 4 volts coming through a voltage divider between the battery's positive and negative terminals.

Normally you would connect the battery first to the charger, then plug in the mains socket and then turn on the switch to start the charger, in between connecting the battery and turning on the switch I find myself facing a situation where there will be voltage (4 volts max) on the ATtiny24 analog pin without the controller being powered up. Is this safe to do?

Thanks.

Connecting voltages to input pins on unpowered devices is generally a bad idea. The device will be powered through the clamp diode on the input pin and may be damaged or otherwise malfunction.

If you can't avoid doing so, put a 4k7 or 10k resistor in series with the lead to limit the current.

Seems like a similar question, and therefore possible solution is found in this thread? Presuming you have a spare pin of course...

waqaszahid:
voltage at that analog input will be 4 volts coming through a voltage divider between the battery's positive and negative terminals.

the divider will protect the chip from pin voltage with no vcc. no special circuits required.

john1993:
the divider will protect the chip from pin voltage with no vcc. no special circuits required.

Ensure that the divider uses at least 1k resistance per volt - thus limiting the current to 1 mA or less - and take into account that this will for whatever period it happens, be discharging the battery at this rate.

Thank you members for your kind replies.

I already have a 4.7 V shunt zener diode protecting the analog input pin at the ATtiny24, so I am not really worried about a high voltage getting through to the pin, I am thinking that the controller might malfunction once it is powered up if I have a voltage on it's input pin in idle state.

My code already takes up a full 2048KB so unfortunately having an extra pin isn't an option at the moment.

I was thinking that I do have a 12VDC supply on the board for a cooling fan, may be I can use the 12 volts to power up a voltage follower op-amp and feed the battery voltage through it to the controller pin, since the op-amp will only give an output once it is turned on along with the controller board so I think I will have some degree of protection and could avoid a controller malfunction.

I already have a 4.7 V shunt zener diode protecting the analog input pin at the ATtiny24,

You don't understand the problem. The Zener diode will not protect against overcurrent through the input clamp diode, if the ATTiny is not powered.

Thanks for your response Jremington, apologies, I missed your point, I should have a resistor going to the pin not just a simple tap through a voltage divider. For the sake of safety I have decided to avoid the condition altogether and now my configuration will allow for a voltage measurement only when the microcontroller is powered up, thanks for the information on the clamp diodes I'll keep that in mind for future projects.

waqaszahid:
Thanks for your response Jremington, apologies, I missed your point, I should have a resistor going to the pin not just a simple tap through a voltage divider.

But a "simple tap through a voltage divider" is in fact a resistor going to the pin. See my reply #4.

waqaszahid:
For the sake of safety I have decided to avoid the condition altogether and now my configuration will allow for a voltage measurement only when the microcontroller is powered up, thanks for the information on the clamp diodes I'll keep that in mind for future projects.

And just how are you arranging that? Exactly how are you disconnecting the input?

Paul__B:
See my reply #4.

you do have to give paul credit (whether he deserves it or not, lol).

Hello Paul,

Thanks for the response and for clearing the voltage divider confusion.

I have two separate circuits, the controller with the ATtiny which can switch the charging ON and OFF through a relay by simply disconnecting the battery from the charger and the other one is the power circuit which is the actual charger itself, the reason why I chose to built it this way is because I am constantly changing my power circuit and trying to improve it, I am on my second iteration at the moment, so I decided to built a generic controller with 3 on board N/O relay outputs that can turn ON and OFF the charging as and when required and can select different current levels at which to charge the battery.

Since my charge cut-off right now simply happens by disconnecting the battery through a relay, the only change I had to do was to connect the positive terminal of the battery at the relay contact which didn't have the voltage divider connected to it. So the voltage divider is only fed once the relay is closed, the reason why I wanted to avoid this in the beginning is because once the charging starts the terminal voltage of the battery goes up by 0.8 to 0.9 volts so a voltage measurement at that point won't give you the actual battery voltage. I wanted to measure the open circuit terminal voltage at the battery as I wanted to include an overcharge protection functionality in my code that would only allow for a charge cycle to begin if the battery is below a certain voltage.

My charger works primarily by using the delta T/delta t (temperature gradient) charge termination method, voltage measurement is just used as a backup so I compensated for the 0.9 to 0.8 volt increase in battery voltage in my code, the arrangement works well at the moment.

May be when I have finalized the design I can replace the relay cut off method with something more elegant.

lol and yes John, I must appreciate everyone coming in with their suggestions.

And that is the correct answer - a relay powered by the mains (through the charger) will only draw current itself and only put a discharge load on the battery when it is being powered, so it will not accidentally discharge.

And that was pretty fast!

a 100k divider will not discharge either. far less current than internal r of the battery.

I have put my first blog discussing my design

Thanks for all the support guys! couldn't have been possible without your support.