Hi,
I am trying to determine if a 12V power source is on or off in order to take action. In fact, I have D2 attached an an interrupt.
I am pretty familiar with the ways to power this board, and in fact am using the 5v pin to do so.
I am using an LM 1805 to convert from 12-5V. I have the 12V source going into the input, the ground going to ground, and the output going to D2 on the Nano. I also have a 10K ohm resistor across the output/ground pins of the LM 1805 as a pulldown resistor for D2.
When I connect the output of the LM 1805 to D2, the board lights up. I have D2 set to INPUT of course, which I thought would put "the equivalent of a 100M Ohm resistor in front of the input" and therefore not even be able to supply enough power to power the board.
This is the biggest circuit I've built, but this particular part of it is pretty isolated, so I'm very confused. Any help is appreciated-
You must not connect an external voltage to an I/O pin if that voltage may be present when the device is not powered - there is a protection diode between each I/O pin and vcc (and ground) to prevent the voltage from exceeding VCC pr going below ground, but these are only good up to 1mA or so. You're backpowering the device through the protection diode,greatly exceeding this limit, and are liable to blow the pin if you havent done so already.
Also, you dont need a regulator there- a simple voltage divider is fine.
In fact, if you chose the value of the resistors in said divider wisely, you could kill two birds with one stone. Just use resistors that would limit current flow to under 1mA worst case (worst case being, assume the pin is held at gnd), and you're fine.
A diode from the pin to vcc would give one more confidence. Just dont be an idiot and use a diode with enough reverse leakage to overcome your pulldown (such diodes do exist! Recently I was designing a dc-dc boost converter to run from a battery, so I was all, well we want to minimize power consumption, so pick the lowest drop diode we can find - I picked an overspec'ed diode with like .2v forward drop. Then I put the load to sleep, looked at the output of the boost controller on the scope, comparing it to the figures in the datasheet and wondered why the boost controller was not going into its low current power save mode. Well duh, dumbass, it's because the reverse leakage across that excuse for a diode you paid out the ass for is higher than the current threshold at which the boost controller would go into low power mode, what did you expect to happen? But yeah, since I did that - and assembled a panel of the damned things, from which I had to remove the old diode and hand-solder new ones onto - I always ask "okay, and what will a bit of reverse leakage across that do?" about every diode I use)
Well son of a B, I had an almost complete quick reply, rep'd you and lost it! : (
I had to read that last paragraph 3 times, but I get it. Thanks for the lesson, I didn't really think reverse leakage was a thing I generally had to worry about. I don't use diodes often, but I just assume the leakage is tiny (cue someone telling me about assumptions and what happens when they're made).
I thought about using a voltage divider but I don't have the right resistors and I had the regulators laying around. Oh, and the voltage I'm detecting is going to swing by about 40%, complicating things.
Anyhoo, that's super annoying. I thought the 100M Ohm series resistor on the pins would take care of the possibility of backpowering it, which is why I quoted the arduino tutorial on digital input https://www.arduino.cc/en/Tutorial/DigitalPins
lamerz, as Hasan would say.
--Edit--
I may have just realized something - is the 100M Ohm resistor only part of the circuit when the arduino is (normally) powered on?
40% swing on 5V is, from memory, still enough to detect a high. Else you can put a capacitor over it. Alternatively you might be able to use an analogue pin to measure; but that depends on your requirements.
sterretje:
Which 100 M resistor are you talking about?
40% swing on 5V is, from memory, still enough to detect a high. Else you can put a capacitor over it. Alternatively you might be able to use an analogue pin to measure; but that depends on your requirements.
excerpt: "Pins configured [as input] are said to be in a high-impedance state. Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin."
You're probably right about the 40% swing, it would just mean I had to be fairly precise on which resistors I used in the voltage divider.
The protection diode is before that "resistor" (there is no actual resistor there - it's just connected to the gate of a fet, and there's a very small amount of leakage such that treating it as a 100M resistor is a good approximation to calculate the current into or out of a pin set INPUT - provided that the voltage applied to that pin is between Gnd and Vcc).